Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: chrome/installer/automation_test/verifier.py

Issue 20578004: Initial commit for the Automated Installer Testing Framework. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add data. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import _winreg
6
7
8 def Verify(config):
9 for verifier_name, value in config.iteritems():
10 if verifier_name == "RegistryEntries":
11 VerifyRegistryEntries(value)
12 else:
13 # TODO(sukolsak): implement other verifiers
14 pass
15
16
17 def VerifyRegistryEntries(entries):
18 for key, entry in entries.iteritems():
19 if VerifyRegistryEntry(key, entry):
20 print "Passed"
21 else:
22 print "Failed"
23
24
25 def RootKeyConstant(key):
26 if key == "HKEY_CLASSES_ROOT":
27 return _winreg.HKEY_CLASSES_ROOT
28 if key == "HKEY_CURRENT_USER":
29 return _winreg.HKEY_CURRENT_USER
30 if key == "HKEY_LOCAL_MACHINE":
31 return _winreg.HKEY_LOCAL_MACHINE
32 if key == "HKEY_USERS":
33 return _winreg.HKEY_USERS
34 raise Exception("Unknown registry key")
35
36
37 def VerifyRegistryEntry(key, entry):
38 expected = entry["expected"]
39 print " - " + key
40 if expected:
41 print " exists..."
42 else:
43 print " doesn't exist..."
44 try:
45 root_key, sub_key = key.split("\\", 1)
46 reg_key = _winreg.OpenKey(RootKeyConstant(root_key), \
47 sub_key, 0, _winreg.KEY_READ)
48 if expected == False:
49 return False
50 if "value" in entry:
51 # TODO(sukolsak): implement value
52 pass
53 return True
54 except WindowsError:
55 return expected == False
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698