~mirabilos/klibc/master

« back to all changes in this revision

Viewing changes to usr/klibc/tests/setenvtest.c

  • Committer: H. Peter Anvin
  • Date: 2006-05-01 00:56:02 UTC
  • Revision ID: git-v1:5dea5e01daaaff0685016f23b5cb46240f28e792
[klibc] Reorganize the standalone klibc tree to match the in-kernel tree

Right now, it's harder than it should to apply and test patches using
the standalone klibc tree.  Reorganize the standalone tree to match
the in-kernel tree.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <stdio.h>
 
3
#include <unistd.h>
 
4
 
 
5
int main(int argc, char *argv[])
 
6
{
 
7
  (void)argc; (void)argv;
 
8
 
 
9
  /* Set SETENV */
 
10
  setenv("SETENV", "setenv", 1);
 
11
 
 
12
  /* Set PUTENV */
 
13
  putenv("PUTENV=putenv");
 
14
 
 
15
  /* Print the results... */
 
16
  printf("SETENV = %s\n", getenv("SETENV"));
 
17
  printf("PUTENV = %s\n", getenv("PUTENV"));
 
18
 
 
19
  /* Override tests */
 
20
  setenv("SETENV", "setenv_good", 1);
 
21
  putenv("PUTENV=putenv_good");
 
22
  printf("SETENV = %s\n", getenv("SETENV"));
 
23
  printf("PUTENV = %s\n", getenv("PUTENV"));
 
24
 
 
25
  /* Non-override test */
 
26
  setenv("SETENV", "setenv_bad", 0);
 
27
  setenv("NEWENV", "newenv_good", 0);
 
28
  printf("SETENV = %s\n", getenv("SETENV"));
 
29
  printf("NEWENV = %s\n", getenv("NEWENV"));
 
30
 
 
31
  /* Undef test */
 
32
  unsetenv("SETENV");
 
33
  unsetenv("NEWENV");
 
34
  printf("SETENV = %s\n", getenv("SETENV"));
 
35
  printf("NEWENV = %s\n", getenv("NEWENV"));
 
36
 
 
37
  return 0;
 
38
}