lin
2025-07-30 fcd736bf35fd93b563e9bbf594f2aa7b62028cc9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Module to compare two machines."""
 
from __future__ import print_function
 
import os.path
import sys
import argparse
 
from machine_manager import CrosMachine
 
 
def PrintUsage(msg):
  print(msg)
  print('Usage: ')
  print('\n compare_machines.py --chromeos_root=/path/to/chroot/ '
        'machine1 machine2 ...')
 
 
def Main(argv):
 
  parser = argparse.ArgumentParser()
  parser.add_argument(
      '--chromeos_root',
      default='/path/to/chromeos',
      dest='chromeos_root',
      help='ChromeOS root checkout directory')
  parser.add_argument('remotes', nargs=argparse.REMAINDER)
 
  options = parser.parse_args(argv)
 
  machine_list = options.remotes
  if len(machine_list) < 2:
    PrintUsage('ERROR: Must specify at least two machines.')
    return 1
  elif not os.path.exists(options.chromeos_root):
    PrintUsage('Error: chromeos_root does not exist %s' % options.chromeos_root)
    return 1
 
  chroot = options.chromeos_root
  cros_machines = []
  test_machine_checksum = None
  for m in machine_list:
    cm = CrosMachine(m, chroot, 'average')
    cros_machines = cros_machines + [cm]
    test_machine_checksum = cm.machine_checksum
 
  ret = 0
  for cm in cros_machines:
    print('checksum for %s : %s' % (cm.name, cm.machine_checksum))
    if cm.machine_checksum != test_machine_checksum:
      ret = 1
      print('Machine checksums do not all match')
 
  if ret == 0:
    print('Machines all match.')
 
  return ret
 
 
if __name__ == '__main__':
  retval = Main(sys.argv[1:])
  sys.exit(retval)