1617a3babSopenharmony_ci//
2617a3babSopenharmony_ci// Copyright (C) 2016 Google, Inc.
3617a3babSopenharmony_ci//
4617a3babSopenharmony_ci// All rights reserved.
5617a3babSopenharmony_ci//
6617a3babSopenharmony_ci// Redistribution and use in source and binary forms, with or without
7617a3babSopenharmony_ci// modification, are permitted provided that the following conditions
8617a3babSopenharmony_ci// are met:
9617a3babSopenharmony_ci//
10617a3babSopenharmony_ci//    Redistributions of source code must retain the above copyright
11617a3babSopenharmony_ci//    notice, this list of conditions and the following disclaimer.
12617a3babSopenharmony_ci//
13617a3babSopenharmony_ci//    Redistributions in binary form must reproduce the above
14617a3babSopenharmony_ci//    copyright notice, this list of conditions and the following
15617a3babSopenharmony_ci//    disclaimer in the documentation and/or other materials provided
16617a3babSopenharmony_ci//    with the distribution.
17617a3babSopenharmony_ci//
18617a3babSopenharmony_ci//    Neither the name of Google Inc. nor the names of its
19617a3babSopenharmony_ci//    contributors may be used to endorse or promote products derived
20617a3babSopenharmony_ci//    from this software without specific prior written permission.
21617a3babSopenharmony_ci//
22617a3babSopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23617a3babSopenharmony_ci// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24617a3babSopenharmony_ci// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25617a3babSopenharmony_ci// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26617a3babSopenharmony_ci// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27617a3babSopenharmony_ci// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28617a3babSopenharmony_ci// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29617a3babSopenharmony_ci// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30617a3babSopenharmony_ci// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31617a3babSopenharmony_ci// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32617a3babSopenharmony_ci// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33617a3babSopenharmony_ci// POSSIBILITY OF SUCH DAMAGE.
34617a3babSopenharmony_ci
35617a3babSopenharmony_ci#include <memory>
36617a3babSopenharmony_ci#include <string>
37617a3babSopenharmony_ci
38617a3babSopenharmony_ci#include <gtest/gtest.h>
39617a3babSopenharmony_ci
40617a3babSopenharmony_ci#include "Initializer.h"
41617a3babSopenharmony_ci#include "Settings.h"
42617a3babSopenharmony_ci
43617a3babSopenharmony_ciint main(int argc, char** argv)
44617a3babSopenharmony_ci{
45617a3babSopenharmony_ci    ::testing::InitGoogleTest(&argc, argv);
46617a3babSopenharmony_ci
47617a3babSopenharmony_ci    std::unique_ptr<glslangtest::GlslangInitializer> initializer(
48617a3babSopenharmony_ci        new glslangtest::GlslangInitializer);
49617a3babSopenharmony_ci
50617a3babSopenharmony_ci    glslangtest::GlobalTestSettings.initializer = initializer.get();
51617a3babSopenharmony_ci
52617a3babSopenharmony_ci    for (int i = 1; i < argc; ++i) {
53617a3babSopenharmony_ci        if (std::string("--update-mode") == argv[i]) {
54617a3babSopenharmony_ci            glslangtest::GlobalTestSettings.updateMode = true;
55617a3babSopenharmony_ci        }
56617a3babSopenharmony_ci        if (std::string("--test-root") == argv[i]) {
57617a3babSopenharmony_ci            // Allow the user set the test root directory.  This is useful
58617a3babSopenharmony_ci            // for testing with files from another source tree.
59617a3babSopenharmony_ci            if (i + 1 < argc) {
60617a3babSopenharmony_ci                glslangtest::GlobalTestSettings.testRoot = argv[i + 1];
61617a3babSopenharmony_ci                i++;
62617a3babSopenharmony_ci            } else {
63617a3babSopenharmony_ci                printf("error: --test-root requires an argument\n");
64617a3babSopenharmony_ci                return 1;
65617a3babSopenharmony_ci            }
66617a3babSopenharmony_ci        }
67617a3babSopenharmony_ci        if (std::string("--help") == argv[i]) {
68617a3babSopenharmony_ci            printf("\nExtra options:\n\n");
69617a3babSopenharmony_ci            printf("  --update-mode\n      Update the golden results for the tests.\n");
70617a3babSopenharmony_ci            printf("  --test-root <arg>\n      Specify the test root directory (useful for testing with\n      files from another source tree).\n");
71617a3babSopenharmony_ci        }
72617a3babSopenharmony_ci    }
73617a3babSopenharmony_ci
74617a3babSopenharmony_ci    const int result = RUN_ALL_TESTS();
75617a3babSopenharmony_ci
76617a3babSopenharmony_ci    glslangtest::GlobalTestSettings.initializer = nullptr;
77617a3babSopenharmony_ci
78617a3babSopenharmony_ci    return result;
79617a3babSopenharmony_ci}
80