summaryrefslogtreecommitdiffstats
path: root/third_party/python/gyp/test/linux/gyptest-ldflags-from-environment.py
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/python/gyp/test/linux/gyptest-ldflags-from-environment.py')
-rw-r--r--third_party/python/gyp/test/linux/gyptest-ldflags-from-environment.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/third_party/python/gyp/test/linux/gyptest-ldflags-from-environment.py b/third_party/python/gyp/test/linux/gyptest-ldflags-from-environment.py
new file mode 100644
index 0000000000..4aea193e4b
--- /dev/null
+++ b/third_party/python/gyp/test/linux/gyptest-ldflags-from-environment.py
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+
+# Copyright (c) 2017 Google Inc. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Verifies the use of linker flags in environment variables.
+
+In this test, gyp and build both run in same local environment.
+"""
+
+import TestGyp
+
+import re
+import subprocess
+import sys
+
+FORMATS = ('make', 'ninja')
+
+if sys.platform.startswith('linux'):
+ test = TestGyp.TestGyp(formats=FORMATS)
+
+ CHDIR = 'ldflags-from-environment'
+ with TestGyp.LocalEnv({'LDFLAGS': '-Wl,--dynamic-linker=/target',
+ 'LDFLAGS_host': '-Wl,--dynamic-linker=/host',
+ 'GYP_CROSSCOMPILE': '1'}):
+ test.run_gyp('test.gyp', chdir=CHDIR)
+ test.build('test.gyp', chdir=CHDIR)
+
+ def GetDynamicLinker(p):
+ p = test.built_file_path(p, chdir=CHDIR)
+ r = re.compile(r'\[Requesting program interpreter: ([^\]]+)\]')
+ proc = subprocess.Popen(['readelf', '-l', p], stdout=subprocess.PIPE)
+ o = proc.communicate()[0].decode('utf-8')
+ assert not proc.returncode
+ return r.search(o).group(1)
+
+ if GetDynamicLinker('ldflags') != '/target':
+ test.fail_test()
+
+ if GetDynamicLinker('ldflags_host') != '/host':
+ test.fail_test()
+
+ test.pass_test()