1 | //===-- Loader test to check args to main ---------------------------------===// |
2 | // |
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 |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #include "test/IntegrationTest/test.h" |
10 | |
11 | static bool my_streq(const char *lhs, const char *rhs) { |
12 | const char *l, *r; |
13 | for (l = lhs, r = rhs; *l != '\0' && *r != '\0'; ++l, ++r) |
14 | if (*l != *r) |
15 | return false; |
16 | |
17 | return *l == '\0' && *r == '\0'; |
18 | } |
19 | |
20 | TEST_MAIN(int argc, char **argv, char **envp) { |
21 | ASSERT_TRUE(argc == 4); |
22 | ASSERT_TRUE(my_streq(lhs: argv[1], rhs: "1" )); |
23 | ASSERT_TRUE(my_streq(lhs: argv[2], rhs: "2" )); |
24 | ASSERT_TRUE(my_streq(lhs: argv[3], rhs: "3" )); |
25 | |
26 | bool found_france = false; |
27 | bool found_germany = false; |
28 | for (; *envp != nullptr; ++envp) { |
29 | if (my_streq(lhs: *envp, rhs: "FRANCE=Paris" )) |
30 | found_france = true; |
31 | if (my_streq(lhs: *envp, rhs: "GERMANY=Berlin" )) |
32 | found_germany = true; |
33 | } |
34 | |
35 | ASSERT_TRUE(found_france && found_germany); |
36 | |
37 | return 0; |
38 | } |
39 | |