From 470182bb6eef79e52f276447b9f9eb556e05fef9 Mon Sep 17 00:00:00 2001
From: Conrad Meyer <cem@FreeBSD.org>
Date: Mon, 18 Nov 2019 04:03:11 +0000
Subject: [PATCH] Link in NetBSD's unifdef(1) tests

Skip one, is it currently fails.
---
 contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh |  4 ++++
 etc/mtree/BSD.tests.dist                        |  2 ++
 usr.bin/unifdef/Makefile                        |  5 +++++
 usr.bin/unifdef/tests/Makefile                  | 12 ++++++++++++
 4 files changed, 23 insertions(+)
 create mode 100644 usr.bin/unifdef/tests/Makefile

diff --git a/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh
index 43ca2808d7fa..751c303075b8 100755
--- a/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh
+++ b/contrib/netbsd-tests/usr.bin/unifdef/t_basic.sh
@@ -51,6 +51,10 @@ lastline_body() {
 	printf '#ifdef foo\n#endif\n' >input
 	atf_check -o file:input unifdef -Ubar input
 
+	# Begin FreeBSD
+	atf_skip "our version doesn't have this behavior"
+	# Endif
+
 	# Without newline after cpp directive
 	printf '#ifdef foo\n#endif' >input
 	atf_check -o file:input unifdef -Ubar input
diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist
index 0980847ceafd..ec2ce0e13191 100644
--- a/etc/mtree/BSD.tests.dist
+++ b/etc/mtree/BSD.tests.dist
@@ -1064,6 +1064,8 @@
         ..
         uuencode
         ..
+        unifdef
+        ..
         uniq
         ..
         vmstat
diff --git a/usr.bin/unifdef/Makefile b/usr.bin/unifdef/Makefile
index dcd358f23192..c38dae383ddd 100644
--- a/usr.bin/unifdef/Makefile
+++ b/usr.bin/unifdef/Makefile
@@ -1,8 +1,13 @@
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 # $FreeBSD$
 
+.include <src.opts.mk>
+
 PROG=	unifdef
 SCRIPTS=unifdefall.sh
 MLINKS=	unifdef.1 unifdefall.1
 
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
 .include <bsd.prog.mk>
diff --git a/usr.bin/unifdef/tests/Makefile b/usr.bin/unifdef/tests/Makefile
new file mode 100644
index 000000000000..ddcfbdc6146e
--- /dev/null
+++ b/usr.bin/unifdef/tests/Makefile
@@ -0,0 +1,12 @@
+# $FreeBSD$
+
+PACKAGE=	tests
+
+NETBSD_ATF_TESTS_SH=	basic_test
+
+${PACKAGE}FILES+=	d_basic.in
+${PACKAGE}FILES+=	d_basic.out
+
+.include <netbsd-tests.test.mk>
+
+.include <bsd.test.mk>