Skip to content

Commit

Permalink
Fix string maniuplation in environment forwarding (chapel-lang#26365)
Browse files Browse the repository at this point in the history
Fixes the string manipulation code for checking which variables to
forward to the system launcher (slurm/pbs).

Fixes an off-by-one error that was added in
chapel-lang#26281

[Reviewed by @e-kayrakli]
  • Loading branch information
jabraham17 authored Dec 6, 2024
2 parents 08f3e9c + eb0aac2 commit 6a6fd26
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 2 additions & 2 deletions runtime/src/chpl-launcher-common.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ char* chpl_get_enviro_keys(char sep)
int keyLen = strstr(environ[i], "=") - environ[i];

// if the key ends with _modshare, skip it
if (keyLen > 8 && strncmp(environ[i] + keyLen - 8, "_modshare", 9) == 0) {
if (keyLen > 8 && strncmp(environ[i] + keyLen - 9, "_modshare", 9) == 0) {
continue;
}
numVars++;
Expand All @@ -563,7 +563,7 @@ char* chpl_get_enviro_keys(char sep)

int keyLen = strstr(environ[i], "=") - environ[i];
// skip keys that end with _modshare
if (keyLen > 8 && strncmp(environ[i] + keyLen - 8, "_modshare", 9) == 0) {
if (keyLen > 8 && strncmp(environ[i] + keyLen - 9, "_modshare", 9) == 0) {
continue;
}
strncpy(buffer + bufferOffset, environ[i], keyLen);
Expand Down
6 changes: 1 addition & 5 deletions util/test/chpl_launchcmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ def main():
"""Run the program!"""
job = AbstractJob.init_from_environment()
(stdout, stderr) = job.run()
logging.debug("I am after run {} {} {} {}", stdout, type(stdout), stderr, type(stderr))
sys.stdout.buffer.write(stdout)
sys.stderr.buffer.write(stderr)
logging.debug("I am after buffer writes")


class AbstractJob(object):
Expand Down Expand Up @@ -403,8 +401,6 @@ def job_status(job_id, output_file):

logging.info('The test finished with output of length {0}.'.format(len(output)))

logging.debug('Returning output and error from job.')

return (output, error)

def submit_job(self, testing_dir, output_file, error_file, input_file):
Expand Down Expand Up @@ -1149,7 +1145,7 @@ def _temp_dir(dir_prefix='chapel-test-tmp'):
yield tmp_dir
finally:
logging.debug('Deleting temporary working directory at: {0}'.format(tmp_dir))
# shutil.rmtree(tmp_dir)
shutil.rmtree(tmp_dir)


if __name__ == '__main__':
Expand Down

0 comments on commit 6a6fd26

Please sign in to comment.