OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [fs/] [ram/] [current/] [tests/] [ramfs1.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      ramfs1.c
4
//
5
//      Test fileio system
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):           nickg
43
// Contributors:        nickg
44
// Date:                2000-05-25
45
// Purpose:             Test fileio system
46
// Description:         This test uses the testfs to check out the initialization
47
//                      and basic operation of the fileio system
48
//                      
49
//                      
50
//                      
51
//                      
52
//                      
53
//              
54
//
55
//####DESCRIPTIONEND####
56
//
57
//==========================================================================
58
 
59
#include <pkgconf/hal.h>
60
#include <pkgconf/kernel.h>
61
#include <pkgconf/io_fileio.h>
62
#include <pkgconf/fs_ram.h>
63
 
64
#include <cyg/kernel/ktypes.h>         // base kernel types
65
#include <cyg/infra/cyg_trac.h>        // tracing macros
66
#include <cyg/infra/cyg_ass.h>         // assertion macros
67
 
68
#include <unistd.h>
69
#include <fcntl.h>
70
#include <sys/stat.h>
71
#include <errno.h>
72
#include <string.h>
73
#include <dirent.h>
74
 
75
#include <stdio.h>
76
#include <cyg/fileio/fileio.h>
77
 
78
#include <cyg/infra/testcase.h>
79
#include <cyg/infra/diag.h>            // HAL polled output
80
 
81
//==========================================================================
82
 
83
#if 0
84
MTAB_ENTRY( ramfs_mte1,
85
                   "/",
86
                   "ramfs",
87
                   "",
88
                   0);
89
#endif
90
 
91
//==========================================================================
92
 
93
#define SHOW_RESULT( _fn, _res ) \
94
diag_printf("<FAIL>: " #_fn "() returned %ld %s\n", (long)_res, _res<0?strerror(errno):"");
95
 
96
//==========================================================================
97
 
98
#define IOSIZE  100
99
 
100
#define LONGNAME1       "long_file_name_that_should_take_up_more_than_one_directory_entry_1"
101
#define LONGNAME2       "long_file_name_that_should_take_up_more_than_one_directory_entry_2"
102
 
103
 
104
//==========================================================================
105
 
106
#ifndef CYGPKG_LIBC_STRING
107
 
108
char *strcat( char *s1, const char *s2 )
109
{
110
    char *s = s1;
111
    while( *s1 ) s1++;
112
    while( (*s1++ = *s2++) != 0);
113
    return s;
114
}
115
 
116
#endif
117
 
118
//==========================================================================
119
 
120
static void listdir( char *name, int statp, int numexpected, int *numgot )
121
{
122
    int err;
123
    DIR *dirp;
124
    int num=0;
125
 
126
    diag_printf("<INFO>: reading directory %s\n",name);
127
 
128
    dirp = opendir( name );
129
    if( dirp == NULL ) SHOW_RESULT( opendir, -1 );
130
 
131
    for(;;)
132
    {
133
        struct dirent *entry = readdir( dirp );
134
 
135
        if( entry == NULL )
136
            break;
137
        num++;
138
        diag_printf("<INFO>: entry %14s",entry->d_name);
139
#ifdef CYGPKG_FS_RAM_RET_DIRENT_DTYPE
140
        diag_printf(" d_type %2x", entry->d_type);
141
#endif
142
        if( statp )
143
        {
144
            char fullname[PATH_MAX];
145
            struct stat sbuf;
146
 
147
            if( name[0] )
148
            {
149
                strcpy(fullname, name );
150
                if( !(name[0] == '/' && name[1] == 0 ) )
151
                    strcat(fullname, "/" );
152
            }
153
            else fullname[0] = 0;
154
 
155
            strcat(fullname, entry->d_name );
156
 
157
            err = stat( fullname, &sbuf );
158
            if( err < 0 )
159
            {
160
                if( errno == ENOSYS )
161
                    diag_printf(" <no status available>");
162
                else SHOW_RESULT( stat, err );
163
            }
164
            else
165
            {
166
                diag_printf(" [mode %08x ino %08x nlink %d size %ld]",
167
                            sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,
168
                            (unsigned long) sbuf.st_size);
169
            }
170
#ifdef CYGPKG_FS_RAM_RET_DIRENT_DTYPE
171
            if ((entry->d_type & S_IFMT) != (sbuf.st_mode & S_IFMT))
172
              CYG_TEST_FAIL("File mode's don't match between dirent and stat");
173
#endif
174
        }
175
 
176
        diag_printf("\n");
177
    }
178
 
179
    err = closedir( dirp );
180
    if( err < 0 ) SHOW_RESULT( stat, err );
181
    if (numexpected >= 0 && num != numexpected)
182
        CYG_TEST_FAIL("Wrong number of dir entries\n");
183
    if ( numgot != NULL )
184
        *numgot = num;
185
}
186
 
187
//==========================================================================
188
 
189
static void createfile( char *name, size_t size )
190
{
191
    char buf[IOSIZE];
192
    int fd;
193
    ssize_t wrote;
194
    int i;
195
    int err;
196
 
197
    diag_printf("<INFO>: create file %s size %zd\n",name,size);
198
 
199
    err = access( name, F_OK );
200
    if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
201
 
202
    for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256;
203
 
204
    fd = open( name, O_WRONLY|O_CREAT );
205
    if( fd < 0 ) SHOW_RESULT( open, fd );
206
 
207
    while( size > 0 )
208
    {
209
        ssize_t len = size;
210
        if ( len > IOSIZE ) len = IOSIZE;
211
 
212
        wrote = write( fd, buf, len );
213
        if( wrote != len ) SHOW_RESULT( write, wrote );
214
 
215
        size -= wrote;
216
    }
217
 
218
    err = close( fd );
219
    if( err < 0 ) SHOW_RESULT( close, err );
220
}
221
 
222
//==========================================================================
223
 
224
#if 0
225
static void maxfile( char *name )
226
{
227
    char buf[IOSIZE];
228
    int fd;
229
    ssize_t wrote;
230
    int i;
231
    int err;
232
    size_t size = 0;
233
 
234
    diag_printf("<INFO>: create maximal file %s\n",name);
235
 
236
    err = access( name, F_OK );
237
    if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
238
 
239
    for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256;
240
 
241
    fd = open( name, O_WRONLY|O_CREAT );
242
    if( fd < 0 ) SHOW_RESULT( open, fd );
243
 
244
    do
245
    {
246
        wrote = write( fd, buf, IOSIZE );
247
        if( wrote < 0 ) SHOW_RESULT( write, wrote );
248
 
249
        size += wrote;
250
 
251
    } while( wrote == IOSIZE );
252
 
253
    diag_printf("<INFO>: file size == %d\n",size);
254
 
255
    err = close( fd );
256
    if( err < 0 ) SHOW_RESULT( close, err );
257
}
258
#endif
259
 
260
//==========================================================================
261
 
262
static void checkfile( char *name )
263
{
264
    char buf[IOSIZE];
265
    int fd;
266
    ssize_t done;
267
    int i;
268
    int err;
269
    off_t pos = 0;
270
 
271
    diag_printf("<INFO>: check file %s\n",name);
272
 
273
    err = access( name, F_OK );
274
    if( err != 0 ) SHOW_RESULT( access, err );
275
 
276
    fd = open( name, O_RDONLY );
277
    if( fd < 0 ) SHOW_RESULT( open, fd );
278
 
279
    for(;;)
280
    {
281
        done = read( fd, buf, IOSIZE );
282
        if( done < 0 ) SHOW_RESULT( read, done );
283
 
284
        if( done == 0 ) break;
285
 
286
        for( i = 0; i < done; i++ )
287
            if( buf[i] != i%256 )
288
            {
289
                diag_printf("buf[%ld+%d](%02x) != %02x\n",
290
                            (unsigned long)pos,i,buf[i],i%256);
291
                CYG_TEST_FAIL("Data read not equal to data written\n");
292
            }
293
 
294
        pos += done;
295
    }
296
 
297
    err = close( fd );
298
    if( err < 0 ) SHOW_RESULT( close, err );
299
}
300
 
301
//==========================================================================
302
 
303
static void copyfile( char *name2, char *name1 )
304
{
305
 
306
    int err;
307
    char buf[IOSIZE];
308
    int fd1, fd2;
309
    ssize_t done, wrote;
310
 
311
    diag_printf("<INFO>: copy file %s -> %s\n",name2,name1);
312
 
313
    err = access( name1, F_OK );
314
    if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
315
 
316
    err = access( name2, F_OK );
317
    if( err != 0 ) SHOW_RESULT( access, err );
318
 
319
    fd1 = open( name1, O_WRONLY|O_CREAT );
320
    if( fd1 < 0 ) SHOW_RESULT( open, fd1 );
321
 
322
    fd2 = open( name2, O_RDONLY );
323
    if( fd2 < 0 ) SHOW_RESULT( open, fd2 );
324
 
325
    for(;;)
326
    {
327
        done = read( fd2, buf, IOSIZE );
328
        if( done < 0 ) SHOW_RESULT( read, done );
329
 
330
        if( done == 0 ) break;
331
 
332
        wrote = write( fd1, buf, done );
333
        if( wrote != done ) SHOW_RESULT( write, wrote );
334
 
335
        if( wrote != done ) break;
336
    }
337
 
338
    err = close( fd1 );
339
    if( err < 0 ) SHOW_RESULT( close, err );
340
 
341
    err = close( fd2 );
342
    if( err < 0 ) SHOW_RESULT( close, err );
343
 
344
}
345
 
346
//==========================================================================
347
 
348
static void comparefiles( char *name2, char *name1 )
349
{
350
    int err;
351
    char buf1[IOSIZE];
352
    char buf2[IOSIZE];
353
    int fd1, fd2;
354
    ssize_t done1, done2;
355
    int i;
356
 
357
    diag_printf("<INFO>: compare files %s == %s\n",name2,name1);
358
 
359
    err = access( name1, F_OK );
360
    if( err != 0 ) SHOW_RESULT( access, err );
361
 
362
    err = access( name1, F_OK );
363
    if( err != 0 ) SHOW_RESULT( access, err );
364
 
365
    fd1 = open( name1, O_RDONLY );
366
    if( fd1 < 0 ) SHOW_RESULT( open, fd1 );
367
 
368
    fd2 = open( name2, O_RDONLY );
369
    if( fd2 < 0 ) SHOW_RESULT( open, fd2 );
370
 
371
    for(;;)
372
    {
373
        done1 = read( fd1, buf1, IOSIZE );
374
        if( done1 < 0 ) SHOW_RESULT( read, done1 );
375
 
376
        done2 = read( fd2, buf2, IOSIZE );
377
        if( done2 < 0 ) SHOW_RESULT( read, done2 );
378
 
379
        if( done1 != done2 )
380
            diag_printf("Files different sizes\n");
381
 
382
        if( done1 == 0 ) break;
383
 
384
        for( i = 0; i < done1; i++ )
385
            if( buf1[i] != buf2[i] )
386
            {
387
                diag_printf("buf1[%d](%02x) != buf1[%d](%02x)\n",i,buf1[i],i,buf2[i]);
388
                CYG_TEST_FAIL("Data in files not equal\n");
389
            }
390
    }
391
 
392
    err = close( fd1 );
393
    if( err < 0 ) SHOW_RESULT( close, err );
394
 
395
    err = close( fd2 );
396
    if( err < 0 ) SHOW_RESULT( close, err );
397
 
398
}
399
 
400
//==========================================================================
401
 
402
void checkcwd( const char *cwd )
403
{
404
    static char cwdbuf[PATH_MAX];
405
    char *ret;
406
 
407
    ret = getcwd( cwdbuf, sizeof(cwdbuf));
408
    if( ret == NULL ) SHOW_RESULT( getcwd, ret );
409
 
410
    if( strcmp( cwdbuf, cwd ) != 0 )
411
    {
412
        diag_printf( "cwdbuf %s cwd %s\n",cwdbuf, cwd );
413
        CYG_TEST_FAIL( "Current directory mismatch");
414
    }
415
}
416
 
417
//==========================================================================
418
// main
419
 
420
int main( int argc, char **argv )
421
{
422
    int err;
423
    int existingdirents=-1;
424
#if defined(CYGSEM_FILEIO_BLOCK_USAGE) && defined(CYGPKG_FS_RAM_BLOCKS_ARRAY)
425
    struct cyg_fs_block_usage usage;
426
#endif
427
 
428
    CYG_TEST_INIT();
429
 
430
    // --------------------------------------------------------------
431
 
432
    err = mount( "", "/", "ramfs" );
433
    if( err < 0 ) SHOW_RESULT( mount, err );
434
 
435
    err = chdir( "/" );
436
    if( err < 0 ) SHOW_RESULT( chdir, err );
437
 
438
    checkcwd( "/" );
439
 
440
    listdir( "/", true, -1, &existingdirents );
441
    if ( existingdirents < 2 )
442
        CYG_TEST_FAIL("Not enough dir entries\n");
443
    // --------------------------------------------------------------
444
#if defined(CYGSEM_FILEIO_BLOCK_USAGE) && defined(CYGPKG_FS_RAM_BLOCKS_ARRAY)
445
    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
446
    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
447
    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
448
                usage.total_blocks, usage.total_blocks * usage.block_size);
449
    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
450
                usage.free_blocks, usage.free_blocks * usage.block_size);
451
    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
452
#endif
453
    // --------------------------------------------------------------
454
 
455
    createfile( "/foo", 202 );
456
    checkfile( "foo" );
457
    copyfile( "foo", "fee");
458
    checkfile( "fee" );
459
    comparefiles( "foo", "/fee" );
460
    diag_printf("<INFO>: mkdir bar\n");
461
    err = mkdir( "/bar", 0 );
462
    if( err < 0 ) SHOW_RESULT( mkdir, err );
463
 
464
    listdir( "/" , true, existingdirents+3, NULL );
465
 
466
    copyfile( "fee", "/bar/fum" );
467
    checkfile( "bar/fum" );
468
    comparefiles( "/fee", "bar/fum" );
469
 
470
    diag_printf("<INFO>: cd bar\n");
471
    err = chdir( "bar" );
472
    if( err < 0 ) SHOW_RESULT( chdir, err );
473
 
474
    checkcwd( "/bar" );
475
 
476
    diag_printf("<INFO>: rename /foo bundy\n");
477
    err = rename( "/foo", "bundy" );
478
    if( err < 0 ) SHOW_RESULT( rename, err );
479
 
480
    listdir( "/", true, existingdirents+2, NULL );
481
    listdir( "" , true, 4, NULL );
482
 
483
    checkfile( "/bar/bundy" );
484
    comparefiles("/fee", "bundy" );
485
 
486
    // --------------------------------------------------------------
487
 
488
    createfile( LONGNAME1, 123 );
489
    checkfile( LONGNAME1 );
490
    copyfile( LONGNAME1, LONGNAME2 );
491
 
492
    listdir( "", false, 6, NULL );
493
 
494
    diag_printf("<INFO>: unlink " LONGNAME1 "\n");
495
    err = unlink( LONGNAME1 );
496
    if( err < 0 ) SHOW_RESULT( unlink, err );
497
 
498
    diag_printf("<INFO>: unlink " LONGNAME2 "\n");
499
    err = unlink( LONGNAME2 );
500
    if( err < 0 ) SHOW_RESULT( unlink, err );
501
 
502
 
503
    // --------------------------------------------------------------
504
 
505
    diag_printf("<INFO>: unlink fee\n");
506
    err = unlink( "/fee" );
507
    if( err < 0 ) SHOW_RESULT( unlink, err );
508
 
509
    diag_printf("<INFO>: unlink fum\n");
510
    err = unlink( "fum" );
511
    if( err < 0 ) SHOW_RESULT( unlink, err );
512
 
513
    diag_printf("<INFO>: unlink /bar/bundy\n");
514
    err = unlink( "/bar/bundy" );
515
    if( err < 0 ) SHOW_RESULT( unlink, err );
516
 
517
    diag_printf("<INFO>: cd /\n");
518
    err = chdir( "/" );
519
    if( err < 0 ) SHOW_RESULT( chdir, err );
520
 
521
    checkcwd( "/" );
522
 
523
    diag_printf("<INFO>: rmdir /bar\n");
524
    err = rmdir( "/bar" );
525
    if( err < 0 ) SHOW_RESULT( rmdir, err );
526
 
527
    listdir( "/", false, existingdirents, NULL );
528
 
529
    // --------------------------------------------------------------
530
 
531
    diag_printf("<INFO>: mount /ram \n");
532
    err = mount( "", "/ram", "ramfs" );
533
    if( err < 0 ) SHOW_RESULT( mount, err );
534
 
535
    createfile( "/ram/tinky", 456 );
536
    copyfile( "/ram/tinky", "/ram/laalaa" );
537
    checkfile( "/ram/tinky");
538
    checkfile( "/ram/laalaa");
539
    comparefiles( "/ram/tinky", "/ram/laalaa" );
540
 
541
    diag_printf("<INFO>: cd /ram\n");
542
    err = chdir( "/ram" );
543
    if( err < 0 ) SHOW_RESULT( chdir, err );
544
 
545
    checkcwd( "/ram" );
546
 
547
    diag_printf("<INFO>: mkdir noonoo\n");
548
    err = mkdir( "noonoo", 0 );
549
    if( err < 0 ) SHOW_RESULT( mkdir, err );
550
 
551
    listdir( "." , true, existingdirents+3, NULL);
552
 
553
    diag_printf("<INFO>: cd noonoo\n");
554
    err = chdir( "noonoo" );
555
    if( err < 0 ) SHOW_RESULT( chdir, err );
556
 
557
    checkcwd( "/ram/noonoo" );
558
 
559
    createfile( "tinky", 678 );
560
    checkfile( "tinky" );
561
 
562
    createfile( "dipsy", 3456 );
563
    checkfile( "dipsy" );
564
    copyfile( "dipsy", "po" );
565
    checkfile( "po" );
566
    comparefiles( "dipsy", "po" );
567
 
568
    listdir( ".", true, 5, NULL );
569
    listdir( "", true, 5, NULL );
570
    listdir( "..", true, existingdirents+3, NULL );
571
 
572
    // --------------------------------------------------------------
573
#if defined(CYGSEM_FILEIO_BLOCK_USAGE) && defined(CYGPKG_FS_RAM_BLOCKS_ARRAY)
574
    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
575
    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
576
    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
577
                usage.total_blocks, usage.total_blocks * usage.block_size);
578
    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
579
                usage.free_blocks, usage.free_blocks * usage.block_size);
580
    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
581
#endif
582
    // --------------------------------------------------------------
583
 
584
    diag_printf("<INFO>: unlink tinky\n");
585
    err = unlink( "tinky" );
586
    if( err < 0 ) SHOW_RESULT( unlink, err );
587
 
588
    diag_printf("<INFO>: unlink dipsy\n");
589
    err = unlink( "dipsy" );
590
    if( err < 0 ) SHOW_RESULT( unlink, err );
591
 
592
    diag_printf("<INFO>: unlink po\n");
593
    err = unlink( "po" );
594
    if( err < 0 ) SHOW_RESULT( unlink, err );
595
 
596
    diag_printf("<INFO>: cd ..\n");
597
    err = chdir( ".." );
598
    if( err < 0 ) SHOW_RESULT( chdir, err );
599
    checkcwd( "/ram" );
600
 
601
    diag_printf("<INFO>: rmdir noonoo\n");
602
    err = rmdir( "noonoo" );
603
    if( err < 0 ) SHOW_RESULT( rmdir, err );
604
 
605
    // --------------------------------------------------------------
606
 
607
    err = mkdir( "x", 0 );
608
    if( err < 0 ) SHOW_RESULT( mkdir, err );
609
 
610
    err = mkdir( "x/y", 0 );
611
    if( err < 0 ) SHOW_RESULT( mkdir, err );
612
 
613
    err = mkdir( "x/y/z", 0 );
614
    if( err < 0 ) SHOW_RESULT( mkdir, err );
615
 
616
    err = mkdir( "x/y/z/w", 0 );
617
    if( err < 0 ) SHOW_RESULT( mkdir, err );
618
 
619
    diag_printf("<INFO>: cd /ram/x/y/z/w\n");
620
    err = chdir( "/ram/x/y/z/w" );
621
    if( err < 0 ) SHOW_RESULT( chdir, err );
622
    checkcwd( "/ram/x/y/z/w" );
623
 
624
    diag_printf("<INFO>: cd ..\n");
625
    err = chdir( ".." );
626
    if( err < 0 ) SHOW_RESULT( chdir, err );
627
    checkcwd( "/ram/x/y/z" );
628
 
629
    diag_printf("<INFO>: cd .\n");
630
    err = chdir( "." );
631
    if( err < 0 ) SHOW_RESULT( chdir, err );
632
    checkcwd( "/ram/x/y/z" );
633
 
634
    diag_printf("<INFO>: cd ../../y\n");
635
    err = chdir( "../../y" );
636
    if( err < 0 ) SHOW_RESULT( chdir, err );
637
    checkcwd( "/ram/x/y" );
638
 
639
    diag_printf("<INFO>: cd ../..\n");
640
    err = chdir( "../.." );
641
    if( err < 0 ) SHOW_RESULT( chdir, err );
642
    checkcwd( "/ram" );
643
 
644
    diag_printf("<INFO>: rmdir x/y/z/w\n");
645
    err = rmdir( "x/y/z/w" );
646
    if( err < 0 ) SHOW_RESULT( rmdir, err );
647
 
648
    diag_printf("<INFO>: rmdir x/y/z\n");
649
    err = rmdir( "x/y/z" );
650
    if( err < 0 ) SHOW_RESULT( rmdir, err );
651
 
652
    diag_printf("<INFO>: rmdir x/y\n");
653
    err = rmdir( "x/y" );
654
    if( err < 0 ) SHOW_RESULT( rmdir, err );
655
 
656
    diag_printf("<INFO>: rmdir x\n");
657
    err = rmdir( "x" );
658
    if( err < 0 ) SHOW_RESULT( rmdir, err );
659
 
660
    // --------------------------------------------------------------
661
 
662
    diag_printf("<INFO>: unlink tinky\n");
663
    err = unlink( "tinky" );
664
    if( err < 0 ) SHOW_RESULT( unlink, err );
665
 
666
    diag_printf("<INFO>: unlink laalaa\n");
667
    err = unlink( "laalaa" );
668
    if( err < 0 ) SHOW_RESULT( unlink, err );
669
 
670
    diag_printf("<INFO>: cd /\n");
671
    err = chdir( "/" );
672
    if( err < 0 ) SHOW_RESULT( chdir, err );
673
    checkcwd( "/" );
674
 
675
    diag_printf("<INFO>: umount /ram\n");
676
    err = umount( "/ram" );
677
    if( err < 0 ) SHOW_RESULT( umount, err );
678
 
679
    CYG_TEST_PASS_FINISH("ramfs1");
680
}
681
 
682
// -------------------------------------------------------------------------
683
// EOF ramfs1.c

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.