Commit f2e1adff authored by Yusuke Sato's avatar Yusuke Sato Committed by Chromium LUCI CQ

arc: Remove arc_property_util* and fake_cros_config.*

The former has been moved to platform2/arc/setup. The latter
is not used anymore.

BUG=chromium:1163122
TEST=try

Change-Id: I104a468668b7e56087740818ef5cdf93a370f761
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613398
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarYury Khmel <khmel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846270}
parent f92b961c
......@@ -233,8 +233,6 @@ static_library("arc_base") {
"session/arc_container_client_adapter.h",
"session/arc_data_remover.cc",
"session/arc_data_remover.h",
"session/arc_property_util.cc",
"session/arc_property_util.h",
"session/arc_session.cc",
"session/arc_session.h",
"session/arc_session_impl.cc",
......@@ -340,8 +338,6 @@ static_library("arc_test_support") {
"test/fake_bluetooth_instance.h",
"test/fake_clipboard_instance.cc",
"test/fake_clipboard_instance.h",
"test/fake_cros_config.cc",
"test/fake_cros_config.h",
"test/fake_file_system_instance.cc",
"test/fake_file_system_instance.h",
"test/fake_intent_helper_instance.cc",
......@@ -416,7 +412,6 @@ source_set("unit_tests") {
"property/arc_property_bridge_unittest.cc",
"session/arc_container_client_adapter_unittest.cc",
"session/arc_data_remover_unittest.cc",
"session/arc_property_util_unittest.cc",
"session/arc_session_impl_unittest.cc",
"session/arc_session_runner_unittest.cc",
"session/arc_vm_client_adapter_unittest.cc",
......@@ -476,12 +471,3 @@ source_set("unit_tests") {
"//url:url",
]
}
fuzzer_test("arc_property_util_expand_property_contents_fuzzer") {
sources = [ "session/arc_property_util_expand_property_contents_fuzzer.cc" ]
deps = [
":arc",
":arc_test_support",
"//base",
]
}
This diff is collapsed.
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ARC_SESSION_ARC_PROPERTY_UTIL_H_
#define COMPONENTS_ARC_SESSION_ARC_PROPERTY_UTIL_H_
#include <string>
#include "base/optional.h"
#include "base/values.h"
namespace base {
class FilePath;
} // namespace base
namespace arc {
// A class that reads and parses |kArcBuildProperties| command line flags and
// holds the result as a dictionary. This is a drop-in replacement of the
// brillo::CrosConfigInterface classes (which are not available in Chromium).
class CrosConfig {
public:
CrosConfig();
virtual ~CrosConfig();
CrosConfig(const CrosConfig&) = delete;
CrosConfig& operator=(const CrosConfig&) = delete;
// Find the |property| in the dictionary and assigns the result to |val_out|.
// Returns true when the property is found. The function always returns false
// when |path| is not |kCrosConfigPropertiesPath|.
virtual bool GetString(const std::string& path,
const std::string& property,
std::string* val_out);
private:
base::Optional<base::Value> info_;
};
// Expands the contents of a template Android property file. Strings like
// {property} will be looked up in |config| and replaced with their values.
// Returns true if all {} strings were successfully expanded, or false if any
// properties were not found.
bool ExpandPropertyContentsForTesting(const std::string& content,
CrosConfig* config,
std::string* expanded_content);
// Truncates the value side of an Android key=val property line, including
// handling the special case of build fingerprint.
bool TruncateAndroidPropertyForTesting(const std::string& line,
std::string* truncated);
// Expands properties (i.e. {property-name}) in |input| with the dictionary
// |config| provides, and writes the results to |output|. Returns true if the
// output file is successfully written.
bool ExpandPropertyFileForTesting(const base::FilePath& input,
const base::FilePath& output,
CrosConfig* config);
// Calls ExpandPropertyFile for {build,default,vendor_build}.prop files in
// |source_path|. Expanded files are written in |dest_path|. Returns true on
// success. When |single_file| is true, only one file (|dest_path| itself) is
// written. All expanded properties are included in the single file.
// When |add_native_bridge_64_bit_support| is true, add / modify some properties
// related to supported CPU ABIs.
bool ExpandPropertyFiles(const base::FilePath& source_path,
const base::FilePath& dest_path,
bool single_file,
bool add_native_bridge_64bit_support);
} // namespace arc
#endif // COMPONENTS_ARC_SESSION_ARC_PROPERTY_UTIL_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/arc/session/arc_property_util.h"
#include <stddef.h>
#include <stdint.h>
#include <fuzzer/FuzzedDataProvider.h>
#include <map>
#include <string>
#include "base/command_line.h"
#include "components/arc/test/fake_cros_config.h"
#include "testing/libfuzzer/libfuzzer_exports.h"
namespace {
constexpr size_t kMaxInputSize = 64 * 1024;
}
extern "C" int LLVMFuzzerInitialize(int* argc, char*** argv) {
base::CommandLine::Init(*argc, *argv);
return 0;
}
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
// Limit the input size to avoid timing out on ClusterFuzz.
if (size > kMaxInputSize)
return 0;
FuzzedDataProvider data_provider(data, size);
std::string content = data_provider.ConsumeRandomLengthString(size);
arc::FakeCrosConfig config;
while (data_provider.remaining_bytes()) {
// Cannot use |ConsumeRandomLengthString| in a loop because it can enter an
// infinite loop by always returning an empty string.
size_t path_size = data_provider.ConsumeIntegralInRange<size_t>(
0, data_provider.remaining_bytes());
std::string path =
std::string("/") + data_provider.ConsumeBytesAsString(path_size);
if (data_provider.remaining_bytes() == 0)
break;
size_t property_size = data_provider.ConsumeIntegralInRange<size_t>(
1, data_provider.remaining_bytes());
std::string property = data_provider.ConsumeBytesAsString(property_size);
if (data_provider.remaining_bytes() == 0)
break;
size_t val_size = data_provider.ConsumeIntegralInRange<size_t>(
1, data_provider.remaining_bytes());
std::string val = data_provider.ConsumeBytesAsString(val_size);
config.SetString(path, property, val);
}
std::string expanded_content;
arc::ExpandPropertyContentsForTesting(content, &config, &expanded_content);
return 0;
}
This diff is collapsed.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/arc/test/fake_cros_config.h"
namespace arc {
FakeCrosConfig::FakeCrosConfig() = default;
FakeCrosConfig::~FakeCrosConfig() = default;
bool FakeCrosConfig::GetString(const std::string& path,
const std::string& property,
std::string* val_out) {
auto it = overrides_.find(property);
if (it != overrides_.end()) {
*val_out = it->second;
return true;
}
return arc::CrosConfig::GetString(path, property, val_out);
}
void FakeCrosConfig::SetString(const std::string& path,
const std::string& property,
const std::string& value) {
overrides_.emplace(property, value);
}
} // namespace arc
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_ARC_TEST_FAKE_CROS_CONFIG_H_
#define COMPONENTS_ARC_TEST_FAKE_CROS_CONFIG_H_
#include <map>
#include <string>
#include "components/arc/session/arc_property_util.h"
namespace arc {
// A fake arc::CrosConfig used for testing.
class FakeCrosConfig : public arc::CrosConfig {
public:
FakeCrosConfig();
~FakeCrosConfig() override;
FakeCrosConfig(const FakeCrosConfig&) = delete;
FakeCrosConfig& operator=(const FakeCrosConfig&) = delete;
// arc::CrosConfig:
bool GetString(const std::string& path,
const std::string& property,
std::string* val_out) override;
// Sets the value of a property specified by |path| and |property| to |value|.
void SetString(const std::string& path,
const std::string& property,
const std::string& value);
private:
// A map of overridden properties to their values.
std::map<std::string, std::string> overrides_;
};
} // namespace arc
#endif // COMPONENTS_ARC_TEST_FAKE_CROS_CONFIG_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment