Added chip revision constant
[AROS.git] / test / dos / setenv.c
blob02375172fbe8b089885b47fa17f9f033aa28282d
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <string.h>
7 #include <stdio.h>
8 #include <proto/dos.h>
10 static void testvalue(CONST_STRPTR var, STRPTR expval, ULONG explen, BOOL expnull, LONG cnt)
12 TEXT buffer[10];
13 LONG len;
14 struct LocalVar * lv;
16 if ((len = GetVar(var, buffer, sizeof(buffer), 0)) < 0)
17 printf("test %d ERROR getvar %d\n", (int)cnt, (int)len);
18 else
19 printf("test %d getvar '%s'\n", (int)cnt, buffer);
20 if ((lv = FindVar(var, 0)) == NULL)
21 printf("test %d ERROR findvar\n", (int)cnt);
22 else
23 printf("test %d findvar lv_Value=%p, lv_Len=%d\n", (int)cnt, lv->lv_Value, (int)lv->lv_Len);
24 if (lv->lv_Len != explen)
25 printf("test %d ERROR lv_Len, expected %d, found %d\n", (int)cnt, (int)explen, (int)lv->lv_Len);
26 if (expnull && lv->lv_Value != NULL)
27 printf("test %d ERROR lv_Value expected NULL, found %p\n", (int)cnt, lv->lv_Value);
29 if (!expnull && lv->lv_Value == NULL)
30 printf("test %d ERROR lv_Value expected not NULL, found %p\n", (int)cnt, lv->lv_Value);
33 int main(void)
35 CONST_STRPTR var="abc";
36 STRPTR val="cde";
37 LONG cnt = 1;
39 /* Behavior validated with OS3.x */
41 printf("test %d setvar '%s'\n", (int)cnt, val);
42 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
43 printf("error setvar\n");
44 testvalue(var, val, 3, FALSE, cnt++);
46 val="";
47 printf("test %d setvar '%s'\n", (int)cnt, val);
48 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
49 printf("error setvar\n");
50 testvalue(var, val, 0, TRUE, cnt++);
52 val="abcd";
53 printf("test %d setvar '%s'\n", (int)cnt, val);
54 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
55 printf("error setvar\n");
56 testvalue(var, val, 4, FALSE, cnt++);
58 val="";
59 printf("test %d setvar '%s'\n", (int)cnt, val);
60 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
61 printf("error setvar\n");
62 testvalue(var, val, 0, TRUE, cnt++);
64 val="";
65 printf("test %d setvar '%s'\n", (int)cnt, val);
66 if (SetVar(var, val, strlen(val), 0) == DOSFALSE)
67 printf("error setvar\n");
68 testvalue(var, val, 0, TRUE, cnt++);
70 return 0;