def testConversion(self): """Test converting to/from protobuf.""" profile1 = sysroot_lib.Profile('profile') profile2 = sysroot_lib.Profile() proto1 = common_pb2.Profile(name='profile') proto2 = common_pb2.Profile() self.assertEqual(profile1.as_protobuf, proto1) self.assertEqual(profile2.as_protobuf, proto2) self.assertEqual(profile1, sysroot_lib.Profile.from_protobuf(proto1)) self.assertEqual(profile2, sysroot_lib.Profile.from_protobuf(proto2))
def testConversion(self): """Test protobuf conversion methods.""" build_target = BuildTarget(name='board') build_target_with_profile = BuildTarget('board', profile='profile') proto = common_pb2.BuildTarget(name='board') profile_proto = common_pb2.Profile(name='profile') # Profile is moving to sysroot_lib.Profile. self.assertEqual(proto, build_target.as_protobuf) self.assertEqual(proto, build_target_with_profile.as_protobuf) self.assertEqual(build_target, BuildTarget.from_protobuf(proto)) self.assertEqual(common_pb2.Profile(), build_target.profile_protobuf) self.assertEqual(profile_proto, build_target_with_profile.profile_protobuf)
def testSuccessPackageIndexes(self): """Test successful call with package_indexes.""" # Prevent argument validation error. self.PatchObject(sysroot_lib.Sysroot, 'IsToolchainInstalled', return_value=True) package_indexes = [ common_pb2.PackageIndexInfo( snapshot_sha='SHA', snapshot_number=5, build_target=common_pb2.BuildTarget(name='board'), location='LOCATION', profile=common_pb2.Profile(name='profile')), common_pb2.PackageIndexInfo( snapshot_sha='SHA2', snapshot_number=4, build_target=common_pb2.BuildTarget(name='board'), location='LOCATION2', profile=common_pb2.Profile(name='profile')) ] in_proto = self._InputProto(build_target=self.build_target, sysroot_path=self.sysroot, package_indexes=package_indexes) out_proto = self._OutputProto() rc_patch = self.PatchObject(sysroot_service, 'BuildPackagesRunConfig') self.PatchObject(sysroot_service, 'BuildPackages') rc = sysroot_controller.InstallPackages(in_proto, out_proto, self.api_config) self.assertFalse(rc) rc_patch.assert_called_with( usepkg=True, install_debug_symbols=True, packages=[], package_indexes=[ binpkg.PackageIndexInfo.from_protobuf(x) for x in package_indexes ], use_flags=[], use_goma=False, incremental_build=False)
def as_protobuf(self): return common_pb2.Profile(name=self._name)
def testArgumentHandling(self): """Test the arguments get processed and passed correctly.""" sysroot_path = '/sysroot/path' sysroot = sysroot_lib.Sysroot(sysroot_path) create_patch = self.PatchObject(sysroot_service, 'Create', return_value=sysroot) rc_patch = self.PatchObject(sysroot_service, 'SetupBoardRunConfig') # Default values. board = 'board' profile = None force = False upgrade_chroot = True in_proto = self._InputProto(build_target=board, profile=profile, replace=force, current=not upgrade_chroot) out_proto = self._OutputProto() sysroot_controller.Create(in_proto, out_proto, self.api_config) # Default value checks. rc_patch.assert_called_with(force=force, upgrade_chroot=upgrade_chroot, package_indexes=[]) self.assertEqual(board, out_proto.sysroot.build_target.name) self.assertEqual(sysroot_path, out_proto.sysroot.path) # Not default values. create_patch.reset_mock() board = 'board' profile = 'profile' force = True upgrade_chroot = False package_indexes = [ common_pb2.PackageIndexInfo( snapshot_sha='SHA', snapshot_number=5, build_target=common_pb2.BuildTarget(name=board), location='LOCATION', profile=common_pb2.Profile(name=profile)), common_pb2.PackageIndexInfo( snapshot_sha='SHA2', snapshot_number=4, build_target=common_pb2.BuildTarget(name=board), location='LOCATION2', profile=common_pb2.Profile(name=profile)) ] in_proto = self._InputProto(build_target=board, profile=profile, replace=force, current=not upgrade_chroot, package_indexes=package_indexes) out_proto = self._OutputProto() sysroot_controller.Create(in_proto, out_proto, self.api_config) # Not default value checks. rc_patch.assert_called_with( force=force, package_indexes=[ binpkg.PackageIndexInfo.from_protobuf(x) for x in package_indexes ], upgrade_chroot=upgrade_chroot) self.assertEqual(board, out_proto.sysroot.build_target.name) self.assertEqual(sysroot_path, out_proto.sysroot.path)