blob: 3babe54206f2e4f2964de37eaea67d0f580ac733 [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
Spandan Das2c2219b2021-08-25 17:47:43 +000021from signature_patterns import * #pylint: disable=unused-wildcard-import,wildcard-import
22
Paul Duffin67b9d612021-07-21 17:38:47 +010023
24class TestGeneratedPatterns(unittest.TestCase):
Spandan Das2c2219b2021-08-25 17:47:43 +000025 def produce_patterns_from_string(self, csvdata):
26 with io.StringIO(csvdata) as f:
Paul Duffin67b9d612021-07-21 17:38:47 +010027 return produce_patterns_from_stream(f)
28
29 def test_generate(self):
Spandan Das2c2219b2021-08-25 17:47:43 +000030 #pylint: disable=line-too-long
31 patterns = self.produce_patterns_from_string(
32 '''
Paul Duffin6ffdff82021-08-09 13:47:19 +010033Ljava/lang/ProcessBuilder$Redirect$1;-><init>()V,blocked
34Ljava/lang/Character$UnicodeScript;->of(I)Ljava/lang/Character$UnicodeScript;,public-api
Paul Duffin67b9d612021-07-21 17:38:47 +010035Ljava/lang/Object;->hashCode()I,public-api,system-api,test-api
36Ljava/lang/Object;->toString()Ljava/lang/String;,blocked
Spandan Das2c2219b2021-08-25 17:47:43 +000037'''
38 )
39 #pylint: enable=line-too-long
Paul Duffin67b9d612021-07-21 17:38:47 +010040 expected = [
Paul Duffin6ffdff82021-08-09 13:47:19 +010041 "java/lang/Character",
42 "java/lang/Object",
43 "java/lang/ProcessBuilder",
Paul Duffin67b9d612021-07-21 17:38:47 +010044 ]
45 self.assertEqual(expected, patterns)
46
Spandan Das2c2219b2021-08-25 17:47:43 +000047
Paul Duffin67b9d612021-07-21 17:38:47 +010048if __name__ == '__main__':
49 unittest.main(verbosity=2)