[SCCP] Avoid modifying AdditionalUsers while iterating over it
[llvm-project.git] / libc / test / loader / linux / args_test.cpp
blob47bdbba542cf2de5a2155c511c5710cc382c2300
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 //===----------------------------------------------------------------------===//
9 #undef NDEBUG
10 #include "src/assert/assert.h"
12 static bool my_streq(const char *lhs, const char *rhs) {
13 const char *l, *r;
14 for (l = lhs, r = rhs; *l != '\0' && *r != '\0'; ++l, ++r)
15 if (*l != *r)
16 return false;
18 return *l == '\0' && *r == '\0';
21 int main(int argc, char **argv, char **envp) {
22 assert(argc == 4 && "Unexpected argc.");
23 assert(my_streq(argv[1], "1") && "Unexpected argv[1].");
24 assert(my_streq(argv[2], "2") && "Unexpected argv[2].");
25 assert(my_streq(argv[3], "3") && "Unexpected argv[3].");
27 bool found_france = false;
28 bool found_germany = false;
29 for (; *envp != nullptr; ++envp) {
30 if (my_streq(*envp, "FRANCE=Paris"))
31 found_france = true;
32 if (my_streq(*envp, "GERMANY=Berlin"))
33 found_germany = true;
36 assert(found_france && found_germany &&
37 "Did not find whats expected in envp.");
39 return 0;