sys_epoll_test.cpp revision f04935c85e0b466f0d30d2cd4c0fa2fff62e7d6d
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 <signal.h>
21#include <sys/epoll.h>
22
23TEST(sys_epoll, smoke) {
24  int epoll_fd = epoll_create(1);
25  ASSERT_NE(-1, epoll_fd) << strerror(errno);
26  epoll_event events[1];
27
28  // Regular epoll_wait.
29  ASSERT_EQ(0, epoll_wait(epoll_fd, events, 1, 1));
30
31  // epoll_pwait without a sigset (which is equivalent to epoll_wait).
32  ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, NULL));
33
34  // epoll_pwait with a sigset.
35  sigset_t ss;
36  sigemptyset(&ss);
37  sigaddset(&ss, SIGPIPE);
38  ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, &ss));
39}
40