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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [fs/] [jffs2/] [current/] [tests/] [jffs2_1.c] - Blame information for rev 817

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      jffs2_1.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/io_flash.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
#include <cyg/io/flash.h>
68
 
69
#include <unistd.h>
70
#include <fcntl.h>
71
#include <sys/stat.h>
72
#include <errno.h>
73
#include <string.h>
74
#include <dirent.h>
75
#include <stdio.h>
76
#include <stdlib.h>
77
 
78
#include <cyg/fileio/fileio.h>
79
 
80
#include <cyg/infra/testcase.h>
81
#include <cyg/infra/diag.h>            // HAL polled output
82
 
83
#include <pkgconf/fs_jffs2.h>   // Address of JFFS2
84
 
85
//==========================================================================
86
// Mount details
87
 
88
#define stringify2(_x_) #_x_
89
#define stringify(_x_) stringify2(_x_)
90
 
91
#if defined(CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1)
92
# define JFFS2_TEST_DEV CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1
93
#elif defined(CYGFUN_IO_FLASH_BLOCK_FROM_FIS)
94
# define JFFS2_TEST_DEV "/dev/flash/fis/jffs2test"
95
#else
96
// fall back to using a user set area in the first device (only)
97
# define JFFS2_TEST_DEV "/dev/flash/0/" stringify(CYGNUM_FS_JFFS2_TEST_OFFSET) "," stringify(CYGNUM_FS_JFFS2_TEST_LENGTH)
98
#endif
99
 
100
// we could use an mtab but we don't in order to get better diagnostics
101
// by calling mount() directly.
102
 
103
#if 0
104
MTAB_ENTRY( jffs2_mte1,
105
                   "/",
106
                   "jffs2",
107
                   CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1,
108
                   0);
109
#endif
110
 
111
//==========================================================================
112
 
113
#define SHOW_RESULT( _fn, _res ) \
114
diag_printf("<FAIL>: " #_fn "() returned %ld %s\n",  \
115
            (unsigned long)_res, _res<0?strerror(errno):"");
116
 
117
//==========================================================================
118
 
119
#define IOSIZE  1000
120
 
121
#define LONGNAME1       "long_file_name_that_should_take_up_more_than_one_directory_entry_1"
122
#define LONGNAME2       "long_file_name_that_should_take_up_more_than_one_directory_entry_2"
123
 
124
 
125
//==========================================================================
126
 
127
#ifndef CYGPKG_LIBC_STRING
128
 
129
char *strcat( char *s1, const char *s2 )
130
{
131
    char *s = s1;
132
    while( *s1 ) s1++;
133
    while( (*s1++ = *s2++) != 0);
134
    return s;
135
}
136
 
137
#endif
138
 
139
//==========================================================================
140
 
141
static void listdir( char *name, int statp, int numexpected, int *numgot )
142
{
143
    int err;
144
    DIR *dirp;
145
    int num=0;
146
 
147
    diag_printf("<INFO>: reading directory %s\n",name);
148
 
149
    dirp = opendir( name );
150
    if( dirp == NULL ) SHOW_RESULT( opendir, -1 );
151
 
152
    for(;;)
153
    {
154
        struct dirent *entry = readdir( dirp );
155
 
156
        if( entry == NULL )
157
            break;
158
        num++;
159
        diag_printf("<INFO>: entry %14s",entry->d_name);
160
#ifdef CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE
161
        diag_printf(" d_type %2d", entry->d_type);
162
#endif
163
        if( statp )
164
        {
165
            char fullname[PATH_MAX];
166
            struct stat sbuf;
167
 
168
            if( name[0] )
169
            {
170
                strcpy(fullname, name );
171
                if( !(name[0] == '/' && name[1] == 0 ) )
172
                    strcat(fullname, "/" );
173
            }
174
            else fullname[0] = 0;
175
 
176
            strcat(fullname, entry->d_name );
177
 
178
            err = stat( fullname, &sbuf );
179
            if( err < 0 )
180
            {
181
                if( errno == ENOSYS )
182
                    diag_printf(" <no status available>");
183
                else SHOW_RESULT( stat, err );
184
            }
185
            else
186
            {
187
                diag_printf(" [mode %08x ino %08x nlink %d size %ld]",
188
                            sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,
189
                            (unsigned long) sbuf.st_size);
190
            }
191
#ifdef CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE
192
            if ((entry->d_type & S_IFMT) != (sbuf.st_mode & S_IFMT))
193
              CYG_TEST_FAIL("File mode's don't match between dirent and stat");
194
#endif
195
        }
196
 
197
        diag_printf("\n");
198
    }
199
 
200
    err = closedir( dirp );
201
    if( err < 0 ) SHOW_RESULT( stat, err );
202
    if (numexpected >= 0 && num != numexpected)
203
        CYG_TEST_FAIL("Wrong number of dir entries\n");
204
    if ( numgot != NULL )
205
        *numgot = num;
206
}
207
 
208
//==========================================================================
209
 
210
static void createfile( char *name, size_t size )
211
{
212
    unsigned char buf[IOSIZE];
213
    int fd;
214
    ssize_t wrote;
215
    int i;
216
    int err;
217
 
218
    diag_printf("<INFO>: create file %s size %d\n",name,size);
219
 
220
    err = access( name, F_OK );
221
    if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
222
 
223
    for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256;
224
 
225
    fd = open( name, O_WRONLY|O_CREAT );
226
    if( fd < 0 ) SHOW_RESULT( open, fd );
227
 
228
    while( size > 0 )
229
    {
230
        ssize_t len = size;
231
        if ( len > IOSIZE ) len = IOSIZE;
232
 
233
        wrote = write( fd, buf, len );
234
        if( wrote != len ) SHOW_RESULT( write, wrote );
235
 
236
        size -= wrote;
237
    }
238
 
239
    err = close( fd );
240
    if( err < 0 ) SHOW_RESULT( close, err );
241
}
242
 
243
//==========================================================================
244
 
245
#if 0
246
static void maxfile( char *name )
247
{
248
    char buf[IOSIZE];
249
    int fd;
250
    ssize_t wrote;
251
    int i;
252
    int err;
253
    size_t size = 0;
254
 
255
    diag_printf("<INFO>: create maximal file %s\n",name);
256
 
257
    err = access( name, F_OK );
258
    if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
259
 
260
    for( i = 0; i < IOSIZE; i++ ) buf[i] = i%256;
261
 
262
    fd = open( name, O_WRONLY|O_CREAT );
263
    if( fd < 0 ) SHOW_RESULT( open, fd );
264
 
265
    do
266
    {
267
        wrote = write( fd, buf, IOSIZE );
268
        if( wrote < 0 ) SHOW_RESULT( write, wrote );
269
 
270
        size += wrote;
271
 
272
    } while( wrote == IOSIZE );
273
 
274
    diag_printf("<INFO>: file size == %d\n",size);
275
 
276
    err = close( fd );
277
    if( err < 0 ) SHOW_RESULT( close, err );
278
}
279
#endif
280
 
281
//==========================================================================
282
 
283
static void checkfile( char *name )
284
{
285
    unsigned char buf[IOSIZE];
286
    int fd;
287
    ssize_t done;
288
    int i;
289
    int err;
290
    off_t pos = 0;
291
 
292
    diag_printf("<INFO>: check file %s\n",name);
293
 
294
    err = access( name, F_OK );
295
    if( err != 0 ) SHOW_RESULT( access, err );
296
 
297
    fd = open( name, O_RDONLY );
298
    if( fd < 0 ) SHOW_RESULT( open, fd );
299
 
300
    for(;;)
301
    {
302
        done = read( fd, buf, IOSIZE );
303
        if( done < 0 ) SHOW_RESULT( read, done );
304
 
305
        if( done == 0 ) break;
306
 
307
        for( i = 0; i < done; i++ )
308
            if( buf[i] != i%256 )
309
            {
310
                diag_printf("buf[%ld+%d](%02x) != %02x\n",
311
                            (unsigned long)pos,i,buf[i],i%256);
312
                CYG_TEST_FAIL("Data read not equal to data written\n");
313
            }
314
 
315
        pos += done;
316
    }
317
 
318
    err = close( fd );
319
    if( err < 0 ) SHOW_RESULT( close, err );
320
}
321
 
322
//==========================================================================
323
 
324
static void copyfile( char *name2, char *name1 )
325
{
326
 
327
    int err;
328
    char buf[IOSIZE];
329
    int fd1, fd2;
330
    ssize_t done, wrote;
331
 
332
    diag_printf("<INFO>: copy file %s -> %s\n",name2,name1);
333
 
334
    err = access( name1, F_OK );
335
    if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
336
 
337
    err = access( name2, F_OK );
338
    if( err != 0 ) SHOW_RESULT( access, err );
339
 
340
    fd1 = open( name1, O_WRONLY|O_CREAT );
341
    if( fd1 < 0 ) SHOW_RESULT( open, fd1 );
342
 
343
    fd2 = open( name2, O_RDONLY );
344
    if( fd2 < 0 ) SHOW_RESULT( open, fd2 );
345
 
346
    for(;;)
347
    {
348
        done = read( fd2, buf, IOSIZE );
349
        if( done < 0 ) SHOW_RESULT( read, done );
350
 
351
        if( done == 0 ) break;
352
 
353
        wrote = write( fd1, buf, done );
354
        if( wrote != done ) SHOW_RESULT( write, wrote );
355
 
356
        if( wrote != done ) break;
357
    }
358
 
359
    err = close( fd1 );
360
    if( err < 0 ) SHOW_RESULT( close, err );
361
 
362
    err = close( fd2 );
363
    if( err < 0 ) SHOW_RESULT( close, err );
364
 
365
}
366
 
367
//==========================================================================
368
 
369
static void comparefiles( char *name2, char *name1 )
370
{
371
    int err;
372
    char buf1[IOSIZE];
373
    char buf2[IOSIZE];
374
    int fd1, fd2;
375
    ssize_t done1, done2;
376
    int i;
377
 
378
    diag_printf("<INFO>: compare files %s == %s\n",name2,name1);
379
 
380
    err = access( name1, F_OK );
381
    if( err != 0 ) SHOW_RESULT( access, err );
382
 
383
    err = access( name1, F_OK );
384
    if( err != 0 ) SHOW_RESULT( access, err );
385
 
386
    fd1 = open( name1, O_RDONLY );
387
    if( fd1 < 0 ) SHOW_RESULT( open, fd1 );
388
 
389
    fd2 = open( name2, O_RDONLY );
390
    if( fd2 < 0 ) SHOW_RESULT( open, fd2 );
391
 
392
    for(;;)
393
    {
394
        done1 = read( fd1, buf1, IOSIZE );
395
        if( done1 < 0 ) SHOW_RESULT( read, done1 );
396
 
397
        done2 = read( fd2, buf2, IOSIZE );
398
        if( done2 < 0 ) SHOW_RESULT( read, done2 );
399
 
400
        if( done1 != done2 )
401
            diag_printf("Files different sizes\n");
402
 
403
        if( done1 == 0 ) break;
404
 
405
        for( i = 0; i < done1; i++ )
406
            if( buf1[i] != buf2[i] )
407
            {
408
                diag_printf("buf1[%d](%02x) != buf1[%d](%02x)\n",i,buf1[i],i,buf2[i]);
409
                CYG_TEST_FAIL("Data in files not equal\n");
410
            }
411
    }
412
 
413
    err = close( fd1 );
414
    if( err < 0 ) SHOW_RESULT( close, err );
415
 
416
    err = close( fd2 );
417
    if( err < 0 ) SHOW_RESULT( close, err );
418
 
419
}
420
 
421
//==========================================================================
422
 
423
void checkcwd( const char *cwd )
424
{
425
    static char cwdbuf[PATH_MAX];
426
    char *ret;
427
 
428
    ret = getcwd( cwdbuf, sizeof(cwdbuf));
429
    if( ret == NULL ) SHOW_RESULT( getcwd, ret );
430
 
431
    if( strcmp( cwdbuf, cwd ) != 0 )
432
    {
433
        diag_printf( "cwdbuf %s cwd %s\n",cwdbuf, cwd );
434
        CYG_TEST_FAIL( "Current directory mismatch");
435
    }
436
}
437
 
438
//==========================================================================
439
// main
440
 
441
int main( int argc, char **argv )
442
{
443
    int err;
444
    //int i;
445
    int existingdirents=-1;
446
 
447
    struct mallinfo info;
448
 
449
    info =  mallinfo();
450
    diag_printf("arenasize %d, freeblocks %d, totalallocated %d, totalfree %d, maxfree %d\n",
451
                info.arena, info.ordblks, info.uordblks, info.fordblks, info.maxfree);
452
 
453
    CYG_TEST_INIT();
454
 
455
    // --------------------------------------------------------------
456
 
457
    err = mount( JFFS2_TEST_DEV, "/", "jffs2" );
458
    if( err < 0 ) SHOW_RESULT( mount, err );
459
 
460
    err = chdir( "/" );
461
    if( err < 0 ) SHOW_RESULT( chdir, err );
462
 
463
    checkcwd( "/" );
464
 
465
    listdir( "/", true, -1, &existingdirents );
466
    if ( existingdirents < 2 )
467
        CYG_TEST_FAIL("Not enough dir entries\n");
468
 
469
    // --------------------------------------------------------------
470
 
471
    createfile( "/foo", 202 );
472
    checkfile( "foo" );
473
    copyfile( "foo", "fee");
474
    checkfile( "fee" );
475
    comparefiles( "foo", "/fee" );
476
    diag_printf("<INFO>: mkdir bar\n");
477
    err = mkdir( "/bar", 0 );
478
    if( err < 0 ) SHOW_RESULT( mkdir, err );
479
 
480
    listdir( "/" , true, existingdirents+3, NULL );
481
 
482
    copyfile( "fee", "/bar/fum" );
483
    checkfile( "bar/fum" );
484
    comparefiles( "/fee", "bar/fum" );
485
 
486
    diag_printf("<INFO>: cd bar\n");
487
    err = chdir( "bar" );
488
    if( err < 0 ) SHOW_RESULT( chdir, err );
489
 
490
    checkcwd( "/bar" );
491
 
492
    diag_printf("<INFO>: rename /foo bundy\n");
493
    err = rename( "/foo", "bundy" );
494
    if( err < 0 ) SHOW_RESULT( rename, err );
495
 
496
    listdir( "/", true, existingdirents+2, NULL );
497
    listdir( "" , true, 4, NULL );
498
 
499
    checkfile( "/bar/bundy" );
500
    comparefiles("/fee", "bundy" );
501
 
502
    // --------------------------------------------------------------
503
 
504
    createfile( LONGNAME1, 123 );
505
    checkfile( LONGNAME1 );
506
    copyfile( LONGNAME1, LONGNAME2 );
507
 
508
    listdir( "", false, 6, NULL );
509
 
510
    diag_printf("<INFO>: unlink " LONGNAME1 "\n");
511
    err = unlink( LONGNAME1 );
512
    if( err < 0 ) SHOW_RESULT( unlink, err );
513
 
514
    diag_printf("<INFO>: unlink " LONGNAME2 "\n");
515
    err = unlink( LONGNAME2 );
516
    if( err < 0 ) SHOW_RESULT( unlink, err );
517
 
518
 
519
    // --------------------------------------------------------------
520
 
521
    diag_printf("<INFO>: unlink fee\n");
522
    err = unlink( "/fee" );
523
    if( err < 0 ) SHOW_RESULT( unlink, err );
524
 
525
    diag_printf("<INFO>: unlink fum\n");
526
    err = unlink( "fum" );
527
    if( err < 0 ) SHOW_RESULT( unlink, err );
528
 
529
    diag_printf("<INFO>: unlink /bar/bundy\n");
530
    err = unlink( "/bar/bundy" );
531
    if( err < 0 ) SHOW_RESULT( unlink, err );
532
 
533
    diag_printf("<INFO>: cd /\n");
534
    err = chdir( "/" );
535
    if( err < 0 ) SHOW_RESULT( chdir, err );
536
 
537
    checkcwd( "/" );
538
 
539
    diag_printf("<INFO>: rmdir /bar\n");
540
    err = rmdir( "/bar" );
541
    if( err < 0 ) SHOW_RESULT( rmdir, err );
542
 
543
    listdir( "/", false, existingdirents, NULL );
544
 
545
    // --------------------------------------------------------------
546
 
547
    diag_printf("<INFO>: mount /jffs2 \n");
548
    err = mount( JFFS2_TEST_DEV, "/jffs2", "jffs2" );
549
    if( err < 0 ) SHOW_RESULT( mount, err );
550
 
551
    createfile( "/jffs2/tinky", 456 );
552
    copyfile( "/jffs2/tinky", "/jffs2/laalaa" );
553
    checkfile( "/jffs2/tinky");
554
    checkfile( "/jffs2/laalaa");
555
    comparefiles( "/jffs2/tinky", "/jffs2/laalaa" );
556
 
557
    diag_printf("<INFO>: cd /jffs2\n");
558
    err = chdir( "/jffs2" );
559
    if( err < 0 ) SHOW_RESULT( chdir, err );
560
 
561
    checkcwd( "/jffs2" );
562
 
563
    diag_printf("<INFO>: mkdir noonoo\n");
564
    err = mkdir( "noonoo", 0 );
565
    if( err < 0 ) SHOW_RESULT( mkdir, err );
566
 
567
    listdir( "." , true, existingdirents+3, NULL);
568
 
569
    diag_printf("<INFO>: cd noonoo\n");
570
    err = chdir( "noonoo" );
571
    if( err < 0 ) SHOW_RESULT( chdir, err );
572
 
573
    checkcwd( "/jffs2/noonoo" );
574
 
575
    createfile( "tinky", 678 );
576
    checkfile( "tinky" );
577
 
578
    createfile( "dipsy", 3456 );
579
    checkfile( "dipsy" );
580
    copyfile( "dipsy", "po" );
581
    checkfile( "po" );
582
    comparefiles( "dipsy", "po" );
583
 
584
 
585
    /*for(i=0;i<2048;i++) {
586
        diag_printf("<INFO>: churningchurningchurning................................ITERATION = %d\n", i);
587
        createfile( "churningchurningchurning", 4096 );
588
        diag_printf("<INFO>: unlink churningchurningchurning\n");
589
        err = unlink( "churningchurningchurning" );
590
        if( err < 0 ) SHOW_RESULT( unlink, err );
591
    }*/
592
 
593
 
594
    listdir( ".", true, 5, NULL );
595
    listdir( "", true, 5, NULL );
596
    listdir( "..", true, existingdirents+3, NULL );
597
 
598
    // --------------------------------------------------------------
599
 
600
    diag_printf("<INFO>: unlink tinky\n");
601
    err = unlink( "tinky" );
602
    if( err < 0 ) SHOW_RESULT( unlink, err );
603
 
604
    diag_printf("<INFO>: unlink dipsy\n");
605
    err = unlink( "dipsy" );
606
    if( err < 0 ) SHOW_RESULT( unlink, err );
607
 
608
    diag_printf("<INFO>: unlink po\n");
609
    err = unlink( "po" );
610
    if( err < 0 ) SHOW_RESULT( unlink, err );
611
 
612
    diag_printf("<INFO>: cd ..\n");
613
    err = chdir( ".." );
614
    if( err < 0 ) SHOW_RESULT( chdir, err );
615
    checkcwd( "/jffs2" );
616
 
617
    diag_printf("<INFO>: rmdir noonoo\n");
618
    err = rmdir( "noonoo" );
619
    if( err < 0 ) SHOW_RESULT( rmdir, err );
620
 
621
    // --------------------------------------------------------------
622
 
623
    err = mkdir( "x", 0 );
624
    if( err < 0 ) SHOW_RESULT( mkdir, err );
625
 
626
    err = mkdir( "x/y", 0 );
627
    if( err < 0 ) SHOW_RESULT( mkdir, err );
628
 
629
    err = mkdir( "x/y/z", 0 );
630
    if( err < 0 ) SHOW_RESULT( mkdir, err );
631
 
632
    err = mkdir( "x/y/z/w", 0 );
633
    if( err < 0 ) SHOW_RESULT( mkdir, err );
634
 
635
    diag_printf("<INFO>: cd /jffs2/x/y/z/w\n");
636
    err = chdir( "/jffs2/x/y/z/w" );
637
    if( err < 0 ) SHOW_RESULT( chdir, err );
638
    checkcwd( "/jffs2/x/y/z/w" );
639
 
640
    diag_printf("<INFO>: cd ..\n");
641
    err = chdir( ".." );
642
    if( err < 0 ) SHOW_RESULT( chdir, err );
643
    checkcwd( "/jffs2/x/y/z" );
644
 
645
    diag_printf("<INFO>: cd .\n");
646
    err = chdir( "." );
647
    if( err < 0 ) SHOW_RESULT( chdir, err );
648
    checkcwd( "/jffs2/x/y/z" );
649
 
650
    diag_printf("<INFO>: cd ../../y\n");
651
    err = chdir( "../../y" );
652
    if( err < 0 ) SHOW_RESULT( chdir, err );
653
    checkcwd( "/jffs2/x/y" );
654
 
655
    diag_printf("<INFO>: cd ../..\n");
656
    err = chdir( "../.." );
657
    if( err < 0 ) SHOW_RESULT( chdir, err );
658
    checkcwd( "/jffs2" );
659
 
660
    diag_printf("<INFO>: rmdir x/y/z/w\n");
661
    err = rmdir( "x/y/z/w" );
662
    if( err < 0 ) SHOW_RESULT( rmdir, err );
663
 
664
    diag_printf("<INFO>: rmdir x/y/z\n");
665
    err = rmdir( "x/y/z" );
666
    if( err < 0 ) SHOW_RESULT( rmdir, err );
667
 
668
    diag_printf("<INFO>: rmdir x/y\n");
669
    err = rmdir( "x/y" );
670
    if( err < 0 ) SHOW_RESULT( rmdir, err );
671
 
672
    diag_printf("<INFO>: rmdir x\n");
673
    err = rmdir( "x" );
674
    if( err < 0 ) SHOW_RESULT( rmdir, err );
675
 
676
    // --------------------------------------------------------------
677
 
678
    diag_printf("<INFO>: unlink tinky\n");
679
    err = unlink( "tinky" );
680
    if( err < 0 ) SHOW_RESULT( unlink, err );
681
 
682
    diag_printf("<INFO>: unlink laalaa\n");
683
    err = unlink( "laalaa" );
684
    if( err < 0 ) SHOW_RESULT( unlink, err );
685
 
686
    diag_printf("<INFO>: cd /\n");
687
    err = chdir( "/" );
688
    if( err < 0 ) SHOW_RESULT( chdir, err );
689
    checkcwd( "/" );
690
 
691
    diag_printf("<INFO>: umount /jffs2\n");
692
    err = umount( "/jffs2" );
693
    if( err < 0 ) SHOW_RESULT( umount, err );
694
 
695
#ifdef CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_2
696
    diag_printf("<INFO>: mounting second JFFS2 filesystem on /mnt\n");
697
 
698
    err = mount( CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_2, "/mnt", "jffs2" );
699
    if( err < 0 ) SHOW_RESULT( mount, err );
700
 
701
    err = chdir( "/" );
702
    if( err < 0 ) SHOW_RESULT( chdir, err );
703
 
704
    checkcwd( "/" );
705
 
706
    listdir( "/", true, -1, &existingdirents );
707
    if ( existingdirents < 2 )
708
        CYG_TEST_FAIL("Not enough dir entries\n");
709
 
710
    listdir( "/mnt", true, -1, &existingdirents );
711
    if ( existingdirents < 2 )
712
        CYG_TEST_FAIL("Not enough dir entries\n");
713
 
714
    diag_printf("<INFO>: umount /mnt\n");
715
    err = umount( "/mnt" );
716
#endif
717
 
718
    diag_printf("<INFO>: umount /\n");
719
    err = umount( "/" );
720
    if( err < 0 ) SHOW_RESULT( umount, err );
721
 
722
    CYG_TEST_PASS_FINISH("jffs2_1");
723
}
724
 
725
// -------------------------------------------------------------------------
726
// EOF jffs2_1.c

powered by: WebSVN 2.1.0

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