diff --git a/tests/Android.mk b/tests/Android.mk index e60b90893..39c28a41d 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -80,6 +80,7 @@ test_src_files = \ string_test.cpp \ strings_test.cpp \ stubs_test.cpp \ + sys_select_test.cpp \ sys_sendfile_test.cpp \ sys_stat_test.cpp \ system_properties_test.cpp \ diff --git a/tests/fortify_test.cpp b/tests/fortify_test.cpp index 3a1bb93a3..abe2cae5a 100644 --- a/tests/fortify_test.cpp +++ b/tests/fortify_test.cpp @@ -350,7 +350,7 @@ TEST(DEATHTEST, strlen_fortified) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; char buf[10]; memcpy(buf, "0123456789", sizeof(buf)); - ASSERT_EXIT(printf("%d", strlen(buf)), testing::KilledBySignal(SIGABRT), ""); + ASSERT_EXIT(printf("%zd", strlen(buf)), testing::KilledBySignal(SIGABRT), ""); } TEST(DEATHTEST, strchr_fortified) { diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index d4d38f521..d82921b30 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -56,7 +57,7 @@ static void* IdFn(void* arg) { } static void* SleepFn(void* arg) { - sleep(reinterpret_cast(arg)); + sleep(reinterpret_cast(arg)); return NULL; } @@ -140,7 +141,7 @@ TEST(pthread, pthread_no_op_detach_after_join) { // ...but t2's join on t1 still goes ahead (which we can tell because our join on t2 finishes). void* join_result; ASSERT_EQ(0, pthread_join(t2, &join_result)); - ASSERT_EQ(0, reinterpret_cast(join_result)); + ASSERT_EQ(0U, reinterpret_cast(join_result)); } TEST(pthread, pthread_join_self) { @@ -190,7 +191,7 @@ TEST(pthread, pthread_sigmask) { void* join_result; ASSERT_EQ(0, pthread_join(signal_thread, &join_result)); ASSERT_EQ(SIGUSR1, received_signal); - ASSERT_EQ(0, reinterpret_cast(join_result)); + ASSERT_EQ(0U, reinterpret_cast(join_result)); } #if __BIONIC__ @@ -348,7 +349,7 @@ TEST(pthread, pthread_join__multijoin) { // ...but t2's join on t1 still goes ahead (which we can tell because our join on t2 finishes). void* join_result; ASSERT_EQ(0, pthread_join(t2, &join_result)); - ASSERT_EQ(0, reinterpret_cast(join_result)); + ASSERT_EQ(0U, reinterpret_cast(join_result)); } static void* GetActualGuardSizeFn(void* arg) { diff --git a/tests/sys_select_test.cpp b/tests/sys_select_test.cpp new file mode 100644 index 000000000..36f01b386 --- /dev/null +++ b/tests/sys_select_test.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed 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. + */ + +#include + +#include +#include +#include + +TEST(sys_select, fd_set_smoke) { + fd_set fds; + FD_ZERO(&fds); + + for (size_t i = 0; i < 1024; ++i) { + EXPECT_FALSE(FD_ISSET(i, &fds)); + } + + FD_SET(0, &fds); + EXPECT_TRUE(FD_ISSET(0, &fds)); + EXPECT_FALSE(FD_ISSET(1, &fds)); + FD_SET(1, &fds); + EXPECT_TRUE(FD_ISSET(0, &fds)); + EXPECT_TRUE(FD_ISSET(1, &fds)); + FD_CLR(0, &fds); + EXPECT_FALSE(FD_ISSET(0, &fds)); + EXPECT_TRUE(FD_ISSET(1, &fds)); + FD_CLR(1, &fds); + EXPECT_FALSE(FD_ISSET(0, &fds)); + EXPECT_FALSE(FD_ISSET(1, &fds)); +}