svn commit: r319012 - in stable/10: etc/mtree lib/libkvm lib/libkvm/tests
Ngie Cooper
ngie at FreeBSD.org
Sat May 27 23:26:12 UTC 2017
Author: ngie
Date: Sat May 27 23:26:10 2017
New Revision: 319012
URL: https://svnweb.freebsd.org/changeset/base/319012
Log:
MFC r316099:
lib/libkvm: start adding basic tests for kvm(3)
- kvm_close: add a testcase to verify support for errno = EINVAL / -1
(see D10065) when kd == NULL is provided to the libcall.
- kvm_geterr:
-- Add a negative testcase for kd == NULL returning "" (see D10022).
-- Add two positive testcases:
--- test the error case using kvm_write on a O_RDONLY descriptor.
--- test the "no error" case using kvm_read(3) and kvm_nlist(3) as
helper routines and by injecting a bogus error message via
_kvm_err (an internal API) _kvm_err was used as there isn't a
formalized way to clear the error output, and because
kvm_nlist always returns ENOENT with the NULL terminator today.
- kvm_open, kvm_open2:
-- Add some basic negative tests for kvm_open(3) and kvm_open2(3).
Testing positive cases with a specific
`corefile`/`execfile`/`resolver` requires more work and would require
user intervention today in order to reliably test this out.
MFC note:
lib/libkvm/kvm_open2_test is not compiled/tested because ^/stable/10
lacks the kvm_open2(3) libcall.
Added:
stable/10/lib/libkvm/tests/
- copied from r316099, head/lib/libkvm/tests/
Modified:
stable/10/etc/mtree/BSD.tests.dist
stable/10/lib/libkvm/Makefile
stable/10/lib/libkvm/tests/Makefile
stable/10/lib/libkvm/tests/kvm_geterr_test.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/etc/mtree/BSD.tests.dist
==============================================================================
--- stable/10/etc/mtree/BSD.tests.dist Sat May 27 23:24:33 2017 (r319011)
+++ stable/10/etc/mtree/BSD.tests.dist Sat May 27 23:26:10 2017 (r319012)
@@ -310,6 +310,8 @@
..
libcrypt
..
+ libkvm
+ ..
libmp
..
libnv
Modified: stable/10/lib/libkvm/Makefile
==============================================================================
--- stable/10/lib/libkvm/Makefile Sat May 27 23:24:33 2017 (r319011)
+++ stable/10/lib/libkvm/Makefile Sat May 27 23:26:10 2017 (r319012)
@@ -34,4 +34,10 @@ MLINKS+=kvm_getprocs.3 kvm_getargv.3 kvm
MLINKS+=kvm_open.3 kvm_close.3 kvm_open.3 kvm_openfiles.3
MLINKS+=kvm_read.3 kvm_write.3
+.include <bsd.own.mk>
+
+.if ${MK_TESTS} != "no"
+SUBDIR+= tests
+.endif
+
.include <bsd.lib.mk>
Modified: stable/10/lib/libkvm/tests/Makefile
==============================================================================
--- head/lib/libkvm/tests/Makefile Tue Mar 28 17:37:49 2017 (r316099)
+++ stable/10/lib/libkvm/tests/Makefile Sat May 27 23:26:10 2017 (r319012)
@@ -5,11 +5,13 @@
ATF_TESTS_C+= kvm_close_test
ATF_TESTS_C+= kvm_geterr_test
ATF_TESTS_C+= kvm_open_test
-ATF_TESTS_C+= kvm_open2_test
+# NB: kvm_open2(3) isn't available on ^/stable/10
+#ATF_TESTS_C+= kvm_open2_test
CFLAGS.kvm_geterr_test+= -I${.CURDIR:H}
-LIBADD+= kvm
+DPADD+= ${LIBKVM}
+LDADD+= -lkvm
WARNS?= 6
Modified: stable/10/lib/libkvm/tests/kvm_geterr_test.c
==============================================================================
--- head/lib/libkvm/tests/kvm_geterr_test.c Tue Mar 28 17:37:49 2017 (r316099)
+++ stable/10/lib/libkvm/tests/kvm_geterr_test.c Sat May 27 23:26:10 2017 (r319012)
@@ -56,6 +56,8 @@ ATF_TC_BODY(kvm_geterr_negative_test_NUL
ATF_REQUIRE(!errbuf_has_error(kvm_geterr(NULL)));
}
+/* 1100090 was where kvm_open2(3) was introduced. */
+#if __FreeBSD_version >= 1100091
ATF_TC(kvm_geterr_positive_test_error);
ATF_TC_HEAD(kvm_geterr_positive_test_error, tc)
{
@@ -125,13 +127,16 @@ ATF_TC_BODY(kvm_geterr_positive_test_no_
ATF_REQUIRE_MSG(kvm_close(kd) == 0, "kvm_close failed: %s",
strerror(errno));
}
+#endif
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, kvm_geterr_negative_test_NULL);
+#if __FreeBSD_version >= 1100091
ATF_TP_ADD_TC(tp, kvm_geterr_positive_test_error);
ATF_TP_ADD_TC(tp, kvm_geterr_positive_test_no_error);
+#endif
return (atf_no_error());
}
More information about the svn-src-all
mailing list