/*
 * Copyright 2014 The Netty Project
 *
 * The Netty Project licenses this file to you under the Apache License,
 * version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at:
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */
package io.netty.channel.epoll;

import org.junit.Assert;
import org.junit.Test;

public class EpollTest {

    @Test
    public void testIsAvailable() {
        Assert.assertTrue(Epoll.isAvailable());
    }
}

@@ -660,32 +660,161 @@
 .epoll;%0A%0Aimport 
+io.netty.channel.unix.FileDescriptor;%0Aimport org.junit.Test;%0A%0Aimport java.util.concurrent.atomic.AtomicReference;%0A%0Aimport static 
 org.junit.Assert
@@ -813,16 +813,29 @@
 t.Assert
+.assertEquals
 ;%0Aimport
@@ -827,32 +827,39 @@
 tEquals;%0Aimport 
+static 
 org.junit.Test;%0A
@@ -852,20 +852,76 @@
 g.junit.
-Test
+Assert.assertNull;%0Aimport static org.junit.Assert.assertTrue
 ;%0A%0Apubli
@@ -995,23 +995,16 @@
         
-Assert.
 assertTr
@@ -1027,16 +1027,1600 @@
 able());
+%0A    %7D%0A%0A    // Testcase for https://github.com/netty/netty/issues/8444%0A    @Test(timeout = 5000)%0A    public void testEpollWaitWithTimeOutMinusOne() throws Exception  %7B%0A        final EpollEventArray eventArray = new EpollEventArray(8);%0A        try %7B%0A            final FileDescriptor epoll = Native.newEpollCreate();%0A            final FileDescriptor timerFd = Native.newTimerFd();%0A            final FileDescriptor eventfd = Native.newEventFd();%0A            Native.epollCtlAdd(epoll.intValue(), timerFd.intValue(), Native.EPOLLIN);%0A            Native.epollCtlAdd(epoll.intValue(), eventfd.intValue(), Native.EPOLLIN);%0A%0A            final AtomicReference%3CThrowable%3E ref = new AtomicReference%3CThrowable%3E();%0A            Thread t = new Thread(new Runnable() %7B%0A                @Override%0A                public void run() %7B%0A                    try %7B%0A                        assertEquals(1, Native.epollWait(epoll, eventArray, timerFd, -1, -1));%0A                        // This should have been woken up because of eventfd_write.%0A                        assertEquals(eventfd.intValue(), eventArray.fd(0));%0A                    %7D catch (Throwable cause) %7B%0A                        ref.set(cause);%0A                    %7D%0A                %7D%0A            %7D);%0A            t.start();%0A            t.join(1000);%0A            assertTrue(t.isAlive());%0A            Native.eventFdWrite(eventfd.intValue(), 1);%0A%0A            t.join();%0A            assertNull(ref.get());%0A            epoll.close();%0A            timerFd.close();%0A            eventfd.close();%0A        %7D finally %7B%0A            eventArray.free();%0A        %7D
 %0A    %7D%0A%7D

Add testcase for epollWait(...) with negative timerfd values. (#8447)