Skip to content

Commit

Permalink
clang-format sysman test files (#132)
Browse files Browse the repository at this point in the history
Signed-off-by: B, Vishnu Khanth <[email protected]>
  • Loading branch information
vishnu-khanth authored Jan 7, 2025
1 parent b9ec3a9 commit 38ae470
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ int main(int argc, char **argv) {
exit(1);
}
LOG_INFO << "Child Process : Sysman initialized";
// We must retrieve the SysMan Drivers on the system, then verify that the driver has valid devices.
// The first driver with valid devices will be used.
// We must retrieve the SysMan Drivers on the system, then verify that the
// driver has valid devices. The first driver with valid devices will be used.
auto zes_drivers = lzt::get_all_zes_driver_handles();
zes_driver_handle_t zes_driver_used;
for (const auto &zes_driver : zes_drivers) {
Expand All @@ -107,7 +107,8 @@ int main(int argc, char **argv) {
break;
}
}
auto sysman_devices = lzt::get_zes_devices(lzt::get_zes_device_count(zes_driver_used), zes_driver_used);
auto sysman_devices = lzt::get_zes_devices(
lzt::get_zes_device_count(zes_driver_used), zes_driver_used);
EXPECT_FALSE(sysman_devices.empty());

std::vector<UUID> sysman_device_uuids{};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ TEST_F(
zes_power_sustained_limit_t pSustained = {};
zes_power_burst_limit_t pBurst = {};
zes_power_peak_limit_t pPeak = {};
auto status = lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak);
auto status =
lzt::get_power_limits(p_power_handle, &pSustained, &pBurst, &pPeak);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand Down Expand Up @@ -198,17 +199,17 @@ TEST_F(
zes_power_sustained_limit_t pSustainedInitial = {};
zes_power_burst_limit_t pBurstInitial = {};
zes_power_peak_limit_t pPeakInitial = {};
auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial,
&pPeakInitial);
auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial,
&pBurstInitial, &pPeakInitial);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
zes_power_sustained_limit_t pSustainedLater = {};
zes_power_burst_limit_t pBurstLater = {};
zes_power_peak_limit_t pPeakLater = {};
status = lzt::get_power_limits(p_power_handle, &pSustainedLater, &pBurstLater,
&pPeakLater);
status = lzt::get_power_limits(p_power_handle, &pSustainedLater,
&pBurstLater, &pPeakLater);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand Down Expand Up @@ -239,8 +240,9 @@ TEST_F(
zes_power_sustained_limit_t pSustainedInitial = {};
zes_power_burst_limit_t pBurstInitial = {};
zes_power_peak_limit_t pPeakInitial = {};
auto status = lzt::get_power_limits(p_power_handle, &pSustainedInitial, &pBurstInitial,
&pPeakInitial); // get default power values
auto status = lzt::get_power_limits(
p_power_handle, &pSustainedInitial, &pBurstInitial,
&pPeakInitial); // get default power values
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand Down Expand Up @@ -268,17 +270,19 @@ TEST_F(
}
pPeakSet.powerDC = pPeakInitial.powerDC;
if (pBurstSet.enabled && pSustainedSet.enabled) {
status = lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet,
&pPeakSet); // Set power values
status =
lzt::set_power_limits(p_power_handle, &pSustainedSet, &pBurstSet,
&pPeakSet); // Set power values
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
zes_power_sustained_limit_t pSustainedGet = {};
zes_power_burst_limit_t pBurstGet = {};
zes_power_peak_limit_t pPeakGet = {};
status = lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet,
&pPeakGet); // Get power values
status =
lzt::get_power_limits(p_power_handle, &pSustainedGet, &pBurstGet,
&pPeakGet); // Get power values
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand All @@ -296,8 +300,8 @@ TEST_F(
pPeakSet.powerDC); // Verify whether values match or not
}
status = lzt::set_power_limits(p_power_handle, &pSustainedInitial,
&pBurstInitial,
&pPeakInitial); // Set values to default
&pBurstInitial,
&pPeakInitial); // Set values to default
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand Down Expand Up @@ -352,7 +356,7 @@ TEST_F(
auto status =
lzt::get_power_energy_threshold(p_power_handle, &pThreshold);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
ASSERT_GE(pThreshold.threshold, 0);
Expand Down Expand Up @@ -420,8 +424,9 @@ TEST_F(
lzt::set_power_energy_threshold(p_power_handle, threshold); // set test
// value
zes_energy_threshold_t pThresholdGet = {};
status = lzt::get_power_energy_threshold(p_power_handle,
&pThresholdGet); // get test value
status =
lzt::get_power_energy_threshold(p_power_handle,
&pThresholdGet); // get test value
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand Down Expand Up @@ -565,7 +570,8 @@ TEST_F(
if (power_sustained_set.limitValueLocked == false) {
status = lzt::set_power_limits_ext(
p_power_handle, &count_power,
power_limits_descriptors.data()); // set power limits for all descriptors
power_limits_descriptors
.data()); // set power limits for all descriptors

if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
Expand All @@ -580,7 +586,7 @@ TEST_F(
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_get) {
if (p_power_limits_descriptor_get.level ==
ZES_POWER_LEVEL_SUSTAINED) {
Expand All @@ -593,9 +599,10 @@ TEST_F(
EXPECT_EQ(power_sustained_get.interval, power_sustained_set.interval);
EXPECT_EQ(power_sustained_get.limit, power_sustained_set.limit);

status = lzt::set_power_limits_ext(p_power_handle, &count_power,
power_limits_descriptors_initial
.data()); // restore initial limits
status =
lzt::set_power_limits_ext(p_power_handle, &count_power,
power_limits_descriptors_initial
.data()); // restore initial limits
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand Down Expand Up @@ -653,7 +660,8 @@ TEST_F(
if (power_peak_set.limitValueLocked == false) {
status = lzt::set_power_limits_ext(
p_power_handle, &count_power,
power_limits_descriptors.data()); // set power limits for all descriptors
power_limits_descriptors
.data()); // set power limits for all descriptors

if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
Expand All @@ -668,7 +676,7 @@ TEST_F(
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_get) {
if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK) {
power_peak_get = p_power_limits_descriptor_get;
Expand Down Expand Up @@ -711,7 +719,7 @@ TEST_F(

zes_power_limit_ext_desc_t power_burst_set = {};

std::vector<zes_power_limit_ext_desc_t> power_limits_descriptors;
std::vector<zes_power_limit_ext_desc_t> power_limits_descriptors;
auto status = lzt::get_power_limits_ext(
p_power_handle, &count_power,
power_limits_descriptors); // get power limits for all descriptors
Expand All @@ -737,7 +745,8 @@ TEST_F(
if (power_burst_set.limitValueLocked == false) {
status = lzt::set_power_limits_ext(
p_power_handle, &count_power,
power_limits_descriptors.data()); // set power limits for all descriptors
power_limits_descriptors
.data()); // set power limits for all descriptors

if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
Expand All @@ -752,7 +761,7 @@ TEST_F(
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_get) {
if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_BURST) {
power_burst_get = p_power_limits_descriptor_get;
Expand Down Expand Up @@ -823,7 +832,8 @@ TEST_F(
if (power_instantaneous_set.limitValueLocked == false) {
status = lzt::set_power_limits_ext(
p_power_handle, &count_power,
power_limits_descriptors.data()); // set power limits for all descriptors
power_limits_descriptors
.data()); // set power limits for all descriptors

if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
Expand All @@ -832,12 +842,13 @@ TEST_F(
zes_power_limit_ext_desc_t power_instantaneous_get = {};

std::vector<zes_power_limit_ext_desc_t> power_limits_descriptors_get;
status = lzt::get_power_limits_ext(p_power_handle, &count_power, power_limits_descriptors_get);
status = lzt::get_power_limits_ext(p_power_handle, &count_power,
power_limits_descriptors_get);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_get) {
if (p_power_limits_descriptor_get.level ==
ZES_POWER_LEVEL_INSTANTANEOUS) {
Expand Down Expand Up @@ -1012,27 +1023,28 @@ TEST_F(

if (power_sustained_Max.limitValueLocked == false) {
status = lzt::set_power_limits_ext(power_card_handle, &count_power,
&power_sustained_Max);
&power_sustained_Max);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
std::vector<zes_power_limit_ext_desc_t> power_limits_descriptors_getMax;
std::vector<zes_power_limit_ext_desc_t>
power_limits_descriptors_getMax;
status = lzt::get_power_limits_ext(power_card_handle, &count_power,
power_limits_descriptors_getMax);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_getMax) {
if (p_power_limits_descriptor_get.level ==
ZES_POWER_LEVEL_SUSTAINED) {
power_sustained_getMax = p_power_limits_descriptor_get;
}
}
status = lzt::set_power_limits_ext(power_card_handle, &count_power,
&power_sustained_Initial);
&power_sustained_Initial);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand All @@ -1044,7 +1056,7 @@ TEST_F(
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_get) {
if (p_power_limits_descriptor_get.level ==
ZES_POWER_LEVEL_SUSTAINED) {
Expand Down Expand Up @@ -1075,10 +1087,10 @@ TEST_F(
uint32_t count_power = 0;
uint32_t single_count = 1;
bool peak_limit_available = false;

std::vector<zes_power_limit_ext_desc_t> power_limits_descriptors;
auto status = lzt::get_power_limits_ext(power_card_handle, &count_power,
power_limits_descriptors);
power_limits_descriptors);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand All @@ -1098,7 +1110,7 @@ TEST_F(

if (power_limits_descriptors[i].limitValueLocked == false) {
status = lzt::set_power_limits_ext(power_card_handle, &single_count,
&power_peak_Max);
&power_peak_Max);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand All @@ -1111,15 +1123,15 @@ TEST_F(
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_getMax) {
if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK &&
p_power_limits_descriptor_get.source == power_source) {
power_peak_getMax = p_power_limits_descriptor_get;
}
}
status = lzt::set_power_limits_ext(power_card_handle, &single_count,
&power_peak_initial);
&power_peak_initial);
if (status == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
continue;
}
Expand All @@ -1131,7 +1143,7 @@ TEST_F(
continue;
}
EXPECT_EQ(status, ZE_RESULT_SUCCESS);
for (const auto& p_power_limits_descriptor_get :
for (const auto &p_power_limits_descriptor_get :
power_limits_descriptors_get) {
if (p_power_limits_descriptor_get.level == ZES_POWER_LEVEL_PEAK &&
p_power_limits_descriptor_get.source == power_source) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ std::vector<zes_freq_handle_t> get_freq_handles(zes_device_handle_t device,
zes_freq_state_t get_freq_state(zes_freq_handle_t pFreqHandle);
zes_freq_range_t get_freq_range(zes_freq_handle_t pFreqHandle);
void set_freq_range(zes_freq_handle_t pFreqHandle, zes_freq_range_t &pLimits);
void set_freq_range(zes_freq_handle_t pFreqHandle,
zes_freq_range_t &pLimits, ze_result_t &result);
void set_freq_range(zes_freq_handle_t pFreqHandle, zes_freq_range_t &pLimits,
ze_result_t &result);
zes_freq_properties_t get_freq_properties(zes_freq_handle_t pFreqHandle);
zes_freq_range_t get_and_validate_freq_range(zes_freq_handle_t pFreqHandle);
uint32_t get_available_clock_count(zes_freq_handle_t pFreqHandle);
Expand Down
17 changes: 9 additions & 8 deletions utils/test_harness/sysman/include/test_harness_sysman_power.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,24 @@ std::vector<zes_pwr_handle_t> get_power_handles(zes_device_handle_t device,
zes_pwr_handle_t get_card_power_handle(zes_device_handle_t device);
zes_power_properties_t get_power_properties(zes_pwr_handle_t pPowerhandle);
ze_result_t get_power_limits(zes_pwr_handle_t pPowerHandle,
zes_power_sustained_limit_t *pSustained,
zes_power_burst_limit_t *pBurst,
zes_power_peak_limit_t *pPeak);
zes_power_sustained_limit_t *pSustained,
zes_power_burst_limit_t *pBurst,
zes_power_peak_limit_t *pPeak);
ze_result_t set_power_limits(zes_pwr_handle_t pPowerHandle,
zes_power_sustained_limit_t *pSustained,
zes_power_burst_limit_t *pBurst,
zes_power_peak_limit_t *pPeak);
zes_power_sustained_limit_t *pSustained,
zes_power_burst_limit_t *pBurst,
zes_power_peak_limit_t *pPeak);
void get_power_energy_counter(zes_pwr_handle_t pPowerHandle,
zes_power_energy_counter_t *pEnergy);
ze_result_t get_power_energy_threshold(zes_pwr_handle_t pPowerHandle,
zes_energy_threshold_t *pThreshold);
void set_power_energy_threshold(zes_pwr_handle_t pPowerHandle,
double threshold);
ze_result_t get_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount,
ze_result_t get_power_limits_ext(
zes_pwr_handle_t hPower, uint32_t *pCount,
std::vector<zes_power_limit_ext_desc_t> &pPowerLimitsDescriptors);
ze_result_t set_power_limits_ext(zes_pwr_handle_t hPower, uint32_t *pCount,
zes_power_limit_ext_desc_t *pSustained);
zes_power_limit_ext_desc_t *pSustained);
void compare_power_descriptor_structures(
zes_power_limit_ext_desc_t firstDescriptor,
zes_power_limit_ext_desc_t secondDescriptor);
Expand Down
Loading

0 comments on commit 38ae470

Please sign in to comment.