1 /* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
2
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15
16 // testing function from unnamed namespace
17 #include "tensorflow/lite/delegates/gpu/cl/cl_device.h"
18
19 #include <gmock/gmock.h>
20 #include <gtest/gtest.h>
21
22 namespace tflite {
23 namespace gpu {
24 namespace cl {
25
TEST(QualcommOpenClCompilerVersionParsing,Base)26 TEST(QualcommOpenClCompilerVersionParsing, Base) {
27 AdrenoInfo::OpenClCompilerVersion result;
28 ParseQualcommOpenClCompilerVersion("random text Compiler E031.79.53.41",
29 &result);
30 EXPECT_EQ(result.major, 79);
31 EXPECT_EQ(result.minor, 53);
32 EXPECT_EQ(result.patch, 41);
33 }
34
TEST(QualcommOpenClCompilerVersionParsing,WrongFormat0)35 TEST(QualcommOpenClCompilerVersionParsing, WrongFormat0) {
36 AdrenoInfo::OpenClCompilerVersion result;
37 ParseQualcommOpenClCompilerVersion("random text Assembler A337.79.53.41",
38 &result);
39 EXPECT_EQ(result.major, 0);
40 EXPECT_EQ(result.minor, 0);
41 EXPECT_EQ(result.patch, 0);
42 }
43
TEST(QualcommOpenClCompilerVersionParsing,WrongFormat1)44 TEST(QualcommOpenClCompilerVersionParsing, WrongFormat1) {
45 AdrenoInfo::OpenClCompilerVersion result;
46 ParseQualcommOpenClCompilerVersion("random text Compiler E031.79.53.4",
47 &result);
48 EXPECT_EQ(result.major, 0);
49 EXPECT_EQ(result.minor, 0);
50 EXPECT_EQ(result.patch, 0);
51 }
52
TEST(QualcommOpenClCompilerVersionParsing,WrongFormat2)53 TEST(QualcommOpenClCompilerVersionParsing, WrongFormat2) {
54 AdrenoInfo::OpenClCompilerVersion result;
55 ParseQualcommOpenClCompilerVersion("random text Compiler E031:79:53:41",
56 &result);
57 EXPECT_EQ(result.major, 0);
58 EXPECT_EQ(result.minor, 0);
59 EXPECT_EQ(result.patch, 0);
60 }
61
TEST(QualcommOpenClCompilerVersionParsing,WrongFormat3)62 TEST(QualcommOpenClCompilerVersionParsing, WrongFormat3) {
63 AdrenoInfo::OpenClCompilerVersion result;
64 ParseQualcommOpenClCompilerVersion("random text Compiler E031.79.x53.41",
65 &result);
66 EXPECT_EQ(result.major, 0);
67 EXPECT_EQ(result.minor, 0);
68 EXPECT_EQ(result.patch, 0);
69 }
70
TEST(QualcommOpenClCompilerVersionParsing,WrongFormat4)71 TEST(QualcommOpenClCompilerVersionParsing, WrongFormat4) {
72 AdrenoInfo::OpenClCompilerVersion result;
73 ParseQualcommOpenClCompilerVersion("random text Compiler E031.a9.53.41",
74 &result);
75 EXPECT_EQ(result.major, 0);
76 EXPECT_EQ(result.minor, 0);
77 EXPECT_EQ(result.patch, 0);
78 }
79
80 } // namespace cl
81 } // namespace gpu
82 } // namespace tflite
83