api: Fix glob pattern for log files
Recent runs of CQ with failed emerge commands reveals that the package
name is available in the output proto, but the paths were not correctly
located. This CL edits the glob path to reflect the correct naming
scheme and emits a warning to build logs when no matching log files are
found.
BUG=b:204816060
TEST=unit
TEST=CQ forthcoming
TEST=ran gen_call_scripts after breaking net-wireless/floss locally.
Build log included the emitted warning before glob path was changed,
and now includes the log path in the output proto.
Change-Id: I0c29c4403c0f587ba9f5be2ef6de62555be935dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3336658
Tested-by: Lizzy Presland <zland@google.com>
Auto-Submit: Lizzy Presland <zland@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/sysroot_unittest.py b/api/controller/sysroot_unittest.py
index fba510e..e03c95a 100644
--- a/api/controller/sysroot_unittest.py
+++ b/api/controller/sysroot_unittest.py
@@ -278,7 +278,7 @@
timestamp (datetime): timestamp used to name the file.
"""
path = os.path.join(log_path,
- f'{pkg_info.category}:{pkg_info.package}:' \
+ f'{pkg_info.category}:{pkg_info.pvr}:' \
f'{timestamp.strftime("%Y%m%d-%H%M%S")}.log')
osutils.WriteFile(path,
f'Test log file for package {pkg_info.category}/'
@@ -364,7 +364,7 @@
in_proto = self._InputProto(build_target=self.board,
sysroot_path=self.sysroot)
- err_pkgs = ['cat/pkg', 'cat2/pkg2']
+ err_pkgs = ['cat/pkg-1.0-r1', 'cat2/pkg2-1.0-r1']
err_cpvs = [package_info.parse(pkg) for pkg in err_pkgs]
expected = [('cat', 'pkg'), ('cat2', 'pkg2')]
@@ -393,7 +393,7 @@
package = controller_util.deserialize_package_info(data.name)
cat_pkg = (data.name.category, data.name.package_name)
self.assertIn(cat_pkg, expected)
- self.assertEqual(data.log_path.path, new_logs[package.atom])
+ self.assertEqual(data.log_path.path, new_logs[package.cpvr])
# TODO(b/206514844): remove when field is deleted
for package in out_proto.failed_packages:
@@ -481,7 +481,7 @@
timestamp (datetime): timestamp used to name the file.
"""
path = os.path.join(log_path,
- f'{pkg_info.category}:{pkg_info.package}:' \
+ f'{pkg_info.category}:{pkg_info.pvr}:' \
f'{timestamp.strftime("%Y%m%d-%H%M%S")}.log')
osutils.WriteFile(path, f'Test log file for package {pkg_info.category}/'
f'{pkg_info.package} written to {path}')
@@ -744,7 +744,7 @@
out_proto = self._OutputProto()
# Failed package info and expected list for verification.
- err_pkgs = ['cat/pkg', 'cat2/pkg2']
+ err_pkgs = ['cat/pkg-1.0-r3', 'cat2/pkg2-1.0-r1']
err_cpvs = [package_info.parse(cpv) for cpv in err_pkgs]
expected = [('cat', 'pkg'), ('cat2', 'pkg2')]
@@ -770,7 +770,7 @@
package = controller_util.deserialize_package_info(data.name)
cat_pkg = (data.name.category, data.name.package_name)
self.assertIn(cat_pkg, expected)
- self.assertEqual(data.log_path.path, new_logs[package.atom])
+ self.assertEqual(data.log_path.path, new_logs[package.cpvr])
# TODO(b/206514844): remove when field is deleted
for package in out_proto.failed_packages: