aboutsummaryrefslogtreecommitdiff
path: root/build/test_extract_platform.py
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2017-01-17 14:03:38 -0800
committerDan Albert <danalbert@google.com>2017-01-17 14:52:49 -0800
commit73089be86e5d82caf390af2608560257118dfea2 (patch)
tree6800cd74f7cd3346c3b25416831090f95871418f /build/test_extract_platform.py
parent46d79a8c39e0a9b1f53a6f8e1aff6bac5b116fa8 (diff)
downloadndk-73089be86e5d82caf390af2608560257118dfea2.tar.gz
Replace extract-platform.awk with Python.
Test: nose2 && ./run_tests.py --filter project-properties Bug: None Change-Id: I4479a66881f21f97cec6a213d560f190029f5a2c
Diffstat (limited to 'build/test_extract_platform.py')
-rw-r--r--build/test_extract_platform.py60
1 files changed, 60 insertions, 0 deletions
diff --git a/build/test_extract_platform.py b/build/test_extract_platform.py
new file mode 100644
index 000000000..d4619fb50
--- /dev/null
+++ b/build/test_extract_platform.py
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import textwrap
+import unittest
+
+import build.extract_platform
+
+
+class ExtractPlatformTest(unittest.TestCase):
+ def testNumericVersion(self):
+ props_file = textwrap.dedent("""\
+ some
+ # other
+ junk
+ target=android-9
+ foo
+ """).splitlines()
+
+ self.assertEqual(
+ 'android-9', build.extract_platform.get_platform(props_file))
+
+ def testNamedVersion(self):
+ props_file = textwrap.dedent("""\
+ some
+ # other
+ junk
+ target=android-nougat
+ foo
+ """).splitlines()
+
+ self.assertEqual(
+ 'android-nougat', build.extract_platform.get_platform(props_file))
+
+ def testVendorVersion(self):
+ props_file = textwrap.dedent("""\
+ some
+ # other
+ junk
+ target=vendor:something:21
+ foo
+ """).splitlines()
+
+ self.assertEqual(
+ 'android-21', build.extract_platform.get_platform(props_file))
+
+ def testNoVersion(self):
+ self.assertEqual('unknown', build.extract_platform.get_platform([]))