2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Rlogging.c /main/3 1995/10/31 11:52:32 rswiston $ */
31 #define SAVELOG fclose(TermLog); TermLog = fopen("term.log", "a");
36 static char *LogAction[] = {
37 /*0*/ "Testing Resourse Option:logging True",
38 /*1*/ "Testing Resourse Option:logging True but in unwritable directory",
39 /*2*/ "Testing Resourse Option:logging True logFile Term.Log",
40 /*3*/ "Testing Resourse Option:logging False logFile Term.Log",
44 static char *ResourceArr[] = {
46 /*1*/ "logging True ",
47 /*2*/ "logging True logFile Term.Log",
48 /*3*/ "logging False logFile Term.Log",
51 int MakeResourceFile(ResArr)
56 char Resource[50], Value[50];
58 if ((ResFile = fopen("res", "w")) == NULL)
59 {LogError("Resource File Creation fail"); return(-1);}
60 for (i=0; i < 50; i++) Resource[i] = BLANK;
61 for (i=0; i < 50; i++) Value[i] = BLANK;
62 Len = strlen(ResArr); i=0;
65 while (ResArr[i] != BLANK) Resource[j++] = ResArr[i++];
66 Resource[j] = NULLCHAR;
68 while ((ResArr[i] != BLANK) && (ResArr[i] != NULLCHAR))
69 Value[j++] = ResArr[i++];
72 fprintf(ResFile, "%s*%s: %s\n", TERM_EMU, Resource, Value);
78 #define ArrCount (int) (sizeof(ResourceArr) / sizeof(char *))
85 char Command[NEED_LEN];
89 if ((TermLog = fopen("term.log", "a")) == NULL) {
90 if ((TermLog = fopen("term.log", "w")) == NULL)
91 {printf("Logfile could not be opened \n"); exit(-1);}
93 LogError("****************************************************************************");
95 sprintf(Command, "TestName: <%s> STARTS\n", argv[0]);
100 ExecCommand("mkdir tmplog");
101 for (i=0; i < ArrCount; i++) {
103 ExecCommand("xrdb -load xrdb.out");
104 MakeResourceFile(ResourceArr[i]);
106 ExecCommand("xrdb -merge res"); sleep(5);
108 ExecCommand("mv DTtermLog* tmplog"); sleep(1);
109 ExecCommand("mv Term.Log tmplog"); sleep(1);
110 if (i == 1) { /* try in un writable directory */
111 ExecCommand("mkdir unwrite"); sleep(1);
112 ExecCommand("chmod 555 unwrite"); sleep(1);
113 ExecCommand("cd unwrite"); sleep(1);
115 LogError(LogAction[i]);
116 strcpy(Command, TERM_EMU);
118 ExecCommand(Command); sleep(1);
119 if (WaitWinMap("TermWin") < 0) continue;
120 AssignWinName("TermWin", TERM_EMU);
122 WaitWinUnMap("TermWin", 10L);
125 ExecCommand("test-l"); break;
127 ExecCommand("test+l"); break;
129 ExecCommand("test-lf"); break;
130 case 3: ExecCommand("test+l"); break;
133 ExecCommand("cd ..");
134 ExecCommand("rmdir unwrite");
138 ExecCommand("mv tmplog/DTtermLog* ."); sleep(1);
139 ExecCommand("mv tmplog/Term.Log ."); sleep(1);
140 ExecCommand("rmdir tmplog");
142 ExecCommand("xrdb -load xrdb.out");
145 sprintf(Command, "TestName: <%s> ENDS\n", argv[0]);
147 LogError("****************************************************************************");