]>
git.saurik.com Git - apple/dyld.git/blob - testing/kernel-cache-tests/KernelCollection.py
11 class KernelCollection
:
16 def __init__(self
, print_json
):
17 self
.print_json
= print_json
19 def buildKernelCollection(self
, arch_flag
, kernel_cache_path
, kernel_path
, extensions_dir
, bundle_ids
=[], options
=[]):
21 test_root
= os
.path
.dirname(__file__
)
22 build_root
= os
.path
.realpath(os
.path
.dirname(__file__
) + "/..")
23 app_cache_util
= build_root
+ "/../build/Release/dyld_app_cache_util"
24 args
= [app_cache_util
,
25 "-create-kernel-collection", test_root
+ kernel_cache_path
,
26 "-kernel", test_root
+ kernel_path
,
28 if extensions_dir
is not None:
29 args
.append("-extensions")
30 args
.append(test_root
+ extensions_dir
)
31 for bundle_id
in bundle_ids
:
32 args
.append("-bundle-id")
33 args
.append(bundle_id
)
34 file_text
= subprocess
.check_output(["file", build_root
+ kernel_cache_path
]);
36 args
.append(opt
.replace("$PWD", test_root
))
41 runline
= runline
+ '"' + arg
+ '"' + ' '
43 runline
= runline
+ arg
+ ' '
47 print "Run with: " + runline
48 process
= subprocess
.Popen(args
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
49 self
.json_text
, self
.error_message
= process
.communicate()
52 print self
.error_message
53 if process
.returncode
:
54 if not self
.print_json
:
55 print self
.error_message
56 print "Non-zero return code"
57 print "Run with: " + runline
60 #print self.error_message
62 self
.dict = json
.loads(self
.json_text
)
63 self
.error_message
= ""
64 except subprocess
.CalledProcessError
as e
:
65 #print "can't make closure for " + kernel_cache_path
66 self
.error_message
= e
.output
72 def buildPageableKernelCollection(self
, arch_flag
, aux_kernel_cache_path
, kernel_cache_path
, extensions_dir
, bundle_ids
=[], options
=[]):
74 test_root
= os
.path
.dirname(__file__
)
75 build_root
= os
.path
.realpath(os
.path
.dirname(__file__
) + "/..")
76 app_cache_util
= build_root
+ "/../build/Release/dyld_app_cache_util"
77 args
= [app_cache_util
,
78 "-create-pageable-kernel-collection", test_root
+ aux_kernel_cache_path
,
79 "-kernel-collection", test_root
+ kernel_cache_path
,
81 if extensions_dir
is not None:
82 args
.append("-extensions")
83 args
.append(test_root
+ extensions_dir
)
84 for bundle_id
in bundle_ids
:
85 args
.append("-bundle-id")
86 args
.append(bundle_id
)
87 file_text
= subprocess
.check_output(["file", build_root
+ kernel_cache_path
]);
92 print "Run with: " + ' '.join(args
)
93 process
= subprocess
.Popen(args
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
94 self
.json_text
, self
.error_message
= process
.communicate()
97 print self
.error_message
98 if process
.returncode
:
99 if not self
.print_json
:
100 print self
.error_message
101 print "Non-zero return code"
102 print "Run with: " + ' '.join(args
)
104 #print self.json_text
105 #print self.error_message
107 self
.dict = json
.loads(self
.json_text
)
108 self
.error_message
= ""
109 except subprocess
.CalledProcessError
as e
:
110 #print "can't make closure for " + kernel_cache_path
111 self
.error_message
= e
.output
117 def buildAuxKernelCollection(self
, arch_flag
, aux_kernel_cache_path
, kernel_cache_path
, pageable_cache_path
, extensions_dir
, bundle_ids
=[], options
=[]):
119 test_root
= os
.path
.dirname(__file__
)
120 build_root
= os
.path
.realpath(os
.path
.dirname(__file__
) + "/..")
121 app_cache_util
= build_root
+ "/../build/Release/dyld_app_cache_util"
122 args
= [app_cache_util
,
123 "-create-aux-kernel-collection", test_root
+ aux_kernel_cache_path
,
124 "-kernel-collection", test_root
+ kernel_cache_path
,
126 if pageable_cache_path
:
127 args
.append("-pageable-collection")
128 args
.append(test_root
+ pageable_cache_path
)
129 if extensions_dir
is not None:
130 args
.append("-extensions")
131 args
.append(test_root
+ extensions_dir
)
132 for bundle_id
in bundle_ids
:
133 args
.append("-bundle-id")
134 args
.append(bundle_id
)
135 file_text
= subprocess
.check_output(["file", build_root
+ kernel_cache_path
]);
140 print "Run with: " + ' '.join(args
)
141 process
= subprocess
.Popen(args
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
142 self
.json_text
, self
.error_message
= process
.communicate()
145 print self
.error_message
146 if process
.returncode
:
147 if not self
.print_json
:
148 print self
.error_message
149 print "Non-zero return code"
150 print "Run with: " + ' '.join(args
)
152 #print self.json_text
153 #print self.error_message
155 self
.dict = json
.loads(self
.json_text
)
156 self
.error_message
= ""
157 except subprocess
.CalledProcessError
as e
:
158 #print "can't make closure for " + kernel_cache_path
159 self
.error_message
= e
.output
165 def analyze(self
, app_cache_path
, options
=[]):
167 test_root
= os
.path
.dirname(__file__
)
168 build_root
= os
.path
.realpath(os
.path
.dirname(__file__
) + "/..")
169 app_cache_util
= build_root
+ "/../build/Release/dyld_app_cache_util"
170 args
= [app_cache_util
, "-app-cache", test_root
+ app_cache_path
, "-platform", "kernel"]
171 file_text
= subprocess
.check_output(["file", build_root
+ app_cache_path
]);
176 print "Run with: " + ' '.join(args
)
177 process
= subprocess
.Popen(args
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
)
178 self
.json_text
, self
.error_message
= process
.communicate()
181 print self
.error_message
182 if process
.returncode
:
183 if not self
.print_json
:
184 print self
.error_message
185 print "Non-zero return code"
186 print "Run with: " + ' '.join(args
)
188 #print self.json_text
189 #print self.error_message
191 self
.dict = json
.loads(self
.json_text
)
192 self
.error_message
= ""
193 except subprocess
.CalledProcessError
as e
:
194 #print "can't make closure for " + app_cache_path
195 self
.error_message
= e
.output
201 def dictionary(self
):
205 return self
.error_message