1 /*
2 *
3 * Copyright 2015 gRPC authors.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 #include <stdio.h>
20 #include <string.h>
21
22 #include <grpc/support/alloc.h>
23 #include <grpc/support/log.h>
24
25 #include "src/core/lib/gpr/env.h"
26 #include "src/core/lib/gpr/string.h"
27 #include "test/core/util/test_config.h"
28
29 #define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x)
30
test_setenv_getenv(void)31 static void test_setenv_getenv(void) {
32 const char* name = "FOO";
33 const char* value = "BAR";
34 char* retrieved_value;
35
36 LOG_TEST_NAME("test_setenv_getenv");
37
38 gpr_setenv(name, value);
39 retrieved_value = gpr_getenv(name);
40 GPR_ASSERT(retrieved_value != nullptr);
41 GPR_ASSERT(strcmp(value, retrieved_value) == 0);
42 gpr_free(retrieved_value);
43 }
44
main(int argc,char ** argv)45 int main(int argc, char** argv) {
46 grpc_test_init(argc, argv);
47 test_setenv_getenv();
48 return 0;
49 }
50