3
3
// See LICENSE.TXT
4
4
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5
5
6
- #include " fixtures.h"
6
+ #include < uur/ fixtures.h>
7
7
8
8
#include < cstring>
9
9
10
- struct urAdapterGetInfoTest : uur::runtime::urAdapterTest,
11
- ::testing::WithParamInterface<ur_adapter_info_t > {
12
-
13
- void SetUp () {
14
- UUR_RETURN_ON_FATAL_FAILURE (uur::runtime::urAdapterTest::SetUp ());
15
- adapter = adapters[0 ];
16
- }
17
-
18
- ur_adapter_handle_t adapter;
19
- };
20
-
21
- std::unordered_map<ur_adapter_info_t , size_t > adapter_info_size_map = {
22
- {UR_ADAPTER_INFO_BACKEND, sizeof (ur_adapter_backend_t )},
23
- {UR_ADAPTER_INFO_VERSION, sizeof (uint32_t )},
24
- {UR_ADAPTER_INFO_REFERENCE_COUNT, sizeof (uint32_t )},
25
- };
26
-
27
- INSTANTIATE_TEST_SUITE_P (
28
- urAdapterGetInfo, urAdapterGetInfoTest,
29
- ::testing::Values (UR_ADAPTER_INFO_BACKEND, UR_ADAPTER_INFO_VERSION,
30
- UR_ADAPTER_INFO_REFERENCE_COUNT),
31
- [](const ::testing::TestParamInfo<ur_adapter_info_t > &info) {
32
- std::stringstream ss;
33
- ss << info.param ;
34
- return ss.str ();
35
- });
36
-
37
- TEST_P (urAdapterGetInfoTest, Success) {
10
+ using urAdapterGetInfoTest = uur::urAdapterTest;
11
+
12
+ UUR_INSTANTIATE_ADAPTER_TEST_SUITE_P (urAdapterGetInfoTest);
13
+
14
+ TEST_P (urAdapterGetInfoTest, Backend) {
15
+ auto info_type = UR_ADAPTER_INFO_BACKEND;
38
16
size_t size = 0 ;
39
- ur_adapter_info_t info_type = GetParam ();
40
17
ASSERT_SUCCESS_OR_OPTIONAL_QUERY (
41
18
urAdapterGetInfo (adapter, info_type, 0 , nullptr , &size), info_type);
42
19
ASSERT_NE (size, 0 );
43
20
44
- if (const auto expected_size = adapter_info_size_map.find (info_type);
45
- expected_size != adapter_info_size_map.end ()) {
46
- ASSERT_EQ (expected_size->second , size);
47
- }
21
+ ASSERT_EQ (size, sizeof (ur_adapter_backend_t ));
48
22
49
23
std::vector<char > info_data (size);
50
24
ASSERT_SUCCESS (
51
25
urAdapterGetInfo (adapter, info_type, size, info_data.data (), nullptr ));
52
26
}
53
27
28
+ TEST_P (urAdapterGetInfoTest, ReferenceCount) {
29
+ auto info_type = UR_ADAPTER_INFO_REFERENCE_COUNT;
30
+ size_t size = 0 ;
31
+ ASSERT_SUCCESS_OR_OPTIONAL_QUERY (
32
+ urAdapterGetInfo (adapter, info_type, 0 , nullptr , &size), info_type);
33
+ ASSERT_EQ (size, sizeof (uint32_t ));
34
+
35
+ uint32_t reference_count = 0 ;
36
+ ASSERT_SUCCESS (
37
+ urAdapterGetInfo (adapter, info_type, size, &reference_count, nullptr ));
38
+ ASSERT_GE (reference_count, 0 );
39
+ }
40
+
54
41
TEST_P (urAdapterGetInfoTest, InvalidNullHandleAdapter) {
55
42
size_t size = 0 ;
56
- ASSERT_EQ_RESULT (UR_RESULT_ERROR_INVALID_NULL_HANDLE,
57
- urAdapterGetInfo (nullptr , GetParam (), 0 , nullptr , &size));
43
+ ASSERT_EQ_RESULT (
44
+ UR_RESULT_ERROR_INVALID_NULL_HANDLE,
45
+ urAdapterGetInfo (nullptr , UR_ADAPTER_INFO_BACKEND, 0 , nullptr , &size));
58
46
}
59
47
60
- TEST_F (urAdapterGetInfoTest, InvalidEnumerationAdapterInfoType) {
48
+ TEST_P (urAdapterGetInfoTest, InvalidEnumerationAdapterInfoType) {
61
49
size_t size = 0 ;
62
50
ASSERT_EQ_RESULT (UR_RESULT_ERROR_INVALID_ENUMERATION,
63
51
urAdapterGetInfo (adapter, UR_ADAPTER_INFO_FORCE_UINT32, 0 ,
64
52
nullptr , &size));
65
53
}
66
54
67
- TEST_F (urAdapterGetInfoTest, InvalidSizeZero) {
55
+ TEST_P (urAdapterGetInfoTest, InvalidSizeZero) {
68
56
ur_adapter_backend_t backend;
69
57
ASSERT_EQ_RESULT (urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND, 0 ,
70
58
&backend, nullptr ),
71
59
UR_RESULT_ERROR_INVALID_SIZE);
72
60
}
73
61
74
- TEST_F (urAdapterGetInfoTest, InvalidSizeSmall) {
62
+ TEST_P (urAdapterGetInfoTest, InvalidSizeSmall) {
75
63
ur_adapter_backend_t backend;
76
64
ASSERT_EQ_RESULT (urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND,
77
65
sizeof (backend) - 1 , &backend, nullptr ),
78
66
UR_RESULT_ERROR_INVALID_SIZE);
79
67
}
80
68
81
- TEST_F (urAdapterGetInfoTest, InvalidNullPointerPropValue) {
69
+ TEST_P (urAdapterGetInfoTest, InvalidNullPointerPropValue) {
82
70
ur_adapter_backend_t backend;
83
71
ASSERT_EQ_RESULT (urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND,
84
72
sizeof (backend), nullptr , nullptr ),
85
73
UR_RESULT_ERROR_INVALID_NULL_POINTER);
86
74
}
87
75
88
- TEST_F (urAdapterGetInfoTest, InvalidNullPointerPropSizeRet) {
76
+ TEST_P (urAdapterGetInfoTest, InvalidNullPointerPropSizeRet) {
89
77
ASSERT_EQ_RESULT (
90
78
urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND, 0 , nullptr , nullptr ),
91
79
UR_RESULT_ERROR_INVALID_NULL_POINTER);
92
80
}
93
81
94
- TEST_F (urAdapterGetInfoTest, ReferenceCountNotZero) {
82
+ TEST_P (urAdapterGetInfoTest, ReferenceCountNotZero) {
95
83
uint32_t referenceCount = 0 ;
96
84
97
85
ASSERT_SUCCESS (urAdapterGetInfo (adapter, UR_ADAPTER_INFO_REFERENCE_COUNT,
@@ -100,7 +88,7 @@ TEST_F(urAdapterGetInfoTest, ReferenceCountNotZero) {
100
88
ASSERT_GT (referenceCount, 0 );
101
89
}
102
90
103
- TEST_F (urAdapterGetInfoTest, ValidAdapterBackend) {
91
+ TEST_P (urAdapterGetInfoTest, ValidAdapterBackend) {
104
92
ur_adapter_backend_t backend;
105
93
ASSERT_SUCCESS (urAdapterGetInfo (adapter, UR_ADAPTER_INFO_BACKEND,
106
94
sizeof (backend), &backend, nullptr ));
0 commit comments