altos: Unmount file system after each testing pass in ao_fat_test
authorKeith Packard <keithp@keithp.com>
Sun, 31 Mar 2013 19:39:32 +0000 (12:39 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 31 Mar 2013 19:39:32 +0000 (12:39 -0700)
Otherwise, we use stale data and 'bad things' happen.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/drivers/ao_fat.c
src/drivers/ao_fat.h
src/test/ao_fat_test.c

index bb0aa7a221e40e9f0ebfda422603e3d740606611..9cd3d34be25b32cc83ccae414befd1e1b1b5a204 100644 (file)
@@ -608,6 +608,12 @@ ao_fat_setup(void)
        return ao_filesystem_status;
 }
 
        return ao_filesystem_status;
 }
 
+void
+ao_fat_unmount(void)
+{
+       ao_filesystem_setup = 0;
+}
+
 /*
  * Basic file operations
  */
 /*
  * Basic file operations
  */
index 40786990209fb7318013133286a2ec61a4299f40..36aec7dfded5bf299b5760f6364f5fce7e79ab39 100644 (file)
@@ -63,6 +63,9 @@ ao_fat_init(void);
 void
 ao_fat_sync(void);
 
 void
 ao_fat_sync(void);
 
+void
+ao_fat_unmount(void);
+
 int8_t
 ao_fat_full(void);
 
 int8_t
 ao_fat_full(void);
 
index 48d5d8a43401100e7871e7991de9d7b387857df5..eb55d9c8aaef9e0119f7b3c6a8760205588a52e7 100644 (file)
@@ -226,14 +226,15 @@ fatal(char *msg, ...)
 void
 check_fat(void)
 {
 void
 check_fat(void)
 {
-       int     e;
-       int     f;
+       cluster_t       e;
+       int             f;
 
        for (e = 0; e < number_cluster; e++) {
                cluster_t       v = ao_fat_entry_raw_read(e, 0);
                for (f = 1; f < number_fat; f++) {
 
        for (e = 0; e < number_cluster; e++) {
                cluster_t       v = ao_fat_entry_raw_read(e, 0);
                for (f = 1; f < number_fat; f++) {
-                       if (ao_fat_entry_raw_read(e, f) != v)
-                               fatal ("fats differ at %d\n", e);
+                       cluster_t       o = ao_fat_entry_raw_read(e, f);
+                       if (o != v)
+                               fatal ("fats differ at %08x (0 %08x %d %08x)\n", e, v, f, o);
                }
        }
 }
                }
        }
 }
@@ -490,6 +491,7 @@ main(int argc, char **argv)
 #else
                long_test_fs();
 #endif
 #else
                long_test_fs();
 #endif
+               ao_fat_unmount();
        }
 
        return 0;
        }
 
        return 0;