Skip to content

Commit

Permalink
Merge pull request avocado-framework-tests#2801 from nasastry/secvarc…
Browse files Browse the repository at this point in the history
…tl-fix

secvarctl-tests.py: Adjust to upstream changes
  • Loading branch information
PraveenPenguin authored Apr 23, 2024
2 parents ff89990 + 08b569a commit b0b4599
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions security/secvarctl-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os
from avocado import Test
from avocado.utils import archive, build
from avocado.utils import build, distro, git, process
from avocado.utils.software_manager.manager import SoftwareManager


Expand All @@ -31,38 +31,49 @@ def setUp(self):
Install the basic packages to support secvarctl
'''
# Check for basic utilities
self.distro_version = distro.detect()
smm = SoftwareManager()
deps = ['gcc', 'make', 'openssl-devel']
deps = ['gcc', 'make', 'cmake']
if self.distro_version.name in ['rhel', 'redhat']:
deps.extend(['openssl-devel'])
if self.distro_version.name in ['SuSE']:
deps.extend(['libopenssl-devel'])
for package in deps:
if not smm.check_installed(package) and not smm.install(package):
self.cancel('%s is needed for the test to be run' % package)
self.srcdir = ""
run_type = self.params.get('type', default='upstream')
if run_type == "upstream":
def_url = ("https://github.com/open-power/secvarctl/archive/"
"refs/heads/main.zip")
url = self.params.get('url', default=def_url)
tarball = self.fetch_asset(url, expire='7d')
archive.extract(tarball, self.workdir)
self.srcdir = os.path.join(self.workdir, 'secvarctl-main/test')
url = "https://github.com/open-power/secvarctl"
git.get_repo(url, destination_dir=self.workdir, submodule=True, branch="main")
self.srcdir = self.workdir
elif run_type == "distro":
self.srcdir = os.path.join(self.workdir, "secvarctl-distro")
if not os.path.exists(self.srcdir):
os.makedirs(self.srcdir)
self.srcdir = smm.get_source('secvarctl', self.srcdir)
if not self.srcdir:
self.fail("secvarctl source install failed.")
self.srcdir = os.path.join(self.srcdir, 'test')
os.chdir(self.srcdir)
self.build_dir = os.path.join(self.srcdir, "build")
os.mkdir(self.build_dir)
os.chdir(self.build_dir)
rc = process.system("cmake ../")
if rc:
self.cancel("secvarctl:'cmake' command failed, cancelling the test.")

def test(self):
'''
Running tests from secvarctl
'''
count = 0
output = build.run_make(self.srcdir, extra_args="OPENSSL=1",
output = build.run_make(self.build_dir,
process_kwargs={"ignore_status": True})
if output.exit_status:
self.fail("secvarctl 'make check' failed.")
self.cancel("secvarctl:'make' command failed, cancelling the test.")
output = build.run_make(self.srcdir, extra_args="check",
process_kwargs={"ignore_status": True})
if output.exit_status:
self.fail("secvarctl:'make check' command failed. Check the logs.")
for line in output.stdout_text.splitlines():
if 'FAIL:' in line and 'XFAIL:' not in line and \
'# FAIL:' not in line:
Expand Down

0 comments on commit b0b4599

Please sign in to comment.