Skip to content

Commit

Permalink
Merge pull request #18 from buildsi/add/python
Browse files Browse the repository at this point in the history
Testing adding python
  • Loading branch information
vsoch committed Jun 11, 2021
2 parents 150cf1b + c9aa9ea commit 8296e80
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 42 deletions.
1 change: 1 addition & 0 deletions build-si-containers
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ config_schema = {
"versions": {"type": "array", "items": {"type": "string"}},
"headers": {"type": "array", "items": {"type": "string"}},
"libs": {"type": "array", "items": {"type": "string"}},
"libregex": {"type": "array", "items": {"type": "string"}},
"bins": {"type": "array", "items": {"type": "string"}},
"run": {"type": "array", "items": {"type": "string"}},
},
Expand Down
2 changes: 1 addition & 1 deletion templates/Dockerfile.default
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN echo "packages:" > packages.yaml &&\

RUN apt-get update && apt-get install -y curl python3-botocore python3-boto3 && \
spack config add -f "packages.yaml" && \
{% for version in package.versions %}spack install --source {% if cache_only %}--cache-only{% endif %} {{ package.name }}@{{ version }} || echo "There was an issue installing {{ package.name }}@{{ version }}" && \{% endfor %}
{% for version in package.versions %}spack install --source {% if cache_only %}--cache-only{% endif %} --deprecated {{ package.name }}@{{ version }} && \{% endfor %}
printf "Finished installation attempts\n"

FROM quay.io/buildsi/{{ tester.name }}:{{ tester.version }}
Expand Down
95 changes: 54 additions & 41 deletions templates/libabigail/runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3

from glob import glob
import subprocess
import os
import sys
Expand Down Expand Up @@ -59,59 +60,71 @@ def main():
os.chdir(path)
# Add package bin to the path and run extra commands
os.environ["PATH"] = "%s/bin:%s" % (os.getcwd(), envpath)
{% for run in package.run %}run("{{ run }}")
{% for run in package.run %}run('{{ run }}')
{% endfor %}
os.chdir(here){% endif %}

# spec names -> paths
for spec, path in lookup.items():
spec, spec_version = spec.split("@", 1)
{% for lib in package.libs %}print("Testing {{ lib }} with abidw")
out_dir = "/results/{{ tester.name }}/{{ tester.version }}/{{ package.name }}/%s" % spec_version

# Assumes path for spack install
libdir = os.path.dirname("{{ lib }}")
result_dir = os.path.join(out_dir, libdir)
if not os.path.exists(result_dir):
os.makedirs(result_dir)

# Don't run if the library does not exist
lib = "%s/{{ lib }}" % path
if not os.path.exists(lib):
print("Skipping %s, does not exist." % lib)
continue

# We don't need output here, lazy way to do it
run("time -p abidw {% for include in package.headers %} --hd %s/{{ include }} {% endfor %} %s --out-file %s/{{ lib }}.xml > %s/{{ lib }}.xml.log 2>&1" % ({% for include in package.headers %}path, {% endfor %}lib, out_dir, out_dir))

for spec2, path2 in lookup.items():
spec2, spec2_version = spec2.split("@", 1)
print("Comparing %s versions %s and %s {{ lib }} with abidiff" %(spec, spec_version, spec2_version))
out_file = "/results/{{ tester.name }}/{{ tester.version }}/{{ package.name }}/diff/%s-%s" % (spec_version, spec2_version)
create_outdir(out_file)

# Only run if the named library exists
lib2 = "%s/{{ lib }}" % path2
if not os.path.exists(lib2):
print("Skipping %s, does not exist." % lib2)
continue

# Create a list of libs to test
libs = [{% if package.libs %}{% for lib in package.libs %}"{{ lib }}"{% if loop.last %}{% else %},{% endif %}{% endfor %}{% endif %}]

run("time -p abidiff {% for include in package.headers %} --hd1 %s/{{ include }} --hd2 %s/{{ include }} {% endfor %} %s %s > %s > %s.log" %({% for include in package.headers %}path, path2, {% endfor %}lib, lib2, out_file, out_file))
# Add any libregex
{% if package.libregex %}os.chdir(path)
{% for libregex in package.libregex %}libs += glob("{{ libregex }}")
{% endfor %}
os.chdir(here){% endif %}

# If we have bins to run abicompat with
{% if package.bins %}{% for binary in package.bins %}
bin1 = os.path.join(path, "{{ binary }}")
# Loop through all libs
for libname in libs:

# We can only run abicompat if it exists
if os.path.exists(bin1):
print("Testing %s with abidw" % libname)
out_dir = "/results/{{ tester.name }}/{{ tester.version }}/{{ package.name }}/%s" % spec_version

# Assumes path for spack install
libdir = os.path.dirname(libname)
result_dir = os.path.join(out_dir, libdir)
if not os.path.exists(result_dir):
os.makedirs(result_dir)

# Don't run if the library does not exist
lib = "%s/%s" % (path, libname)
if not os.path.exists(lib):
print("Skipping %s, does not exist." % lib)
continue

# We don't need output here, lazy way to do it
run("time -p abidw {% for include in package.headers %} --hd %s/{{ include }} {% endfor %} %s --out-file %s/%s.xml > %s/%s.xml.log 2>&1" % ({% for include in package.headers %}path, {% endfor %}lib, out_dir, libname, out_dir, libname))

out_file = "/results/{{ tester.name }}/{{ tester.version }}/{{ package.name }}/compat/%s-%s" % (spec_version, spec2_version)
for spec2, path2 in lookup.items():
spec2, spec2_version = spec2.split("@", 1)
print("Comparing %s versions %s and %s %s with abidiff" %(spec, spec_version, spec2_version, libname))
out_file = "/results/{{ tester.name }}/{{ tester.version }}/{{ package.name }}/diff/%s-%s" % (spec_version, spec2_version)
create_outdir(out_file)

# Only run if the named library exists
lib2 = "%s/%s" % (path2, libname)
if not os.path.exists(lib2):
print("Skipping %s, does not exist." % lib2)
continue

run("time -p abidiff {% for include in package.headers %} --hd1 %s/{{ include }} --hd2 %s/{{ include }} {% endfor %} %s %s > %s > %s.log" %({% for include in package.headers %}path, path2, {% endfor %}lib, lib2, out_file, out_file))

# If we have bins to run abicompat with
{% if package.bins %}{% for binary in package.bins %}
bin1 = os.path.join(path, "{{ binary }}")

# We can only run abicompat if it exists
if os.path.exists(bin1):

out_file = "/results/{{ tester.name }}/{{ tester.version }}/{{ package.name }}/compat/%s-%s" % (spec_version, spec2_version)
create_outdir(out_file)

# Important! This requires debug sumbols, so we allow to fail since most don't have
run("time -p abicompat %s %s %s > %s > %s.log" % (bin1, lib, lib2, out_file, out_file))
{% endfor %}{% endif %}
{% endfor %}
# Important! This requires debug sumbols, so we allow to fail since most don't have
run("time -p abicompat %s %s %s > %s > %s.log" % (bin1, lib, lib2, out_file, out_file))
{% endfor %}{% endif %}


if __name__ == "__main__":
Expand Down
33 changes: 33 additions & 0 deletions tests/python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package:
name: python
versions:
- "2.7.8"
- "2.7.9"
- "3.9.0"
- "3.8.0"
- "3.7.0"
- "3.6.0"
- "3.5.0"

# Extra commands to run to compile examples.
# Assumes package bin on the path, relative paths to install directory
# We want to be able to compare differently named libpython libraries
# run:
# - cp lib/libpython3.so lib/libpython.so || echo "libpython3 is not present."
# - cp lib/libpython2.so lib/libpython.so || echo "libpython2 is not present."

# Binaries to run tests with across versions (relative to install directory)
# bins:
# - share/openmpi/src/examples/ring_c

headers:
- include

# TODO make a libs regex, should be used to dynamically figure out libs
libregex:
- lib/libpython*.so

test:
# Always use the build cache instead of prebuilt container?
build_cache: false

0 comments on commit 8296e80

Please sign in to comment.