blob: 0431f4501d27edb014052fb580af5a1d26772bc2 [file] [log] [blame]
Paul Duffin67b9d612021-07-21 17:38:47 +01001#!/usr/bin/env python
2#
3# Copyright (C) 2021 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the 'License');
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an 'AS IS' BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""Unit tests for signature_patterns.py."""
18import io
19import unittest
20
21from signature_patterns import *
22
23class TestGeneratedPatterns(unittest.TestCase):
24
25 def produce_patterns_from_string(self, csv):
26 with io.StringIO(csv) as f:
27 return produce_patterns_from_stream(f)
28
29 def test_generate(self):
30 patterns = self.produce_patterns_from_string('''
Paul Duffin6ffdff82021-08-09 13:47:19 +010031Ljava/lang/ProcessBuilder$Redirect$1;-><init>()V,blocked
32Ljava/lang/Character$UnicodeScript;->of(I)Ljava/lang/Character$UnicodeScript;,public-api
Paul Duffin67b9d612021-07-21 17:38:47 +010033Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
34Ljava/lang/Object;->toString()Ljava/lang/String;,blocked
35''')
36 expected = [
Paul Duffin6ffdff82021-08-09 13:47:19 +010037 "java/lang/Character",
38 "java/lang/Object",
39 "java/lang/ProcessBuilder",
Paul Duffin67b9d612021-07-21 17:38:47 +010040 ]
41 self.assertEqual(expected, patterns)
42
43if __name__ == '__main__':
44 unittest.main(verbosity=2)