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

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: code review comments 3 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
Mark Seaborn 2012/02/16 18:42:50 This needs a comment: i.e. we need "#ifdef __GLIBC
bradn 2012/02/16 20:13:10 Done.
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.
397 'is_shared': True, # Is shared code. 399 'is_shared': True, # Is shared code.
398 'is_scons': True, # Is scons file (not one generated by gyp). 400 'is_scons': True, # Is scons file (not one generated by gyp).
399 } 401 }
400 402
401 403
402 def IsValidProp(prop): 404 def IsValidProp(prop):
403 """Returns true if the property name is valid. 405 """Returns true if the property name is valid.
404 406
405 Valid property names start with '.' or are listed in VALID_PROPS. 407 Valid property names start with '.' or are listed in VALID_PROPS.
406 408
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 452
451 if 'akefile' in filename: 453 if 'akefile' in filename:
452 d['is_makefile'] = True 454 d['is_makefile'] = True
453 455
454 if 'src/trusted/' in filename: 456 if 'src/trusted/' in filename:
455 d['is_trusted'] = True 457 d['is_trusted'] = True
456 if 'src/untrusted/stubs/' in filename: 458 if 'src/untrusted/stubs/' in filename:
457 d['is_untrusted_stubs'] = True 459 d['is_untrusted_stubs'] = True
458 if 'src/untrusted/ehsupport/' in filename: 460 if 'src/untrusted/ehsupport/' in filename:
459 d['is_untrusted_ehsupport'] = True 461 d['is_untrusted_ehsupport'] = True
462 if 'src/untrusted/crash_dump/' in filename:
463 d['is_untrusted_crash_dump'] = True
460 if 'src/untrusted/' in filename: 464 if 'src/untrusted/' in filename:
461 d['is_untrusted'] = True 465 d['is_untrusted'] = True
462 if 'src/shared/' in filename: 466 if 'src/shared/' in filename:
463 d['is_shared'] = True 467 d['is_shared'] = True
464 468
465 if (filename.endswith('nacl.scons') or 469 if (filename.endswith('nacl.scons') or
466 filename.endswith('build.scons') or 470 filename.endswith('build.scons') or
467 filename.endswith('SConstruct')): 471 filename.endswith('SConstruct')):
468 d['is_scons'] = True 472 d['is_scons'] = True
469 473
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 num_error += 1 586 num_error += 1
583 continue 587 continue
584 588
585 errors, warnings = CheckFile(filename, True) 589 errors, warnings = CheckFile(filename, True)
586 if errors: 590 if errors:
587 num_error += 1 591 num_error += 1
588 return num_error 592 return num_error
589 593
590 if __name__ == '__main__': 594 if __name__ == '__main__':
591 sys.exit(main(sys.argv[1:])) 595 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698