]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/fs/ram/v2_0/tests/ramfs1.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / fs / ram / v2_0 / tests / ramfs1.c
index 42fdbc1cd255fef82c6da93d269566c5116219c1..88eb01e85c2cc75f52675990249ff481108af358 100644 (file)
@@ -61,6 +61,7 @@
 #include <pkgconf/hal.h>
 #include <pkgconf/kernel.h>
 #include <pkgconf/io_fileio.h>
+#include <pkgconf/fs_ram.h>
 
 #include <cyg/kernel/ktypes.h>         // base kernel types
 #include <cyg/infra/cyg_trac.h>        // tracing macros
@@ -73,6 +74,7 @@
 #include <string.h>
 #include <dirent.h>
 
+#include <stdio.h>
 #include <cyg/fileio/fileio.h>
 
 #include <cyg/infra/testcase.h>
@@ -136,6 +138,9 @@ static void listdir( char *name, int statp, int numexpected, int *numgot )
             break;
         num++;
         diag_printf("<INFO>: entry %14s",entry->d_name);
+#ifdef CYGPKG_FS_RAM_RET_DIRENT_DTYPE
+        diag_printf(" d_type %2x", entry->d_type);
+#endif
         if( statp )
         {
             char fullname[PATH_MAX];
@@ -164,6 +169,10 @@ static void listdir( char *name, int statp, int numexpected, int *numgot )
                             sbuf.st_mode,sbuf.st_ino,sbuf.st_nlink,
                             (unsigned long) sbuf.st_size);
             }
+#ifdef CYGPKG_FS_RAM_RET_DIRENT_DTYPE
+            if ((entry->d_type & S_IFMT) != (sbuf.st_mode & S_IFMT))
+              CYG_TEST_FAIL("File mode's don't match between dirent and stat");
+#endif
         }
 
         diag_printf("\n");
@@ -187,7 +196,7 @@ static void createfile( char *name, size_t size )
     int i;
     int err;
 
-    diag_printf("<INFO>: create file %s size %d\n",name,size);
+    diag_printf("<INFO>: create file %s size %zd\n",name,size);
 
     err = access( name, F_OK );
     if( err < 0 && errno != EACCES ) SHOW_RESULT( access, err );
@@ -414,6 +423,9 @@ int main( int argc, char **argv )
 {
     int err;
     int existingdirents=-1;
+#if defined(CYGSEM_FILEIO_BLOCK_USAGE) && defined(CYGPKG_FS_RAM_BLOCKS_ARRAY)
+    struct cyg_fs_block_usage usage;
+#endif
 
     CYG_TEST_INIT();
 
@@ -430,7 +442,16 @@ int main( int argc, char **argv )
     listdir( "/", true, -1, &existingdirents );
     if ( existingdirents < 2 )
         CYG_TEST_FAIL("Not enough dir entries\n");
-
+    // --------------------------------------------------------------
+#if defined(CYGSEM_FILEIO_BLOCK_USAGE) && defined(CYGPKG_FS_RAM_BLOCKS_ARRAY)
+    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
+    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
+    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
+               usage.total_blocks, usage.total_blocks * usage.block_size); 
+    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
+               usage.free_blocks, usage.free_blocks * usage.block_size); 
+    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
+#endif
     // --------------------------------------------------------------
 
     createfile( "/foo", 202 );
@@ -551,6 +572,16 @@ int main( int argc, char **argv )
     listdir( "..", true, existingdirents+3, NULL );
 
     // --------------------------------------------------------------
+#if defined(CYGSEM_FILEIO_BLOCK_USAGE) && defined(CYGPKG_FS_RAM_BLOCKS_ARRAY)
+    err = cyg_fs_getinfo("/", FS_INFO_BLOCK_USAGE, &usage, sizeof(usage));
+    if( err < 0 ) SHOW_RESULT( cyg_fs_getinfo, err );
+    diag_printf("<INFO>: total size: %6lld blocks, %10lld bytes\n",
+               usage.total_blocks, usage.total_blocks * usage.block_size); 
+    diag_printf("<INFO>: free size:  %6lld blocks, %10lld bytes\n",
+               usage.free_blocks, usage.free_blocks * usage.block_size); 
+    diag_printf("<INFO>: block size: %6u bytes\n", usage.block_size);
+#endif
+    // --------------------------------------------------------------
 
     diag_printf("<INFO>: unlink tinky\n");    
     err = unlink( "tinky" );