Skip to content

Commit 6f983b3

Browse files
committed
testsuite: test HOSTNAME variable handling
Problem: There are no tests that ensure the job shell corrects HOSTNAME when set but leaves it unset when it is not set. Add a couple tests to t2602-job-shell.t to verify handling of HOSTNAME.
1 parent ce03c06 commit 6f983b3

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

t/t2602-job-shell.t

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,18 @@ test_expect_success 'job-shell: fails if FLUX_EXEC_PROTOCOL_FD incorrect' '
340340
-n2 -N2 hostname 2>protocol_fd_invalid.err &&
341341
grep FLUX_EXEC_PROTOCOL_FD protocol_fd_invalid.err
342342
'
343-
343+
test_expect_success 'job-shell: corrects HOSTNAME environment variable' '
344+
HOSTNAME=incorrect \
345+
flux run -n1 printenv HOSTNAME >hostname.out &&
346+
test_debug "cat hostname.out" &&
347+
test "$(hostname)" = "$(cat hostname.out)"
348+
'
349+
test_expect_success 'job-shell: leaves HOSTNAME unset if not set' '
350+
( unset HOSTNAME &&
351+
test_expect_code 1 flux run -n1 printenv HOSTNAME >hostname.out2
352+
) &&
353+
test_must_be_empty hostname.out2
354+
'
344355
# Note: in below tests, os.exit(True) returns with nonzero exit code,
345356
# so the sense of the tests is reversed so the tasks exit with zero exit
346357
# code for success.

0 commit comments

Comments
 (0)