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

Side by Side Diff: tools/binary_size/analyze_test.py

Issue 2724253002: V1 of //tools/binary_size rewrite (Closed)
Patch Set: README tweaks, more cases for function parsing Created 3 years, 9 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 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import logging
7 import sys
8 import unittest
9
10 import analyze
11
12
13 class AnalyzeTest(unittest.TestCase):
14
15 def testParseFunctionSignature(self):
16 def check(ret_part, name_part, params_part):
17 name_and_params = name_part + params_part
18 got_full, got_name = analyze._ParseFunctionSignature(name_and_params)
19 self.assertEqual(name_part, got_name)
20 self.assertEqual(name_and_params, got_full)
21 if ret_part:
22 full_signature = ret_part + name_and_params
23 got_full, got_name = analyze._ParseFunctionSignature(full_signature)
24 self.assertEqual(name_part, got_name)
25 self.assertEqual(name_and_params, got_full)
26
27 check('bool ',
28 'foo::Bar<unsigned int, int>::Do<unsigned int>',
29 '(unsigned int)')
30 check('base::internal::CheckedNumeric<int>& ',
31 'base::internal::CheckedNumeric<int>::operator+=<int>',
32 '(int)')
33 check('base::internal::CheckedNumeric<int>& ',
34 'b::i::CheckedNumeric<int>::MathOp<b::i::CheckedAddOp, int>',
35 '(int)')
36 check('', '(anonymous namespace)::GetBridge', '(long long)')
37 check('', 'operator delete', '(void*)')
38 check('', 'b::i::DstRangeRelationToSrcRangeImpl<long long, long long, '
39 'std::__ndk1::numeric_limits, (b::i::Integer)1>::Check',
40 '(long long)')
41 check('', 'cc::LayerIterator::operator cc::LayerIteratorPosition const',
42 '() const')
43 check('decltype ({parm#1}((SkRecords::NoOp)())) ',
44 'SkRecord::Record::visit<SkRecords::Draw&>',
45 '(SkRecords::Draw&) const')
46 check('', 'base::internal::BindStateBase::BindStateBase',
47 '(void (*)(), void (*)(base::internal::BindStateBase const*))')
48 check('int ', 'std::__ndk1::__c11_atomic_load<int>',
49 '(std::__ndk1::<int> volatile*, std::__ndk1::memory_order)')
50 check('std::basic_ostream<char, std::char_traits<char> >& ',
51 'std::operator<< <std::char_traits<char> >',
52 '(std::basic_ostream<char, std::char_traits<char> >&, char)')
53 check('v8::internal::SlotCallbackResult ',
54 'v8::internal::UpdateTypedSlotHelper::UpdateCodeTarget'
55 '<v8::PointerUpdateJobTraits<(v8::Direction)1>::Foo(v8::Heap*, '
56 'v8::MemoryChunk*)::{lambda(v8::SlotType, unsigned char*)#2}::'
57 'operator()(v8::SlotType, unsigned char*, unsigned char*) '
58 'const::{lambda(v8::Object**)#1}>',
59 '(v8::RelocInfo, v8::Foo<(v8::PointerDirection)1>::Bar(v8::Heap*)::'
60 '{lambda(v8::SlotType)#2}::operator()(v8::SlotType) const::'
61 '{lambda(v8::Object**)#1})')
62 check('',
63 'WTF::StringAppend<WTF::String, WTF::String>::operator WTF::String',
64 '() const')
65 # SkArithmeticImageFilter.cpp has class within function body. e.g.:
66 # ArithmeticFP::onCreateGLSLInstance() looks like:
67 # class ArithmeticFP {
68 # GrGLSLFragmentProcessor* onCreateGLSLInstance() const {
69 # class GLSLFP {
70 # void emitCode(EmitArgs& args) { ... }
71 # };
72 # ...
73 # }
74 # };
75 SIG = '(anonymous namespace)::Foo::Baz() const::GLSLFP::onData(Foo, Bar)'
76 got_name = analyze._ParseFunctionSignature(SIG)[1]
77 self.assertEqual('(anonymous namespace)::Foo::Baz', got_name)
78
79
80 if __name__ == '__main__':
81 logging.basicConfig(level=logging.DEBUG,
82 format='%(levelname).1s %(relativeCreated)6d %(message)s')
83 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698