blob: eec1c68186bd04e63ca0b7f777857d7345e4bf6c [file] [log] [blame]
David Srbecky0adf4d82018-10-01 18:17:45 +01001#!/usr/bin/env python
2#
3# Copyright (C) 2018 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
17import unittest
18import make_header
19
20test_input = r'''
21// Check that the various other assembly lines are ignored.
22.globl _Z49AsmDefineHelperFor_MIRROR_OBJECT_LOCK_WORD_OFFSETv
23.type _Z49AsmDefineHelperFor_MIRROR_OBJECT_LOCK_WORD_OFFSETv,%function
24.ascii ">>MIRROR_OBJECT_LOCK_WORD_OFFSET #4 #0<<"
25bx lr
26
27// Check large positive 32-bit constant.
28.ascii ">>OBJECT_ALIGNMENT_MASK_TOGGLED #4294967288 #0<<"
29
30// Check large positive 64-bit constant (it overflows into negative value).
31.ascii ">>OBJECT_ALIGNMENT_MASK_TOGGLED64 #-8 #0<<"
32
33// Check negative constant.
34.ascii ">>JIT_CHECK_OSR #-1 #1<<"
35'''
36
37test_output = r'''
38#define JIT_CHECK_OSR -0x1
39#define JIT_CHECK_OSR -0x1
40#define MIRROR_OBJECT_LOCK_WORD_OFFSET 0x4
41#define MIRROR_OBJECT_LOCK_WORD_OFFSET 0x4
42#define OBJECT_ALIGNMENT_MASK_TOGGLED 0xfffffff8
43#define OBJECT_ALIGNMENT_MASK_TOGGLED 0xfffffff8
44#define OBJECT_ALIGNMENT_MASK_TOGGLED64 0xfffffffffffffff8
45#define OBJECT_ALIGNMENT_MASK_TOGGLED64 0xfffffffffffffff8
46'''
47
48class CppDefineGeneratorTest(unittest.TestCase):
49 def test_convert(self):
50 self.assertEqual(test_output.strip(), make_header.convert(test_input))
51
52if __name__ == '__main__':
53 unittest.main()