Fix the compare_image_2d_and_1d_array test case bug
[contrib/beignet.git] / benchmark / benchmark_run.cpp
1 /*
2  * Copyright © 2012 Intel Corporation
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  *
17  * Author: Benjamin Segovia <benjamin.segovia@intel.com>
18  */
19
20 /**
21  * \file utest_run.cpp
22  * \author Benjamin Segovia <benjamin.segovia@intel.com>
23  *
24  * Just run the unit tests. The user can possibly provides the subset of it
25  */
26 #include "utest_helper.hpp"
27 #include "utest_exception.hpp"
28 #include <iostream>
29 #include <getopt.h>
30
31 static const char *shortopts = "c:lanh";
32 struct option longopts[] = {
33 {"casename", required_argument, NULL, 'c'},
34 {"list", no_argument, NULL, 'l'},
35 {"all", no_argument, NULL, 'a'},
36 {"allnoissue", no_argument, NULL, 'n'},
37 {"help", no_argument, NULL, 'h'},
38 {0, 0, 0, 0},
39 };
40
41 void usage()
42 {
43     std::cout << "\
44 Usage:\n\
45   ./utest_run <option>\n\
46 \n\
47   option:\n\
48     -c <casename>: run sub-case named 'casename'\n\
49     -l           : list all the available case name\n\
50     -a           : run all test cases\n\
51     -n           : run all test cases without known issue (default option)\n\
52     -h           : display this usage\n\
53 \
54     "<< std::endl;
55 }
56
57 int main(int argc, char *argv[])
58 {
59
60   int c = 0;
61   cl_ocl_init();
62
63   c = getopt_long (argc, argv, shortopts, longopts, NULL);
64
65   if (argc == 1)
66     c = 'n';
67   if (argc == 2 && c < 1 ){
68     c = 'c';
69     optarg = argv[1];
70   }
71
72   do {
73     switch (c)
74     {
75       case 'c':
76         try {
77           UTest::run(optarg);
78         }
79         catch (Exception e){
80           std::cout << "  " << e.what() << "    [SUCCESS]" << std::endl;
81         }
82
83         break;
84
85       case 'l':
86         UTest::listAllCases();
87         break;
88
89       case 'a':
90         try {
91           UTest::runAll();
92         }
93         catch (Exception e){
94           std::cout << "  " << e.what() << "    [SUCCESS]" << std::endl;
95         }
96
97         break;
98
99       case 'n':
100         try {
101           UTest::runAllBenchMark();
102         }
103         catch (Exception e){
104           std::cout << "  " << e.what() << "    [SUCCESS]" << std::endl;
105         }
106
107         break;
108
109       case 'h':
110       default:
111         usage();
112         exit(1);
113     }
114   } while ((c = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1);
115
116   cl_ocl_destroy();
117 }