sys_epoll_test.cpp revision 11952073af22568bba0b661f7a9d4402c443a888
1/* 2 * Copyright (C) 2013 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#include <gtest/gtest.h> 18 19#include <errno.h> 20#include <sys/epoll.h> 21 22TEST(sys_epoll, smoke) { 23 int epoll_fd = epoll_create(1); 24 ASSERT_NE(-1, epoll_fd) << strerror(errno); 25 epoll_event events[1]; 26 27 // Regular epoll_wait. 28 ASSERT_EQ(0, epoll_wait(epoll_fd, events, 1, 1)); 29 30 // epoll_pwait without a sigset (which is equivalent to epoll_wait). 31 ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, NULL)); 32 33 // epoll_pwait with a sigset. 34 sigset_t ss; 35 sigemptyset(&ss); 36 sigaddset(&ss, SIGPIPE); 37 ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, &ss)); 38} 39