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

Side by Side Diff: tools/code_hygiene.py

Issue 9316125: Adding untrusted crash dump / stack trace tests. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: add json escaping to fix windows Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. 2 # Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Simple Code Hygiene tool meant to be run as a presubmit test or standalone 6 """Simple Code Hygiene tool meant to be run as a presubmit test or standalone
7 7
8 Usage: 8 Usage:
9 ./code_hygiene.py <file1> <file2> ... 9 ./code_hygiene.py <file1> <file2> ...
10 10
11 For the styleguides see: 11 For the styleguides see:
12 http://code.google.com/p/soc/wiki/PythonStyleGuide 12 http://code.google.com/p/soc/wiki/PythonStyleGuide
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 class UntrustedIfDefChecker(GenericRegexChecker): 225 class UntrustedIfDefChecker(GenericRegexChecker):
226 """No #ifdef in untrusted code (except stubs).""" 226 """No #ifdef in untrusted code (except stubs)."""
227 def __init__(self): 227 def __init__(self):
228 GenericRegexChecker.__init__(self, r'^#if') 228 GenericRegexChecker.__init__(self, r'^#if')
229 return 229 return
230 230
231 def FileFilter(self, props): 231 def FileFilter(self, props):
232 if 'is_untrusted' not in props: return False 232 if 'is_untrusted' not in props: return False
233 if 'is_untrusted_stubs' in props: return False 233 if 'is_untrusted_stubs' in props: return False
234 if 'is_untrusted_ehsupport' in props: return False 234 if 'is_untrusted_ehsupport' in props: return False
235 if 'is_untrusted_crash_dump' in props: return False
235 return '.c' in props or '.cc' in props 236 return '.c' in props or '.cc' in props
236 237
237 238
238 class UntrustedAsmChecker(GenericRegexChecker): 239 class UntrustedAsmChecker(GenericRegexChecker):
239 """No inline assembler in untrusted code.""" 240 """No inline assembler in untrusted code."""
240 def __init__(self): 241 def __init__(self):
241 # TODO(robertm): also cope with asm 242 # TODO(robertm): also cope with asm
242 GenericRegexChecker.__init__(self, r'__asm__') 243 GenericRegexChecker.__init__(self, r'__asm__')
243 return 244 return
244 245
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 # the magic string '@PROPS[prop1,prop2,...]' anywhere in the first 2k of 388 # the magic string '@PROPS[prop1,prop2,...]' anywhere in the first 2k of
388 # data. 389 # data.
389 390
390 VALID_PROPS = { 391 VALID_PROPS = {
391 'name': True, # Filename, only prop with a value. 392 'name': True, # Filename, only prop with a value.
392 'is_makefile': True, 393 'is_makefile': True,
393 'is_trusted': True, # Is trusted code. 394 'is_trusted': True, # Is trusted code.
394 'is_untrusted': True, # Is untrusted code. 395 'is_untrusted': True, # Is untrusted code.
395 'is_untrusted_stubs': True, # Is untrusted/stubs code. 396 'is_untrusted_stubs': True, # Is untrusted/stubs code.
396 'is_untrusted_ehsupport': True, # Is untrusted/ehsupport code. 397 'is_untrusted_ehsupport': True, # Is untrusted/ehsupport code.
398 'is_untrusted_crash_dump': True, # Is untrusted/crash_dump code.
399 # Untrusted crash dumps need to vary by
400 # #ifdef __GLIBC__ because different
401 # memory layout information is available.
397 'is_shared': True, # Is shared code. 402 'is_shared': True, # Is shared code.
398 'is_scons': True, # Is scons file (not one generated by gyp). 403 'is_scons': True, # Is scons file (not one generated by gyp).
399 } 404 }
400 405
401 406
402 def IsValidProp(prop): 407 def IsValidProp(prop):
403 """Returns true if the property name is valid. 408 """Returns true if the property name is valid.
404 409
405 Valid property names start with '.' or are listed in VALID_PROPS. 410 Valid property names start with '.' or are listed in VALID_PROPS.
406 411
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 455
451 if 'akefile' in filename: 456 if 'akefile' in filename:
452 d['is_makefile'] = True 457 d['is_makefile'] = True
453 458
454 if 'src/trusted/' in filename: 459 if 'src/trusted/' in filename:
455 d['is_trusted'] = True 460 d['is_trusted'] = True
456 if 'src/untrusted/stubs/' in filename: 461 if 'src/untrusted/stubs/' in filename:
457 d['is_untrusted_stubs'] = True 462 d['is_untrusted_stubs'] = True
458 if 'src/untrusted/ehsupport/' in filename: 463 if 'src/untrusted/ehsupport/' in filename:
459 d['is_untrusted_ehsupport'] = True 464 d['is_untrusted_ehsupport'] = True
465 if 'src/untrusted/crash_dump/' in filename:
466 d['is_untrusted_crash_dump'] = True
460 if 'src/untrusted/' in filename: 467 if 'src/untrusted/' in filename:
461 d['is_untrusted'] = True 468 d['is_untrusted'] = True
462 if 'src/shared/' in filename: 469 if 'src/shared/' in filename:
463 d['is_shared'] = True 470 d['is_shared'] = True
464 471
465 if (filename.endswith('nacl.scons') or 472 if (filename.endswith('nacl.scons') or
466 filename.endswith('build.scons') or 473 filename.endswith('build.scons') or
467 filename.endswith('SConstruct')): 474 filename.endswith('SConstruct')):
468 d['is_scons'] = True 475 d['is_scons'] = True
469 476
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 num_error += 1 589 num_error += 1
583 continue 590 continue
584 591
585 errors, warnings = CheckFile(filename, True) 592 errors, warnings = CheckFile(filename, True)
586 if errors: 593 if errors:
587 num_error += 1 594 num_error += 1
588 return num_error 595 return num_error
589 596
590 if __name__ == '__main__': 597 if __name__ == '__main__':
591 sys.exit(main(sys.argv[1:])) 598 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698