1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 //  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 //  By downloading, copying, installing or using the software you agree to this license.
6 //  If you do not agree to this license, do not download, install,
7 //  copy or use the software.
8 //
9 //
10 //                           License Agreement
11 //                For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 //   * Redistribution's of source code must retain the above copyright notice,
21 //     this list of conditions and the following disclaimer.
22 //
23 //   * Redistribution's in binary form must reproduce the above copyright notice,
24 //     this list of conditions and the following disclaimer in the documentation
25 //     and/or other materials provided with the distribution.
26 //
27 //   * The name of the copyright holders may not be used to endorse or promote products
28 //     derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42 
43 #include "test_precomp.hpp"
44 
45 #ifdef HAVE_CUDA
46 
47 using namespace std;
48 using namespace cv;
49 using namespace cv::cuda;
50 using namespace cvtest;
51 using namespace testing;
52 
main(int argc,char ** argv)53 int main(int argc, char** argv)
54 {
55     try
56     {
57         const std::string keys =
58                 "{ h help ?            |      | Print help}"
59                 "{ i info              |      | Print information about system and exit }"
60                 "{ device              | -1   | Device on which tests will be executed (-1 means all devices) }"
61                 "{ nvtest_output_level | none | NVidia test verbosity level (none, compact, full) }"
62                 ;
63 
64         CommandLineParser cmd(argc, (const char**)argv, keys);
65 
66         if (cmd.has("help"))
67         {
68             cmd.printMessage();
69             return 0;
70         }
71 
72         printCudaInfo();
73 
74         if (cmd.has("info"))
75         {
76             return 0;
77         }
78 
79         int device = cmd.get<int>("device");
80         if (device < 0)
81         {
82             DeviceManager::instance().loadAll();
83 
84             cout << "Run tests on all supported devices \n" << endl;
85         }
86         else
87         {
88             DeviceManager::instance().load(device);
89 
90             DeviceInfo info(device);
91             cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
92         }
93 
94         string outputLevel = cmd.get<string>("nvtest_output_level");
95 
96         if (outputLevel == "none")
97             nvidiaTestOutputLevel = OutputLevelNone;
98         else if (outputLevel == "compact")
99             nvidiaTestOutputLevel = OutputLevelCompact;
100         else if (outputLevel == "full")
101             nvidiaTestOutputLevel = OutputLevelFull;
102 
103         TS::ptr()->init("gpu");
104         InitGoogleTest(&argc, argv);
105 
106         return RUN_ALL_TESTS();
107     }
108     catch (const exception& e)
109     {
110         cerr << e.what() << endl;
111         return -1;
112     }
113     catch (...)
114     {
115         cerr << "Unknown error" << endl;
116         return -1;
117     }
118 
119     return 0;
120 }
121 
122 #else // HAVE_CUDA
123 
main()124 int main()
125 {
126     printf("OpenCV was built without CUDA support\n");
127     return 0;
128 }
129 
130 #endif // HAVE_CUDA
131