Paul Duffin | 67b9d61 | 2021-07-21 17:38:47 +0100 | [diff] [blame] | 1 | #!/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.""" |
| 18 | import io |
| 19 | import unittest |
| 20 | |
| 21 | from signature_patterns import * |
| 22 | |
| 23 | class 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 Duffin | 6ffdff8 | 2021-08-09 13:47:19 +0100 | [diff] [blame^] | 31 | Ljava/lang/ProcessBuilder$Redirect$1;-><init>()V,blocked |
| 32 | Ljava/lang/Character$UnicodeScript;->of(I)Ljava/lang/Character$UnicodeScript;,public-api |
Paul Duffin | 67b9d61 | 2021-07-21 17:38:47 +0100 | [diff] [blame] | 33 | Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api |
| 34 | Ljava/lang/Object;->toString()Ljava/lang/String;,blocked |
| 35 | ''') |
| 36 | expected = [ |
Paul Duffin | 6ffdff8 | 2021-08-09 13:47:19 +0100 | [diff] [blame^] | 37 | "java/lang/Character", |
| 38 | "java/lang/Object", |
| 39 | "java/lang/ProcessBuilder", |
Paul Duffin | 67b9d61 | 2021-07-21 17:38:47 +0100 | [diff] [blame] | 40 | ] |
| 41 | self.assertEqual(expected, patterns) |
| 42 | |
| 43 | if __name__ == '__main__': |
| 44 | unittest.main(verbosity=2) |