Chromium Code Reviews| Index: tools/cygprofile/check_orderfile_unittest.py |
| diff --git a/tools/cygprofile/check_orderfile_unittest.py b/tools/cygprofile/check_orderfile_unittest.py |
| new file mode 100755 |
| index 0000000000000000000000000000000000000000..0050b9cc2b16f3935e8cccf8d334fa2bb3c7d38c |
| --- /dev/null |
| +++ b/tools/cygprofile/check_orderfile_unittest.py |
| @@ -0,0 +1,60 @@ |
| +#!/usr/bin/python |
| +# Copyright 2015 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +import unittest |
| + |
| +import check_orderfile |
| +import symbol_extractor |
| + |
| + |
| +class TestCheckOrderFile(unittest.TestCase): |
| + def testMatchesSymbols(self): |
| + symbol_infos = [ |
|
pasko
2015/02/02 10:00:30
using this list as a global constant in the test f
Benoit L
2015/02/02 13:11:45
Done.
|
| + symbol_extractor.SymbolInfo('first', 0x1, 0, ''), |
| + symbol_extractor.SymbolInfo('second', 0x2, 0, ''), |
| + symbol_extractor.SymbolInfo('third', 0x3, 0, ''), |
| + symbol_extractor.SymbolInfo('notProfiled', 0x3, 0, '')] |
| + symbols = ['second', 'third', 'first'] |
| + (_, matched_count, _) = check_orderfile._CountMisorderedSymbols( |
|
pasko
2015/02/02 10:00:30
wouldn't it be good to check the other counts here
Benoit L
2015/02/02 13:11:45
Done.
|
| + symbols, symbol_infos) |
| + self.assertEquals(matched_count, 3) |
| + |
| + def testMissingMatches(self): |
| + symbol_infos = [ |
| + symbol_extractor.SymbolInfo('first', 0x1, 0, ''), |
| + symbol_extractor.SymbolInfo('second', 0x2, 0, ''), |
| + symbol_extractor.SymbolInfo('third', 0x3, 0, ''), |
| + symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, '')] |
| + symbols = ['second', 'third', 'other', 'first'] |
| + (_, matched_count, unmatched_count) = ( |
| + check_orderfile._CountMisorderedSymbols(symbols, symbol_infos)) |
| + self.assertEquals(matched_count, 3) |
| + self.assertEquals(unmatched_count, 1) |
| + |
| + def testNoUnorderedSymbols(self): |
| + symbol_infos = [ |
| + symbol_extractor.SymbolInfo('first', 0x1, 0, ''), |
| + symbol_extractor.SymbolInfo('second', 0x2, 0, ''), |
| + symbol_extractor.SymbolInfo('third', 0x3, 0, ''), |
| + symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, '')] |
| + symbols = ['first', 'other', 'second', 'third', 'noMatchEither'] |
| + (misordered_pairs_count, _, _) = ( |
| + check_orderfile._CountMisorderedSymbols(symbols, symbol_infos)) |
| + self.assertEquals(misordered_pairs_count, 0) |
| + |
| + def testUnorderedSymbols(self): |
| + symbol_infos = [ |
| + symbol_extractor.SymbolInfo('first', 0x1, 0, ''), |
| + symbol_extractor.SymbolInfo('second', 0x2, 0, ''), |
| + symbol_extractor.SymbolInfo('third', 0x3, 0, ''), |
| + symbol_extractor.SymbolInfo('notProfiled', 0x4, 0, '')] |
| + symbols = ['first', 'other', 'third', 'second', 'noMatchEither'] |
| + (misordered_pairs_count, _, _) = ( |
| + check_orderfile._CountMisorderedSymbols(symbols, symbol_infos)) |
| + self.assertEquals(misordered_pairs_count, 1) |
| + |
| + |
| +if __name__ == '__main__': |
| + unittest.main() |