1 //===-- main.cpp ------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
20 main(int argc
, char const *argv
[])
22 // The program writes its output to the following file:
24 // o "output1.txt" for test_pass_host_env_vars() test case
25 // o "output2.txt" for test_run_args_and_env_vars_with_dsym() test case
26 // o "output2.txt" for test_run_args_and_env_vars_with_dwarf() test case
27 std::ofstream outfile
;
29 outfile
.open("output1.txt");
31 outfile
.open("output2.txt");
33 for (unsigned i
= 0; i
< argc
; ++i
) {
34 std::string
theArg(argv
[i
]);
35 if (i
== 1 && "A" == theArg
)
36 outfile
<< "argv[1] matches\n";
38 if (i
== 2 && "B" == theArg
)
39 outfile
<< "argv[2] matches\n";
41 if (i
== 3 && "C" == theArg
)
42 outfile
<< "argv[3] matches\n";
45 // For passing environment vars from the debugger to the launched process.
46 if (::getenv("MY_ENV_VAR")) {
47 std::string
MY_ENV_VAR(getenv("MY_ENV_VAR"));
48 if ("YES" == MY_ENV_VAR
) {
49 outfile
<< "Environment variable 'MY_ENV_VAR' successfully passed.\n";
54 // For passing host environment vars to the launched process.
55 if (::getenv("MY_HOST_ENV_VAR1")) {
56 std::string
MY_HOST_ENV_VAR1(getenv("MY_HOST_ENV_VAR1"));
57 if ("VAR1" == MY_HOST_ENV_VAR1
) {
58 outfile
<< "The host environment variable 'MY_HOST_ENV_VAR1' successfully passed.\n";
62 if (::getenv("MY_HOST_ENV_VAR2")) {
63 std::string
MY_HOST_ENV_VAR2(getenv("MY_HOST_ENV_VAR2"));
64 if ("VAR2" == MY_HOST_ENV_VAR2
) {
65 outfile
<< "The host environment variable 'MY_HOST_ENV_VAR2' successfully passed.\n";
69 std::cerr
<< "This message should go to standard error.\n";
70 std::cout
<< "This message should go to standard out.\n";