SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

Diff markup

Differences between /userland/fstest.c (Article 9) and /userland/fstest.c (Article 8)


001 /* Copyright (C) 2005 David Decotigny             001 /* Copyright (C) 2005 David Decotigny
002                                                   002 
003    This program is free software; you can redi    003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU Genera    004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundatio    005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any lat    006    of the License, or (at your option) any later version.
007                                                   007    
008    This program is distributed in the hope tha    008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the     009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR    010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details    011    GNU General Public License for more details.
012                                                   012    
013    You should have received a copy of the GNU     013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to t    014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 3    015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA.                                           016    USA. 
017 */                                                017 */
018                                                   018 
019 #include <crt.h>                                  019 #include <crt.h>
020 #include <libc.h>                                 020 #include <libc.h>
021 #include <stdarg.h>                               021 #include <stdarg.h>
022 #include <string.h>                               022 #include <string.h>
023 #include <debug.h>                                023 #include <debug.h>
024                                                   024 
025 #include "fstest_utils.h"                         025 #include "fstest_utils.h"
026                                                   026 
027 #define OPEN_BASE_FD 3                         << 
028                                                << 
029 /**                                               027 /**
030  * @file fstest.c                                 028  * @file fstest.c
031  *                                                029  *
032  * File-system tests                              030  * File-system tests
033  */                                               031  */
034                                                   032 
035 int main()                                        033 int main()
036 {                                                 034 {
037   int fd, len;                                    035   int fd, len;
038   char buff[256];                                 036   char buff[256];
039                                                   037 
040   bochs_printf("Hi from fstest\n");               038   bochs_printf("Hi from fstest\n");
041                                                !! 039 
042   ls("/", 1, 1);                                  040   ls("/", 1, 1);
043   ls(".", 1, 1);                                  041   ls(".", 1, 1);
044   ls("", 1, 1);                                   042   ls("", 1, 1);
045   ls(0, 1, 1);                                    043   ls(0, 1, 1);
046                                                   044 
047   TEST_EXPECT_CONDITION(fd = open("", 0),         045   TEST_EXPECT_CONDITION(fd = open("", 0),
048                         RETVAL < 0);              046                         RETVAL < 0);
049                                                   047 
050   TEST_EXPECT_CONDITION(fd = open(0, 0),          048   TEST_EXPECT_CONDITION(fd = open(0, 0),
051                         RETVAL < 0);              049                         RETVAL < 0);
052                                                   050 
053   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR)    051   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR),
054                         RETVAL == OPEN_BASE_FD !! 052                         RETVAL == 0);
055                                                   053 
056   TEST_EXPECT_CONDITION(fd = open("/", O_RDONL    054   TEST_EXPECT_CONDITION(fd = open("/", O_RDONLY),
057                         RETVAL == OPEN_BASE_FD !! 055                         RETVAL == 1);
058                                                   056 
059   TEST_EXPECT_CONDITION(fd = open("/", O_WRONL    057   TEST_EXPECT_CONDITION(fd = open("/", O_WRONLY),
060                         RETVAL == OPEN_BASE_FD !! 058                         RETVAL == 2);
061                                                   059 
062   TEST_EXPECT_CONDITION(close(OPEN_BASE_FD + 1 !! 060   TEST_EXPECT_CONDITION(close(1),
063                         RETVAL == 0);             061                         RETVAL == 0);
064                                                   062   
065   TEST_EXPECT_CONDITION(fd = open("/", O_WRONL    063   TEST_EXPECT_CONDITION(fd = open("/", O_WRONLY),
066                         RETVAL == OPEN_BASE_FD !! 064                         RETVAL == 1);
067                                                   065 
068   TEST_EXPECT_CONDITION(fd = open("//", O_WRON    066   TEST_EXPECT_CONDITION(fd = open("//", O_WRONLY),
069                         RETVAL == OPEN_BASE_FD !! 067                         RETVAL == 3);
070                                                   068 
071   TEST_EXPECT_CONDITION(fd = open("////////",     069   TEST_EXPECT_CONDITION(fd = open("////////", O_WRONLY),
072                         RETVAL == OPEN_BASE_FD !! 070                         RETVAL == 4);
073                                                   071 
074   TEST_EXPECT_CONDITION(fd = open("/does not e    072   TEST_EXPECT_CONDITION(fd = open("/does not exist", O_WRONLY),
075                         RETVAL < 0);              073                         RETVAL < 0);
076                                                   074 
077   TEST_EXPECT_CONDITION(fd = open("////does no    075   TEST_EXPECT_CONDITION(fd = open("////does not exist", O_WRONLY),
078                         RETVAL < 0);              076                         RETVAL < 0);
079                                                   077 
080   TEST_EXPECT_CONDITION(fd = open("/does not e    078   TEST_EXPECT_CONDITION(fd = open("/does not exist/", O_WRONLY),
081                         RETVAL < 0);              079                         RETVAL < 0);
082                                                   080 
083   TEST_EXPECT_CONDITION(fd = open("////does no    081   TEST_EXPECT_CONDITION(fd = open("////does not exist/", O_WRONLY),
084                         RETVAL < 0);              082                         RETVAL < 0);
085                                                   083 
086   TEST_EXPECT_CONDITION(fd = open("/does not e    084   TEST_EXPECT_CONDITION(fd = open("/does not exist////", O_WRONLY),
087                         RETVAL < 0);              085                         RETVAL < 0);
088                                                   086 
089   TEST_EXPECT_CONDITION(fd = open("////does no    087   TEST_EXPECT_CONDITION(fd = open("////does not exist/////", O_WRONLY),
090                         RETVAL < 0);              088                         RETVAL < 0);
091                                                   089 
092   TEST_EXPECT_CONDITION(fd = open("does not ex    090   TEST_EXPECT_CONDITION(fd = open("does not exist", O_WRONLY),
093                         RETVAL < 0);              091                         RETVAL < 0);
094                                                   092 
095   TEST_EXPECT_CONDITION(fd = open("does not ex    093   TEST_EXPECT_CONDITION(fd = open("does not exist/", O_WRONLY),
096                         RETVAL < 0);              094                         RETVAL < 0);
097                                                   095 
098   TEST_EXPECT_CONDITION(fd = open("does not ex    096   TEST_EXPECT_CONDITION(fd = open("does not exist////", O_WRONLY),
099                         RETVAL);                  097                         RETVAL);
100                                                   098 
101   TEST_EXPECT_CONDITION(fd = open("/does not e    099   TEST_EXPECT_CONDITION(fd = open("/does not exist/ab c d", O_WRONLY),
102                         RETVAL < 0);              100                         RETVAL < 0);
103                                                   101 
104   TEST_EXPECT_CONDITION(fd = open("////does no    102   TEST_EXPECT_CONDITION(fd = open("////does not exist/ab c d", O_WRONLY),
105                         RETVAL < 0);              103                         RETVAL < 0);
106                                                   104 
107   TEST_EXPECT_CONDITION(fd = open("/does not e    105   TEST_EXPECT_CONDITION(fd = open("/does not exist////ab c d", O_WRONLY),
108                         RETVAL < 0);              106                         RETVAL < 0);
109                                                   107 
110   TEST_EXPECT_CONDITION(fd = open("////does no    108   TEST_EXPECT_CONDITION(fd = open("////does not exist/////ab c d", O_WRONLY),
111                         RETVAL < 0);              109                         RETVAL < 0);
112                                                   110 
113   TEST_EXPECT_CONDITION(fd = open("does not ex    111   TEST_EXPECT_CONDITION(fd = open("does not exist", O_WRONLY),
114                         RETVAL < 0);              112                         RETVAL < 0);
115                                                   113 
116   TEST_EXPECT_CONDITION(fd = open("does not ex    114   TEST_EXPECT_CONDITION(fd = open("does not exist/ab c d", O_WRONLY),
117                         RETVAL < 0);              115                         RETVAL < 0);
118                                                   116 
119   TEST_EXPECT_CONDITION(fd = open("does not ex    117   TEST_EXPECT_CONDITION(fd = open("does not exist////ab c d", O_WRONLY),
120                         RETVAL < 0);              118                         RETVAL < 0);
121                                                   119 
122   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR)    120   TEST_EXPECT_CONDITION(fd = open("/", O_RDWR),
123                         RETVAL == OPEN_BASE_FD !! 121                         RETVAL == 5);
124                                                   122 
125   TEST_EXPECT_CONDITION(fd = open("/tutu.txt",    123   TEST_EXPECT_CONDITION(fd = open("/tutu.txt", O_RDWR),
126                         RETVAL < 0);              124                         RETVAL < 0);
127                                                   125 
128   ls("/", 1, 1);                                  126   ls("/", 1, 1);
129                                                   127 
130   TEST_EXPECT_CONDITION(fd = open("/tutu.txt",    128   TEST_EXPECT_CONDITION(fd = open("/tutu.txt", O_RDWR | O_CREAT,
131                                   S_IRUSR | S_    129                                   S_IRUSR | S_IWUSR),
132                         RETVAL == OPEN_BASE_FD !! 130                         RETVAL == 6);
133                                                   131   
134   ls("/", 1, 1);                                  132   ls("/", 1, 1);
135                                                   133 
136   TEST_EXPECT_CONDITION(fd = open("tutu.txt",     134   TEST_EXPECT_CONDITION(fd = open("tutu.txt", O_RDWR | O_CREAT),
137                         RETVAL == OPEN_BASE_FD !! 135                         RETVAL == 7);
138                                                   136 
139   /* O_EXCL with an already-existing file */      137   /* O_EXCL with an already-existing file */
140   TEST_EXPECT_CONDITION(fd = open("tutu.txt",     138   TEST_EXPECT_CONDITION(fd = open("tutu.txt", O_RDWR | O_CREAT | O_EXCL),
141                         RETVAL < 0);              139                         RETVAL < 0);
142                                                   140 
143   TEST_EXPECT_CONDITION(fd = open("/toto.txt",    141   TEST_EXPECT_CONDITION(fd = open("/toto.txt", O_RDWR | O_CREAT | O_EXCL,
144                                   S_IRWXALL),     142                                   S_IRWXALL),
145                         RETVAL == OPEN_BASE_FD !! 143                         RETVAL == 8);
146                                                   144 
147   /* O_EXCL with an already-existing file */      145   /* O_EXCL with an already-existing file */
148   TEST_EXPECT_CONDITION(fd = open("toto.txt",     146   TEST_EXPECT_CONDITION(fd = open("toto.txt", O_RDWR | O_CREAT | O_EXCL),
149                         RETVAL < 0);              147                         RETVAL < 0);
150                                                   148 
151   TEST_EXPECT_CONDITION(fd = open("toto.txt",     149   TEST_EXPECT_CONDITION(fd = open("toto.txt", O_RDWR | O_CREAT,
152                                   S_IRUSR | S_    150                                   S_IRUSR | S_IWUSR),
153                         RETVAL == OPEN_BASE_FD !! 151                         RETVAL == 9);
154                                                   152 
155   /* Trailing slash on non-dir entries */         153   /* Trailing slash on non-dir entries */
156   TEST_EXPECT_CONDITION(fd = open("toto.txt/",    154   TEST_EXPECT_CONDITION(fd = open("toto.txt/", O_RDWR), RETVAL < 0);
157   TEST_EXPECT_CONDITION(fd = open("notdir/", O    155   TEST_EXPECT_CONDITION(fd = open("notdir/", O_RDWR | O_CREAT, S_IRWXALL),
158                         RETVAL < 0);              156                         RETVAL < 0);
159   TEST_EXPECT_CONDITION(fd = open("notdir/", O    157   TEST_EXPECT_CONDITION(fd = open("notdir/", O_RDWR), RETVAL < 0);
160                                                   158 
161   /* Substring match */                           159   /* Substring match */
162   TEST_EXPECT_CONDITION(fd = open("toto1.txt",    160   TEST_EXPECT_CONDITION(fd = open("toto1.txt", O_RDWR),
163                         RETVAL < 0);              161                         RETVAL < 0);
164   TEST_EXPECT_CONDITION(fd = open("toto1.tx",     162   TEST_EXPECT_CONDITION(fd = open("toto1.tx", O_RDWR | O_CREAT, S_IWUSR),
165                         RETVAL == OPEN_BASE_FD !! 163                         RETVAL == 10);
166                                                   164 
167   /* Substring match */                           165   /* Substring match */
168   TEST_EXPECT_CONDITION(fd = open("toto.tx", O    166   TEST_EXPECT_CONDITION(fd = open("toto.tx", O_RDWR),
169                         RETVAL < 0);              167                         RETVAL < 0);
170   TEST_EXPECT_CONDITION(fd = open("toto.tx", O    168   TEST_EXPECT_CONDITION(fd = open("toto.tx", O_RDWR | O_CREAT,
171                                   S_IRUSR | S_    169                                   S_IRUSR | S_IWUSR),
172                         RETVAL == OPEN_BASE_FD !! 170                         RETVAL == 11);
173                                                   171 
174   /*                                              172   /*
175    * read/write/seek                              173    * read/write/seek
176    */                                             174    */
177                                                   175 
178   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    176   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
179                         RETVAL == 0);             177                         RETVAL == 0);
180                                                   178 
181   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    179   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET),
182                         RETVAL == 0);             180                         RETVAL == 0);
183                                                   181 
184   strzcpy(buff, "Bonjour !", 256);                182   strzcpy(buff, "Bonjour !", 256);
185   TEST_EXPECT_CONDITION(len = write(fd, buff,     183   TEST_EXPECT_CONDITION(len = write(fd, buff, 10),
186                         RETVAL == 10);            184                         RETVAL == 10);
187                                                   185 
188   ls("/", 1, 1);                                  186   ls("/", 1, 1);
189                                                   187 
190   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    188   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET),
191                         RETVAL == 0);             189                         RETVAL == 0);
192                                                   190 
193   strzcpy(buff, "Garbage garbage garbage", 256    191   strzcpy(buff, "Garbage garbage garbage", 256);
194   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    192   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
195                         RETVAL == 10);            193                         RETVAL == 10);
196   bochs_printf("read s='%s'\n", buff);            194   bochs_printf("read s='%s'\n", buff);
197   TEST_EXPECT_CONDITION(strcmp("Bonjour !", bu    195   TEST_EXPECT_CONDITION(strcmp("Bonjour !", buff), RETVAL ==0);
198   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR)    196   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR), RETVAL == 10);
199                                                   197 
200   /*                                              198   /*
201    * truncate                                     199    * truncate
202    */                                             200    */
203                                                   201 
204   TEST_EXPECT_CONDITION(ftruncate(fd, 3), RETV    202   TEST_EXPECT_CONDITION(ftruncate(fd, 3), RETVAL == 0);
205                                                   203   
206   /* The current position should not have chan    204   /* The current position should not have changed */
207   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR)    205   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_CUR), RETVAL == 10);
208                                                   206 
209   /* Make sure we cannot read anything because    207   /* Make sure we cannot read anything because we get past the end of
210      the file */                                  208      the file */
211   strzcpy(buff, "Garbage garbage garbage", 256    209   strzcpy(buff, "Garbage garbage garbage", 256);
212   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    210   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
213                                                   211 
214   /* Now get back at the begining of the file     212   /* Now get back at the begining of the file */
215   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    213   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);
216                                                   214 
217   /* Make sure that we can read something with    215   /* Make sure that we can read something with the correct first 3
218      characters */                                216      characters */
219   strzcpy(buff, "Garbage garbage garbage", 256    217   strzcpy(buff, "Garbage garbage garbage", 256);
220   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    218   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 3);
221   bochs_printf("read s='%s'\n", buff);            219   bochs_printf("read s='%s'\n", buff);
222   TEST_EXPECT_CONDITION(strncmp("Bon", buff, l    220   TEST_EXPECT_CONDITION(strncmp("Bon", buff, len), RETVAL == 0);
223                                                   221 
224   /*                                              222   /*
225    * open mode                                    223    * open mode
226    */                                             224    */
227                                                   225 
228   ls("/", 1, 1);                                  226   ls("/", 1, 1);
229                                                   227 
230                                                   228 
231   /* Open r/w, create read-only */                229   /* Open r/w, create read-only */
232                                                   230 
233   TEST_EXPECT_CONDITION(fd = open("toto2.txt",    231   TEST_EXPECT_CONDITION(fd = open("toto2.txt", O_RDWR | O_CREAT, S_IRUSR),
234                         RETVAL == OPEN_BASE_FD !! 232                         RETVAL == 12);
235                                                   233 
236   strzcpy(buff, "Garbage garbage garbage", 256    234   strzcpy(buff, "Garbage garbage garbage", 256);
237   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    235   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
238                         RETVAL == 0);             236                         RETVAL == 0);
239                                                   237 
240   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    238   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);
241                                                   239 
242   strzcpy(buff, "Permission denied", 256);        240   strzcpy(buff, "Permission denied", 256);
243   TEST_EXPECT_CONDITION(len = write(fd, buff,     241   TEST_EXPECT_CONDITION(len = write(fd, buff, 10),
244                         RETVAL < 0); /* Permis    242                         RETVAL < 0); /* Permission denied ! */
245                                                   243 
246   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    244   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);
247                                                   245 
248   strzcpy(buff, "Garbage garbage garbage", 256    246   strzcpy(buff, "Garbage garbage garbage", 256);
249   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    247   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
250                                                   248 
251   /* Open read-only, create r/w */                249   /* Open read-only, create r/w */
252                                                   250 
253   TEST_EXPECT_CONDITION(fd = open("toto3.txt",    251   TEST_EXPECT_CONDITION(fd = open("toto3.txt", O_RDONLY | O_CREAT,
254                                   S_IRUSR | S_    252                                   S_IRUSR | S_IWUSR),
255                         RETVAL == OPEN_BASE_FD !! 253                         RETVAL == 13);
256                                                   254 
257   strzcpy(buff, "Garbage garbage garbage", 256    255   strzcpy(buff, "Garbage garbage garbage", 256);
258   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    256   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
259                                                   257 
260   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    258   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
261                                                   259 
262   strzcpy(buff, "Permission denied 2", 256);      260   strzcpy(buff, "Permission denied 2", 256);
263   TEST_EXPECT_CONDITION(len = write(fd, buff,     261   TEST_EXPECT_CONDITION(len = write(fd, buff, 10),
264                         RETVAL < 0); /* Permis    262                         RETVAL < 0); /* Permission denied ! */
265                                                   263 
266   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    264   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
267                                                   265 
268   strzcpy(buff, "Garbage garbage garbage", 256    266   strzcpy(buff, "Garbage garbage garbage", 256);
269   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    267   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
270                                                   268 
271   /* Create another process that chdirs in it     269   /* Create another process that chdirs in it */
272   if (fork() == 0)                                270   if (fork() == 0)
273     {                                             271     {
274       bochs_printf("Hello from child\n");         272       bochs_printf("Hello from child\n");
275       TEST_EXPECT_CONDITION(fd = open("shrd.tx    273       TEST_EXPECT_CONDITION(fd = open("shrd.txt", O_RDWR | O_CREAT, S_IRWXALL),
276                             RETVAL == OPEN_BAS !! 274                             RETVAL == 14);
277       strzcpy(buff, "Hello from child !", 256)    275       strzcpy(buff, "Hello from child !", 256);
278       TEST_EXPECT_CONDITION(len = write(fd, bu    276       TEST_EXPECT_CONDITION(len = write(fd, buff, 19),
279                             RETVAL == 19);        277                             RETVAL == 19);
280       TEST_EXPECT_CONDITION(close(fd), RETVAL     278       TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
281       bochs_printf("Bye from child\n");           279       bochs_printf("Bye from child\n");
282       return 0;                                   280       return 0;
283     }                                             281     }
284                                                   282 
285   bochs_printf("Father sleeping\n");              283   bochs_printf("Father sleeping\n");
286   nanosleep(1, 0);                                284   nanosleep(1, 0);
287   ls("/", 1, 1);                                  285   ls("/", 1, 1);
288   TEST_EXPECT_CONDITION(fd = open("shrd.txt",     286   TEST_EXPECT_CONDITION(fd = open("shrd.txt", O_RDONLY),
289                         RETVAL == OPEN_BASE_FD !! 287                         RETVAL == 14);
290   strzcpy(buff, "Garbage garbage garbage", 256    288   strzcpy(buff, "Garbage garbage garbage", 256);
291   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    289   TEST_EXPECT_CONDITION(len = read(fd, buff, 256),
292                         RETVAL == 19);            290                         RETVAL == 19);
293   bochs_printf("read s='%s'\n", buff);            291   bochs_printf("read s='%s'\n", buff);
294   TEST_EXPECT_CONDITION(strncmp("Hello from ch    292   TEST_EXPECT_CONDITION(strncmp("Hello from child !", buff, len),
295                         RETVAL == 0);             293                         RETVAL == 0);
296   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    294   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
297   TEST_EXPECT_CONDITION(unlink("shrd.txt"), RE    295   TEST_EXPECT_CONDITION(unlink("shrd.txt"), RETVAL == 0);
298   ls("/", 1, 1);                                  296   ls("/", 1, 1);
299                                                   297 
300   /*                                              298   /*
301    * ioctl / fcntl                                299    * ioctl / fcntl
302    */                                             300    */
303                                                   301 
304   TEST_EXPECT_CONDITION(fcntl(fd, 2, 3), RETVA    302   TEST_EXPECT_CONDITION(fcntl(fd, 2, 3), RETVAL < 0); /* Not supported
305                                                   303                                                          by virtfs */
306   TEST_EXPECT_CONDITION(ioctl(fd, 2, 3), RETVA << 
307                                                << 
308                                                   304 
309   ls("/", 1, 1);                                  305   ls("/", 1, 1);
310                                                   306 
311   /*                                              307   /*
312    * creat/link/unlink/symlink                    308    * creat/link/unlink/symlink
313    */                                             309    */
314   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    310   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IRUSR), RETVAL == 0);
315   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    311   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IRWXALL), RETVAL < 0); /*EEXIST*/
316   TEST_EXPECT_CONDITION(link("toto4.txt", "tot    312   TEST_EXPECT_CONDITION(link("toto4.txt", "toto5.txt"), RETVAL == 0);
317   TEST_EXPECT_CONDITION(link("toto4.txt", "tot    313   TEST_EXPECT_CONDITION(link("toto4.txt", "toto5.txt"), RETVAL < 0); /*EEXIST*/
318   TEST_EXPECT_CONDITION(link("toto4.txt", "tot    314   TEST_EXPECT_CONDITION(link("toto4.txt", "toto.txt"), RETVAL < 0); /*EEXIST*/
319   ls("/", 1, 1);                                  315   ls("/", 1, 1);
320   TEST_EXPECT_CONDITION(chmod("toto5.txt", S_I    316   TEST_EXPECT_CONDITION(chmod("toto5.txt", S_IRUSR | S_IWUSR), RETVAL == 0);
321   ls("/", 1, 1);                                  317   ls("/", 1, 1);
322                                                   318 
323   TEST_EXPECT_CONDITION(fd = open("toto5.txt", !! 319   TEST_EXPECT_CONDITION(fd = open("toto5.txt", O_RDWR), RETVAL == 14);
324                         RETVAL == OPEN_BASE_FD << 
325   strzcpy(buff, "Garbage garbage garbage", 256    320   strzcpy(buff, "Garbage garbage garbage", 256);
326   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    321   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
327                                                   322 
328   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    323   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
329                                                   324 
330   strzcpy(buff, "Hello world from toto5", 256)    325   strzcpy(buff, "Hello world from toto5", 256);
331   TEST_EXPECT_CONDITION(len = write(fd, buff,     326   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
332                                                   327 
333   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    328   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
334                                                   329 
335   strzcpy(buff, "Garbage garbage garbage", 256    330   strzcpy(buff, "Garbage garbage garbage", 256);
336   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    331   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
337   bochs_printf("read s='%s'\n", buff);            332   bochs_printf("read s='%s'\n", buff);
338                                                   333 
339   TEST_EXPECT_CONDITION(fd = open("toto4.txt", !! 334   TEST_EXPECT_CONDITION(fd = open("toto4.txt", O_RDWR), RETVAL == 15);
340                         RETVAL == OPEN_BASE_FD << 
341   strzcpy(buff, "Garbage garbage garbage", 256    335   strzcpy(buff, "Garbage garbage garbage", 256);
342   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    336   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
343   bochs_printf("read s='%s'\n", buff);            337   bochs_printf("read s='%s'\n", buff);
344                                                   338 
345   ls("/", 1, 1);                                  339   ls("/", 1, 1);
346                                                   340 
347   TEST_EXPECT_CONDITION(link("dangling", "toto    341   TEST_EXPECT_CONDITION(link("dangling", "toto42.txt"), RETVAL < 0); /*ENOENT*/
348   TEST_EXPECT_CONDITION(unlink("toto4.txt"), R    342   TEST_EXPECT_CONDITION(unlink("toto4.txt"), RETVAL == 0);
349   TEST_EXPECT_CONDITION(unlink("toto42.txt"),     343   TEST_EXPECT_CONDITION(unlink("toto42.txt"), RETVAL < 0); /* ENOENT */
350   TEST_EXPECT_CONDITION(unlink("toto4.txt"), R    344   TEST_EXPECT_CONDITION(unlink("toto4.txt"), RETVAL < 0); /* ENOENT */
351   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    345   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IWUSR | S_IRUSR), RETVAL == 0);
352   TEST_EXPECT_CONDITION(unlink("toto5.txt/"),     346   TEST_EXPECT_CONDITION(unlink("toto5.txt/"), RETVAL < 0); /* EISDIR ? */
353   TEST_EXPECT_CONDITION(rmdir("toto5.txt/"), R    347   TEST_EXPECT_CONDITION(rmdir("toto5.txt/"), RETVAL < 0); /* ENOTDIR ? */
354   TEST_EXPECT_CONDITION(rmdir("toto5.txt"), RE    348   TEST_EXPECT_CONDITION(rmdir("toto5.txt"), RETVAL < 0); /* ENOTDIR ? */
355   TEST_EXPECT_CONDITION(unlink("toto5.txt"), R    349   TEST_EXPECT_CONDITION(unlink("toto5.txt"), RETVAL == 0);
356   TEST_EXPECT_CONDITION(unlink("toto5.txt"), R    350   TEST_EXPECT_CONDITION(unlink("toto5.txt"), RETVAL < 0); /* ENOENT */
357   TEST_EXPECT_CONDITION(creat("toto4.txt", S_I    351   TEST_EXPECT_CONDITION(creat("toto4.txt", S_IRWXALL), RETVAL < 0); /*EEXIST*/
358                                                   352 
359   ls("/", 1, 1);                                  353   ls("/", 1, 1);
360                                                   354 
361   /* Change symlinks */                           355   /* Change symlinks */
362   TEST_EXPECT_CONDITION(symlink("toto4.txt", "    356   TEST_EXPECT_CONDITION(symlink("toto4.txt", "toto5.txt"), RETVAL == 0);
363   TEST_EXPECT_CONDITION(symlink("toto4.txt", "    357   TEST_EXPECT_CONDITION(symlink("toto4.txt", "toto5.txt"), RETVAL < 0); /*EEXIST*/
364   TEST_EXPECT_CONDITION(symlink("toto4.txt", "    358   TEST_EXPECT_CONDITION(symlink("toto4.txt", "toto.txt"), RETVAL < 0); /*EEXIST*/
365                                                   359 
366   ls("/", 1, 1);                                  360   ls("/", 1, 1);
367                                                   361 
368   TEST_EXPECT_CONDITION(fd = open("toto5.txt", !! 362   TEST_EXPECT_CONDITION(fd = open("toto5.txt", O_RDWR), RETVAL == 16);
369                         RETVAL == OPEN_BASE_FD << 
370   strzcpy(buff, "Garbage garbage garbage", 256    363   strzcpy(buff, "Garbage garbage garbage", 256);
371   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    364   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
372                                                   365 
373   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    366   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
374                                                   367 
375   strzcpy(buff, "Hello world from toto5", 256)    368   strzcpy(buff, "Hello world from toto5", 256);
376   TEST_EXPECT_CONDITION(len = write(fd, buff,     369   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
377                                                   370 
378   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    371   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
379                                                   372 
380   strzcpy(buff, "Garbage garbage garbage", 256    373   strzcpy(buff, "Garbage garbage garbage", 256);
381   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    374   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
382   bochs_printf("read s='%s'\n", buff);            375   bochs_printf("read s='%s'\n", buff);
383   TEST_EXPECT_CONDITION(strcmp(buff, "Hello wo    376   TEST_EXPECT_CONDITION(strcmp(buff, "Hello world from toto5"), RETVAL == 0);
384                                                   377 
385   TEST_EXPECT_CONDITION(fd = open("toto4.txt", !! 378   TEST_EXPECT_CONDITION(fd = open("toto4.txt", O_RDWR), RETVAL == 17);
386                         RETVAL == OPEN_BASE_FD << 
387   strzcpy(buff, "Garbage garbage garbage", 256    379   strzcpy(buff, "Garbage garbage garbage", 256);
388   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    380   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
389   bochs_printf("read s='%s'\n", buff);            381   bochs_printf("read s='%s'\n", buff);
390   TEST_EXPECT_CONDITION(strcmp(buff, "Hello wo    382   TEST_EXPECT_CONDITION(strcmp(buff, "Hello world from toto5"), RETVAL == 0);
391                                                   383 
392                                                   384 
393   TEST_EXPECT_CONDITION(symlink("dangling", "t    385   TEST_EXPECT_CONDITION(symlink("dangling", "toto6.txt"), RETVAL == 0);
394   TEST_EXPECT_CONDITION(symlink("dangling", "t    386   TEST_EXPECT_CONDITION(symlink("dangling", "toto6.txt"), RETVAL < 0); /*EEXIST*/
395                                                   387 
396   TEST_EXPECT_CONDITION(fd = open("toto6.txt",    388   TEST_EXPECT_CONDITION(fd = open("toto6.txt", O_RDWR), RETVAL < 0);
397   TEST_EXPECT_CONDITION(fd = open("toto6.txt", !! 389   TEST_EXPECT_CONDITION(fd = open("toto6.txt", O_RDWR | O_NOFOLLOW), RETVAL == 18);
398                         RETVAL == OPEN_BASE_FD << 
399   strzcpy(buff, "Garbage garbage garbage", 256    390   strzcpy(buff, "Garbage garbage garbage", 256);
400   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    391   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 8);
401   bochs_printf("read s='%s'\n", buff);            392   bochs_printf("read s='%s'\n", buff);
402   TEST_EXPECT_CONDITION(strncmp(buff, "danglin    393   TEST_EXPECT_CONDITION(strncmp(buff, "dangling", len), RETVAL == 0);
403                                                   394 
404   ls("/", 1, 1);                                  395   ls("/", 1, 1);
405                                                   396 
406   /* mkdir/rmdir */                               397   /* mkdir/rmdir */
407                                                   398 
408   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRUSR |    399   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRUSR | S_IXUSR), RETVAL == 0);
409   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL    400   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL), RETVAL < 0); /*EEXIST*/
410                                                   401 
411   ls("/", 1, 1);                                  402   ls("/", 1, 1);
412                                                   403 
413   TEST_EXPECT_CONDITION(unlink("yo1"), RETVAL     404   TEST_EXPECT_CONDITION(unlink("yo1"), RETVAL < 0); /*EISDIR*/
414   TEST_EXPECT_CONDITION(unlink("yo1/"), RETVAL    405   TEST_EXPECT_CONDITION(unlink("yo1/"), RETVAL < 0); /*EISDIR*/
415   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL =    406   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL == 0);
416   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL <    407   TEST_EXPECT_CONDITION(rmdir("yo1"), RETVAL < 0); /*ENOENT*/
417   TEST_EXPECT_CONDITION(rmdir("yoda"), RETVAL     408   TEST_EXPECT_CONDITION(rmdir("yoda"), RETVAL < 0); /*ENOENT*/
418                                                   409 
419   ls("/", 1, 1);                                  410   ls("/", 1, 1);
420                                                   411 
421   TEST_EXPECT_CONDITION(mkdir("yoplait1", S_IR    412   TEST_EXPECT_CONDITION(mkdir("yoplait1", S_IRWXALL), RETVAL == 0);
422   TEST_EXPECT_CONDITION(rename("yoplait1", "mo    413   TEST_EXPECT_CONDITION(rename("yoplait1", "mouf1"), RETVAL == 0);
423   TEST_EXPECT_CONDITION(fd = open("mouf1/a", O !! 414   TEST_EXPECT_CONDITION(fd = open("mouf1/a", O_RDWR | O_CREAT, S_IRWXALL), RETVAL == 19);
424                         RETVAL == OPEN_BASE_FD << 
425   TEST_EXPECT_CONDITION(unlink("mouf1/a"), RET    415   TEST_EXPECT_CONDITION(unlink("mouf1/a"), RETVAL == 0);
426   TEST_EXPECT_CONDITION(rmdir("mouf1"), RETVAL    416   TEST_EXPECT_CONDITION(rmdir("mouf1"), RETVAL == 0);
427                                                   417 
428   TEST_EXPECT_CONDITION(mkdir("yoplait2", S_IR    418   TEST_EXPECT_CONDITION(mkdir("yoplait2", S_IRWXALL), RETVAL == 0);
429   TEST_EXPECT_CONDITION(rename("yoplait2", "mo    419   TEST_EXPECT_CONDITION(rename("yoplait2", "mouf2"), RETVAL == 0);
430   TEST_EXPECT_CONDITION(fd = open("mouf2/a", O !! 420   TEST_EXPECT_CONDITION(fd = open("mouf2/a", O_RDWR | O_CREAT, S_IRWXALL), RETVAL == 20);
431                         RETVAL == OPEN_BASE_FD << 
432   TEST_EXPECT_CONDITION(rmdir("mouf2"), RETVAL    421   TEST_EXPECT_CONDITION(rmdir("mouf2"), RETVAL < 0);
433                                                   422 
434   TEST_EXPECT_CONDITION(mkdir("yoplait3", S_IR    423   TEST_EXPECT_CONDITION(mkdir("yoplait3", S_IRWXALL), RETVAL == 0);
435   TEST_EXPECT_CONDITION(rename("yoplait3", "mo    424   TEST_EXPECT_CONDITION(rename("yoplait3", "mouf3"), RETVAL == 0);
436   TEST_EXPECT_CONDITION(creat("mouf3/a", S_IRW    425   TEST_EXPECT_CONDITION(creat("mouf3/a", S_IRWXALL), RETVAL == 0);
437   TEST_EXPECT_CONDITION(unlink("mouf3/a"), RET    426   TEST_EXPECT_CONDITION(unlink("mouf3/a"), RETVAL == 0);
438   TEST_EXPECT_CONDITION(rmdir("mouf3"), RETVAL    427   TEST_EXPECT_CONDITION(rmdir("mouf3"), RETVAL == 0);
439                                                   428 
440   TEST_EXPECT_CONDITION(mkdir("yoplait4", S_IR    429   TEST_EXPECT_CONDITION(mkdir("yoplait4", S_IRWXALL), RETVAL == 0);
441   TEST_EXPECT_CONDITION(rename("yoplait4", "mo    430   TEST_EXPECT_CONDITION(rename("yoplait4", "mouf4"), RETVAL == 0);
442   TEST_EXPECT_CONDITION(creat("mouf4/a", S_IRW    431   TEST_EXPECT_CONDITION(creat("mouf4/a", S_IRWXALL), RETVAL == 0);
443   TEST_EXPECT_CONDITION(rmdir("mouf4"), RETVAL    432   TEST_EXPECT_CONDITION(rmdir("mouf4"), RETVAL < 0);
444                                                   433 
445   ls("/", 1, 1);                                  434   ls("/", 1, 1);
446                                                   435 
447   /* Not supported by virtfs */                << 
448   TEST_EXPECT_CONDITION(mknod("dev1", S_IRWXAL << 
449                         RETVAL == 0);          << 
450   /* Make sure the device cannot be opened (no << 
451      associated to it */                       << 
452   TEST_EXPECT_CONDITION(open("dev1", O_RDONLY) << 
453   TEST_EXPECT_CONDITION(unlink("dev1"), RETVAL << 
454                                                << 
455   ls("/", 1, 1);                                  436   ls("/", 1, 1);
456   ls("..", 1, 1);                                 437   ls("..", 1, 1);
457   ls("../", 1, 1);                                438   ls("../", 1, 1);
458   ls("/..", 1, 1);                                439   ls("/..", 1, 1);
459                                                   440 
460   /* subdirs */                                   441   /* subdirs */
461   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t    442   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY), RETVAL < 0);
462   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t !! 443   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY | O_CREAT, S_IRUSR), RETVAL < 0);
463                                   S_IRUSR), RE << 
464                                                   444 
465   ls("/", 1, 1);                                  445   ls("/", 1, 1);
466   ls("/yo1", 1, 1);                               446   ls("/yo1", 1, 1);
467                                                   447 
468   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL    448   TEST_EXPECT_CONDITION(mkdir("yo1", S_IRWXALL), RETVAL == 0);
469   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t    449   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY), RETVAL < 0);
470   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.t !! 450   TEST_EXPECT_CONDITION(fd = open("yo1/titi1.txt", O_RDONLY | O_CREAT, S_IRUSR), RETVAL == 21);
471                                   S_IRUSR), RE << 
472                                                   451 
473   ls("/", 1, 1);                                  452   ls("/", 1, 1);
474   ls("/yo1", 1, 1);                               453   ls("/yo1", 1, 1);
475                                                   454 
476   TEST_EXPECT_CONDITION(mkdir("yo2", S_IRUSR |    455   TEST_EXPECT_CONDITION(mkdir("yo2", S_IRUSR | S_IXUSR), RETVAL == 0);
477   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.t    456   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.txt", O_RDONLY), RETVAL < 0);
478   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.t !! 457   TEST_EXPECT_CONDITION(fd = open("yo2/titi1.txt", O_RDONLY | O_CREAT, S_IRUSR), RETVAL < 0);
479                                   S_IRUSR), RE << 
480                                                   458 
481   ls("/", 1, 1);                                  459   ls("/", 1, 1);
482                                                   460 
483   TEST_EXPECT_CONDITION(mkdir("yo3", S_IWUSR |    461   TEST_EXPECT_CONDITION(mkdir("yo3", S_IWUSR | S_IXUSR), RETVAL == 0);
484   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.t    462   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.txt", O_RDONLY), RETVAL < 0);
485   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.t !! 463   TEST_EXPECT_CONDITION(fd = open("yo3/titi1.txt", O_RDONLY | O_CREAT, S_IRUSR), RETVAL == 22);
486                                   S_IRUSR), RE << 
487                                                   464 
488   ls("/", 1, 1);                                  465   ls("/", 1, 1);
489                                                   466 
490   TEST_EXPECT_CONDITION(mkdir("yo4", S_IWUSR),    467   TEST_EXPECT_CONDITION(mkdir("yo4", S_IWUSR), RETVAL == 0);
491   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.t    468   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.txt", O_RDONLY), RETVAL < 0);
492   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.t !! 469   TEST_EXPECT_CONDITION(fd = open("yo4/titi1.txt", O_RDONLY | O_CREAT, S_IRUSR), RETVAL < 0);
493                                   S_IRUSR), RE << 
494                                                   470 
495   ls("/", 1, 1);                                  471   ls("/", 1, 1);
496                                                   472 
497   TEST_EXPECT_CONDITION(chdir("nowhere"), RETV    473   TEST_EXPECT_CONDITION(chdir("nowhere"), RETVAL < 0);
498   TEST_EXPECT_CONDITION(chdir("yo1"), RETVAL =    474   TEST_EXPECT_CONDITION(chdir("yo1"), RETVAL == 0);
499                                                   475 
500   ls(".", 1, 1);                                  476   ls(".", 1, 1);
501   ls("/", 1, 1);                                  477   ls("/", 1, 1);
502   ls("..", 1, 1);                                 478   ls("..", 1, 1);
503   ls("../../../../", 1, 1);                       479   ls("../../../../", 1, 1);
504   ls("/../../../../", 1, 1);                      480   ls("/../../../../", 1, 1);
505                                                   481 
506   /* Test chroot */                               482   /* Test chroot */
507                                                   483 
508   TEST_EXPECT_CONDITION(chroot("nowhere"), RET    484   TEST_EXPECT_CONDITION(chroot("nowhere"), RETVAL < 0);
509   TEST_EXPECT_CONDITION(chroot("."), RETVAL ==    485   TEST_EXPECT_CONDITION(chroot("."), RETVAL == 0);
510   ls(".", 1, 1);                                  486   ls(".", 1, 1);
511   ls("/", 1, 1);                                  487   ls("/", 1, 1);
512   ls("..", 1, 1);                                 488   ls("..", 1, 1);
513   ls("../../../../", 1, 1);                       489   ls("../../../../", 1, 1);
514   ls("/../../../../", 1, 1);                      490   ls("/../../../../", 1, 1);
515                                                   491 
516   /* mount */                                     492   /* mount */
517   TEST_EXPECT_CONDITION(mount(NULL, "nowhere",    493   TEST_EXPECT_CONDITION(mount(NULL, "nowhere", NULL, 0, NULL), RETVAL < 0);
518   TEST_EXPECT_CONDITION(mount(NULL, "nowhere",    494   TEST_EXPECT_CONDITION(mount(NULL, "nowhere", "yoplait", 0, NULL), RETVAL < 0);
519   TEST_EXPECT_CONDITION(mount(NULL, "nowhere",    495   TEST_EXPECT_CONDITION(mount(NULL, "nowhere", "virtfs", 0, NULL), RETVAL < 0);
520                                                   496 
521   TEST_EXPECT_CONDITION(mkdir("mnt", S_IRWXALL    497   TEST_EXPECT_CONDITION(mkdir("mnt", S_IRWXALL), RETVAL == 0);
522   TEST_EXPECT_CONDITION(mkdir("mnt/subdir0", S    498   TEST_EXPECT_CONDITION(mkdir("mnt/subdir0", S_IRWXALL), RETVAL == 0);
523   ls("/", 1, 1);                                  499   ls("/", 1, 1);
524   TEST_EXPECT_CONDITION(mount(NULL, "mnt", "vi    500   TEST_EXPECT_CONDITION(mount(NULL, "mnt", "virtfs", 0, NULL), RETVAL == 0);
525   ls("/", 1, 1);                                  501   ls("/", 1, 1);
526   TEST_EXPECT_CONDITION(mkdir("mnt/subdir_moun    502   TEST_EXPECT_CONDITION(mkdir("mnt/subdir_mounted", S_IRWXALL), RETVAL == 0);
527   ls("/", 1, 1);                                  503   ls("/", 1, 1);
528                                                   504 
529   /* Make sure we cannot umount if the FS is i    505   /* Make sure we cannot umount if the FS is in use */
530   TEST_EXPECT_CONDITION(fd = open("mnt/subdir_ !! 506   TEST_EXPECT_CONDITION(fd = open("mnt/subdir_mounted", O_DIRECTORY), RETVAL == 23);
531                         RETVAL == OPEN_BASE_FD << 
532   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL     507   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL < 0);
533   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    508   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
534                                                   509 
535   /* Make sure we cannot umount if the FS is i    510   /* Make sure we cannot umount if the FS is in use */
536   TEST_EXPECT_CONDITION(chdir("mnt"), RETVAL =    511   TEST_EXPECT_CONDITION(chdir("mnt"), RETVAL == 0);
537   TEST_EXPECT_CONDITION(umount("/mnt"), RETVAL    512   TEST_EXPECT_CONDITION(umount("/mnt"), RETVAL < 0);
538   TEST_EXPECT_CONDITION(chdir(".."), RETVAL ==    513   TEST_EXPECT_CONDITION(chdir(".."), RETVAL == 0);
539   ls(".", 1, 1);                                  514   ls(".", 1, 1);
540                                                   515   
541   /* Create another process that chdirs in it     516   /* Create another process that chdirs in it */
542   if (fork() == 0)                                517   if (fork() == 0)
543     {                                             518     {
544       bochs_printf("Hello from child\n");         519       bochs_printf("Hello from child\n");
545       TEST_EXPECT_CONDITION(chdir("mnt"), RETV    520       TEST_EXPECT_CONDITION(chdir("mnt"), RETVAL == 0);
546       TEST_EXPECT_CONDITION(fd = open("subdir_ !! 521       TEST_EXPECT_CONDITION(fd = open("subdir_mounted", O_DIRECTORY), RETVAL == 23);
547                             RETVAL == OPEN_BAS << 
548       bochs_printf("Child sleeping...\n");        522       bochs_printf("Child sleeping...\n");
549       nanosleep(2, 0);                            523       nanosleep(2, 0);
550       bochs_printf("Bye from child\n");           524       bochs_printf("Bye from child\n");
551       return 0;                                   525       return 0;
552     }                                             526     }
553   else                                            527   else
554     {                                             528     {
555       bochs_printf("Father sleeping\n");          529       bochs_printf("Father sleeping\n");
556       nanosleep(1, 0);                            530       nanosleep(1, 0);
557       bochs_printf("Father trying to umount, s    531       bochs_printf("Father trying to umount, should fail (a process chdir'ed in it)\n");
558       TEST_EXPECT_CONDITION(umount("mnt"), RET    532       TEST_EXPECT_CONDITION(umount("mnt"), RETVAL < 0);
559       bochs_printf("Father Resuming normal ope    533       bochs_printf("Father Resuming normal operation in 3s...\n");
560       nanosleep(3, 0);                            534       nanosleep(3, 0);
561     }                                             535     }
562                                                   536 
563   TEST_EXPECT_CONDITION(umount(NULL), RETVAL <    537   TEST_EXPECT_CONDITION(umount(NULL), RETVAL < 0);
564   TEST_EXPECT_CONDITION(umount("nowhere"), RET    538   TEST_EXPECT_CONDITION(umount("nowhere"), RETVAL < 0);
565   ls("/", 1, 1);                                  539   ls("/", 1, 1);
566   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL     540   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL == 0);
567   ls("/", 1, 1);                                  541   ls("/", 1, 1);
568   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL     542   TEST_EXPECT_CONDITION(umount("mnt"), RETVAL < 0);
569                                                   543 
570   /*                                              544   /*
571    * Mountchain exploration                       545    * Mountchain exploration
572    */                                             546    */
573   TEST_EXPECT_CONDITION(mkdir("/mnt2", S_IRWXA    547   TEST_EXPECT_CONDITION(mkdir("/mnt2", S_IRWXALL), RETVAL == 0);
574   TEST_EXPECT_CONDITION(mkdir("/mnt2/nothing-m    548   TEST_EXPECT_CONDITION(mkdir("/mnt2/nothing-mounted", S_IRWXALL), RETVAL == 0);
575   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "v    549   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "virtfs", 0, NULL), RETVAL == 0);
576   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoin    550   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoint-1", S_IRWXALL), RETVAL == 0);
577   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "v    551   TEST_EXPECT_CONDITION(mount(NULL, "mnt2", "virtfs", 0, NULL), RETVAL == 0);
578   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoin    552   TEST_EXPECT_CONDITION(mkdir("/mnt2/mountpoint-2", S_IRWXALL), RETVAL == 0);
579   ls("/", 1, 1);                                  553   ls("/", 1, 1);
580   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL    554   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL == 0);
581   ls("/", 1, 1);                                  555   ls("/", 1, 1);
582   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL    556   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL == 0);
583   ls("/", 1, 1);                                  557   ls("/", 1, 1);
584   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL    558   TEST_EXPECT_CONDITION(umount("mnt2"), RETVAL < 0);
585                                                   559 
586   /*                                              560   /*
587    * Erasing files while they are in use          561    * Erasing files while they are in use
588    */                                             562    */
589                                                   563 
590   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    564   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR | O_CREAT,
591                                   S_IRUSR | S_    565                                   S_IRUSR | S_IWUSR),
592                         RETVAL == OPEN_BASE_FD !! 566                         RETVAL == 23);
593   ls("/", 1, 1);                                  567   ls("/", 1, 1);
594   TEST_EXPECT_CONDITION(unlink("toto8.txt"), R    568   TEST_EXPECT_CONDITION(unlink("toto8.txt"), RETVAL == 0);
595   ls("/", 1, 1);                                  569   ls("/", 1, 1);
596                                                   570 
597   strzcpy(buff, "Garbage garbage garbage", 256    571   strzcpy(buff, "Garbage garbage garbage", 256);
598   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    572   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
599                                                   573 
600   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    574   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
601                                                   575 
602   strzcpy(buff, "Hello world from toto8", 256)    576   strzcpy(buff, "Hello world from toto8", 256);
603   TEST_EXPECT_CONDITION(len = write(fd, buff,     577   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
604                                                   578 
605   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    579   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
606                                                   580 
607   strzcpy(buff, "Garbage garbage garbage", 256    581   strzcpy(buff, "Garbage garbage garbage", 256);
608   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    582   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
609   bochs_printf("read s='%s'\n", buff);            583   bochs_printf("read s='%s'\n", buff);
610                                                   584 
611   /*                                              585   /*
612    * rmdir on still used dirs                     586    * rmdir on still used dirs
613    */                                             587    */
614   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWX    588   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWXALL), RETVAL == 0);
615   TEST_EXPECT_CONDITION(chdir("plotch"), RETVA    589   TEST_EXPECT_CONDITION(chdir("plotch"), RETVAL == 0);
616   TEST_EXPECT_CONDITION(rmdir("../plotch"), RE    590   TEST_EXPECT_CONDITION(rmdir("../plotch"), RETVAL < 0);
617   TEST_EXPECT_CONDITION(chdir(".."), RETVAL ==    591   TEST_EXPECT_CONDITION(chdir(".."), RETVAL == 0);
618   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    592   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL == 0);
619   ls("/", 1, 1);                                  593   ls("/", 1, 1);
620                                                   594 
621   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWX    595   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWXALL), RETVAL == 0);
622   TEST_EXPECT_CONDITION(creat("plotch/a", S_IR    596   TEST_EXPECT_CONDITION(creat("plotch/a", S_IRWXALL), RETVAL == 0);
623   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    597   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL < 0);
624   TEST_EXPECT_CONDITION(unlink("plotch/a"), RE    598   TEST_EXPECT_CONDITION(unlink("plotch/a"), RETVAL == 0);
625   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    599   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL == 0);
626   ls("/", 1, 1);                                  600   ls("/", 1, 1);
627                                                   601 
628   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWX    602   TEST_EXPECT_CONDITION(mkdir("plotch", S_IRWXALL), RETVAL == 0);
629   TEST_EXPECT_CONDITION(fd = open("plotch/a",     603   TEST_EXPECT_CONDITION(fd = open("plotch/a", O_RDWR | O_CREAT, S_IRWXALL),
630                         RETVAL == OPEN_BASE_FD !! 604                         RETVAL == 24);
631   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    605   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL < 0);
632   TEST_EXPECT_CONDITION(unlink("plotch/a"), RE    606   TEST_EXPECT_CONDITION(unlink("plotch/a"), RETVAL == 0);
633   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVA    607   TEST_EXPECT_CONDITION(rmdir("plotch"), RETVAL == 0);
634   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    608   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
635   ls("/", 1, 1);                                  609   ls("/", 1, 1);
636                                                   610 
637   TEST_EXPECT_CONDITION(mkdir("this is ", S_IR    611   TEST_EXPECT_CONDITION(mkdir("this is ", S_IRWXALL), RETVAL == 0);
638   TEST_EXPECT_CONDITION(mkdir("this is / a lon    612   TEST_EXPECT_CONDITION(mkdir("this is / a long path", S_IRWXALL), RETVAL == 0);
639   TEST_EXPECT_CONDITION(mkdir("this is / a lon    613   TEST_EXPECT_CONDITION(mkdir("this is / a long path/tothe", S_IRWXALL), RETVAL == 0);
640   TEST_EXPECT_CONDITION(mkdir("this is / a lon    614   TEST_EXPECT_CONDITION(mkdir("this is / a long path/tothe/destination ", S_IRWXALL), RETVAL == 0);
641   TEST_EXPECT_CONDITION(mkdir("this is / a lon    615   TEST_EXPECT_CONDITION(mkdir("this is / a long path/tothe/destination / directory", S_IRWXALL), RETVAL == 0);
642   TEST_EXPECT_CONDITION(fd = open("this is / a    616   TEST_EXPECT_CONDITION(fd = open("this is / a long path/tothe/destination / directory/a", O_RDWR | O_CREAT, S_IRWXALL),
643                         RETVAL == OPEN_BASE_FD !! 617                         RETVAL == 24);
644   TEST_EXPECT_CONDITION(rmdir("this is / a lon    618   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination / directory"), RETVAL < 0);
645   TEST_EXPECT_CONDITION(unlink("this is / a lo    619   TEST_EXPECT_CONDITION(unlink("this is / a long path/tothe/destination / directory/a"), RETVAL == 0);
646   TEST_EXPECT_CONDITION(rmdir("this is / a lon    620   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination / directory"), RETVAL == 0);
647   TEST_EXPECT_CONDITION(rmdir("this is / a lon    621   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination / directory/"), RETVAL < 0);
648   TEST_EXPECT_CONDITION(rmdir("this is / a lon    622   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/destination "), RETVAL == 0);
649   TEST_EXPECT_CONDITION(rmdir("this is / a lon    623   TEST_EXPECT_CONDITION(rmdir("this is / a long path/tothe/"), RETVAL == 0);
650   TEST_EXPECT_CONDITION(rmdir("this is / a lon    624   TEST_EXPECT_CONDITION(rmdir("this is / a long path"), RETVAL == 0);
651   TEST_EXPECT_CONDITION(rmdir("this is "), RET    625   TEST_EXPECT_CONDITION(rmdir("this is "), RETVAL == 0);
652   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    626   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
653   ls("/", 1, 1);                                  627   ls("/", 1, 1);
654                                                   628 
655   /*                                              629   /*
656    * Unlink/link files while they are in use      630    * Unlink/link files while they are in use
657    */                                             631    */
658                                                   632 
659   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    633   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR | O_CREAT,
660                                   S_IRUSR | S_    634                                   S_IRUSR | S_IWUSR),
661                         RETVAL == OPEN_BASE_FD !! 635                         RETVAL == 24);
662   ls("/", 1, 1);                                  636   ls("/", 1, 1);
663   TEST_EXPECT_CONDITION(link("toto8.txt", "tot    637   TEST_EXPECT_CONDITION(link("toto8.txt", "toto9.txt"), RETVAL == 0);
664   TEST_EXPECT_CONDITION(unlink("toto8.txt"), R    638   TEST_EXPECT_CONDITION(unlink("toto8.txt"), RETVAL == 0);
665   ls("/", 1, 1);                                  639   ls("/", 1, 1);
666                                                   640 
667   strzcpy(buff, "Garbage garbage garbage", 256    641   strzcpy(buff, "Garbage garbage garbage", 256);
668   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    642   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
669                                                   643 
670   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    644   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
671                                                   645 
672   strzcpy(buff, "Hello world from toto8", 256)    646   strzcpy(buff, "Hello world from toto8", 256);
673   TEST_EXPECT_CONDITION(len = write(fd, buff,     647   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
674                                                   648 
675   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    649   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
676                                                   650 
677   strzcpy(buff, "Garbage garbage garbage", 256    651   strzcpy(buff, "Garbage garbage garbage", 256);
678   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    652   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
679   bochs_printf("read s='%s'\n", buff);            653   bochs_printf("read s='%s'\n", buff);
680                                                   654 
681   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    655   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR), RETVAL < 0);
682   TEST_EXPECT_CONDITION(fd = open("toto9.txt", !! 656   TEST_EXPECT_CONDITION(fd = open("toto9.txt", O_RDWR), RETVAL == 25);
683                         RETVAL == OPEN_BASE_FD << 
684                                                   657 
685   strzcpy(buff, "Garbage garbage garbage", 256    658   strzcpy(buff, "Garbage garbage garbage", 256);
686   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    659   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
687   bochs_printf("read s='%s'\n", buff);            660   bochs_printf("read s='%s'\n", buff);
688   TEST_EXPECT_CONDITION(unlink("toto9.txt"), R    661   TEST_EXPECT_CONDITION(unlink("toto9.txt"), RETVAL == 0);
689   ls("/", 1, 1);                                  662   ls("/", 1, 1);
690                                                   663 
691   /*                                              664   /*
692    * Rename files while they are in use           665    * Rename files while they are in use
693    */                                             666    */
694                                                   667 
695   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    668   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR | O_CREAT,
696                                   S_IRUSR | S_    669                                   S_IRUSR | S_IWUSR),
697                         RETVAL == OPEN_BASE_FD !! 670                         RETVAL == 26);
698   ls("/", 1, 1);                                  671   ls("/", 1, 1);
699   TEST_EXPECT_CONDITION(rename("toto8.txt", "t    672   TEST_EXPECT_CONDITION(rename("toto8.txt", "toto9.txt"), RETVAL == 0);
700   ls("/", 1, 1);                                  673   ls("/", 1, 1);
701                                                   674 
702   strzcpy(buff, "Garbage garbage garbage", 256    675   strzcpy(buff, "Garbage garbage garbage", 256);
703   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    676   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 0);
704                                                   677 
705   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    678   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
706                                                   679 
707   strzcpy(buff, "Hello world from toto8", 256)    680   strzcpy(buff, "Hello world from toto8", 256);
708   TEST_EXPECT_CONDITION(len = write(fd, buff,     681   TEST_EXPECT_CONDITION(len = write(fd, buff, 24), RETVAL == 24);
709                                                   682 
710   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET)    683   TEST_EXPECT_CONDITION(lseek(fd, 0, SEEK_SET), RETVAL == 0);  
711                                                   684 
712   strzcpy(buff, "Garbage garbage garbage", 256    685   strzcpy(buff, "Garbage garbage garbage", 256);
713   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    686   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
714   bochs_printf("read s='%s'\n", buff);            687   bochs_printf("read s='%s'\n", buff);
715   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    688   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
716                                                   689 
717   TEST_EXPECT_CONDITION(fd = open("toto8.txt",    690   TEST_EXPECT_CONDITION(fd = open("toto8.txt", O_RDWR), RETVAL < 0);
718   TEST_EXPECT_CONDITION(fd = open("toto9.txt", !! 691   TEST_EXPECT_CONDITION(fd = open("toto9.txt", O_RDWR), RETVAL == 26);
719                         RETVAL == OPEN_BASE_FD << 
720                                                   692 
721   strzcpy(buff, "Garbage garbage garbage", 256    693   strzcpy(buff, "Garbage garbage garbage", 256);
722   TEST_EXPECT_CONDITION(len = read(fd, buff, 2    694   TEST_EXPECT_CONDITION(len = read(fd, buff, 256), RETVAL == 24);
723   bochs_printf("read s='%s'\n", buff);            695   bochs_printf("read s='%s'\n", buff);
724   TEST_EXPECT_CONDITION(unlink("toto9.txt"), R    696   TEST_EXPECT_CONDITION(unlink("toto9.txt"), RETVAL == 0);
725   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0    697   TEST_EXPECT_CONDITION(close(fd), RETVAL == 0);
726                                                   698 
727   /* Rename */                                    699   /* Rename */
728   ls("/", 1, 1);                                  700   ls("/", 1, 1);
729   TEST_EXPECT_CONDITION(rename("/mnt/subdir0",    701   TEST_EXPECT_CONDITION(rename("/mnt/subdir0", "subdir42"), RETVAL == 0);
730   ls("/", 1, 1);                                  702   ls("/", 1, 1);
731   TEST_EXPECT_CONDITION(rename("titi1.txt", "s    703   TEST_EXPECT_CONDITION(rename("titi1.txt", "subdir42"), RETVAL < 0);
732   ls("/", 1, 1);                                  704   ls("/", 1, 1);
733   TEST_EXPECT_CONDITION(rename("titi1.txt", "s    705   TEST_EXPECT_CONDITION(rename("titi1.txt", "subdir42/titi.txt"), RETVAL == 0);
734                                                   706 
735   /* Rename a dir being used */                   707   /* Rename a dir being used */
736   TEST_EXPECT_CONDITION(chdir("subdir42"), RET    708   TEST_EXPECT_CONDITION(chdir("subdir42"), RETVAL == 0);
737   ls(".", 1, 1);                                  709   ls(".", 1, 1);
738   ls("..", 1, 1);                                 710   ls("..", 1, 1);
739   ls("/", 1, 1);                                  711   ls("/", 1, 1);
740   TEST_EXPECT_CONDITION(rename("../subdir42",     712   TEST_EXPECT_CONDITION(rename("../subdir42", "../subdir000"), RETVAL == 0);
741   ls(".", 1, 1);                                  713   ls(".", 1, 1);
742   ls("/", 1, 1);                                  714   ls("/", 1, 1);
743   ls("..", 1, 1);                                 715   ls("..", 1, 1);
744                                                   716 
745   /*                                              717   /*
746    * test mmap                                    718    * test mmap
747    */                                             719    */
748                                                   720 
749   /* Common use: shared file suppressed as soo    721   /* Common use: shared file suppressed as soon as possible */
750   TEST_EXPECT_CONDITION(fd = open("mmap.txt",     722   TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
751                                   S_IRUSR | S_    723                                   S_IRUSR | S_IWUSR),
752                         RETVAL == OPEN_BASE_FD !! 724                         RETVAL == 26);
753   if (fork() == 0)                                725   if (fork() == 0)
754     {                                             726     {
755       char *shrd;                                 727       char *shrd;
756       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     728       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
757                                         MAP_SH    729                                         MAP_SHARED, fd, 4096),
758                             shrd != NULL);        730                             shrd != NULL);
759       nanosleep(1, 0);                            731       nanosleep(1, 0);
760       strzcpy(shrd, "Hello1 from the child (sh    732       strzcpy(shrd, "Hello1 from the child (shared mapping) !", 4096);
761       return 0;                                   733       return 0;
762     }                                             734     }
763   else                                            735   else
764     {                                             736     {
765       char *shrd;                                 737       char *shrd;
766       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     738       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
767                                         MAP_SH    739                                         MAP_SHARED, fd, 4096),
768                             shrd != NULL);        740                             shrd != NULL);
769       strzcpy(shrd, "Garbage garbage garbage",    741       strzcpy(shrd, "Garbage garbage garbage", 256);
770       nanosleep(2, 0);                            742       nanosleep(2, 0);
771       bochs_printf("Father woken up\n");          743       bochs_printf("Father woken up\n");
772       bochs_printf("Read string from child: '%    744       bochs_printf("Read string from child: '%s'\n", shrd);
773       TEST_EXPECT_CONDITION(strcmp(shrd, "Hell    745       TEST_EXPECT_CONDITION(strcmp(shrd, "Hello1 from the child (shared mapping) !"),
774                             RETVAL == 0);         746                             RETVAL == 0);
775       munmap(shrd, 8192);                         747       munmap(shrd, 8192);
776     }                                             748     }
777   ls("/", 1, 1);                                  749   ls("/", 1, 1);
778   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RE    750   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RETVAL == 0);
779   ls("/", 1, 1);                                  751   ls("/", 1, 1);
780                                                   752 
781   /* Common use: shared file suppressed as soo    753   /* Common use: shared file suppressed as soon as possible */
782   TEST_EXPECT_CONDITION(fd = open("mmap.txt",     754   TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
783                                   S_IRUSR | S_    755                                   S_IRUSR | S_IWUSR),
784                         RETVAL == OPEN_BASE_FD !! 756                         RETVAL == 27);
785   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RE    757   TEST_EXPECT_CONDITION(unlink("mmap.txt"), RETVAL == 0);
786   if (fork() == 0)                                758   if (fork() == 0)
787     {                                             759     {
788       char *shrd;                                 760       char *shrd;
789       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     761       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
790                                         MAP_SH    762                                         MAP_SHARED, fd, 4096),
791                             shrd != NULL);        763                             shrd != NULL);
792       nanosleep(1, 0);                            764       nanosleep(1, 0);
793       strzcpy(shrd, "Hello2 from the child (sh    765       strzcpy(shrd, "Hello2 from the child (shared mapping) !", 4096);
794       return 0;                                   766       return 0;
795     }                                             767     }
796   else                                            768   else
797     {                                             769     {
798       char *shrd;                                 770       char *shrd;
799       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     771       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
800                                         MAP_SH    772                                         MAP_SHARED, fd, 4096),
801                             shrd != NULL);        773                             shrd != NULL);
802       strzcpy(shrd, "Garbage garbage garbage",    774       strzcpy(shrd, "Garbage garbage garbage", 256);
803       nanosleep(2, 0);                            775       nanosleep(2, 0);
804       bochs_printf("Father woken up\n");          776       bochs_printf("Father woken up\n");
805       bochs_printf("Read string from child: '%    777       bochs_printf("Read string from child: '%s'\n", shrd);
806       TEST_EXPECT_CONDITION(strcmp(shrd, "Hell    778       TEST_EXPECT_CONDITION(strcmp(shrd, "Hello2 from the child (shared mapping) !"),
807                             RETVAL == 0);         779                             RETVAL == 0);
808     }                                             780     }
809   ls("/", 1, 1);                                  781   ls("/", 1, 1);
810                                                   782 
811   /* Basic use */                                 783   /* Basic use */
812   TEST_EXPECT_CONDITION(creat("mmap.txt", S_IR !! 784   TEST_EXPECT_CONDITION(creat("mmap.txt", S_IRWXALL), RETVAL == 0);
813   if (fork() == 0)                                785   if (fork() == 0)
814     {                                             786     {
815       char *shrd;                                 787       char *shrd;
816       TEST_EXPECT_CONDITION(fd = open("mmap.tx    788       TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
817                                       S_IRUSR     789                                       S_IRUSR | S_IWUSR),
818                             RETVAL == OPEN_BAS !! 790                             RETVAL == 28);
819       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     791       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
820                                         MAP_SH    792                                         MAP_SHARED, fd, 4096),
821                             shrd != NULL);        793                             shrd != NULL);
822       nanosleep(1, 0);                            794       nanosleep(1, 0);
823       strzcpy(shrd, "Hello3 from the child (sh    795       strzcpy(shrd, "Hello3 from the child (shared mapping) !", 4096);
824       return 0;                                   796       return 0;
825     }                                             797     }
826   else                                            798   else
827     {                                             799     {
828       char *shrd;                                 800       char *shrd;
829       TEST_EXPECT_CONDITION(fd = open("mmap.tx    801       TEST_EXPECT_CONDITION(fd = open("mmap.txt", O_RDWR | O_CREAT,
830                                       S_IRUSR     802                                       S_IRUSR | S_IWUSR),
831                             RETVAL == OPEN_BAS !! 803                             RETVAL == 28);
832       TEST_EXPECT_CONDITION(shrd = mmap(NULL,     804       TEST_EXPECT_CONDITION(shrd = mmap(NULL, 4096, PROT_READ | PROT_WRITE,
833                                         MAP_SH    805                                         MAP_SHARED, fd, 4096),
834                             shrd != NULL);        806                             shrd != NULL);
835       strzcpy(shrd, "Garbage garbage garbage",    807       strzcpy(shrd, "Garbage garbage garbage", 256);
836       nanosleep(2, 0);                            808       nanosleep(2, 0);
837       bochs_printf("Father woken up\n");          809       bochs_printf("Father woken up\n");
838       bochs_printf("Read string from child: '%    810       bochs_printf("Read string from child: '%s'\n", shrd);
839       TEST_EXPECT_CONDITION(strcmp(shrd, "Hell    811       TEST_EXPECT_CONDITION(strcmp(shrd, "Hello3 from the child (shared mapping) !"),
840                             RETVAL == 0);         812                             RETVAL == 0);
841     }                                             813     }
842   ls("/", 1, 1);                                  814   ls("/", 1, 1);
843                                                   815   
844   bochs_printf("Bye from fstest\n");              816   bochs_printf("Bye from fstest\n");
845   ls("/", 1, 1);                                  817   ls("/", 1, 1);
846   return 0;                                       818   return 0;
847 }                                                 819 }
                                                      

source navigation ] diff markup ] identifier search ] general search ]