Page MenuHomeFreeBSD

libc: tests: add some tests for fdwalk(3)
Needs ReviewPublic

Authored by kevans on Oct 15 2020, 9:16 PM.

Details

Reviewers
mjg
jhibbits
Summary

These tests are purely based on my expectations from reading the documentation provided on Oracle's website[0]. It covers the following scenarios:

  • trivial_test: Basically functions, iterates in order.
  • early_term_test: Early termination works, and returns the non-0 return value from the callback.
  • gap_test: Tests that fdwalk will infact skip over gaps if some intermediate fds have been closed.
  • rlim_test: Ensure that we're not being artifically limited to walking fds lower than the RLIMIT_NOFILE specified.
  • concur_test: Tests that fdwalk(3) is walking over a snapshot of the fd space from when it started.
  • same_thr_test: Ditto that, except open the extra fds in the same thread instead of a concurrent thread
  • empty_test: empty fd table should result in no callback, and return 0

The rlimit test isn't strictly necessary, but it was inspired by the Oracle documentation pointing out that closefrom doesn't actually behave like their example because it's not limiting itself to closing only those under RLIMIT_NOFILE. It's really just testing that we're not artificially limited by an rlimit in what we can walk.

[0] https://docs.oracle.com/cd/E19683-01/816-5214/6mbcfdl0g/index.html

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 34204

Event Timeline

kevans edited the summary of this revision. (Show Details)
  • Fix a typo in cleanup that went unnoticed because kyua isolation (s/</<=)
  • Add another test for 'consistent snapshot', fds opened directly in the callback for the first fd
kevans edited the summary of this revision. (Show Details)

Sorry, last change... throw in a fork+closefrom+fdwalk test