Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csmock: fallback cov build 2023.6.1 #121

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions py/common/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with csmock. If not, see <http://www.gnu.org/licenses/>.

import re
import subprocess


def shell_quote(str_in):
Expand Down Expand Up @@ -121,3 +122,19 @@ def dirs_to_scan_by_args(parser, args, props, tool):
props.need_rpm_bi = True

return dirs_to_scan


def get_coverity_version(install_dir="/opt/coverity/"):
Fixed Show fixed Hide fixed
"""
Retrieve the version information from the coverity executable.

Returns:
string of the version information or None otherwise.
"""
executable_path = f"{install_dir}bin/coverity"
try:
version_info = subprocess.check_output([executable_path, "--version"])
version_text = version_info.decode("utf-8")
return version_text.strip().split()[0]
except (subprocess.CalledProcessError, FileNotFoundError):
return None
4 changes: 4 additions & 0 deletions py/csmock
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import time

# local imports
import csmock.common.util
from csmock.common.util import get_coverity_version
from csmock.common.util import shell_quote
from csmock.common.util import strlist_to_shell_cmd
from csmock.common.results import FatalError
Expand Down Expand Up @@ -516,6 +517,9 @@ class ScanProps:
return cmd_out

def wrap_shell_cmd_by_env(self, cmd_in, extra_env={}):
# cov-build needs extra env vars below when running under 2023.6.1.
if get_coverity_version() == "2023.6.1":
extra_env.update({"COVERITY_POSIX_SPAWN_FALLBACK": 1})
# merge self.env with extra_env
env = self.env.copy()
env.update(extra_env)
Expand Down