freebsd-dev/tests/sys
Enji Cooper a60d9a9892 Fix KAT(CCM)?Parser file descriptor leaks
Make `KAT(CCM)?Parser` into a context suite-capable object by implementing
`__enter__` and `__exit__` methods which manage opening up the file descriptors
and closing them on context exit. This implementation was decided over adding
destructor logic to a `__del__` method, as there are a number of issues around
object lifetimes when dealing with threading cleanup, atexit handlers, and a
number of other less obvious edgecases. Plus, the architected solution is more
pythonic and clean.

Complete the iterator implementation by implementing a `__next__` method for
both classes which handles iterating over the data using a generator pattern,
and by changing `__iter__` to return the object instead of the data which it
would iterate over. Alias the `__next__` method to `next` when working with
python 2.x in order to maintain functional compatibility between the two major
versions.

As part of this work and to ensure readability, push the initialization of the
parser objects up one layer and pass it down to a helper function. This could
have been done via a decorator, but I was trying to keep it simple for other
developers to make it easier to modify in the future.

This fixes ResourceWarnings with python 3.

PR:		237403
MFC after:	1 week
Tested with:	python 2.7.16 (amd64), python 3.6.8 (amd64)
2019-05-21 02:30:43 +00:00
..
acl Add a very basic regression test for setfacl -R with NFSv4 ACLs. 2018-10-26 21:20:04 +00:00
aio Revert r337929 2018-08-16 22:04:00 +00:00
audit Fix and simplify code by using ATF_REQUIRE_FEATURE macro 2019-04-01 14:21:32 +00:00
auditpipe Introduce test program for auditpipe(4) 2018-07-26 00:16:41 +00:00
capsicum Integrate capsicum-test into the FreeBSD test suite 2019-04-01 21:24:50 +00:00
cddl Remove duplicate ${PACKAGE}FILES+= cleanup.ksh line 2019-03-16 03:37:47 +00:00
common tests: Move common (vnet) test functions into a common file 2019-03-04 18:15:06 +00:00
fifo other: Fix several typos and minor errors 2017-12-27 03:23:58 +00:00
file Revert r337929 2018-08-16 22:04:00 +00:00
fs Fix sys.fs.tmpfs.mknod_test.{char, block} by reverting r321967 2018-07-21 20:14:01 +00:00
geom Skip test component_selection:run_latest_genid if gmirror/gnop GEOM classes 2019-04-23 21:07:47 +00:00
kern Fix sys.kern.coredump_phnum_test.coredump_phnum on i386 2019-04-22 11:21:20 +00:00
kqueue Temporarily skip flakey test cases 2018-12-06 09:22:35 +00:00
mac DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
mqueue DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
net tun tests: Test renaming and destroying a tun interface in a vnet jail 2019-03-05 15:49:30 +00:00
netinet Plug a trivial memory leak. 2018-11-20 18:13:18 +00:00
netipsec ipsec tests: Skip if ipsec.ko is not loaded 2019-05-16 02:18:57 +00:00
netmap netmap: add test cases for multiple host rings 2019-04-13 12:50:47 +00:00
netpfil pf tests: Fail the test if we can't set the rules 2019-04-18 10:54:08 +00:00
opencrypto Fix KAT(CCM)?Parser file descriptor leaks 2019-05-21 02:30:43 +00:00
pjdfstest DIRDEPS_BUILD: Update dependencies. 2017-10-31 00:07:04 +00:00
posixshm Revert r337929 2018-08-16 22:04:00 +00:00
sys Improve tree(3) tests by using ATF_REQUIRE where applicable. 2019-05-20 18:35:23 +00:00
vfs vfs_lookup: Allow PATH_MAX-1 symlinks 2017-11-17 19:25:39 +00:00
vm Add a few regression tests for mlock(2). 2019-05-01 15:28:23 +00:00
Makefile tests: Move common (vnet) test functions into a common file 2019-03-04 18:15:06 +00:00
Makefile.depend DIRDEPS_BUILD: Connect MK_TESTS. 2016-03-09 22:46:01 +00:00
Makefile.inc Use MK_CHECK_USE_SANDBOX in tests/..., to deal with the fact that 2017-08-02 22:24:08 +00:00