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 b6c83f2..aafa5c0 100644 (file)
 #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;
@@ -95,6 +101,8 @@ static int yramsim_rd_chunk (struct yaffs_dev *dev, int pageId,
        unsigned char * d;
        unsigned char *s;
 
+       stats_reads++;
+
        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");
 
+       stats_writes++;
+
        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);
 
+       stats_erases++;
+
        CheckInitialised();
        return yramsim_erase_internal(sim,blockId,0);
 }
@@ -309,3 +321,11 @@ struct yaffs_dev *yaffs_rtems_flashsim_setup(void)
                                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 d9b5e41..50f259b 100644 (file)
@@ -5,5 +5,7 @@ struct yaffs_dev;
 
 struct yaffs_dev *yaffs_rtems_flashsim_setup(void);
 
+void yaffs_rtems_flashsim_dump_status(void);
+
 #endif
 
index 0ac7a67..4d23917 100644 (file)
@@ -76,6 +76,8 @@ rtems_task Init(
 
        run_the_test();
 
+       yaffs_rtems_flashsim_dump_status();
+
    exit(0);
 }