TEST(semaphore, sem_timedwait_monotonic_np) { #if defined(__BIONIC__) sem_timedwait_helper(CLOCK_MONOTONIC, sem_timedwait_monotonic_np); #else // __BIONIC__ GTEST_SKIP() << "sem_timedwait_monotonic_np is only supported on bionic"; #endif // __BIONIC__ }
TEST(sys_random, getrandom_EFAULT) { #if defined(HAVE_SYS_RANDOM) errno = 0; ASSERT_EQ(-1, getrandom(nullptr, 256, 0)); ASSERT_EQ(EFAULT, errno); #else GTEST_SKIP() << "<sys/random.h> not available"; #endif }
TEST(sys_random, getrandom_EINVAL) { #if defined(HAVE_SYS_RANDOM) errno = 0; char buf[64]; ASSERT_EQ(-1, getrandom(buf, sizeof(buf), ~0)); ASSERT_EQ(EINVAL, errno); #else GTEST_SKIP() << "<sys/random.h> not available"; #endif }
TEST(sys_random, getrandom) { #if defined(HAVE_SYS_RANDOM) char buf1[64]; char buf2[64]; ASSERT_EQ(64, getrandom(buf1, sizeof(buf1), 0)); ASSERT_EQ(64, getrandom(buf2, sizeof(buf2), 0)); ASSERT_TRUE(memcmp(buf1, buf2, sizeof(buf1)) != 0); #else GTEST_SKIP() << "<sys/random.h> not available"; #endif }
TEST(sys_random, getentropy_EIO) { #if defined(HAVE_SYS_RANDOM) char buf[BUFSIZ]; static_assert(BUFSIZ > 256, "BUFSIZ <= 256!"); errno = 0; ASSERT_EQ(-1, getentropy(buf, sizeof(buf))); ASSERT_EQ(EIO, errno); #else GTEST_SKIP() << "<sys/random.h> not available"; #endif }
TEST(stdio_ext, __fseterr) { #if defined(__GLIBC__) GTEST_SKIP() << "glibc doesn't have __fseterr, but gnulib will use it"; #else FILE* fp = fopen("/dev/null", "w"); ASSERT_FALSE(ferror(fp)); __fseterr(fp); ASSERT_TRUE(ferror(fp)); clearerr(fp); ASSERT_FALSE(ferror(fp)); fclose(fp); #endif }
TEST(semaphore, sem_wait_no_EINTR_in_sdk_less_equal_than_23) { #if defined(__BIONIC__) android_set_application_target_sdk_version(__ANDROID_API_M__); sem_t s; ASSERT_EQ(0, sem_init(&s, 0, 0)); ScopedSignalHandler handler(SIGUSR1, sem_wait_test_signal_handler); pthread_t thread; ASSERT_EQ(0, pthread_create(&thread, nullptr, SemWaitEINTRThreadFn, &s)); // Give some time for the thread to run sem_wait. usleep(500000); ASSERT_EQ(0, pthread_kill(thread, SIGUSR1)); // Give some time for the thread to handle signal. usleep(500000); ASSERT_EQ(0, sem_post(&s)); void* result; ASSERT_EQ(0, pthread_join(thread, &result)); ASSERT_EQ(0U, reinterpret_cast<uintptr_t>(result)); #else GTEST_SKIP() << "This test tests sem_wait's compatibility for old sdk versions"; #endif }
TEST(sys_sem, smoke) { if (semctl(-1, 0, IPC_RMID) == -1 && errno == ENOSYS) { GTEST_SKIP() << "no <sys/sem.h> support in this kernel"; } // Create a semaphore. TemporaryDir dir; key_t key = ftok(dir.path, 1); int id = semget(key, 1, IPC_CREAT|0666); ASSERT_NE(id, -1); // Check semaphore info. semid_ds ds; memset(&ds, 0, sizeof(ds)); ASSERT_EQ(0, semctl(id, 0, IPC_STAT, &ds)); ASSERT_EQ(1U, ds.sem_nsems); ASSERT_EQ(0, semctl(id, 0, GETVAL)); // Increment. sembuf ops[] = {{ .sem_num = 0, .sem_op = 1, .sem_flg = 0 }};
TEST_F(JoinHashStepsTest, ThrowWhenNoNullValuesArePassed) { if (!HYRISE_DEBUG) GTEST_SKIP(); size_t radix_bit_count = 0; std::vector<std::vector<size_t>> histograms; const auto chunk_offsets = determine_chunk_offsets(_table_with_nulls_and_zeros->get_output()); const auto materialized_without_null_handling = materialize_input<int, int, false>( _table_with_nulls_and_zeros->get_output(), ColumnID{0}, chunk_offsets, histograms, radix_bit_count); // We want to test a non-NULL-considering Radix Container, ensure we did it correctly EXPECT_EQ(materialized_without_null_handling.null_value_bitvector->size(), 0); // Using true as the NULL handing flag should lead to an error, // because we did not create NULL value information during materialization. // Note, the extra parantheses are required for Gtest since otherwise the preprocessor // has problems resolving this code line (see https://stackoverflow.com/a/35957776/1147726) EXPECT_THROW((partition_radix_parallel<int, int, true>)(materialized_without_null_handling, chunk_offsets, histograms, radix_bit_count), std::logic_error); }