xref: /aosp_15_r20/external/llvm-libc/test/integration/startup/gpu/args_test.cpp (revision 71db0c75aadcf003ffe3238005f61d7618a3fead)
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 
my_streq(const char * lhs,const char * rhs)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 
TEST_MAIN(int argc,char ** argv,char ** envp)20 TEST_MAIN(int argc, char **argv, char **envp) {
21   ASSERT_TRUE(argc == 4);
22   ASSERT_TRUE(my_streq(argv[1], "1"));
23   ASSERT_TRUE(my_streq(argv[2], "2"));
24   ASSERT_TRUE(my_streq(argv[3], "3"));
25 
26   bool found_france = false;
27   bool found_germany = false;
28   for (; *envp != nullptr; ++envp) {
29     if (my_streq(*envp, "FRANCE=Paris"))
30       found_france = true;
31     if (my_streq(*envp, "GERMANY=Berlin"))
32       found_germany = true;
33   }
34 
35   ASSERT_TRUE(found_france && found_germany);
36 
37   return 0;
38 }
39