2017-03-07 20:19:05 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2017 The Android Open Source Project
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
2019-02-15 22:48:38 +01:00
|
|
|
#include "linker_config.h"
|
|
|
|
#include "linker_utils.h"
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2018-11-15 00:19:53 +01:00
|
|
|
#include <android-base/file.h>
|
2017-04-06 01:20:29 +02:00
|
|
|
#include <android-base/scopeguard.h>
|
2017-03-07 20:19:05 +01:00
|
|
|
#include <android-base/stringprintf.h>
|
2023-03-23 00:12:49 +01:00
|
|
|
#include <vector>
|
2017-03-07 20:19:05 +01:00
|
|
|
|
2017-06-16 07:43:16 +02:00
|
|
|
#if defined(__LP64__)
|
|
|
|
#define ARCH_SUFFIX "64"
|
|
|
|
#else
|
|
|
|
#define ARCH_SUFFIX ""
|
|
|
|
#endif
|
2017-03-07 20:19:05 +01:00
|
|
|
|
2020-06-02 08:38:49 +02:00
|
|
|
// clang-format off
|
2017-03-07 20:19:05 +01:00
|
|
|
static const char* config_str =
|
|
|
|
"# comment \n"
|
|
|
|
"dir.test = /data/local/tmp\n"
|
|
|
|
"\n"
|
|
|
|
"[test]\n"
|
|
|
|
"\n"
|
|
|
|
"enable.target.sdk.version = true\n"
|
|
|
|
"additional.namespaces=system\n"
|
2017-11-29 10:30:53 +01:00
|
|
|
"additional.namespaces+=vndk\n"
|
2019-01-13 06:03:25 +01:00
|
|
|
"additional.namespaces+=vndk_in_system\n"
|
2017-03-07 20:19:05 +01:00
|
|
|
"namespace.default.isolated = true\n"
|
|
|
|
"namespace.default.search.paths = /vendor/${LIB}\n"
|
|
|
|
"namespace.default.permitted.paths = /vendor/${LIB}\n"
|
2017-11-29 10:30:53 +01:00
|
|
|
"namespace.default.asan.search.paths = /data\n"
|
|
|
|
"namespace.default.asan.search.paths += /vendor/${LIB}\n"
|
2017-03-07 20:19:05 +01:00
|
|
|
"namespace.default.asan.permitted.paths = /data:/vendor\n"
|
2023-03-23 00:12:49 +01:00
|
|
|
"namespace.default.hwasan.search.paths = /vendor/${LIB}/hwasan\n"
|
|
|
|
"namespace.default.hwasan.search.paths += /vendor/${LIB}\n"
|
|
|
|
"namespace.default.hwasan.permitted.paths = /vendor/${LIB}/hwasan\n"
|
|
|
|
"namespace.default.hwasan.permitted.paths += /vendor/${LIB}\n"
|
2017-03-07 20:19:05 +01:00
|
|
|
"namespace.default.links = system\n"
|
2017-11-29 10:30:53 +01:00
|
|
|
"namespace.default.links += vndk\n"
|
|
|
|
// irregular whitespaces are added intentionally for testing purpose
|
|
|
|
"namespace.default.link.system.shared_libs= libc.so\n"
|
|
|
|
"namespace.default.link.system.shared_libs += libm.so:libdl.so\n"
|
|
|
|
"namespace.default.link.system.shared_libs +=libstdc++.so\n"
|
|
|
|
"namespace.default.link.vndk.shared_libs = libcutils.so:libbase.so\n"
|
2017-03-07 20:19:05 +01:00
|
|
|
"namespace.system.isolated = true\n"
|
2017-04-03 16:10:37 +02:00
|
|
|
"namespace.system.visible = true\n"
|
2017-03-07 20:19:05 +01:00
|
|
|
"namespace.system.search.paths = /system/${LIB}\n"
|
|
|
|
"namespace.system.permitted.paths = /system/${LIB}\n"
|
|
|
|
"namespace.system.asan.search.paths = /data:/system/${LIB}\n"
|
|
|
|
"namespace.system.asan.permitted.paths = /data:/system\n"
|
2023-03-23 00:12:49 +01:00
|
|
|
"namespace.system.hwasan.search.paths = /system/${LIB}/hwasan\n"
|
|
|
|
"namespace.system.hwasan.search.paths += /system/${LIB}\n"
|
|
|
|
"namespace.system.hwasan.permitted.paths = /system/${LIB}/hwasan\n"
|
|
|
|
"namespace.system.hwasan.permitted.paths += /system/${LIB}\n"
|
2017-11-29 10:30:53 +01:00
|
|
|
"namespace.vndk.isolated = tr\n"
|
|
|
|
"namespace.vndk.isolated += ue\n" // should be ignored and return as 'false'.
|
|
|
|
"namespace.vndk.search.paths = /system/${LIB}/vndk\n"
|
|
|
|
"namespace.vndk.asan.search.paths = /data\n"
|
|
|
|
"namespace.vndk.asan.search.paths += /system/${LIB}/vndk\n"
|
2023-03-23 00:12:49 +01:00
|
|
|
"namespace.vndk.hwasan.search.paths = /system/${LIB}/vndk/hwasan\n"
|
|
|
|
"namespace.vndk.hwasan.search.paths += /system/${LIB}/vndk\n"
|
2018-01-18 05:05:09 +01:00
|
|
|
"namespace.vndk.links = default\n"
|
|
|
|
"namespace.vndk.link.default.allow_all_shared_libs = true\n"
|
2019-01-13 06:03:25 +01:00
|
|
|
"namespace.vndk.link.vndk_in_system.allow_all_shared_libs = true\n"
|
|
|
|
"namespace.vndk_in_system.isolated = true\n"
|
|
|
|
"namespace.vndk_in_system.visible = true\n"
|
|
|
|
"namespace.vndk_in_system.search.paths = /system/${LIB}\n"
|
|
|
|
"namespace.vndk_in_system.permitted.paths = /system/${LIB}\n"
|
2020-06-02 08:38:49 +02:00
|
|
|
"namespace.vndk_in_system.whitelisted = libz.so:libyuv.so\n"
|
|
|
|
"namespace.vndk_in_system.whitelisted += libtinyxml2.so\n"
|
2020-07-30 09:09:18 +02:00
|
|
|
"namespace.vndk_in_system.allowed_libs = libfoo.so:libbar.so\n"
|
|
|
|
"namespace.vndk_in_system.allowed_libs += libtinyxml3.so\n"
|
2017-03-07 20:19:05 +01:00
|
|
|
"\n";
|
2020-06-02 08:38:49 +02:00
|
|
|
// clang-format on
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
static bool write_version(const std::string& path, uint32_t version) {
|
|
|
|
std::string content = android::base::StringPrintf("%d", version);
|
|
|
|
return android::base::WriteStringToFile(content, path);
|
|
|
|
}
|
|
|
|
|
2017-06-16 07:43:16 +02:00
|
|
|
static std::vector<std::string> resolve_paths(std::vector<std::string> paths) {
|
|
|
|
std::vector<std::string> resolved_paths;
|
|
|
|
resolve_paths(paths, &resolved_paths);
|
|
|
|
return resolved_paths;
|
|
|
|
}
|
2017-03-07 20:19:05 +01:00
|
|
|
|
2023-03-23 00:12:49 +01:00
|
|
|
enum class SmokeTestType {
|
|
|
|
None,
|
|
|
|
Asan,
|
|
|
|
Hwasan,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void run_linker_config_smoke_test(SmokeTestType type) {
|
|
|
|
std::vector<std::string> expected_default_search_path;
|
|
|
|
std::vector<std::string> expected_default_permitted_path;
|
|
|
|
std::vector<std::string> expected_system_search_path;
|
|
|
|
std::vector<std::string> expected_system_permitted_path;
|
|
|
|
std::vector<std::string> expected_vndk_search_path;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case SmokeTestType::None:
|
|
|
|
expected_default_search_path = { "/vendor/lib" ARCH_SUFFIX };
|
|
|
|
expected_default_permitted_path = { "/vendor/lib" ARCH_SUFFIX };
|
|
|
|
expected_system_search_path = { "/system/lib" ARCH_SUFFIX };
|
|
|
|
expected_system_permitted_path = { "/system/lib" ARCH_SUFFIX };
|
|
|
|
expected_vndk_search_path = { "/system/lib" ARCH_SUFFIX "/vndk" };
|
|
|
|
break;
|
|
|
|
case SmokeTestType::Asan:
|
|
|
|
expected_default_search_path = { "/data", "/vendor/lib" ARCH_SUFFIX };
|
|
|
|
expected_default_permitted_path = { "/data", "/vendor" };
|
|
|
|
expected_system_search_path = { "/data", "/system/lib" ARCH_SUFFIX };
|
|
|
|
expected_system_permitted_path = { "/data", "/system" };
|
|
|
|
expected_vndk_search_path = { "/data", "/system/lib" ARCH_SUFFIX "/vndk" };
|
|
|
|
break;
|
|
|
|
case SmokeTestType::Hwasan:
|
|
|
|
expected_default_search_path = { "/vendor/lib" ARCH_SUFFIX "/hwasan", "/vendor/lib" ARCH_SUFFIX };
|
|
|
|
expected_default_permitted_path = { "/vendor/lib" ARCH_SUFFIX "/hwasan", "/vendor/lib" ARCH_SUFFIX };
|
|
|
|
expected_system_search_path = { "/system/lib" ARCH_SUFFIX "/hwasan" , "/system/lib" ARCH_SUFFIX };
|
|
|
|
expected_system_permitted_path = { "/system/lib" ARCH_SUFFIX "/hwasan", "/system/lib" ARCH_SUFFIX };
|
|
|
|
expected_vndk_search_path = { "/system/lib" ARCH_SUFFIX "/vndk/hwasan", "/system/lib" ARCH_SUFFIX "/vndk" };
|
|
|
|
break;
|
|
|
|
}
|
2017-03-07 20:19:05 +01:00
|
|
|
|
2023-03-23 00:12:49 +01:00
|
|
|
expected_default_search_path = resolve_paths(expected_default_search_path);
|
|
|
|
// expected_default_permitted_path is skipped on purpose, permitted paths
|
|
|
|
// do not get resolved in linker_config.cpp
|
|
|
|
expected_system_search_path = resolve_paths(expected_system_search_path);
|
|
|
|
// expected_system_permitted_path is skipped on purpose, permitted paths
|
|
|
|
// do not get resolved in linker_config.cpp
|
|
|
|
expected_vndk_search_path = resolve_paths(expected_vndk_search_path);
|
2017-11-29 10:30:53 +01:00
|
|
|
|
2017-03-07 20:19:05 +01:00
|
|
|
TemporaryFile tmp_file;
|
|
|
|
close(tmp_file.fd);
|
|
|
|
tmp_file.fd = -1;
|
|
|
|
|
|
|
|
android::base::WriteStringToFile(config_str, tmp_file.path);
|
|
|
|
|
|
|
|
TemporaryDir tmp_dir;
|
|
|
|
|
|
|
|
std::string executable_path = std::string(tmp_dir.path) + "/some-binary";
|
|
|
|
std::string version_file = std::string(tmp_dir.path) + "/.version";
|
|
|
|
|
2017-04-06 01:20:29 +02:00
|
|
|
auto file_guard =
|
|
|
|
android::base::make_scope_guard([&version_file] { unlink(version_file.c_str()); });
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
ASSERT_TRUE(write_version(version_file, 113U)) << strerror(errno);
|
|
|
|
|
|
|
|
// read config
|
|
|
|
const Config* config = nullptr;
|
|
|
|
std::string error_msg;
|
|
|
|
ASSERT_TRUE(Config::read_binary_config(tmp_file.path,
|
|
|
|
executable_path.c_str(),
|
2023-03-23 00:12:49 +01:00
|
|
|
type == SmokeTestType::Asan,
|
|
|
|
type == SmokeTestType::Hwasan,
|
2017-03-07 20:19:05 +01:00
|
|
|
&config,
|
|
|
|
&error_msg)) << error_msg;
|
|
|
|
ASSERT_TRUE(config != nullptr);
|
|
|
|
ASSERT_TRUE(error_msg.empty());
|
|
|
|
|
2018-11-13 01:01:37 +01:00
|
|
|
ASSERT_EQ(113, config->target_sdk_version());
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
const NamespaceConfig* default_ns_config = config->default_namespace_config();
|
|
|
|
ASSERT_TRUE(default_ns_config != nullptr);
|
|
|
|
|
|
|
|
ASSERT_TRUE(default_ns_config->isolated());
|
2017-04-03 16:10:37 +02:00
|
|
|
ASSERT_FALSE(default_ns_config->visible());
|
2023-03-23 00:12:49 +01:00
|
|
|
ASSERT_EQ(expected_default_search_path, default_ns_config->search_paths());
|
|
|
|
ASSERT_EQ(expected_default_permitted_path, default_ns_config->permitted_paths());
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
const auto& default_ns_links = default_ns_config->links();
|
2017-11-29 10:30:53 +01:00
|
|
|
ASSERT_EQ(2U, default_ns_links.size());
|
2018-01-18 05:05:09 +01:00
|
|
|
|
2017-03-07 20:19:05 +01:00
|
|
|
ASSERT_EQ("system", default_ns_links[0].ns_name());
|
|
|
|
ASSERT_EQ("libc.so:libm.so:libdl.so:libstdc++.so", default_ns_links[0].shared_libs());
|
2018-01-18 05:05:09 +01:00
|
|
|
ASSERT_FALSE(default_ns_links[0].allow_all_shared_libs());
|
|
|
|
|
2017-11-29 10:30:53 +01:00
|
|
|
ASSERT_EQ("vndk", default_ns_links[1].ns_name());
|
|
|
|
ASSERT_EQ("libcutils.so:libbase.so", default_ns_links[1].shared_libs());
|
2018-01-18 05:05:09 +01:00
|
|
|
ASSERT_FALSE(default_ns_links[1].allow_all_shared_libs());
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
auto& ns_configs = config->namespace_configs();
|
2019-01-13 06:03:25 +01:00
|
|
|
ASSERT_EQ(4U, ns_configs.size());
|
2017-03-07 20:19:05 +01:00
|
|
|
|
|
|
|
// find second namespace
|
|
|
|
const NamespaceConfig* ns_system = nullptr;
|
2017-11-29 10:30:53 +01:00
|
|
|
const NamespaceConfig* ns_vndk = nullptr;
|
2019-01-13 06:03:25 +01:00
|
|
|
const NamespaceConfig* ns_vndk_in_system = nullptr;
|
2017-03-07 20:19:05 +01:00
|
|
|
for (auto& ns : ns_configs) {
|
|
|
|
std::string ns_name = ns->name();
|
2019-01-13 06:03:25 +01:00
|
|
|
ASSERT_TRUE(ns_name == "system" || ns_name == "default" ||
|
|
|
|
ns_name == "vndk" || ns_name == "vndk_in_system")
|
2017-03-07 20:19:05 +01:00
|
|
|
<< "unexpected ns name: " << ns->name();
|
|
|
|
|
|
|
|
if (ns_name == "system") {
|
|
|
|
ns_system = ns.get();
|
2017-11-29 10:30:53 +01:00
|
|
|
} else if (ns_name == "vndk") {
|
|
|
|
ns_vndk = ns.get();
|
2019-01-13 06:03:25 +01:00
|
|
|
} else if (ns_name == "vndk_in_system") {
|
|
|
|
ns_vndk_in_system = ns.get();
|
2017-03-07 20:19:05 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT_TRUE(ns_system != nullptr) << "system namespace was not found";
|
|
|
|
|
|
|
|
ASSERT_TRUE(ns_system->isolated());
|
2017-04-03 16:10:37 +02:00
|
|
|
ASSERT_TRUE(ns_system->visible());
|
2023-03-23 00:12:49 +01:00
|
|
|
ASSERT_EQ(expected_system_search_path, ns_system->search_paths());
|
|
|
|
ASSERT_EQ(expected_system_permitted_path, ns_system->permitted_paths());
|
2017-11-29 10:30:53 +01:00
|
|
|
|
|
|
|
ASSERT_TRUE(ns_vndk != nullptr) << "vndk namespace was not found";
|
|
|
|
|
|
|
|
ASSERT_FALSE(ns_vndk->isolated()); // malformed bool property
|
2018-01-18 05:05:09 +01:00
|
|
|
ASSERT_FALSE(ns_vndk->visible()); // undefined bool property
|
2023-03-23 00:12:49 +01:00
|
|
|
ASSERT_EQ(expected_vndk_search_path, ns_vndk->search_paths());
|
2018-01-18 05:05:09 +01:00
|
|
|
|
|
|
|
const auto& ns_vndk_links = ns_vndk->links();
|
|
|
|
ASSERT_EQ(1U, ns_vndk_links.size());
|
|
|
|
ASSERT_EQ("default", ns_vndk_links[0].ns_name());
|
|
|
|
ASSERT_TRUE(ns_vndk_links[0].allow_all_shared_libs());
|
2019-01-13 06:03:25 +01:00
|
|
|
|
|
|
|
ASSERT_TRUE(ns_vndk_in_system != nullptr) << "vndk_in_system namespace was not found";
|
2020-07-30 09:09:18 +02:00
|
|
|
ASSERT_EQ(std::vector<std::string>({"libz.so", "libyuv.so", "libtinyxml2.so", "libfoo.so",
|
|
|
|
"libbar.so", "libtinyxml3.so"}),
|
|
|
|
ns_vndk_in_system->allowed_libs());
|
2017-03-07 20:19:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(linker_config, smoke) {
|
2023-03-23 00:12:49 +01:00
|
|
|
run_linker_config_smoke_test(SmokeTestType::None);
|
2017-03-07 20:19:05 +01:00
|
|
|
}
|
|
|
|
|
2017-08-04 03:25:46 +02:00
|
|
|
TEST(linker_config, asan_smoke) {
|
2023-03-23 00:12:49 +01:00
|
|
|
run_linker_config_smoke_test(SmokeTestType::Asan);
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(linker_config, hwasan_smoke) {
|
|
|
|
run_linker_config_smoke_test(SmokeTestType::Hwasan);
|
2017-08-04 03:25:46 +02:00
|
|
|
}
|
2018-01-18 05:05:09 +01:00
|
|
|
|
|
|
|
TEST(linker_config, ns_link_shared_libs_invalid_settings) {
|
|
|
|
// This unit test ensures an error is emitted when a namespace link in ld.config.txt specifies
|
|
|
|
// both shared_libs and allow_all_shared_libs.
|
|
|
|
|
|
|
|
static const char config_str[] =
|
|
|
|
"dir.test = /data/local/tmp\n"
|
|
|
|
"\n"
|
|
|
|
"[test]\n"
|
|
|
|
"additional.namespaces = system\n"
|
|
|
|
"namespace.default.links = system\n"
|
|
|
|
"namespace.default.link.system.shared_libs = libc.so:libm.so\n"
|
|
|
|
"namespace.default.link.system.allow_all_shared_libs = true\n"
|
|
|
|
"\n";
|
|
|
|
|
|
|
|
TemporaryFile tmp_file;
|
|
|
|
close(tmp_file.fd);
|
|
|
|
tmp_file.fd = -1;
|
|
|
|
|
|
|
|
android::base::WriteStringToFile(config_str, tmp_file.path);
|
|
|
|
|
|
|
|
TemporaryDir tmp_dir;
|
|
|
|
|
|
|
|
std::string executable_path = std::string(tmp_dir.path) + "/some-binary";
|
|
|
|
|
|
|
|
const Config* config = nullptr;
|
|
|
|
std::string error_msg;
|
|
|
|
ASSERT_FALSE(Config::read_binary_config(tmp_file.path,
|
|
|
|
executable_path.c_str(),
|
|
|
|
false,
|
2023-03-23 00:12:49 +01:00
|
|
|
false,
|
2018-01-18 05:05:09 +01:00
|
|
|
&config,
|
|
|
|
&error_msg));
|
|
|
|
ASSERT_TRUE(config == nullptr);
|
|
|
|
ASSERT_EQ(std::string(tmp_file.path) + ":6: "
|
|
|
|
"error: both shared_libs and allow_all_shared_libs are set for default->system link.",
|
|
|
|
error_msg);
|
|
|
|
}
|
2018-06-18 08:30:18 +02:00
|
|
|
|
|
|
|
TEST(linker_config, dir_path_resolve) {
|
|
|
|
// This unit test ensures the linker resolves paths of dir.${section}
|
|
|
|
// properties to real path.
|
|
|
|
|
|
|
|
TemporaryDir tmp_dir;
|
|
|
|
|
|
|
|
std::string sub_dir = std::string(tmp_dir.path) + "/subdir";
|
|
|
|
mkdir(sub_dir.c_str(), 0755);
|
|
|
|
|
|
|
|
auto subdir_guard =
|
|
|
|
android::base::make_scope_guard([&sub_dir] { rmdir(sub_dir.c_str()); });
|
|
|
|
|
|
|
|
std::string symlink_path = std::string(tmp_dir.path) + "/symlink";
|
|
|
|
symlink(sub_dir.c_str(), symlink_path.c_str());
|
|
|
|
|
|
|
|
auto symlink_guard =
|
|
|
|
android::base::make_scope_guard([&symlink_path] { unlink(symlink_path.c_str()); });
|
|
|
|
|
|
|
|
std::string config_str =
|
|
|
|
"dir.test = " + symlink_path + "\n"
|
|
|
|
"\n"
|
|
|
|
"[test]\n";
|
|
|
|
|
|
|
|
TemporaryFile tmp_file;
|
|
|
|
close(tmp_file.fd);
|
|
|
|
tmp_file.fd = -1;
|
|
|
|
|
|
|
|
android::base::WriteStringToFile(config_str, tmp_file.path);
|
|
|
|
|
|
|
|
std::string executable_path = sub_dir + "/some-binary";
|
|
|
|
|
|
|
|
const Config* config = nullptr;
|
|
|
|
std::string error_msg;
|
|
|
|
|
|
|
|
ASSERT_TRUE(Config::read_binary_config(tmp_file.path,
|
|
|
|
executable_path.c_str(),
|
|
|
|
false,
|
2023-03-23 00:12:49 +01:00
|
|
|
false,
|
2018-06-18 08:30:18 +02:00
|
|
|
&config,
|
|
|
|
&error_msg)) << error_msg;
|
|
|
|
|
|
|
|
ASSERT_TRUE(config != nullptr) << error_msg;
|
|
|
|
ASSERT_TRUE(error_msg.empty()) << error_msg;
|
|
|
|
}
|