@Test
@PrepareForTest({Log.class, Os.class})

public void testPoll_retryInterrupt() throws Exception {
    mockStatic(Log.class);
    mockStatic(Os.class);
    when(Os.poll(any(StructPollfd[].class), anyInt())).then(new Answer<Integer>() {
        @Override
        public Integer answer(InvocationOnMock invocation) throws Throwable {
            // First try fails with EINTR, seconds returns success.
            if (testResult++ == 0) {
                // Android actually sets all OsConstants to 0 when running the
                // unit tests, so this works, but another constant would have
                // exactly the same result.
                throw new ErrnoException("poll", OsConstants.EINTR);
            }
            return 0;
        }
    });
    // poll() will be interrupted first time, so called a second time.
    assertEquals(0, FileHelper.poll(null, 0));
    assertEquals(2, testResult);
}