Add toolchain_test.py to naclbuild.py
[nacl-build.git] / toolchain_test.py
blobd62e85ad973108da08e66cedaa4a2883c26f1824
2 import subprocess
3 import unittest
6 class ToolchainTests(unittest.TestCase):
8 def test_padding_unusual_code_sections(self):
9 # Test that ends of code sections are padded with NOPs not
10 # zeroes when concatenated by the linker.
11 subprocess.check_call(["nacl-gcc", "-c", "tests/section-padding.S",
12 "-o", "tests/section-padding-1.o"])
13 subprocess.check_call(["nacl-gcc", "-c", "tests/section-padding.S",
14 "-Dfoo=foo2",
15 "-o", "tests/section-padding-2.o"])
16 # Use of --relocatable mimics how glibc links libc.so in two
17 # steps, producing libc_pic.os as an intermediate object.
18 subprocess.check_call(["nacl-ld", "--relocatable",
19 "tests/section-padding-1.o",
20 "tests/section-padding-2.o",
21 "-o", "tests/section-padding-both.o"])
22 # Link into an .so so that we can run ncval on it.
23 # TODO: Make ncval work on .o files.
24 subprocess.check_call(["nacl-gcc", "-shared",
25 "-Lglibc/ld",
26 "tests/section-padding-both.o",
27 "-o", "tests/section-padding-both.so"])
28 subprocess.check_call(["ncval", "tests/section-padding-both.so"])
31 if __name__ == "__main__":
32 unittest.main()