def main():
  """entry point."""
  (options, unused_args) = ParseCLIArgs()
  dmg = options.dmg
  verbosity = options.verbosity
  tests_dir = options.testdir
  config_dir = options.configdir
  root = options.root
  if not dmg and not root:
    print "Use --dmg to specify a dmg file or --root to specify a directory."
    sys.exit(1)
  if dmg:
    print "Mounting disk image... (this may take some time)"
    mountpoint = AttachDiskImage(dmg)
    if not mountpoint:
      print "Unable to mount %s" % dmg
      sys.exit(2)
  elif root:
    if not os.path.isdir(root):
      print "%s not a directory" % root
      sys.exit(2)
    mountpoint = root
    print "Checking %s" % mountpoint
  print

  dirname = os.path.dirname(sys.argv[0])
  os.chdir(dirname)
  tests = ListTests(tests_dir)
  test_results = {}
  combo_suite = unittest.TestSuite()
  for test in tests:
    test_path = os.path.join(tests_dir, test)
    combo_suite.addTests(GetTestSuite(test_path, mountpoint, options))

  test_results = unittest.TextTestRunner(verbosity=verbosity).run(combo_suite)

  if dmg:
    DetachDiskImage(mountpoint)

  if test_results.wasSuccessful():
    sys.exit(0)
  else:
    SummarizeResults(test_results)
    bad = len(test_results.errors) + len(test_results.failures)
    sys.exit(bad)
dataset/ETHPy150Open MacSysadmin/pymacadmin/utilities/diskimage_unittesting/run_image_tests.py/main/original