Add stats to flash simulator
authorCharles Manning <cdhmanning@gmail.com>
Thu, 19 Mar 2020 02:14:30 +0000 (15:14 +1300)
committerCharles Manning <cdhmanning@gmail.com>
Thu, 19 Mar 2020 02:14:30 +0000 (15:14 +1300)
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
rtems/rtems-y-test/basic-test/README [new file with mode: 0644]
rtems/rtems-y-test/common/yaffs-rtems-flashsim.c
rtems/rtems-y-test/common/yaffs-rtems-flashsim.h
rtems/rtems-y-test/common/yaffs-rtems-test-wrapper.c

diff --git a/rtems/rtems-y-test/basic-test/README b/rtems/rtems-y-test/basic-test/README
new file mode 100644 (file)
index 0000000..83403b6
--- /dev/null
@@ -0,0 +1,4 @@
+The basic tests test common fs operations such as open, close, read, write etc.
+
+Multiple files and directories are opened, created, read, deleted, truncated etc.
+
index b6c83f206e9dfd3b1dcd2c8695e0596a6029730b..aafa5c0714a8e7ca8bf988730d31d8611ad30b6d 100644 (file)
 #define dout(...) do { } while(0)
 #endif
 
 #define dout(...) do { } while(0)
 #endif
 
+
+
+uint32_t stats_reads;
+uint32_t stats_writes;
+uint32_t stats_erases;
+
 typedef struct {
        unsigned char page[PAGES_PER_BLOCK][PAGE_SIZE];
        unsigned blockOk;
 typedef struct {
        unsigned char page[PAGES_PER_BLOCK][PAGE_SIZE];
        unsigned blockOk;
@@ -95,6 +101,8 @@ static int yramsim_rd_chunk (struct yaffs_dev *dev, int pageId,
        unsigned char * d;
        unsigned char *s;
 
        unsigned char * d;
        unsigned char *s;
 
+       stats_reads++;
+
        if(blockId >= sim->nBlocks ||
           pageOffset >= PAGES_PER_BLOCK ||
           dataLength >DATA_SIZE ||
        if(blockId >= sim->nBlocks ||
           pageOffset >= PAGES_PER_BLOCK ||
           dataLength >DATA_SIZE ||
@@ -132,6 +140,8 @@ static int yramsim_wr_chunk (struct yaffs_dev *dev, int pageId,
 
        dout("wr_chunk\n");
 
 
        dout("wr_chunk\n");
 
+       stats_writes++;
+
        if(blockId >= sim->nBlocks ||
           pageOffset >= PAGES_PER_BLOCK ||
           dataLength >DATA_SIZE ||
        if(blockId >= sim->nBlocks ||
           pageOffset >= PAGES_PER_BLOCK ||
           dataLength >DATA_SIZE ||
@@ -157,6 +167,8 @@ static int yramsim_erase(struct yaffs_dev *dev, int blockId)
 {
        SimData *sim = DevToSim(dev);
 
 {
        SimData *sim = DevToSim(dev);
 
+       stats_erases++;
+
        CheckInitialised();
        return yramsim_erase_internal(sim,blockId,0);
 }
        CheckInitialised();
        return yramsim_erase_internal(sim,blockId,0);
 }
@@ -309,3 +321,11 @@ struct yaffs_dev *yaffs_rtems_flashsim_setup(void)
                                0, 99);
 }
 
                                0, 99);
 }
 
+
+void yaffs_rtems_flashsim_dump_status(void)
+{
+       printf("\nFlashsim stats\n");
+       printf("reads.....%d\n", stats_reads);
+       printf("writes....%d\n", stats_writes);
+       printf("erases....%d\n", stats_erases);
+}
index d9b5e41a12d51aa38d3e5107c8a9351d2141a639..50f259b9795cea3609c4fe45ea4322988c56a1cd 100644 (file)
@@ -5,5 +5,7 @@ struct yaffs_dev;
 
 struct yaffs_dev *yaffs_rtems_flashsim_setup(void);
 
 
 struct yaffs_dev *yaffs_rtems_flashsim_setup(void);
 
+void yaffs_rtems_flashsim_dump_status(void);
+
 #endif
 
 #endif
 
index 0ac7a67b3617c61b9f45ae5212de1cd1f8f3352c..4d23917a5468b8e4a11b953124e194c10ee5c65c 100644 (file)
@@ -76,6 +76,8 @@ rtems_task Init(
 
        run_the_test();
 
 
        run_the_test();
 
+       yaffs_rtems_flashsim_dump_status();
+
    exit(0);
 }
 
    exit(0);
 }