Skip to content

Commit 3a79d12

Browse files
authored
Make printchplbuilds test work in more configs (#26390)
Makes `test/chplenv/printchplbuilds/printchplbuilds-print1.chpl` work in more configs. Namely, that the test now works regardless of the value of `CHPL_HWLOC` and also works with `CHPL_COMM=ofi` [Reviewed by @jhh67]
2 parents 712ad27 + 883ddff commit 3a79d12

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/chplenv/printchplbuilds/printchplbuilds-print1.prediff

+13-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ with open(sys.argv[2], 'w') as f:
2525
# now we need to generate a good file
2626
printchplenv = os.path.join(chpl_home, 'util/printchplenv')
2727

28+
# this defines the order of the variables printchplbuilds might print
29+
# we fill in the values from the output of printchplenv, if they exist
30+
# depending on the configuration, not all may be printed by printchplbuilds
31+
# for this reason, we can specify a filter function that will be called with the chplenv dict
2832
chpl_vars = [
2933
("CHPL_TARGET_PLATFORM", None),
3034
("CHPL_TARGET_COMPILER", None),
@@ -34,12 +38,15 @@ chpl_vars = [
3438
("CHPL_COMM", None),
3539
("CHPL_COMM_SUBSTRATE", None),
3640
("CHPL_GASNET_SEGMENT", None),
41+
("CHPL_LIBFABRIC", None, lambda env: env["CHPL_COMM"] == "ofi"),
42+
("CHPL_COMM_OFI_OOB", None, lambda env: env["CHPL_COMM"] == "ofi"),
3743
("CHPL_TASKS", None),
3844
("CHPL_TIMERS", None),
3945
("CHPL_UNWIND", None),
4046
("CHPL_MEM", None),
4147
("CHPL_ATOMICS", None),
4248
("CHPL_HWLOC", None),
49+
("CHPL_HWLOC_PCI", None, lambda env: env["CHPL_HWLOC"] == "bundled"),
4350
("CHPL_RE2", None),
4451
("CHPL_AUX_FILESYS", None),
4552
("CHPL_LIB_PIC", None),
@@ -48,13 +55,15 @@ chpl_vars = [
4855
chplenv_out = [l.strip() for l in sp.check_output([printchplenv, "--all", "--internal", "--simple"]).decode().splitlines()]
4956
chplenv = {k: v for k, v in [l.split("=", 1) for l in chplenv_out]}
5057

51-
# fill in the chplvars
52-
for i, (k, v) in enumerate(chpl_vars):
53-
if not v:
58+
# fill in the chplvars, checking the filter function if it exists
59+
for i, cv in enumerate(chpl_vars):
60+
k, v = cv[:2]
61+
if not v and (len(cv) < 3 or cv[2](chplenv)):
5462
chpl_vars[i] = (k, chplenv.get(k, "NA"))
5563

5664
# write the good file
5765
goodfile = os.path.splitext(__file__)[0] + ".good"
5866
with open(goodfile, 'w') as f:
5967
print("<Current>", file=f)
60-
print("\n".join([f"{k}: {v}" for k, v in chpl_vars]), file=f)
68+
# only print the variables that have a value
69+
print("\n".join([f"{cv[0]}: {cv[1]}" for cv in chpl_vars if cv[1]]), file=f)

0 commit comments

Comments
 (0)