Author: bapt
Date: Sat May  2 11:09:58 2015
New Revision: 282338
URL: https://svnweb.freebsd.org/changeset/base/282338

Log:
  Add regression tests for soelim(1)

Added:
  head/usr.bin/soelim/tests/
  head/usr.bin/soelim/tests/Makefile   (contents, props changed)
  head/usr.bin/soelim/tests/basic   (contents, props changed)
  head/usr.bin/soelim/tests/basic.in   (contents, props changed)
  head/usr.bin/soelim/tests/basic.out   (contents, props changed)
  head/usr.bin/soelim/tests/nonexisting.in   (contents, props changed)
  head/usr.bin/soelim/tests/soelim.sh   (contents, props changed)
Modified:
  head/etc/mtree/BSD.tests.dist
  head/usr.bin/soelim/Makefile

Modified: head/etc/mtree/BSD.tests.dist
==============================================================================
--- head/etc/mtree/BSD.tests.dist       Sat May  2 08:31:16 2015        
(r282337)
+++ head/etc/mtree/BSD.tests.dist       Sat May  2 11:09:58 2015        
(r282338)
@@ -546,6 +546,8 @@
             regress.multitest.out
             ..
         ..
+        soelim
+        ..
         timeout
         ..
         tr

Modified: head/usr.bin/soelim/Makefile
==============================================================================
--- head/usr.bin/soelim/Makefile        Sat May  2 08:31:16 2015        
(r282337)
+++ head/usr.bin/soelim/Makefile        Sat May  2 11:09:58 2015        
(r282338)
@@ -1,5 +1,11 @@
 # $FreeBSD$
 
+.include <src.opts.mk>
+
 PROG=  soelim
 
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
 .include <bsd.prog.mk>

Added: head/usr.bin/soelim/tests/Makefile
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/Makefile  Sat May  2 11:09:58 2015        
(r282338)
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+TESTSDIR=      ${TESTSBASE}/usr.bin/soelim
+
+ATF_TESTS_SH=  soelim
+
+FILES=         nonexisting.in \
+               basic.in \
+               basic \
+               basic.out
+FILESDIR=      ${TESTSDIR}
+
+.include <bsd.test.mk>

Added: head/usr.bin/soelim/tests/basic
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/basic     Sat May  2 11:09:58 2015        
(r282338)
@@ -0,0 +1 @@
+basic has been included

Added: head/usr.bin/soelim/tests/basic.in
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/basic.in  Sat May  2 11:09:58 2015        
(r282338)
@@ -0,0 +1,3 @@
+This is a test
+.so basic
+end

Added: head/usr.bin/soelim/tests/basic.out
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/basic.out Sat May  2 11:09:58 2015        
(r282338)
@@ -0,0 +1,3 @@
+This is a test
+basic has been included
+end

Added: head/usr.bin/soelim/tests/nonexisting.in
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/nonexisting.in    Sat May  2 11:09:58 2015        
(r282338)
@@ -0,0 +1,3 @@
+This is a test
+.so nonexistingfile
+This is next

Added: head/usr.bin/soelim/tests/soelim.sh
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ head/usr.bin/soelim/tests/soelim.sh Sat May  2 11:09:58 2015        
(r282338)
@@ -0,0 +1,96 @@
+# $FreeBSD$
+
+atf_test_case stdin
+stdin_head()
+{
+       atf_set "descr" "stdin functionality"
+}
+
+stdin_body()
+{
+       # no file after .so
+       atf_check \
+               -o inline:".so\n" \
+               -e empty \
+               -s exit:0 \
+               soelim <<-EOF
+.so
+EOF
+
+       # only space after .so
+       atf_check \
+               -o inline:".so          \n" \
+               -e empty \
+               -s exit:0 \
+               soelim <<-EOF
+.so    
+EOF
+
+       # explicit stdin
+       atf_check \
+               -o inline:".so\n" \
+               -e empty \
+               -s exit:0 \
+               soelim - <<-EOF
+.so
+EOF
+
+       atf_check \
+               -o empty \
+               -e inline:"soelim: can't open 'afile': No such file or 
directory\n" \
+               -s exit:1 \
+               soelim <<-EOF
+.so afile
+EOF
+
+       atf_check \
+               -o inline:".soafile\n" \
+               -e empty \
+               -s exit:0 \
+               soelim <<-EOF
+.soafile
+EOF
+
+       atf_check \
+               -o empty \
+               -e inline:"soelim: can't open 'afile': No such file or 
directory\n" \
+               -s exit:1 \
+               soelim -C <<-EOF
+.soafile
+EOF
+}
+
+atf_test_case files
+files_head()
+{
+       atf_set "descr" "testing files"
+}
+
+files_body()
+{
+       atf_check \
+               -o inline:"This is a test\n" \
+               -e inline:"soelim: can't open 'nonexistingfile': No such file 
or directory\n" \
+               -s exit:1 \
+               soelim $(atf_get_srcdir)/nonexisting.in
+
+       cp $(atf_get_srcdir)/basic .
+       atf_check \
+               -o file:$(atf_get_srcdir)/basic.out \
+               -e empty \
+               -s exit:0 \
+               soelim $(atf_get_srcdir)/basic.in
+
+       rm -f basic
+       atf_check \
+               -o file:$(atf_get_srcdir)/basic.out \
+               -e empty \
+               -s exit:0 \
+               soelim -I$(atf_get_srcdir) $(atf_get_srcdir)/basic.in
+}
+
+atf_init_test_cases()
+{
+       atf_add_test_case stdin
+       atf_add_test_case files
+}
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to