diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-08-10 16:36:33 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-08-10 16:36:33 +0000 |
commit | e296c8e33449dc121a02d0270c66e778ae140617 (patch) | |
tree | 1157bd83a201df23a82aa488dbe08d9dcb433071 /nuttx/examples/mount | |
parent | e4f032ec91a96d59957fe29997524c9a2bb69603 (diff) | |
download | px4-nuttx-e296c8e33449dc121a02d0270c66e778ae140617.tar.gz px4-nuttx-e296c8e33449dc121a02d0270c66e778ae140617.tar.bz2 px4-nuttx-e296c8e33449dc121a02d0270c66e778ae140617.zip |
Added test for mkfatfs
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@807 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/examples/mount')
-rw-r--r-- | nuttx/examples/mount/mount.h | 3 | ||||
-rw-r--r-- | nuttx/examples/mount/mount_main.c | 25 | ||||
-rw-r--r-- | nuttx/examples/mount/ramdisk.c | 13 |
3 files changed, 30 insertions, 11 deletions
diff --git a/nuttx/examples/mount/mount.h b/nuttx/examples/mount/mount.h index 388a6200b..5a2ab61cd 100644 --- a/nuttx/examples/mount/mount.h +++ b/nuttx/examples/mount/mount.h @@ -66,7 +66,8 @@ # if !defined(CONFIG_EXAMPLES_MOUNT_RAMDEVNO) # define CONFIG_EXAMPLES_MOUNT_RAMDEVNO 0 # endif -# define MKMOUNT_DEVNAME(m) "/dev/ram" #m +# define STR_RAMDEVNO(m) #m +# define MKMOUNT_DEVNAME(m) "/dev/ram" STR_RAMDEVNO(m) # define MOUNT_DEVNAME MKMOUNT_DEVNAME(CONFIG_EXAMPLES_MOUNT_RAMDEVNO) #endif diff --git a/nuttx/examples/mount/mount_main.c b/nuttx/examples/mount/mount_main.c index 3959abefb..74c692e77 100644 --- a/nuttx/examples/mount/mount_main.c +++ b/nuttx/examples/mount/mount_main.c @@ -76,7 +76,9 @@ static const char g_testdir1[] = "/mnt/fs/TestDir"; static const char g_testdir2[] = "/mnt/fs/NewDir1"; static const char g_testdir3[] = "/mnt/fs/NewDir2"; static const char g_testdir4[] = "/mnt/fs/NewDir3"; +#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME static const char g_testfile1[] = "/mnt/fs/TestDir/TestFile.txt"; +#endif static const char g_testfile2[] = "/mnt/fs/TestDir/WrTest1.txt"; static const char g_testfile3[] = "/mnt/fs/NewDir1/WrTest2.txt"; static const char g_testfile4[] = "/mnt/fs/NewDir3/Renamed.txt"; @@ -218,7 +220,7 @@ static void show_directories(const char *path, int indent) /**************************************************************************** * Name: fail_read_open ****************************************************************************/ - +#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME static void fail_read_open(const char *path, int expectederror) { int fd; @@ -239,6 +241,7 @@ static void fail_read_open(const char *path, int expectederror) g_nerrors++; } } +#endif /**************************************************************************** * Name: read_test_file @@ -587,6 +590,7 @@ int user_start(int argc, char *argv[]) if (ret < 0) { printf("user_start: ERROR failed to create RAM disk\n"); + return 1; } #endif @@ -603,12 +607,21 @@ int user_start(int argc, char *argv[]) show_statfs(g_mntdir); show_statfs(g_target); +#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME /* Read a test file that is already on the test file system image */ show_directories("", 0); succeed_stat(g_testfile1); show_statfs(g_testfile1); read_test_file(g_testfile1); +#else + /* Create the test directory that would have been on the canned filesystem */ + + succeed_mkdir(g_testdir1); + show_directories("", 0); + succeed_stat(g_testdir1); + show_statfs(g_testdir1); +#endif /* Write a test file into a pre-existing directory on the test file system */ @@ -623,8 +636,9 @@ int user_start(int argc, char *argv[]) read_test_file(g_testfile2); /* Try rmdir() against a file on the directory. It should fail with ENOTDIR */ - +#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME fail_rmdir(g_testfile1, ENOTDIR); +#endif /* Try rmdir() against the test directory. It should fail with ENOTEMPTY */ @@ -635,15 +649,16 @@ int user_start(int argc, char *argv[]) fail_unlink(g_testdir1, EISDIR); /* Try unlink() against the test file1. It should succeed. */ - +#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME succeed_unlink(g_testfile1); fail_stat(g_testfile1, ENOENT); show_directories("", 0); +#endif /* Attempt to open testfile1 should fail with ENOENT */ - +#ifdef CONFIG_EXAMPLES_MOUNT_DEVNAME fail_read_open(g_testfile1, ENOENT); - +#endif /* Try rmdir() against the test directory. It should still fail with ENOTEMPTY */ fail_rmdir(g_testdir1, ENOTEMPTY); diff --git a/nuttx/examples/mount/ramdisk.c b/nuttx/examples/mount/ramdisk.c index 47238e336..905c56492 100644 --- a/nuttx/examples/mount/ramdisk.c +++ b/nuttx/examples/mount/ramdisk.c @@ -40,9 +40,9 @@ #include <nuttx/config.h> #include <sys/types.h> +#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <debug.h> #include <errno.h> #include <nuttx/ramdisk.h> @@ -105,7 +105,8 @@ int create_ramdisk(void) pbuffer = (char*)malloc(BUFFER_SIZE); if (!pbuffer) { - dbg("Failed to allocate ramdisk of size %d\n", BUFFER_SIZE); + printf("create_ramdisk: Failed to allocate ramdisk of size %d\n", + BUFFER_SIZE); return -ENOMEM; } @@ -114,11 +115,12 @@ int create_ramdisk(void) ret = rd_register(CONFIG_EXAMPLES_MOUNT_RAMDEVNO, pbuffer, CONFIG_EXAMPLES_MOUNT_NSECTORS, - CONFIG_EXAMPLES_MOUNT_NSECTORS, + CONFIG_EXAMPLES_MOUNT_SECTORSIZE, TRUE); if (ret < 0) { - dbg("Failed to register ramdisk at %s\n", g_source); + printf("create_ramdisk: Failed to register ramdisk at %s: %d\n", + g_source, -ret); free(pbuffer); return ret; } @@ -128,7 +130,8 @@ int create_ramdisk(void) ret = mkfatfs(g_source, &g_fmt); if (ret < 0) { - dbg("Failed to create FAT filesystem on ramdisk at %s\n", g_source); + printf("create_ramdisk: Failed to create FAT filesystem on ramdisk at %s\n", + g_source); /* free(pbuffer); -- RAM disk is registered */ return ret; } |