Add a unit test to ensure object file order

Part of the changes to make input and output filenames in targets be
deterministic.
pull/952/head
Nirbheek Chauhan 8 years ago
parent 706425abd1
commit f3bb6bb227
  1. 11
      run_unittests.py
  2. 3
      test cases/common/5 linkstatic/libfile2.c
  3. 3
      test cases/common/5 linkstatic/libfile3.c
  4. 3
      test cases/common/5 linkstatic/libfile4.c
  5. 2
      test cases/common/5 linkstatic/meson.build

@ -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()

@ -0,0 +1,3 @@
int func2() {
return 2;
}

@ -0,0 +1,3 @@
int func3() {
return 3;
}

@ -0,0 +1,3 @@
int func4() {
return 4;
}

@ -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)

Loading…
Cancel
Save