1 //
2 // Copyright 2019 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5
6 // system_utils_unittest_helper.cpp: Helper to the SystemUtils.RunApp unittest
7
8 #include "test_utils_unittest_helper.h"
9
10 #include "../src/tests/test_utils/runner/TestSuite.h"
11 #include "common/system_utils.h"
12
13 #include <string.h>
14
15 // This variable is also defined in angle_unittest_main.
16 bool gVerbose = false;
17
main(int argc,char ** argv)18 int main(int argc, char **argv)
19 {
20 bool runTestSuite = false;
21
22 for (int argIndex = 1; argIndex < argc; ++argIndex)
23 {
24 if (strcmp(argv[argIndex], kRunTestSuite) == 0)
25 {
26 runTestSuite = true;
27 }
28 }
29
30 if (runTestSuite)
31 {
32 angle::TestSuite testSuite(&argc, argv);
33 return testSuite.run();
34 }
35
36 if (argc != 3 || strcmp(argv[1], kRunAppTestArg1) != 0 || strcmp(argv[2], kRunAppTestArg2) != 0)
37 {
38 fprintf(stderr, "Expected command line:\n%s %s %s\n", argv[0], kRunAppTestArg1,
39 kRunAppTestArg2);
40 return EXIT_FAILURE;
41 }
42
43 std::string env = angle::GetEnvironmentVar(kRunAppTestEnvVarName);
44 if (env == "")
45 {
46 printf("%s", kRunAppTestStdout);
47 fflush(stdout);
48 fprintf(stderr, "%s", kRunAppTestStderr);
49 }
50 else
51 {
52 fprintf(stderr, "%s", env.c_str());
53 }
54
55 return EXIT_SUCCESS;
56 }
57