Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Hanlde regression when there is no activator available/accessible (li…
Browse files Browse the repository at this point in the history
…ke with Controller SW)
  • Loading branch information
xlz-jbleclere committed Feb 14, 2022
1 parent bb424a5 commit 5bb672b
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ unsigned int DrmControllerRegistersStrategy_v7_0_0::readLicenseTimerLoadErrorReg
return DrmControllerRegistersStrategyInterface::readErrorRegister(mDrmLicenseTimerLoadErrorPosition, mDrmLicenseTimerLoadErrorMask, licenseTimerLoadError);
}

/** waitActivationErrorRegister
/** waitLicenseTimerLoadErrorRegister
* \brief Wait error to reach specified value.
* This method will access to the system bus to read the error register.
* \param[in] timeout is the timeout value in micro seconds.
Expand Down
7 changes: 4 additions & 3 deletions petalinux/setup_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ pip3 install wheel pyopencl pytest pytest-flask flake8

# Compile DRM library
#If drm folder is not already installed: git clone --recursive https://github.com/Accelize/drm.git -b kria
cd drm
#cd drm
mkdir build
cd build
cmake -DPYTHON3=ON -DTESTS=ON -DCMAKE_BUILD_TYPE=Debug ..
make
DRMLIB_BUILD=$(pwd)
cd ..

# Before executing the non-regression script
export XILINX_XRT=/usr

# To execute the non-regression script in C
python3 -m pytest --backend=c --cred=../../cred.json --server=dev --fpga_image=fpga-drm-hybrid-adder.som --drm_controller_base_address=0xA0010000 -ra tests
LD_LIBRARY_PATH=$DRMLIB_BUILD python3 -m pytest --backend=c --cred=../../cred.json --server=dev --fpga_image=fpga-drm-hybrid-adder.som --drm_controller_base_address=0xA0010000 -ra tests
# To execute the non-regression script in C++
python3 -m pytest --backend=c++ --cred=../../cred.json --server=dev --fpga_image=fpga-drm-hybrid-adder.som --drm_controller_base_address=0xA0010000 -ra tests
LD_LIBRARY_PATH=$DRMLIB_BUILD python3 -m pytest --backend=c++ --cred=../../cred.json --server=dev --fpga_image=fpga-drm-hybrid-adder.som --drm_controller_base_address=0xA0010000 -ra tests
2 changes: 1 addition & 1 deletion source/drm_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ class DRM_LOCAL DrmManager::Impl {
mFrequencyCurr = double(mFrequencyInit);
mBypassFrequencyDetection = JVgetOptional( conf_drm, "bypass_frequency_detection", Json::booleanValue,
mBypassFrequencyDetection ).asBool();
mIsHybrid = JVgetOptional( conf_drm, "drm_software", Json::booleanValue, false ).asBool();
mIsHybrid = JVgetOptional( conf_drm, "drm_software", Json::booleanValue, false ).asBool();
}

// Optionally, check derived product
Expand Down
24 changes: 12 additions & 12 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,10 @@ def scanActivatorsByCard(driver, base_addr):
break
base_addr_list.append(base_addr)
base_addr += 0x10000
# if len(base_addr_list) == 0:
# raise IOError('No activator found on slot #%d' % driver._fpga_slot_id)
activators = ActivatorsInFPGA(driver, base_addr_list)
if len(base_addr_list):
activators = ActivatorsInFPGA(driver, base_addr_list)
else:
activators = ActivatorsInFPGA(None, base_addr_list)
print('Found %d activator(s) on slot #%d' % (len(base_addr_list), driver._fpga_slot_id))
return activators

Expand All @@ -340,7 +341,7 @@ def autotest(self, is_activated=None):
"""
Verify IP works as expected
"""
if self.base_address is None:
if self.driver is None:
return
# Test IP mailbox depending on activation status
activated = self.get_status()
Expand Down Expand Up @@ -380,7 +381,7 @@ def generate_coin(self, coins=None):
Args:
coins (int): Number of coins to generate.
"""
if self.base_address is None:
if self.driver is None:
return 0
if coins is None:
coins = randint(1,10)
Expand All @@ -394,7 +395,7 @@ def reset_coin(self):
"""
Reset the coins counter
"""
if self.base_address is None:
if self.driver is None:
return
self.metering_data = 0
if self.event_cnt_flag:
Expand All @@ -408,7 +409,7 @@ def check_coin(self, coins=None):
Args:
coins (int): Number of coins to compare to.
"""
if self.base_address is None:
if self.driver is None:
return 0
# Read counter in Activation's registry
if self.event_cnt_flag:
Expand Down Expand Up @@ -443,8 +444,8 @@ class ActivatorsInFPGA:
"""
def __init__(self, driver, base_address_list):
self.activators = list()
if base_address_list is None:
self.activators.append(SingleActivator(driver, None))
if driver is None:
self.activators.append(SingleActivator(None, None))
else:
for addr in base_address_list:
self.activators.append(SingleActivator(driver, addr))
Expand Down Expand Up @@ -813,7 +814,7 @@ def __init__(self, tmpdir, url, **kwargs):
for k, v in kwargs.items():
if isinstance(v, dict):
content[k].update(v)
else:
else:
content[k] = v
filename = 'conf%f.json' % time()
_Json.__init__(self, tmpdir, filename, content)
Expand Down Expand Up @@ -938,7 +939,6 @@ def conf_json(request, pytestconfig, tmpdir):
design_param = {'boardType': hash_value}
# Build config content
log_param = {'log_verbosity': pytestconfig.getoption("loglevel")}
print('pytestconfig.getoption("logformat")=', pytestconfig.getoption("logformat"))
if pytestconfig.getoption("logformat") == 1:
log_param['log_format'] = LOG_FORMAT_LONG
else:
Expand Down Expand Up @@ -1390,7 +1390,7 @@ def log_file_factory(pytestconfig, request, accelize_drm):

# Determine log file format
log_file_format = LOG_FORMAT_LONG if pytestconfig.getoption("logfile") is not None else LOG_FORMAT_LONG

# Determine log file append mode
log_file_append = pytestconfig.getoption("logfileappend")

Expand Down
4 changes: 0 additions & 4 deletions tests/test_metered_mode_on_hw.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def test_fast_start_stop(accelize_drm, conf_json, cred_json, async_handler, log_
activators.autotest(is_activated=False)
assert sum(drm_manager.get('metered_data')) == 0
async_cb.assert_NoError()
drm_manager.deactivate()
logfile.remove()


Expand Down Expand Up @@ -85,7 +84,6 @@ def test_metered_start_stop_short_time(accelize_drm, conf_json, cred_json, async
activators.autotest(is_activated=False)
activators.check_coin()
async_cb.assert_NoError()
drm_manager.deactivate()
logfile.remove()


Expand Down Expand Up @@ -175,7 +173,6 @@ def test_metered_start_stop_long_time(accelize_drm, conf_json, cred_json, async_
assert not drm_manager.get('license_status')
activators.autotest(is_activated=False)
async_cb.assert_NoError()
drm_manager.deactivate()
logfile.remove()


Expand Down Expand Up @@ -249,7 +246,6 @@ def test_metered_pause_resume_long_time(accelize_drm, conf_json, cred_json, asyn
activators.autotest(is_activated=False)
assert drm_manager.get('session_id') != session_id
async_cb.assert_NoError()
drm_manager.deactivate()
logfile.remove()


Expand Down
9 changes: 3 additions & 6 deletions tests/test_cosimulation.py → tests/test_som_cosimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,10 @@ def test_hybrid_fast_start_stop(accelize_drm, conf_json, cred_json, async_handle
driver.write_register_callback,
async_cb.callback
) as drm_manager:
#assert not drm_manager.get('license_status')
#activators.autotest(is_activated=False)
assert not drm_manager.get('license_status')
drm_manager.activate()
drm_manager.deactivate()
#assert not drm_manager.get('license_status')
#activators.autotest(is_activated=False)
#assert sum(drm_manager.get('metered_data')) == 0
#async_cb.assert_NoError()
assert not drm_manager.get('license_status')
async_cb.assert_NoError()
logfile.remove()

0 comments on commit 5bb672b

Please sign in to comment.