New script to tell if machines are 'identical' for crosperf.

This script calls the functions in machine_manager.py and
verifies that two or more machines are 'identical' for the purposes
of running crosperf.  I have several times needed to do this type
of thing, so I decided to extract the functionality into its own
script.

BUG=None
TEST=Tested in my directory.

Change-Id: I2a410eefe7e1b46f6c5cad477640ea7974a614c7
Reviewed-on: https://chrome-internal-review.googlesource.com/188197
Reviewed-by: Luis Lozano <llozano@chromium.org>
Reviewed-by: Caroline Tice <cmtice@google.com>
Commit-Queue: Caroline Tice <cmtice@google.com>
Tested-by: Caroline Tice <cmtice@google.com>
diff --git a/crosperf/compare_machines.py b/crosperf/compare_machines.py
new file mode 100644
index 0000000..a6be0c6
--- /dev/null
+++ b/crosperf/compare_machines.py
@@ -0,0 +1,64 @@
+#!/usr/bin/python
+
+# 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.
+
+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)
+
+    false_arg = True
+    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
+
+    retval = 0
+    for cm in cros_machines:
+        print "checksum for %s : %s" % (cm.name, cm.machine_checksum)
+        if cm.machine_checksum != test_machine_checksum:
+                retval = 1
+                print "Machine checksums do not all match"
+
+    if retval == 0:
+        print "Machines all match."
+
+    return retval
+
+
+if __name__ == '__main__':
+    retval = Main(sys.argv[1:])
+    sys.exit(retval)
+