aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-10-25 14:14:44 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2016-10-25 14:36:47 +0530
commitf3bb6bb227af00411346cfe3d901532c00ceeb55 (patch)
tree88a1fdc6c522efdc4397c7396bb89a0dc3059ce8
parent706425abd172df6686aab40f110b341c62721361 (diff)
downloadmeson-f3bb6bb227af00411346cfe3d901532c00ceeb55.zip
meson-f3bb6bb227af00411346cfe3d901532c00ceeb55.tar.gz
meson-f3bb6bb227af00411346cfe3d901532c00ceeb55.tar.bz2
Add a unit test to ensure object file order
Part of the changes to make input and output filenames in targets be deterministic.
-rwxr-xr-xrun_unittests.py11
-rw-r--r--test cases/common/5 linkstatic/libfile2.c3
-rw-r--r--test cases/common/5 linkstatic/libfile3.c3
-rw-r--r--test cases/common/5 linkstatic/libfile4.c3
-rw-r--r--test cases/common/5 linkstatic/meson.build2
5 files changed, 21 insertions, 1 deletions
diff --git a/run_unittests.py b/run_unittests.py
index b9c1397..9391eae 100755
--- a/run_unittests.py
+++ b/run_unittests.py
@@ -136,5 +136,16 @@ class LinuxlikeTests(unittest.TestCase):
self.assertTrue('-Werror' in vala_command)
self.assertTrue('-Werror' in c_command)
+ def test_static_compile_order(self):
+ testdir = os.path.join(self.common_test_dir, '5 linkstatic')
+ self.init(testdir)
+ compdb = self.get_compdb()
+ # Rules will get written out in this order
+ self.assertTrue(compdb[0]['file'].endswith("libfile.c"))
+ self.assertTrue(compdb[1]['file'].endswith("libfile2.c"))
+ self.assertTrue(compdb[2]['file'].endswith("libfile3.c"))
+ self.assertTrue(compdb[3]['file'].endswith("libfile4.c"))
+ # FIXME: We don't have access to the linker command
+
if __name__ == '__main__':
unittest.main()
diff --git a/test cases/common/5 linkstatic/libfile2.c b/test cases/common/5 linkstatic/libfile2.c
new file mode 100644
index 0000000..89780f5
--- /dev/null
+++ b/test cases/common/5 linkstatic/libfile2.c
@@ -0,0 +1,3 @@
+int func2() {
+ return 2;
+}
diff --git a/test cases/common/5 linkstatic/libfile3.c b/test cases/common/5 linkstatic/libfile3.c
new file mode 100644
index 0000000..5e0d08b
--- /dev/null
+++ b/test cases/common/5 linkstatic/libfile3.c
@@ -0,0 +1,3 @@
+int func3() {
+ return 3;
+}
diff --git a/test cases/common/5 linkstatic/libfile4.c b/test cases/common/5 linkstatic/libfile4.c
new file mode 100644
index 0000000..3645c31
--- /dev/null
+++ b/test cases/common/5 linkstatic/libfile4.c
@@ -0,0 +1,3 @@
+int func4() {
+ return 4;
+}
diff --git a/test cases/common/5 linkstatic/meson.build b/test cases/common/5 linkstatic/meson.build
index c1cb8b6..1f02a5c 100644
--- a/test cases/common/5 linkstatic/meson.build
+++ b/test cases/common/5 linkstatic/meson.build
@@ -1,6 +1,6 @@
project('static library linking test', 'c')
-lib = build_target('mylib', 'libfile.c', target_type : 'static_library')
+lib = build_target('mylib', 'libfile.c', 'libfile2.c', 'libfile3.c', 'libfile4.c', target_type : 'static_library')
exe = executable('prog', 'main.c', link_with : lib)
test('runtest', exe)