Wanderer/Info: fix compilation
[AROS.git] / test / library / peropenertest.c
blob9967fcf1db5fe9d174a883f6ff9fce5a909cc9ad
1 /*
2 Copyright © 2008-2009, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <proto/exec.h>
7 #include <proto/dos.h>
8 #include <proto/peropener.h>
9 #include <proto/pertask.h>
11 /* Block autopenening of PeropenerBase */
12 struct Library *PeropenerBase = NULL;
14 void testperopener_reg()
16 struct Library *base1, *base2;
18 FPuts(Output(), (STRPTR)"Testing peropener.library, reg calls\n");
20 base1=OpenLibrary((STRPTR)"peropener.library",0);
21 base2=OpenLibrary((STRPTR)"peropener.library",0);
23 /* Set value for base1 */
24 PeropenerBase = base1;
25 PeropenerSetValueReg(1);
27 /* Set value for base2 */
28 PeropenerBase = base2;
29 PeropenerSetValueReg(2);
31 /* Check value for base2 */
32 Printf((STRPTR)"Checking value for base2: 2 == %ld %s\n",
33 PeropenerGetValueReg(), (PeropenerGetValueReg() == 2) ? "OK" : "FAIL!"
36 /* Check value for base1 */
37 PeropenerBase = base1;
38 Printf((STRPTR)"Checking value for base1: 1 == %ld %s\n",
39 PeropenerGetValueReg(), (PeropenerGetValueReg() == 1) ? "OK" : "FAIL!"
40 );/* This FAILS because reg calls don't seem to set the libbase slot like stack calls do */
42 FPrintf(Output(), (STRPTR)"base1=%lx, base2=%lx\n", base1, base2);
44 if (base1 != NULL)
45 CloseLibrary(base1);
46 if (base2 != NULL)
47 CloseLibrary(base2);
50 void testperopener_stack()
52 struct Library *base1, *base2;
54 FPuts(Output(), (STRPTR)"Testing peropener.library, stack calls\n");
56 base1=OpenLibrary((STRPTR)"peropener.library",0);
57 base2=OpenLibrary((STRPTR)"peropener.library",0);
59 /* Set value for base1 */
60 PeropenerBase = base1;
61 PeropenerSetValueStack(1);
63 /* Check .unusedlibbase option with base1 */
64 if (PeropenerNoLib() != 1)
65 Printf("Error calling PeropenerNoLib()\n");
67 /* Set value for base2 */
68 PeropenerBase = base2;
69 PeropenerSetValueStack(2);
71 /* Check .function option with base2 */
72 if (PeropenerNameChange() != 1)
73 Printf("Error calling PeropenerNameChange()\n");
75 /* Check value for base2 */
76 Printf((STRPTR)"Checking value for base2: 2 == %ld %s\n",
77 PeropenerGetValueStack(), (PeropenerGetValueStack() == 2) ? "OK" : "FAIL!"
80 /* Check value for base1 */
81 PeropenerBase = base1;
82 Printf((STRPTR)"Checking value for base1: 1 == %ld %s\n",
83 PeropenerGetValueStack(), (PeropenerGetValueStack() == 1) ? "OK" : "FAIL!"
86 FPrintf(Output(), (STRPTR)"base1=%lx, base2=%lx\n", base1, base2);
88 if (base1 != NULL)
89 CloseLibrary(base1);
90 if (base2 != NULL)
91 CloseLibrary(base2);
95 int main (int argc, char ** argv)
97 struct Library *base1, *base2;
98 BPTR seglist;
100 testperopener_stack();
101 testperopener_reg();
103 FPuts(Output(), (STRPTR)"\nTesting pertask.library\n");
105 base1=OpenLibrary((STRPTR)"pertask.library",0);
106 base2=OpenLibrary((STRPTR)"pertask.library",0);
108 FPrintf(Output(), (STRPTR)"base1=%lx, base2=%lx\n", base1, base2);
110 seglist = LoadSeg((CONST_STRPTR)"peropenertest_child");
111 if (seglist != (BPTR)NULL)
113 SetProgramName("peropenertest_child");
114 RunCommand(seglist, 10*1024, "\n", 1);
115 UnLoadSeg(seglist);
117 else
119 FPrintf(Output(), (STRPTR)"Failed to load peropenertest_child\n");
122 if (base1 != NULL)
123 CloseLibrary(base1);
124 if (base2 != NULL)
125 CloseLibrary(base2);
127 Flush (Output ());
129 return 0;