Remove obsolete test_isolated wrapper function
We already run all of our tests in isolated mode. Change-Id: I8236baa302b1026a9b4a1c33a4aa65e223771bc7
This commit is contained in:
parent
169a84f980
commit
cb0443c0fa
@ -22,7 +22,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "gtest_ex.h"
|
||||
#include "private/ScopeGuard.h"
|
||||
|
||||
#include <string>
|
||||
@ -376,33 +375,31 @@ TEST(dlfcn, check_unload_after_reloc) {
|
||||
// Test dlopens parent1 which loads and relocates libtest_two_parents_child.so
|
||||
// as a second step it dlopens parent2 and dlcloses parent1...
|
||||
|
||||
test_isolated([] {
|
||||
void* handle = dlopen("libtest_two_parents_parent1.so", RTLD_NOW | RTLD_LOCAL);
|
||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||
void* handle = dlopen("libtest_two_parents_parent1.so", RTLD_NOW | RTLD_LOCAL);
|
||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||
|
||||
void* handle2 = dlopen("libtest_two_parents_parent2.so", RTLD_NOW | RTLD_LOCAL);
|
||||
ASSERT_TRUE(handle2 != nullptr) << dlerror();
|
||||
void* handle2 = dlopen("libtest_two_parents_parent2.so", RTLD_NOW | RTLD_LOCAL);
|
||||
ASSERT_TRUE(handle2 != nullptr) << dlerror();
|
||||
|
||||
typedef int (*fn_t) (void);
|
||||
fn_t fn = reinterpret_cast<fn_t>(dlsym(handle2, "check_order_reloc_get_answer"));
|
||||
ASSERT_TRUE(fn != nullptr) << dlerror();
|
||||
ASSERT_EQ(42, fn());
|
||||
typedef int (*fn_t) (void);
|
||||
fn_t fn = reinterpret_cast<fn_t>(dlsym(handle2, "check_order_reloc_get_answer"));
|
||||
ASSERT_TRUE(fn != nullptr) << dlerror();
|
||||
ASSERT_EQ(42, fn());
|
||||
|
||||
ASSERT_EQ(0, dlclose(handle));
|
||||
ASSERT_EQ(0, dlclose(handle));
|
||||
|
||||
handle = dlopen("libtest_two_parents_parent1.so", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle != nullptr);
|
||||
ASSERT_EQ(0, dlclose(handle));
|
||||
handle = dlopen("libtest_two_parents_parent1.so", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle != nullptr);
|
||||
ASSERT_EQ(0, dlclose(handle));
|
||||
|
||||
fn = reinterpret_cast<fn_t>(dlsym(handle2, "check_order_reloc_get_answer"));
|
||||
ASSERT_TRUE(fn != nullptr) << dlerror();
|
||||
ASSERT_EQ(42, fn());
|
||||
fn = reinterpret_cast<fn_t>(dlsym(handle2, "check_order_reloc_get_answer"));
|
||||
ASSERT_TRUE(fn != nullptr) << dlerror();
|
||||
ASSERT_EQ(42, fn());
|
||||
|
||||
ASSERT_EQ(0, dlclose(handle2));
|
||||
ASSERT_EQ(0, dlclose(handle2));
|
||||
|
||||
handle = dlopen("libtest_two_parents_parent1.so", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle == nullptr);
|
||||
});
|
||||
handle = dlopen("libtest_two_parents_parent1.so", RTLD_NOW | RTLD_LOCAL | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle == nullptr);
|
||||
}
|
||||
|
||||
extern "C" int check_order_reloc_root_get_answer_impl() {
|
||||
@ -485,25 +482,23 @@ TEST(dlfcn, dlopen_check_rtld_global) {
|
||||
// libtest_with_dependency_loop_b.so -> libtest_with_dependency_loop_c.so ->
|
||||
// libtest_with_dependency_loop_a.so
|
||||
TEST(dlfcn, dlopen_check_loop) {
|
||||
test_isolated([] {
|
||||
void* handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW);
|
||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||
void* f = dlsym(handle, "dlopen_test_loopy_function");
|
||||
ASSERT_TRUE(f != nullptr) << dlerror();
|
||||
EXPECT_TRUE(reinterpret_cast<bool (*)(void)>(f)());
|
||||
ASSERT_EQ(0, dlclose(handle));
|
||||
void* handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW);
|
||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||
void* f = dlsym(handle, "dlopen_test_loopy_function");
|
||||
ASSERT_TRUE(f != nullptr) << dlerror();
|
||||
EXPECT_TRUE(reinterpret_cast<bool (*)(void)>(f)());
|
||||
ASSERT_EQ(0, dlclose(handle));
|
||||
|
||||
// dlopen second time to make sure that the library was unloaded correctly
|
||||
handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle == nullptr);
|
||||
// dlopen second time to make sure that the library was unloaded correctly
|
||||
handle = dlopen("libtest_with_dependency_loop.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle == nullptr);
|
||||
#ifdef __BIONIC__
|
||||
// TODO: glibc returns nullptr on dlerror() here. Is it bug?
|
||||
ASSERT_STREQ("dlopen failed: library \"libtest_with_dependency_loop.so\" wasn't loaded and RTLD_NOLOAD prevented it", dlerror());
|
||||
// TODO: glibc returns nullptr on dlerror() here. Is it bug?
|
||||
ASSERT_STREQ("dlopen failed: library \"libtest_with_dependency_loop.so\" wasn't loaded and RTLD_NOLOAD prevented it", dlerror());
|
||||
#endif
|
||||
|
||||
handle = dlopen("libtest_with_dependency_a.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle == nullptr);
|
||||
});
|
||||
handle = dlopen("libtest_with_dependency_a.so", RTLD_NOW | RTLD_NOLOAD);
|
||||
ASSERT_TRUE(handle == nullptr);
|
||||
}
|
||||
|
||||
TEST(dlfcn, dlopen_nodelete) {
|
||||
@ -830,15 +825,13 @@ TEST(dlfcn, dlsym_weak_func) {
|
||||
}
|
||||
|
||||
TEST(dlfcn, dlopen_undefined_weak_func) {
|
||||
test_isolated([] {
|
||||
void* handle = dlopen("libtest_dlopen_weak_undefined_func.so", RTLD_NOW);
|
||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||
int (*weak_func)();
|
||||
weak_func = reinterpret_cast<int (*)()>(dlsym(handle, "use_weak_undefined_func"));
|
||||
ASSERT_TRUE(weak_func != nullptr) << dlerror();
|
||||
EXPECT_EQ(6551, weak_func());
|
||||
dlclose(handle);
|
||||
});
|
||||
void* handle = dlopen("libtest_dlopen_weak_undefined_func.so", RTLD_NOW);
|
||||
ASSERT_TRUE(handle != nullptr) << dlerror();
|
||||
int (*weak_func)();
|
||||
weak_func = reinterpret_cast<int (*)()>(dlsym(handle, "use_weak_undefined_func"));
|
||||
ASSERT_TRUE(weak_func != nullptr) << dlerror();
|
||||
EXPECT_EQ(6551, weak_func());
|
||||
dlclose(handle);
|
||||
}
|
||||
|
||||
TEST(dlfcn, dlopen_symlink) {
|
||||
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2014 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 <gtest/gtest.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
template<typename F>
|
||||
void test_isolated(F test) {
|
||||
int pid = fork();
|
||||
ASSERT_NE(-1, pid) << strerror(errno);
|
||||
|
||||
if (pid == 0) {
|
||||
test();
|
||||
_exit(testing::Test::HasFailure() ? 1 : 0);
|
||||
}
|
||||
|
||||
int status;
|
||||
ASSERT_EQ(pid, waitpid(pid, &status, 0));
|
||||
ASSERT_TRUE(WIFEXITED(status));
|
||||
ASSERT_EQ(0, WEXITSTATUS(status)) << "Forked test has failed, see above..";
|
||||
}
|
@ -19,7 +19,6 @@
|
||||
#include "private/ScopeGuard.h"
|
||||
#include "BionicDeathTest.h"
|
||||
#include "ScopedSignalHandler.h"
|
||||
#include "gtest_ex.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
@ -817,23 +816,21 @@ static void AtForkChild1() { g_atfork_child_calls = (g_atfork_child_calls << 4)
|
||||
static void AtForkChild2() { g_atfork_child_calls = (g_atfork_child_calls << 4) | 2; }
|
||||
|
||||
TEST(pthread, pthread_atfork_smoke) {
|
||||
test_isolated([] {
|
||||
ASSERT_EQ(0, pthread_atfork(AtForkPrepare1, AtForkParent1, AtForkChild1));
|
||||
ASSERT_EQ(0, pthread_atfork(AtForkPrepare2, AtForkParent2, AtForkChild2));
|
||||
ASSERT_EQ(0, pthread_atfork(AtForkPrepare1, AtForkParent1, AtForkChild1));
|
||||
ASSERT_EQ(0, pthread_atfork(AtForkPrepare2, AtForkParent2, AtForkChild2));
|
||||
|
||||
int pid = fork();
|
||||
ASSERT_NE(-1, pid) << strerror(errno);
|
||||
int pid = fork();
|
||||
ASSERT_NE(-1, pid) << strerror(errno);
|
||||
|
||||
// Child and parent calls are made in the order they were registered.
|
||||
if (pid == 0) {
|
||||
ASSERT_EQ(0x12, g_atfork_child_calls);
|
||||
_exit(0);
|
||||
}
|
||||
ASSERT_EQ(0x12, g_atfork_parent_calls);
|
||||
// Child and parent calls are made in the order they were registered.
|
||||
if (pid == 0) {
|
||||
ASSERT_EQ(0x12, g_atfork_child_calls);
|
||||
_exit(0);
|
||||
}
|
||||
ASSERT_EQ(0x12, g_atfork_parent_calls);
|
||||
|
||||
// Prepare calls are made in the reverse order.
|
||||
ASSERT_EQ(0x21, g_atfork_prepare_calls);
|
||||
});
|
||||
// Prepare calls are made in the reverse order.
|
||||
ASSERT_EQ(0x21, g_atfork_prepare_calls);
|
||||
}
|
||||
|
||||
TEST(pthread, pthread_attr_getscope) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user