Skip to content

Commit

Permalink
KVM: move get_baremetal_dir in common library
Browse files Browse the repository at this point in the history
Signed-off-by: Xudong Hao <[email protected]>
  • Loading branch information
xhao22 committed Sep 5, 2024
1 parent 3fdf349 commit e805f33
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 17 deletions.
27 changes: 27 additions & 0 deletions KVM/qemu/provider/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python3

# SPDX-License-Identifier: GPL-2.0-only
# Copyright (c) 2024 Intel Corporation

# Author: Xudong Hao <[email protected]>
#
# History: Sept. 2024 - Xudong Hao - creation

import os
from virttest import data_dir, asset


def get_baremetal_dir(params):
"""
Get the test provider's BM absolute path.
:param params: Dictionary with the test parameters
"""
provider = params["provider"]
provider_info = asset.get_test_provider_info(provider)
if provider_info["uri"].startswith("file://"):
provider_dir = provider_info["uri"][7:]
else:
provider_dir = data_dir.get_test_provider_dir(provider)
baremetal_dir = os.path.join(provider_dir, "BM")

return baremetal_dir
18 changes: 1 addition & 17 deletions KVM/qemu/tests/x86_cpuid.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,15 @@
from avocado.utils import process
from avocado.core import exceptions
from virttest import error_context, env_process
from virttest import data_dir, asset
from virttest import utils_package
from provider.test_utils import get_baremetal_dir

curr_dir = os.path.dirname(os.path.abspath(__file__))
check_dir = "%s/../../../BM/instruction-check" % curr_dir
sys.path.append(check_dir)
from feature_list import cpuid_info


def get_baremetal_dir(params):
"""
Get the test provider's BM absolute path.
:param params: Dictionary with the test parameters
"""
provider = params["provider"]
provider_info = asset.get_test_provider_info(provider)
if provider_info["uri"].startswith("file://"):
provider_dir = provider_info["uri"][7:]
else:
provider_dir = data_dir.get_test_provider_dir(provider)
baremetal_dir = os.path.join(provider_dir, "BM")

return baremetal_dir


def prepare_cpuid(test, params, src_dir, vm=None, session=None):
"""
Compile cpuid test tool in host or guest.
Expand Down

0 comments on commit e805f33

Please sign in to comment.