Skip to content

Commit 5e7ca0e

Browse files
committed
testsuite: add tests for flux multi-prog
Problem: There are no tests of the `flux multi-prog` utility. Add a new sharness test t2720-python-cli-multi-prog.t for this purpose.
1 parent 129cef2 commit 5e7ca0e

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

t/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ TESTSCRIPTS = \
230230
t2713-python-cli-bulksubmit.t \
231231
t2715-python-cli-cancel.t \
232232
t2716-python-cli-batch-conf.t \
233+
t2720-python-cli-multi-prog.t \
233234
t2800-jobs-cmd.t \
234235
t2800-jobs-cmd-multiuser.t \
235236
t2800-jobs-recursive.t \

t/t2720-python-cli-multi-prog.t

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
#!/bin/sh
2+
3+
test_description='flux multi-prog'
4+
5+
. $(dirname $0)/sharness.sh
6+
7+
8+
# Start an instance with 16 cores across 4 ranks
9+
test_under_flux 4 job
10+
11+
flux setattr log-stderr-level 1
12+
13+
test_expect_success 'flux-multi-prog prints usage with no args' '
14+
test_expect_code 2 flux multi-prog 2>no-args.err &&
15+
grep usage no-args.err
16+
'
17+
test_expect_success 'flux-multi-prog --help works' '
18+
flux multi-prog --help >help.out &&
19+
grep CONFIG help.out
20+
'
21+
test_expect_success 'flux-multi-prog raises error with bad config file' '
22+
test_must_fail flux multi-prog missing.conf 2>missing.err &&
23+
test_debug "cat missing.err" &&
24+
grep "No such file" missing.err
25+
'
26+
test_expect_success 'flux-multi-prog: basic config' '
27+
name=basic &&
28+
cat <<-EOF >${name}.conf &&
29+
# srun docs silly config
30+
4-6 hostname
31+
1,7 echo task%t
32+
0,2-3 echo offset:%o
33+
* echo all task=%t
34+
EOF
35+
cat <<-EOF2 >${name}.expected &&
36+
0: echo offset:0
37+
1: echo task1
38+
2: echo offset:1
39+
3: echo offset:2
40+
4: hostname
41+
5: hostname
42+
6: hostname
43+
7: echo task7
44+
8: echo all task=8
45+
9: echo all task=9
46+
EOF2
47+
flux multi-prog -n 0-9 ${name}.conf >${name}.out &&
48+
test_debug "cat ${name}.out" &&
49+
test_cmp ${name}.expected ${name}.out
50+
'
51+
test_expect_success 'flux-multi-prog: position of "*" does not matter' '
52+
name=basic &&
53+
cat <<-EOF >${name}.conf &&
54+
# srun docs silly config
55+
* echo all task=%t
56+
4-6 hostname
57+
1,7 echo task%t
58+
0,2-3 echo offset:%o
59+
EOF
60+
cat <<-EOF2 >${name}.expected &&
61+
0: echo offset:0
62+
1: echo task1
63+
2: echo offset:1
64+
3: echo offset:2
65+
4: hostname
66+
5: hostname
67+
6: hostname
68+
7: echo task7
69+
8: echo all task=8
70+
9: echo all task=9
71+
EOF2
72+
flux multi-prog -n 0-9 ${name}.conf >${name}.out &&
73+
test_debug "cat ${name}.out" &&
74+
test_cmp ${name}.expected ${name}.out
75+
'
76+
test_expect_success 'flux-multi-prog: command and args accept quoting' '
77+
name=quoting &&
78+
cat <<-"EOF" >${name}.conf &&
79+
0-1 echo "foo bar" %t # line comment for good measure
80+
EOF
81+
cat <<-EOF >${name}.expected &&
82+
0: echo '"'"'foo bar'"'"' 0
83+
1: echo '"'"'foo bar'"'"' 1
84+
EOF
85+
flux multi-prog -n 0-1 ${name}.conf >${name}.out &&
86+
test_debug "cat ${name}.out" &&
87+
test_cmp ${name}.expected ${name}.out
88+
'
89+
test_expect_success 'flux-multi-prog: missing tasks raise error' '
90+
name=missing-task &&
91+
cat <<-EOF >${name}.conf &&
92+
0-1 foo
93+
EOF
94+
test_must_fail flux multi-prog -n 0-3 ${name}.conf 2>${name}.err &&
95+
test_debug "cat ${name}.err" &&
96+
grep "No matching line for rank 2" ${name}.err
97+
'
98+
test_expect_success 'flux-multi-prog: invalid idset raises error' '
99+
name=bad-line &&
100+
cat <<-EOF >${name}.conf &&
101+
# good line:
102+
0-1 hostname
103+
# bad line:
104+
1-0 hostname
105+
EOF
106+
test_must_fail flux multi-prog -n 0-1 ${name}.conf 2>${name}.err &&
107+
test_debug "cat ${name}.err" &&
108+
grep "line 4: invalid idset: 1-0" ${name}.err
109+
'
110+
test_expect_success 'flux-multi-prog: invalid line raises error' '
111+
name=bad-line2 &&
112+
cat <<-EOF >${name}.conf &&
113+
0-1 echo "foo bar baz
114+
EOF
115+
test_must_fail flux multi-prog -n 0-1 ${name}.conf 2>${name}.err &&
116+
test_debug "cat ${name}.err" &&
117+
grep "No closing quotation" ${name}.err
118+
'
119+
test_expect_success 'flux-multi-prog uses FLUX_TASK_RANK by default' '
120+
FLUX_TASK_RANK=7 flux multi-prog basic.conf >env.out &&
121+
test_debug "cat env.out" &&
122+
test "$(cat env.out)" = "task7"
123+
'
124+
test_expect_success 'flux-multi-prog works under flux-run' '
125+
flux run -n8 --label-io flux multi-prog basic.conf >run.out &&
126+
test_debug "cat run.out" &&
127+
grep "7: task7" run.out &&
128+
grep "0: offset:0" run.out &&
129+
grep "3: offset:2" run.out
130+
'
131+
test_done

0 commit comments

Comments
 (0)