Commit 09ad54d0 authored by Yusuke Sato's avatar Yusuke Sato Committed by Commit Bot

arcvm: Move more tests for ARC properties from platform2 to Chromium

The plan is to stop using the platform2 functions sometime soon.

BUG=b:144199481
TEST=try

Change-Id: Iad53b4818459b31bd43d6065191ccd0c6403bbda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032721
Commit-Queue: Yusuke Sato <yusukes@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737453}
parent 42ab5e74
......@@ -44,8 +44,8 @@ constexpr int kAndroidMaxPropertyLength = 91;
// of the ones in platform2/arc/setup/arc_setup_util.cc. Do not modify the
// implementation directly here. Instead, modify it in platform2 with proper
// unit tests, then roll the change into Chromium.
// TODO(yusukes): Once we stop supporting the container, move the unit tests
// to Chromium and delete platform2/arc/setup/.
// TODO(yusukes): Once we stop expanding the properties in arc-setup for the
// container, remove the code in platform2/arc/setup/.
bool FindProperty(const std::string& line_prefix_to_find,
std::string* out_prop,
......@@ -107,6 +107,8 @@ bool TruncateAndroidProperty(const std::string& line, std::string* truncated) {
return true;
}
// Computes the value of ro.oem.key1 based on the build-time ro.product.board
// value and the device's region of origin.
std::string ComputeOEMKey(brillo::CrosConfigInterface* config,
const std::string& board) {
std::string regions;
......@@ -254,6 +256,17 @@ bool CrosConfig::GetString(const std::string& path,
return true;
}
bool ExpandPropertyContentsForTesting(const std::string& content,
brillo::CrosConfigInterface* config,
std::string* expanded_content) {
return ExpandPropertyContents(content, config, expanded_content);
}
bool TruncateAndroidPropertyForTesting(const std::string& line,
std::string* truncated) {
return TruncateAndroidProperty(line, truncated);
}
bool ExpandPropertyFile(const base::FilePath& input,
const base::FilePath& output,
CrosConfig* config) {
......
......@@ -22,21 +22,34 @@ namespace arc {
class CrosConfig {
public:
CrosConfig();
~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|.
bool GetString(const std::string& path,
const std::string& property,
std::string* val_out);
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.
......
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