Add ConstraintSuite for model_sku.json.
- Start with simple check that "model" key exists.
BUG=chromium:1085429
TEST=CQ
Change-Id: Id70af4d4787a6f7eb7ad7efc4531015d2acf22a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/config/+/2222843
Commit-Queue: Andrew Lamb <andrewlamb@chromium.org>
Tested-by: Andrew Lamb <andrewlamb@chromium.org>
Reviewed-by: Sean McAllister <smcallis@google.com>
Reviewed-by: David Burger <dburger@chromium.org>
Reviewed-by: C Shapiro <shapiroc@chromium.org>
diff --git a/payload_utils/checker/io_utils.py b/payload_utils/checker/io_utils.py
index bfd02da..1d698af 100644
--- a/payload_utils/checker/io_utils.py
+++ b/payload_utils/checker/io_utils.py
@@ -3,7 +3,8 @@
# found in the LICENSE file.
"""IO-related helper functions."""
-import os
+import json
+import pathlib
from chromiumos.config.payload import config_bundle_pb2
@@ -21,3 +22,13 @@
with open(path, 'r') as f:
json_format.Parse(f.read(), project_config)
return project_config
+
+
+def read_model_sku_json(factory_dir: pathlib.Path) -> dict:
+ """Reads and parses the model_sku.json file.
+
+ Args:
+ factory_dir: Path to a project's factory dir.
+ """
+ with open(factory_dir.joinpath('generated', 'model_sku.json')) as f:
+ return json.load(f)