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

public void testCloseOrWarn_fileDescriptor() throws Exception {
    FileDescriptor fd = mock(FileDescriptor.class);
    mockStatic(Log.class);
    mockStatic(Os.class);
    when(Log.e(anyString(), anyString(), any(Throwable.class))).then(new CountingAnswer(null));
    // Closing null should work just fine
    testResult = 0;
    assertNull(FileHelper.closeOrWarn((FileDescriptor) null, "tag", "msg"));
    assertEquals(0, testResult);
    // Successfully closing the file should not log.
    testResult = 0;
    assertNull(FileHelper.closeOrWarn(fd, "tag", "msg"));
    assertEquals(0, testResult);
    // If closing fails, it should log.
    testResult = 0;
    doThrow(new ErrnoException("close", 0)).when(Os.class, "close", any(FileDescriptor.class));
    assertNull(FileHelper.closeOrWarn(fd, "tag", "msg"));
    assertEquals(1, testResult);
}