Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 7 Sep 2017 16:54:48 +0000 (UTC)
From:      Alan Somers <asomers@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323275 - in head: bin/chflags bin/chflags/tests bin/mkdir bin/mkdir/tests bin/rcp bin/rcp/tests bin/rmdir bin/rmdir/tests etc/mtree
Message-ID:  <201709071654.v87Gsm7V040618@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: asomers
Date: Thu Sep  7 16:54:47 2017
New Revision: 323275
URL: https://svnweb.freebsd.org/changeset/base/323275

Log:
  Add basic tests for chflags, mkdir, rcp, and rmdir
  
  Add basic command line parsing test coverage for these utilities.  The tests
  were automatically generated based on their man pages.  These tests can be
  expanded by hand for more thorough coverage.  The aim is to generate very
  basic amount of test coverage for all the utilities in the base system.
  
  Submitted by:	shivansh
  Reviewed by:	asomers, brooks
  MFC after:	3 weeks
  Sponsored by:	Google, Inc (GSoC 2017)
  Differential Revision:	https://reviews.freebsd.org/D12036

Added:
  head/bin/chflags/tests/
  head/bin/chflags/tests/Makefile   (contents, props changed)
  head/bin/chflags/tests/chflags_test.sh   (contents, props changed)
  head/bin/mkdir/tests/
  head/bin/mkdir/tests/Makefile   (contents, props changed)
  head/bin/mkdir/tests/mkdir_test.sh   (contents, props changed)
  head/bin/rcp/tests/
  head/bin/rcp/tests/Makefile   (contents, props changed)
  head/bin/rcp/tests/rcp_test.sh   (contents, props changed)
  head/bin/rmdir/tests/
  head/bin/rmdir/tests/Makefile   (contents, props changed)
  head/bin/rmdir/tests/rmdir_test.sh   (contents, props changed)
Modified:
  head/bin/chflags/Makefile
  head/bin/mkdir/Makefile
  head/bin/rcp/Makefile
  head/bin/rmdir/Makefile
  head/etc/mtree/BSD.tests.dist

Modified: head/bin/chflags/Makefile
==============================================================================
--- head/bin/chflags/Makefile	Thu Sep  7 16:43:12 2017	(r323274)
+++ head/bin/chflags/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -4,4 +4,7 @@
 PACKAGE=runtime
 PROG=	chflags
 
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
 .include <bsd.prog.mk>

Added: head/bin/chflags/tests/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/chflags/tests/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+=  chflags_test
+
+.include <bsd.test.mk>

Added: head/bin/chflags/tests/chflags_test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/chflags/tests/chflags_test.sh	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,63 @@
+#
+# Copyright 2017 Shivansh Rai
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+usage_output='usage: chflags'
+
+atf_test_case invalid_usage
+invalid_usage_head()
+{
+	atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
+}
+
+invalid_usage_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -f
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -H
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -h
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -L
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -P
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -R
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags -v
+}
+
+atf_test_case no_arguments
+no_arguments_head()
+{
+	atf_set "descr" "Verify that chflags(1) fails and generates a valid usage message when no arguments are supplied"
+}
+
+no_arguments_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" chflags
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case invalid_usage
+	atf_add_test_case no_arguments
+}

Modified: head/bin/mkdir/Makefile
==============================================================================
--- head/bin/mkdir/Makefile	Thu Sep  7 16:43:12 2017	(r323274)
+++ head/bin/mkdir/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -4,4 +4,7 @@
 PACKAGE=runtime
 PROG=	mkdir
 
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
 .include <bsd.prog.mk>

Added: head/bin/mkdir/tests/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/mkdir/tests/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+=  mkdir_test
+
+.include <bsd.test.mk>

Added: head/bin/mkdir/tests/mkdir_test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/mkdir/tests/mkdir_test.sh	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,61 @@
+#
+# Copyright 2017 Shivansh Rai
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+usage_output='usage: mkdir'
+
+atf_test_case invalid_usage
+invalid_usage_head()
+{
+	atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
+}
+
+invalid_usage_body()
+{
+	atf_check -s not-exit:0 -e inline:"mkdir: option requires an argument -- m
+usage: mkdir [-pv] [-m mode] directory_name ...
+" mkdir -m
+	atf_check -s not-exit:0 -e match:"$usage_output" mkdir -p
+	atf_check -s not-exit:0 -e match:"$usage_output" mkdir -v
+}
+
+atf_test_case no_arguments
+no_arguments_head()
+{
+	atf_set "descr" "Verify that mkdir(1) fails and generates a valid usage message when no arguments are supplied"
+}
+
+no_arguments_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" mkdir
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case invalid_usage
+	atf_add_test_case no_arguments
+}

Modified: head/bin/rcp/Makefile
==============================================================================
--- head/bin/rcp/Makefile	Thu Sep  7 16:43:12 2017	(r323274)
+++ head/bin/rcp/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -11,4 +11,7 @@ PACKAGE=rcmds
 BINOWN=	root
 BINMODE=4555
 
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
 .include <bsd.prog.mk>

Added: head/bin/rcp/tests/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/rcp/tests/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+=  rcp_test
+
+.include <bsd.test.mk>

Added: head/bin/rcp/tests/rcp_test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/rcp/tests/rcp_test.sh	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,60 @@
+#
+# Copyright 2017 Shivansh Rai
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+usage_output='usage: rcp'
+
+atf_test_case invalid_usage
+invalid_usage_head()
+{
+	atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
+}
+
+invalid_usage_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" rcp -4
+	atf_check -s not-exit:0 -e match:"$usage_output" rcp -6
+	atf_check -s not-exit:0 -e match:"$usage_output" rcp -p
+	atf_check -s not-exit:0 -e match:"$usage_output" rcp -r
+}
+
+atf_test_case no_arguments
+no_arguments_head()
+{
+	atf_set "descr" "Verify that rcp(1) fails and generates a valid usage message when no arguments are supplied"
+}
+
+no_arguments_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" rcp
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case invalid_usage
+	atf_add_test_case no_arguments
+}

Modified: head/bin/rmdir/Makefile
==============================================================================
--- head/bin/rmdir/Makefile	Thu Sep  7 16:43:12 2017	(r323274)
+++ head/bin/rmdir/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -4,4 +4,7 @@
 PACKAGE=runtime
 PROG=	rmdir
 
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
 .include <bsd.prog.mk>

Added: head/bin/rmdir/tests/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/rmdir/tests/Makefile	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+ATF_TESTS_SH+=  rmdir_test
+
+.include <bsd.test.mk>

Added: head/bin/rmdir/tests/rmdir_test.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/bin/rmdir/tests/rmdir_test.sh	Thu Sep  7 16:54:47 2017	(r323275)
@@ -0,0 +1,58 @@
+#
+# Copyright 2017 Shivansh Rai
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+#
+# $FreeBSD$
+#
+
+usage_output='usage: rmdir'
+
+atf_test_case invalid_usage
+invalid_usage_head()
+{
+	atf_set "descr" "Verify that an invalid usage with a supported option produces a valid error message"
+}
+
+invalid_usage_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" rmdir -p
+	atf_check -s not-exit:0 -e match:"$usage_output" rmdir -v
+}
+
+atf_test_case no_arguments
+no_arguments_head()
+{
+	atf_set "descr" "Verify that rmdir(1) fails and generates a valid usage message when no arguments are supplied"
+}
+
+no_arguments_body()
+{
+	atf_check -s not-exit:0 -e match:"$usage_output" rmdir
+}
+
+atf_init_test_cases()
+{
+	atf_add_test_case invalid_usage
+	atf_add_test_case no_arguments
+}

Modified: head/etc/mtree/BSD.tests.dist
==============================================================================
--- head/etc/mtree/BSD.tests.dist	Thu Sep  7 16:43:12 2017	(r323274)
+++ head/etc/mtree/BSD.tests.dist	Thu Sep  7 16:54:47 2017	(r323275)
@@ -8,6 +8,8 @@
     bin
         cat
         ..
+        chflags
+        ..
         chmod
         ..
         date
@@ -22,6 +24,8 @@
         ..
         ls
         ..
+        mkdir
+        ..
         mv
         ..
         pax
@@ -29,6 +33,10 @@
         pkill
         ..
         pwait
+        ..
+        rcp
+        ..
+        rmdir
         ..
         sh
             builtins



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709071654.v87Gsm7V040618>