Skip to content

Commit f0ecb5a

Browse files
peppsaccharles-lunarg
authored andcommitted
Fix backward loop condition in tests
The loop will only be entered whe .size() returns 1. For all the other case, it'll be skipped as the i == 0 condition is false.
1 parent c5e7cf9 commit f0ecb5a

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

tests/loader_version_tests.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -994,20 +994,24 @@ void CheckDirectDriverLoading(FrameworkEnvironment& env, std::vector<DriverInfo>
994994
// We have to iterate through the driver lists backwards because the loader *prepends* icd's, so the last found ICD is found
995995
// first in the driver list
996996
uint32_t driver_index = 0;
997-
for (size_t i = normal_drivers.size() - 1; i == 0; i--) {
998-
if (normal_drivers.at(i).expect_to_find) {
999-
VkPhysicalDeviceProperties props{};
1000-
inst.functions->vkGetPhysicalDeviceProperties(phys_devs.at(driver_index), &props);
1001-
ASSERT_EQ(props.driverVersion, normal_drivers.at(i).driver_version);
1002-
driver_index++;
997+
if (!normal_drivers.empty()) {
998+
for (int i = normal_drivers.size() - 1; i >= 0; i--) {
999+
if (!exclusive && normal_drivers.at(i).expect_to_find) {
1000+
VkPhysicalDeviceProperties props{};
1001+
inst.functions->vkGetPhysicalDeviceProperties(phys_devs.at(driver_index), &props);
1002+
ASSERT_EQ(props.driverVersion, normal_drivers.at(i).driver_version);
1003+
driver_index++;
1004+
}
10031005
}
10041006
}
1005-
for (size_t i = direct_drivers.size() - 1; i == 0; i--) {
1006-
if (direct_drivers.at(i).expect_to_find) {
1007-
VkPhysicalDeviceProperties props{};
1008-
inst.functions->vkGetPhysicalDeviceProperties(phys_devs.at(driver_index), &props);
1009-
ASSERT_EQ(props.driverVersion, direct_drivers.at(i).driver_version);
1010-
driver_index++;
1007+
if (!direct_drivers.empty()) {
1008+
for (int i = direct_drivers.size() - 1; i >= 0; i--) {
1009+
if (direct_drivers.at(i).expect_to_find) {
1010+
VkPhysicalDeviceProperties props{};
1011+
inst.functions->vkGetPhysicalDeviceProperties(phys_devs.at(driver_index), &props);
1012+
ASSERT_EQ(props.driverVersion, direct_drivers.at(i).driver_version);
1013+
driver_index++;
1014+
}
10111015
}
10121016
}
10131017
}

0 commit comments

Comments
 (0)