test: back-port EMFILE test from master branch

Back-port the test from commit 27795cf from the master branch ("unix:
fix accept() EMFILE error handling").