Skip to content

Commit eb1144e

Browse files
committed
Use NULL separator in RPATH script
1 parent 5e08b6a commit eb1144e

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

easybuild/scripts/rpath_args.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,4 @@ def add_rpath_flag(lib_path, rpath_filter, rpath_lib_paths, cmd_args_rpath, ldfl
183183
cmd_args = cmd_args_rpath + cmd_args
184184

185185

186-
print('\n'.join(cmd_args))
186+
print('\0'.join(cmd_args), end='')

easybuild/scripts/rpath_wrapper_template.sh.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ log "found CMD: $CMD | original command: %(orig_cmd)s | orig args: $*)"
5454
# * -S: disable the import of the module site and the site-dependent manipulations of sys.path that it entails;
5555
# (once we only support Python 3, we can (also) use -I (isolated mode)
5656
log "%(python)s -E -O -s -S %(rpath_args_py)s $CMD '%(rpath_filter)s' '%(rpath_include)s' $*"
57-
readarray -t CMD_ARGS < <( %(python)s -E -O -s -S %(rpath_args_py)s $CMD '%(rpath_filter)s' '%(rpath_include)s' "$@" )
57+
readarray -d '' -t CMD_ARGS < <( %(python)s -E -O -s -S %(rpath_args_py)s $CMD '%(rpath_filter)s' '%(rpath_include)s' "$@" )
5858

5959
# exclude location of this wrapper from $PATH to avoid other potential wrappers calling this wrapper
6060
export PATH=$(echo "$PATH" | tr ':' '\n' | grep -v "^%(wrapper_dir)s$" | tr '\n' ':')

test/framework/toolchain.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,19 @@ def tearDown(self):
8282
st.get_cpu_vendor = self.orig_get_cpu_vendor
8383
super().tearDown()
8484

85-
def run_cmd_and_split(self, cmd):
85+
def run_cmd_and_split(self, cmd, sep='\0'):
8686
"""Run the command, check return code and return output as list of lines"""
8787
with self.mocked_stdout_stderr():
8888
res = run_shell_cmd(cmd)
8989
self.assertEqual(res.exit_code, 0)
9090
out = res.output
91-
# Remove 1 trailing newline
92-
if out:
93-
self.assertEqual(out[-1], '\n')
94-
return out[:-1].split('\n')
91+
if sep == '\0':
92+
return out.split('\0')
93+
else:
94+
# Remove 1 trailing separator
95+
if out:
96+
self.assertEqual(out[-1], sep)
97+
return out[:-1].split(sep)
9598

9699
def get_toolchain(self, name, version=None):
97100
"""Get a toolchain object instance to test with."""
@@ -3123,7 +3126,7 @@ def test_toolchain_prepare_rpath(self):
31233126
r"-DY1=\'\'",
31243127
r"-DY2=\'J\'",
31253128
])
3126-
out = self.run_cmd_and_split(cmd)
3129+
out = self.run_cmd_and_split(cmd, sep='\n')
31273130
expected = [
31283131
'-Wl,--disable-new-dtags',
31293132
'-Wl,-rpath=%s/foo' % self.test_prefix,
@@ -3165,7 +3168,7 @@ def test_toolchain_prepare_rpath(self):
31653168
args.append('-L"%s"' % path_with_spaces)
31663169

31673170
cmd = "g++ ${USER}.c %s" % ' '.join(args)
3168-
out = self.run_cmd_and_split(cmd)
3171+
out = self.run_cmd_and_split(cmd, sep='\n')
31693172

31703173
expected = ('\n'.join([
31713174
'-Wl,--disable-new-dtags',

test/framework/toy_build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,7 @@ def grab_gcc_rpath_wrapper_args():
29782978
gcc_rpath_wrapper_txt = read_file(glob.glob(os.path.join(rpath_wrappers_dir, '*', 'gcc'))[0])
29792979

29802980
# Get the filter and include arguments
2981-
rpath_args_regex = re.compile(r"^readarray -t CMD_ARGS .*rpath_args.py \$CMD "
2981+
rpath_args_regex = re.compile(r"^readarray -d '' -t CMD_ARGS .*rpath_args.py \$CMD "
29822982
r"'(?P<filter_paths>[^ ]*)' '(?P<include_paths>[^ ]*)'.*", re.M)
29832983
res = rpath_args_regex.search(gcc_rpath_wrapper_txt)
29842984
self.assertTrue(res, "Pattern '%s' found in: %s" % (rpath_args_regex.pattern, gcc_rpath_wrapper_txt))

0 commit comments

Comments
 (0)