Add missing JNIEXPORT and JNICALL to create*CTSActivity JNI calls
[platform/upstream/VK-GL-CTS.git] / external / openglcts / modules / runner / glcTestRunnerMain.cpp
1 /*-------------------------------------------------------------------------
2  * OpenGL Conformance Test Suite
3  * -----------------------------
4  *
5  * Copyright (c) 2016 Google Inc.
6  * Copyright (c) 2016 The Khronos Group Inc.
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */ /*!
21  * \file
22  * \brief CTS runner main().
23  */ /*-------------------------------------------------------------------*/
24
25 #include "deString.h"
26 #include "deUniquePtr.hpp"
27 #include "glcTestRunner.hpp"
28 #include "tcuPlatform.hpp"
29 #include "tcuResource.hpp"
30
31 #include <cstdio>
32
33 // See tcuMain.cpp
34 tcu::Platform* createPlatform(void);
35
36 struct CommandLine
37 {
38         CommandLine(void) : runType(glu::ApiType::es(2, 0)), flags(0)
39         {
40         }
41
42         glu::ApiType runType;
43         std::string  dstLogDir;
44         deUint32         flags;
45 };
46
47 static bool parseCommandLine(CommandLine& cmdLine, int argc, const char* const* argv)
48 {
49         for (int argNdx = 1; argNdx < argc; argNdx++)
50         {
51                 const char* arg = argv[argNdx];
52
53                 if (deStringBeginsWith(arg, "--type="))
54                 {
55                         static const struct
56                         {
57                                 const char*  name;
58                                 glu::ApiType runType;
59                         } runTypes[] = { { "es2", glu::ApiType::es(2, 0) },     { "es3", glu::ApiType::es(3, 0) },
60                                                          { "es31", glu::ApiType::es(3, 1) },   { "es32", glu::ApiType::es(3, 2) },
61                                                          { "gl30", glu::ApiType::core(3, 0) }, { "gl31", glu::ApiType::core(3, 1) },
62                                                          { "gl32", glu::ApiType::core(3, 2) }, { "gl33", glu::ApiType::core(3, 3) },
63                                                          { "gl40", glu::ApiType::core(4, 0) }, { "gl41", glu::ApiType::core(4, 1) },
64                                                          { "gl42", glu::ApiType::core(4, 2) }, { "gl43", glu::ApiType::core(4, 3) },
65                                                          { "gl44", glu::ApiType::core(4, 4) }, { "gl45", glu::ApiType::core(4, 5) },
66                                                          { "gl46", glu::ApiType::core(4, 6) } };
67
68                         const char* value = arg + 7;
69                         int                     ndx   = 0;
70
71                         for (; ndx < DE_LENGTH_OF_ARRAY(runTypes); ndx++)
72                         {
73                                 if (deStringEqual(runTypes[ndx].name, value))
74                                 {
75                                         cmdLine.runType = runTypes[ndx].runType;
76                                         break;
77                                 }
78                         }
79
80                         if (ndx >= DE_LENGTH_OF_ARRAY(runTypes))
81                                 return false;
82                 }
83                 else if (deStringBeginsWith(arg, "--logdir="))
84                 {
85                         const char* value = arg + 9;
86                         cmdLine.dstLogDir = value;
87                 }
88                 else if (deStringBeginsWith(arg, "--summary"))
89                 {
90                         cmdLine.flags = glcts::TestRunner::PRINT_SUMMARY;
91                 }
92                 else if (deStringEqual(arg, "--verbose"))
93                         cmdLine.flags = glcts::TestRunner::VERBOSE_ALL;
94                 else
95                         return false;
96         }
97
98         return true;
99 }
100
101 static void printHelp(const char* binName)
102 {
103         printf("%s:\n", binName);
104         printf("  --type=[esN[M]|glNM] Conformance test run type. Choose from\n");
105         printf("                       ES: es2, es3, es31, es32\n");
106         printf("                       GL: gl30, gl31, gl32, gl33, gl40, gl41, gl42, gl43, gl44, gl45, gl46\n");
107         printf("  --logdir=[path]      Destination directory for log files\n");
108         printf("  --summary            Print summary without running the tests\n");
109         printf("  --verbose            Print out and log more information\n");
110 }
111
112 int main(int argc, char** argv)
113 {
114         CommandLine cmdLine;
115
116         if (!parseCommandLine(cmdLine, argc, argv))
117         {
118                 printHelp(argv[0]);
119                 return -1;
120         }
121
122         try
123         {
124                 de::UniquePtr<tcu::Platform> platform(createPlatform());
125                 tcu::DirArchive                          archive(".");
126                 glcts::TestRunner runner(static_cast<tcu::Platform&>(*platform.get()), archive, cmdLine.dstLogDir.c_str(),
127                                                                  cmdLine.runType, cmdLine.flags);
128
129                 for (;;)
130                 {
131                         if (!runner.iterate())
132                                 break;
133                 }
134         }
135         catch (const std::exception& e)
136         {
137                 printf("ERROR: %s\n", e.what());
138                 return -1;
139         }
140
141         return 0;
142 }