Skip to content

Commit

Permalink
Added a CI test for installed libraries when using CMake.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamshapiro0 committed Aug 18, 2023
1 parent f4dd57a commit 42f882f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@ jobs:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_cpp
- name: Run Unit Tests With Installed Libraries (CMake, Linux)
if: matrix.arch == 'x64' && matrix.tool == 'cmake' && matrix.os == 'ubuntu-latest'
env:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_cpp --installed
# Package artifacts (Bazel only -- no need to do this for multiple build
# tools).
Expand Down Expand Up @@ -272,6 +278,12 @@ jobs:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_c_
- name: Run Unit Tests With Installed Libraries (CMake, Linux)
if: matrix.arch == 'x64'
env:
POLARIS_API_KEY: ${{ secrets.POLARIS_API_KEY }}
run: |
./test/run_unit_tests.sh --tool=${{ matrix.tool }} --unique-id-prefix=${{ matrix.tool }}_c_ --installed
# Package artifacts (Bazel only -- no need to do this for multiple build
# tools).
Expand Down
18 changes: 17 additions & 1 deletion c/test/application_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ def __init__(self, application_name, root_dir=None):
# Define and parse arguments.
self.parser = ArgumentParser(usage='%(prog)s [OPTIONS]...')

self.parser.add_argument(
'--installed', action='store_true',
help="Run the application using shared libraries installed on the system (CMake only).")
self.parser.add_argument(
'-p', '--path', metavar='PATH',
help="The path to the application to be run.")
Expand Down Expand Up @@ -84,6 +87,10 @@ def parse_args(self):
print('Error: Unsupported --tool value.')
sys.exit(self.ARGUMENT_ERROR)

if self.options.installed and not self.options.tool == 'cmake':
print('Error: Installed applications only supported for CMake.')
sys.exit(self.ARGUMENT_ERROR)

if self.options.unique_id_prefix is not None:
self.options.unique_id = self.options.unique_id_prefix + self.options.unique_id
if len(self.options.unique_id) > 36:
Expand Down Expand Up @@ -114,6 +121,15 @@ def run(self, return_result=False):
if command[i].endswith(api_key_standin):
command[i] = command[i].replace(api_key_standin, self.options.polaris_api_key)

# If running using installed libraries (CMake), set LD_LIBRARY_PATH to explicitly override the rpath compiled
# into the application. This assumes the application is running out of the build directory, not a copy installed
# on the system. When CMake compiles an application, it sets its rpath to refer to the .so file from the build
# directory. When it installs that application, it strips that rpath.
env = None
if self.options.tool == 'cmake' and self.options.installed:
env = os.environ.copy()
env['LD_LIBRARY_PATH'] = '/usr/local/lib'

# Run the command.
def ignore_signal(sig, frame):
signal.signal(sig, signal.SIG_DFL)
Expand All @@ -126,7 +142,7 @@ def preexec_function():
signal.signal(signal.SIGTERM, ignore_signal)

self.proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8',
preexec_fn=preexec_function)
preexec_fn=preexec_function, env=env)

# Capture SIGINT and SIGTERM and shutdown the application gracefully.
def request_shutdown(sig, frame):
Expand Down

0 comments on commit 42f882f

Please sign in to comment.