testing/: Move all file system tests from examples/ to testing/ (fstest, nxffs, smart, smart_test).

This commit is contained in:
Gregory Nutt 2019-01-24 14:44:54 -06:00
parent 7db2a352fb
commit 60dc0a8f2b
27 changed files with 401 additions and 313 deletions

View File

@ -451,24 +451,6 @@ examples/ft80x
GUI chip. As an example configuration, see
nuttx/configs/viewtool-stm32f107/ft80x/defconfig.
examples/fstest
^^^^^^^^^^^^^^
This is a generic file system test that derives from examples/nxffs. It
was created to test the tmpfs file system, but should work with any file
system provided that all initialization has already been performed prior
to starting the test.
* CONFIG_EXAMPLES_FSTEST: Enable the file system example
* CONFIG_EXAMPLES_FSTEST_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_EXAMPLES_FSTEST_MAXFILE: Determines the maximum size of a file
* CONFIG_EXAMPLES_FSTEST_MAXIO: Max I/O, default 347.
* CONFIG_EXAMPLES_FSTEST_MAXOPEN: Max open files.
* CONFIG_EXAMPLES_FSTEST_MOUNTPT: Path where the file system is mounted.
* CONFIG_EXAMPLES_FSTEST_NLOOPS: Number of test loops. default 100
* CONFIG_EXAMPLES_FSTEST_VERBOSE: Verbose output
examples/ftpc
^^^^^^^^^^^^^
@ -1090,14 +1072,6 @@ examples/nxterm
CONFIG_EXAMPLES_NXTERM_NOTIFYSIGNO -- The signal number to use with
nx_eventnotify(). Default: 4
examples/nxffs
^^^^^^^^^^^^^^
This is a test of the NuttX NXFFS FLASH file system. This is an NXFFS
stress test and beats on the file system very hard. It should only
be used in a simulation environment! Putting this NXFFS test on real
hardware will most likely destroy your FLASH. You have been warned.
examples/nxflat
^^^^^^^^^^^^^^^
@ -1645,44 +1619,6 @@ examples/slcd
* CONFIG_EXAMPLES_SLCD - Enable the SLCD test
examples/smart
^^^^^^^^^^^^^^
This is a test of the SMART file system that derives from
examples/nxffs.
* CONFIG_EXAMPLES_SMART: - Enable the SMART file system example
* CONFIG_EXAMPLES_SMART_ARCHINIT: The default is to use the RAM MTD
device at drivers/mtd/rammtd.c. But an architecture-specific MTD
driver can be used instead by defining CONFIG_EXAMPLES_SMART_ARCHINIT. In
this case, the initialization logic will call smart_archinitialize()
to obtain the MTD driver instance.
* CONFIG_EXAMPLES_SMART_NEBLOCKS: When CONFIG_EXAMPLES_SMART_ARCHINIT is not
defined, this test will use the RAM MTD device at drivers/mtd/rammtd.c
to simulate FLASH. In this case, this value must be provided to give
the nubmer of erase blocks in MTD RAM device. The size of the allocated
RAM drive will be: CONFIG_RAMMTD_ERASESIZE * CONFIG_EXAMPLES_SMART_NEBLOCKS
* CONFIG_EXAMPLES_SMART_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_EXAMPLES_SMART_MAXFILE: Determines the maximum size of a file
* CONFIG_EXAMPLES_SMART_MAXIO: Max I/O, default 347.
* CONFIG_EXAMPLES_SMART_MAXOPEN: Max open files.
* CONFIG_EXAMPLES_SMART_MOUNTPT: SMART mountpoint
* CONFIG_EXAMPLES_SMART_NLOOPS: Number of test loops. default 100
* CONFIG_EXAMPLES_SMART_VERBOSE: Verbose output
examples/smart_test
^^^^^^^^^^^^^^^^^^^
Performs a file-based test on a SMART (or any) filesystem. Validates
seek, append and seek-with-write operations.
* CONFIG_EXAMPLES_SMART_TEST=y
Dependencies:
* CONFIG_NSH_BUILTIN_APPS=y: This test can be built only as an NSH
command
examples/smps
^^^^^^^^^^^^^

View File

@ -1,17 +0,0 @@
Install Program
===============
Source: NuttX
Author: Ken Pettit
Date: April 24, 2013
Performs a file-based test on a SMART (or any) filesystem. Validates seek,
append and seek-with-write operations.
Usage:
flash_test mtdblock_device
Additional options:
--force to replace existing installation

View File

@ -4,8 +4,37 @@ apps/testing README file
The apps/testing directory is used to build NuttX-specific tests and to
include external testing frameworks
examples/ostest
^^^^^^^^^^^^^^^
testing/fstest
==============
This is a generic file system test that derives from testing/nxffs. It
was created to test the tmpfs file system, but should work with any file
system provided that all initialization has already been performed prior
to starting the test.
This test a a general test for any file system, but includes some specific
hooks for the SPIFFS file system.
* CONFIG_TESTING_FSTEST: Enable the file system example
* CONFIG_TESTING_FSTEST_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_TESTING_FSTEST_MAXFILE: Determines the maximum size of a file
* CONFIG_TESTING_FSTEST_MAXIO: Max I/O, default 347.
* CONFIG_TESTING_FSTEST_MAXOPEN: Max open files.
* CONFIG_TESTING_FSTEST_MOUNTPT: Path where the file system is mounted.
* CONFIG_TESTING_FSTEST_NLOOPS: Number of test loops. default 100
* CONFIG_TESTING_FSTEST_VERBOSE: Verbose output
testing/nxffs
=============
This is a test of the NuttX NXFFS FLASH file system. This is an NXFFS
stress test and beats on the file system very hard. It should only
be used in a simulation environment! Putting this NXFFS test on real
hardware will most likely destroy your FLASH. You have been warned.
testing/ostest
==============
This is the NuttX 'qualification' suite. It attempts to exercise
a broad set of OS functionality. Its coverage is not very extensive
@ -38,8 +67,68 @@ examples/ostest
searches for prime numbers in the configurable range, doing that configurable
number of times.
testing/smart
=============
This is a test of the SMART file system that derives from
testing/nxffs.
* CONFIG_TESTING_SMART: - Enable the SMART file system example
* CONFIG_TESTING_SMART_ARCHINIT: The default is to use the RAM MTD
device at drivers/mtd/rammtd.c. But an architecture-specific MTD
driver can be used instead by defining CONFIG_TESTING_SMART_ARCHINIT. In
this case, the initialization logic will call smart_archinitialize()
to obtain the MTD driver instance.
* CONFIG_TESTING_SMART_NEBLOCKS: When CONFIG_TESTING_SMART_ARCHINIT is not
defined, this test will use the RAM MTD device at drivers/mtd/rammtd.c
to simulate FLASH. In this case, this value must be provided to give
the nubmer of erase blocks in MTD RAM device. The size of the allocated
RAM drive will be: CONFIG_RAMMTD_ERASESIZE * CONFIG_TESTING_SMART_NEBLOCKS
* CONFIG_TESTING_SMART_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_TESTING_SMART_MAXFILE: Determines the maximum size of a file
* CONFIG_TESTING_SMART_MAXIO: Max I/O, default 347.
* CONFIG_TESTING_SMART_MAXOPEN: Max open files.
* CONFIG_TESTING_SMART_MOUNTPT: SMART mountpoint
* CONFIG_TESTING_SMART_NLOOPS: Number of test loops. default 100
* CONFIG_TESTING_SMART_VERBOSE: Verbose output
testing/smart_test
==================
Performs a file-based test on a SMART (or any) filesystem. Validates
seek, append and seek-with-write operations.
* CONFIG_TESTING_SMART_TEST=y
Dependencies:
* CONFIG_NSH_BUILTIN_APPS=y: This test can be built only as an NSH
command
Source: NuttX
Author: Ken Pettit
Date: April 24, 2013
Performs a file-based test on a SMART (or any) filesystem. Validates seek,
append and seek-with-write operations.
Usage:
flash_test mtdblock_device
Additional options:
--force to replace existing installation
testing/smp
===========
This is a simple test for SMP functionality. It is basically just the
pthread barrier test with some custom instrumentation.
testing/unity
^^^^^^^^^^^^^^
=============
Unity is a unit testing framework for C developed by ThrowTheSwitch.org:

View File

@ -3,16 +3,16 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_FSTEST
config TESTING_FSTEST
tristate "Generic file system test"
default n
depends on FS_READABLE && FS_WRITABLE
---help---
Enable the generic file system test
if EXAMPLES_FSTEST
if TESTING_FSTEST
config EXAMPLES_FSTEST_PROGNAME
config TESTING_FSTEST_PROGNAME
string "Program name"
default "fstest"
depends on BUILD_LOADABLE
@ -20,43 +20,43 @@ config EXAMPLES_FSTEST_PROGNAME
This is the name of the program that will be use when the NSH ELF
program is installed.
config EXAMPLES_FSTEST_PRIORITY
config TESTING_FSTEST_PRIORITY
int "FS test task priority"
default 100
config EXAMPLES_FSTEST_STACKSIZE
config TESTING_FSTEST_STACKSIZE
int "FS test stack size"
default 2048
config EXAMPLES_FSTEST_MAXNAME
config TESTING_FSTEST_MAXNAME
int "Max name size"
default 32
range 1 255
---help---
Determines the maximum size of names used in the filesystem
config EXAMPLES_FSTEST_MAXFILE
config TESTING_FSTEST_MAXFILE
int "Max file size"
default 8192
---help---
Determines the maximum size of a file
config EXAMPLES_FSTEST_MAXIO
config TESTING_FSTEST_MAXIO
int "Max I/O"
default 347
config EXAMPLES_FSTEST_MAXOPEN
config TESTING_FSTEST_MAXOPEN
int "Max open files"
default 512
config EXAMPLES_FSTEST_MOUNTPT
config TESTING_FSTEST_MOUNTPT
string "FSTEST mountpoint"
config EXAMPLES_FSTEST_NLOOPS
config TESTING_FSTEST_NLOOPS
int "Number of test loops"
default 100
config EXAMPLES_FSTEST_SPIFFS
config TESTING_FSTEST_SPIFFS
bool "Enable SPIFFS testing"
default y
depends on FS_SPIFFS && EXPERIMENTAL
@ -69,7 +69,7 @@ config EXAMPLES_FSTEST_SPIFFS
Marked EXPERIMENTAL because it interferes with test performance.
config EXAMPLES_FSTEST_VERBOSE
config TESTING_FSTEST_VERBOSE
bool "Verbose output"
default n

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/nxffs/Make.defs
# apps/testing/fstest/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
@ -34,6 +34,6 @@
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_NXFFS),)
CONFIGURED_APPS += examples/nxffs
ifneq ($(CONFIG_TESTING_FSTEST),)
CONFIGURED_APPS += testing/fstest
endif

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/fstest/Makefile
# apps/testing/fstest/Makefile
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@ -37,12 +37,12 @@
# Generic file system stress test application info
CONFIG_EXAMPLES_FSTEST_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_EXAMPLES_FSTEST_STACKSIZE ?= 2048
CONFIG_TESTING_FSTEST_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_TESTING_FSTEST_STACKSIZE ?= 2048
APPNAME = fstest
PRIORITY = $(CONFIG_EXAMPLES_FSTEST_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_FSTEST_STACKSIZE)
PRIORITY = $(CONFIG_TESTING_FSTEST_PRIORITY)
STACKSIZE = $(CONFIG_TESTING_FSTEST_STACKSIZE)
# Generic file system stress test
@ -50,9 +50,9 @@ ASRCS =
CSRCS =
MAINSRC = fstest_main.c
CONFIG_EXAMPLES_FSTEST_PROGNAME ?= hello$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_FSTEST_PROGNAME)
CONFIG_TESTING_FSTEST_PROGNAME ?= hello$(EXEEXT)
PROGNAME = $(CONFIG_TESTING_FSTEST_PROGNAME)
MODULE = CONFIG_EXAMPLES_FSTEST
MODULE = CONFIG_TESTING_FSTEST
include $(APPDIR)/Application.mk

20
testing/fstest/README.txt Normal file
View File

@ -0,0 +1,20 @@
README
======
This is a generic file system test that derives from testing/nxffs. It
was created to test the tmpfs file system, but should work with any file
system provided that all initialization has already been performed prior
to starting the test.
This test a a general test for any file system, but includes some specific
hooks for the SPIFFS file system.
* CONFIG_TESTING_FSTEST: Enable the file system example
* CONFIG_TESTING_FSTEST_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_TESTING_FSTEST_MAXFILE: Determines the maximum size of a file
* CONFIG_TESTING_FSTEST_MAXIO: Max I/O, default 347.
* CONFIG_TESTING_FSTEST_MAXOPEN: Max open files.
* CONFIG_TESTING_FSTEST_MOUNTPT: Path where the file system is mounted.
* CONFIG_TESTING_FSTEST_NLOOPS: Number of test loops. default 100
* CONFIG_TESTING_FSTEST_VERBOSE: Verbose output

View File

@ -1,5 +1,5 @@
/****************************************************************************
* examples/fstest/fstest_main.c
* testing/fstest/fstest_main.c
*
* Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -59,37 +59,37 @@
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_EXAMPLES_FSTEST_MAXNAME
# define CONFIG_EXAMPLES_FSTEST_MAXNAME 128
#ifndef CONFIG_TESTING_FSTEST_MAXNAME
# define CONFIG_TESTING_FSTEST_MAXNAME 128
#endif
#if CONFIG_EXAMPLES_FSTEST_MAXNAME > 255
# undef CONFIG_EXAMPLES_FSTEST_MAXNAME
# define CONFIG_EXAMPLES_FSTEST_MAXNAME 255
#if CONFIG_TESTING_FSTEST_MAXNAME > 255
# undef CONFIG_TESTING_FSTEST_MAXNAME
# define CONFIG_TESTING_FSTEST_MAXNAME 255
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MAXFILE
# define CONFIG_EXAMPLES_FSTEST_MAXFILE 8192
#ifndef CONFIG_TESTING_FSTEST_MAXFILE
# define CONFIG_TESTING_FSTEST_MAXFILE 8192
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MAXIO
# define CONFIG_EXAMPLES_FSTEST_MAXIO 347
#ifndef CONFIG_TESTING_FSTEST_MAXIO
# define CONFIG_TESTING_FSTEST_MAXIO 347
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MAXOPEN
# define CONFIG_EXAMPLES_FSTEST_MAXOPEN 512
#ifndef CONFIG_TESTING_FSTEST_MAXOPEN
# define CONFIG_TESTING_FSTEST_MAXOPEN 512
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MOUNTPT
# error CONFIG_EXAMPLES_FSTEST_MOUNTPT must be provided
#ifndef CONFIG_TESTING_FSTEST_MOUNTPT
# error CONFIG_TESTING_FSTEST_MOUNTPT must be provided
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_NLOOPS
# define CONFIG_EXAMPLES_FSTEST_NLOOPS 100
#ifndef CONFIG_TESTING_FSTEST_NLOOPS
# define CONFIG_TESTING_FSTEST_NLOOPS 100
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_VERBOSE
# define CONFIG_EXAMPLES_FSTEST_VERBOSE 0
#ifndef CONFIG_TESTING_FSTEST_VERBOSE
# define CONFIG_TESTING_FSTEST_VERBOSE 0
#endif
/****************************************************************************
@ -110,9 +110,9 @@ struct fstest_filedesc_s
****************************************************************************/
/* Pre-allocated simulated flash */
static uint8_t g_fileimage[CONFIG_EXAMPLES_FSTEST_MAXFILE];
static struct fstest_filedesc_s g_files[CONFIG_EXAMPLES_FSTEST_MAXOPEN];
static const char g_mountdir[] = CONFIG_EXAMPLES_FSTEST_MOUNTPT "/";
static uint8_t g_fileimage[CONFIG_TESTING_FSTEST_MAXFILE];
static struct fstest_filedesc_s g_files[CONFIG_TESTING_FSTEST_MAXOPEN];
static const char g_mountdir[] = CONFIG_TESTING_FSTEST_MOUNTPT "/";
static int g_nfiles;
static int g_ndeleted;
static int g_nfailed;
@ -223,7 +223,7 @@ static inline void fstest_randname(FAR struct fstest_filedesc_s *file)
int i;
dirlen = strlen(g_mountdir);
maxname = CONFIG_EXAMPLES_FSTEST_MAXNAME - dirlen;
maxname = CONFIG_TESTING_FSTEST_MAXNAME - dirlen;
namelen = (rand() % maxname) + 1;
alloclen = namelen + dirlen;
@ -252,7 +252,7 @@ static inline void fstest_randfile(FAR struct fstest_filedesc_s *file)
{
int i;
file->len = (rand() % CONFIG_EXAMPLES_FSTEST_MAXFILE) + 1;
file->len = (rand() % CONFIG_TESTING_FSTEST_MAXFILE) + 1;
for (i = 0; i < file->len; i++)
{
g_fileimage[i] = fstest_randchar();
@ -279,7 +279,7 @@ static void fstest_freefile(FAR struct fstest_filedesc_s *file)
* Name: fstest_gc and fstest_gc_withfd
****************************************************************************/
#ifdef CONFIG_EXAMPLES_FSTEST_SPIFFS
#ifdef CONFIG_TESTING_FSTEST_SPIFFS
static int fstest_gc_withfd(int fd, size_t nbytes)
{
int ret;
@ -351,7 +351,7 @@ static int fstest_gc(size_t nbytes)
/* Find the first valid file */
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL && !file->deleted)
@ -420,7 +420,7 @@ static inline int fstest_wrfile(FAR struct fstest_filedesc_s *file)
for (offset = 0; offset < file->len; )
{
size_t maxio = (rand() % CONFIG_EXAMPLES_FSTEST_MAXIO) + 1;
size_t maxio = (rand() % CONFIG_TESTING_FSTEST_MAXIO) + 1;
size_t nbytestowrite = file->len - offset;
ssize_t nbyteswritten;
@ -466,7 +466,7 @@ static inline int fstest_wrfile(FAR struct fstest_filedesc_s *file)
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf(" Successfully removed partial file\n");
#endif
}
@ -505,7 +505,7 @@ static int fstest_fillfs(void)
g_media_full = false;
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name == NULL)
@ -513,13 +513,13 @@ static int fstest_fillfs(void)
ret = fstest_wrfile(file);
if (ret < 0)
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf("ERROR: Failed to write file %d\n", i);
#endif
return ERROR;
}
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf(" Created file %s\n", file->name);
#endif
g_nfiles++;
@ -541,7 +541,7 @@ static int fstest_fillfs(void)
static ssize_t fstest_rdblock(int fd, FAR struct fstest_filedesc_s *file,
size_t offset, size_t len)
{
size_t maxio = (rand() % CONFIG_EXAMPLES_FSTEST_MAXIO) + 1;
size_t maxio = (rand() % CONFIG_TESTING_FSTEST_MAXIO) + 1;
ssize_t nbytesread;
if (len > maxio)
@ -677,7 +677,7 @@ static unsigned long long fstest_filesize(void)
bytes_used = 0;
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL && !file->deleted)
@ -697,7 +697,7 @@ static unsigned long fstest_filesize(void)
bytes_used = 0;
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL && !file->deleted)
@ -722,7 +722,7 @@ static int fstest_verifyfs(void)
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL)
@ -732,7 +732,7 @@ static int fstest_verifyfs(void)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf("Deleted file %d OK\n", i);
#endif
fstest_freefile(file);
@ -751,7 +751,7 @@ static int fstest_verifyfs(void)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf("ERROR: Successfully read a deleted file\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
@ -763,7 +763,7 @@ static int fstest_verifyfs(void)
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf(" Verified file %s\n", file->name);
#endif
}
@ -814,7 +814,7 @@ static int fstest_delfiles(void)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
if (j >= CONFIG_TESTING_FSTEST_MAXOPEN)
{
j = 0;
}
@ -845,7 +845,7 @@ static int fstest_delfiles(void)
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
file->deleted = true;
@ -869,7 +869,7 @@ static int fstest_delallfiles(void)
int ret;
int i;
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name)
@ -884,7 +884,7 @@ static int fstest_delallfiles(void)
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
fstest_freefile(file);
@ -909,14 +909,14 @@ static int fstest_directory(void)
/* Open the directory */
dirp = opendir(CONFIG_EXAMPLES_FSTEST_MOUNTPT);
dirp = opendir(CONFIG_TESTING_FSTEST_MOUNTPT);
if (!dirp)
{
/* Failed to open the directory */
printf("ERROR: Failed to open directory '%s': %d\n",
CONFIG_EXAMPLES_FSTEST_MOUNTPT, errno);
CONFIG_TESTING_FSTEST_MOUNTPT, errno);
return ERROR;
}
@ -980,10 +980,10 @@ int fstest_main(int argc, char *argv[])
* delete, etc. This beats the FLASH very hard!
*/
#if CONFIG_EXAMPLES_FSTEST_NLOOPS == 0
#if CONFIG_TESTING_FSTEST_NLOOPS == 0
for (i = 0; ; i++)
#else
for (i = 1; i <= CONFIG_EXAMPLES_FSTEST_NLOOPS; i++)
for (i = 1; i <= CONFIG_TESTING_FSTEST_NLOOPS; i++)
#endif
{
/* Write a files to the file system until either (1) all of the open
@ -1017,7 +1017,7 @@ int fstest_main(int argc, char *argv[])
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
@ -1061,7 +1061,7 @@ int fstest_main(int argc, char *argv[])
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
#if CONFIG_TESTING_FSTEST_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);

View File

@ -3,68 +3,68 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_NXFFS
config TESTING_NXFFS
tristate "NXFFS file system example"
default n
---help---
Enable the NXFFS file system example
if EXAMPLES_NXFFS
if TESTING_NXFFS
config EXAMPLES_NXFFS_ARCHINIT
config TESTING_NXFFS_ARCHINIT
bool "Architecture-specific initialization"
default n
---help---
The default is to use the RAM MTD device at drivers/mtd/rammtd.c.
But an architecture-specific MTD driver can be used instead by
defining EXAMPLES_NXFFS_ARCHINIT. In this case, the
defining TESTING_NXFFS_ARCHINIT. In this case, the
initialization logic will call mtdpart_archinitialize() to obtain
the MTD driver instance.
config EXAMPLES_NXFFS_NEBLOCKS
config TESTING_NXFFS_NEBLOCKS
int "Number of erase blocks (simulated)"
default 32
depends on !EXAMPLES_NXFFS_ARCHINIT
depends on !TESTING_NXFFS_ARCHINIT
---help---
When EXAMPLES_NXFFS_ARCHINIT is not defined, this test will use
When TESTING_NXFFS_ARCHINIT is not defined, this test will use
the RAM MTD device at drivers/mtd/rammtd.c to simulate FLASH. In
this case, this value must be provided to give the nubmer of erase
blocks in MTD RAM device.
The size of the allocated RAM drive will be:
RAMMTD_ERASESIZE * EXAMPLES_NXFFS_NEBLOCKS
RAMMTD_ERASESIZE * TESTING_NXFFS_NEBLOCKS
config EXAMPLES_NXFFS_MAXNAME
config TESTING_NXFFS_MAXNAME
int "Max name size"
default 128
range 1 255
---help---
Determines the maximum size of names used in the filesystem
config EXAMPLES_NXFFS_MAXFILE
config TESTING_NXFFS_MAXFILE
int "Max file size"
default 8192
---help---
Determines the maximum size of a file
config EXAMPLES_NXFFS_MAXIO
config TESTING_NXFFS_MAXIO
int "Max I/O"
default 347
config EXAMPLES_NXFFS_MAXOPEN
config TESTING_NXFFS_MAXOPEN
int "Max open files"
default 512
config EXAMPLES_NXFFS_MOUNTPT
config TESTING_NXFFS_MOUNTPT
string "NXFFS mountpoint"
default "/mnt/nxffs"
config EXAMPLES_NXFFS_NLOOPS
config TESTING_NXFFS_NLOOPS
int "Number of test loops"
default 100
config EXAMPLES_NXFFS_VERBOSE
config TESTING_NXFFS_VERBOSE
bool "Verbose output"
default n

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/smart/Make.defs
# apps/testing/nxffs/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
@ -34,6 +34,6 @@
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_SMART),)
CONFIGURED_APPS += examples/smart
ifneq ($(CONFIG_TESTING_NXFFS),)
CONFIGURED_APPS += testing/nxffs
endif

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/nxffs/Makefile
# apps/testing/nxffs/Makefile
#
# Copyright (C) 2011-2012, 2016 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@ -46,6 +46,6 @@ MAINSRC = nxffs_main.c
CONFIG_XYZ_PROGNAME ?= nxffs$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
MODULE = CONFIG_EXAMPLES_NXFFS
MODULE = CONFIG_TESTING_NXFFS
include $(APPDIR)/Application.mk

7
testing/nxffs/README.txt Normal file
View File

@ -0,0 +1,7 @@
README
======
This is a test of the NuttX NXFFS FLASH file system. This is an NXFFS
stress test and beats on the file system very hard. It should only
be used in a simulation environment! Putting this NXFFS test on real
hardware will most likely destroy your FLASH. You have been warned.

View File

@ -1,5 +1,5 @@
/****************************************************************************
* examples/nxffs/nxffs_main.c
* testing/nxffs/nxffs_main.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -61,11 +61,11 @@
/* Configuration ************************************************************/
/* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But
* an architecture-specific MTD driver can be used instead by defining
* CONFIG_EXAMPLES_NXFFS_ARCHINIT. In this case, the initialization logic
* CONFIG_TESTING_NXFFS_ARCHINIT. In this case, the initialization logic
* will call nxffs_archinitialize() to obtain the MTD driver instance.
*/
#ifndef CONFIG_EXAMPLES_NXFFS_ARCHINIT
#ifndef CONFIG_TESTING_NXFFS_ARCHINIT
/* This must exactly match the default configuration in drivers/mtd/rammtd.c */
@ -73,45 +73,45 @@
# define CONFIG_RAMMTD_ERASESIZE 4096
# endif
# ifndef CONFIG_EXAMPLES_NXFFS_NEBLOCKS
# define CONFIG_EXAMPLES_NXFFS_NEBLOCKS (32)
# ifndef CONFIG_TESTING_NXFFS_NEBLOCKS
# define CONFIG_TESTING_NXFFS_NEBLOCKS (32)
# endif
# define EXAMPLES_NXFFS_BUFSIZE \
(CONFIG_RAMMTD_ERASESIZE * CONFIG_EXAMPLES_NXFFS_NEBLOCKS)
# define TESTING_NXFFS_BUFSIZE \
(CONFIG_RAMMTD_ERASESIZE * CONFIG_TESTING_NXFFS_NEBLOCKS)
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_MAXNAME
# define CONFIG_EXAMPLES_NXFFS_MAXNAME 128
#ifndef CONFIG_TESTING_NXFFS_MAXNAME
# define CONFIG_TESTING_NXFFS_MAXNAME 128
#endif
#if CONFIG_EXAMPLES_NXFFS_MAXNAME > 255
# undef CONFIG_EXAMPLES_NXFFS_MAXNAME
# define CONFIG_EXAMPLES_NXFFS_MAXNAME 255
#if CONFIG_TESTING_NXFFS_MAXNAME > 255
# undef CONFIG_TESTING_NXFFS_MAXNAME
# define CONFIG_TESTING_NXFFS_MAXNAME 255
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_MAXFILE
# define CONFIG_EXAMPLES_NXFFS_MAXFILE 8192
#ifndef CONFIG_TESTING_NXFFS_MAXFILE
# define CONFIG_TESTING_NXFFS_MAXFILE 8192
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_MAXIO
# define CONFIG_EXAMPLES_NXFFS_MAXIO 347
#ifndef CONFIG_TESTING_NXFFS_MAXIO
# define CONFIG_TESTING_NXFFS_MAXIO 347
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_MAXOPEN
# define CONFIG_EXAMPLES_NXFFS_MAXOPEN 512
#ifndef CONFIG_TESTING_NXFFS_MAXOPEN
# define CONFIG_TESTING_NXFFS_MAXOPEN 512
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_MOUNTPT
# define CONFIG_EXAMPLES_NXFFS_MOUNTPT "/mnt/nxffs"
#ifndef CONFIG_TESTING_NXFFS_MOUNTPT
# define CONFIG_TESTING_NXFFS_MOUNTPT "/mnt/nxffs"
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_NLOOPS
# define CONFIG_EXAMPLES_NXFFS_NLOOPS 100
#ifndef CONFIG_TESTING_NXFFS_NLOOPS
# define CONFIG_TESTING_NXFFS_NLOOPS 100
#endif
#ifndef CONFIG_EXAMPLES_NXFFS_VERBOSE
# define CONFIG_EXAMPLES_NXFFS_VERBOSE 0
#ifndef CONFIG_TESTING_NXFFS_VERBOSE
# define CONFIG_TESTING_NXFFS_VERBOSE 0
#endif
/****************************************************************************
@ -131,13 +131,13 @@ struct nxffs_filedesc_s
****************************************************************************/
/* Pre-allocated simulated flash */
#ifndef CONFIG_EXAMPLES_NXFFS_ARCHINIT
static uint8_t g_simflash[EXAMPLES_NXFFS_BUFSIZE];
#ifndef CONFIG_TESTING_NXFFS_ARCHINIT
static uint8_t g_simflash[TESTING_NXFFS_BUFSIZE];
#endif
static uint8_t g_fileimage[CONFIG_EXAMPLES_NXFFS_MAXFILE];
static struct nxffs_filedesc_s g_files[CONFIG_EXAMPLES_NXFFS_MAXOPEN];
static const char g_mountdir[] = CONFIG_EXAMPLES_NXFFS_MOUNTPT "/";
static uint8_t g_fileimage[CONFIG_TESTING_NXFFS_MAXFILE];
static struct nxffs_filedesc_s g_files[CONFIG_TESTING_NXFFS_MAXOPEN];
static const char g_mountdir[] = CONFIG_TESTING_NXFFS_MOUNTPT "/";
static int g_nfiles;
static int g_ndeleted;
@ -149,7 +149,7 @@ static struct mallinfo g_mmafter;
* External Functions
****************************************************************************/
#ifdef CONFIG_EXAMPLES_NXFFS_ARCHINIT
#ifdef CONFIG_TESTING_NXFFS_ARCHINIT
extern FAR struct mtd_dev_s *nxffs_archinitialize(void);
#endif
@ -254,7 +254,7 @@ static inline void nxffs_randname(FAR struct nxffs_filedesc_s *file)
int i;
dirlen = strlen(g_mountdir);
maxname = CONFIG_EXAMPLES_NXFFS_MAXNAME - dirlen;
maxname = CONFIG_TESTING_NXFFS_MAXNAME - dirlen;
namelen = (rand() % maxname) + 1;
alloclen = namelen + dirlen;
@ -283,7 +283,7 @@ static inline void nxffs_randfile(FAR struct nxffs_filedesc_s *file)
{
int i;
file->len = (rand() % CONFIG_EXAMPLES_NXFFS_MAXFILE) + 1;
file->len = (rand() % CONFIG_TESTING_NXFFS_MAXFILE) + 1;
for (i = 0; i < file->len; i++)
{
g_fileimage[i] = nxffs_randchar();
@ -339,7 +339,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
for (offset = 0; offset < file->len; )
{
size_t maxio = (rand() % CONFIG_EXAMPLES_NXFFS_MAXIO) + 1;
size_t maxio = (rand() % CONFIG_TESTING_NXFFS_MAXIO) + 1;
size_t nbytestowrite = file->len - offset;
ssize_t nbyteswritten;
@ -378,7 +378,7 @@ static inline int nxffs_wrfile(FAR struct nxffs_filedesc_s *file)
}
else
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf(" Successfully removed partial file\n");
#endif
}
@ -415,7 +415,7 @@ static int nxffs_fillfs(void)
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_NXFFS_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_NXFFS_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name == NULL)
@ -423,13 +423,13 @@ static int nxffs_fillfs(void)
ret = nxffs_wrfile(file);
if (ret < 0)
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf("ERROR: Failed to write file %d\n", i);
#endif
return ERROR;
}
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf(" Created file %s\n", file->name);
#endif
g_nfiles++;
@ -446,7 +446,7 @@ static int nxffs_fillfs(void)
static ssize_t nxffs_rdblock(int fd, FAR struct nxffs_filedesc_s *file,
size_t offset, size_t len)
{
size_t maxio = (rand() % CONFIG_EXAMPLES_NXFFS_MAXIO) + 1;
size_t maxio = (rand() % CONFIG_TESTING_NXFFS_MAXIO) + 1;
ssize_t nbytesread;
if (len > maxio)
@ -568,7 +568,7 @@ static int nxffs_verifyfs(void)
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_NXFFS_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_NXFFS_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL)
@ -578,7 +578,7 @@ static int nxffs_verifyfs(void)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf("Deleted file %d OK\n", i);
#endif
nxffs_freefile(file);
@ -597,7 +597,7 @@ static int nxffs_verifyfs(void)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf("Succesffully read a deleted file\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
@ -609,7 +609,7 @@ static int nxffs_verifyfs(void)
}
else
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf(" Verifed file %s\n", file->name);
#endif
}
@ -660,7 +660,7 @@ static int nxffs_delfiles(void)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN)
if (j >= CONFIG_TESTING_NXFFS_MAXOPEN)
{
j = 0;
}
@ -678,7 +678,7 @@ static int nxffs_delfiles(void)
}
else
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
file->deleted = true;
@ -702,7 +702,7 @@ static int nxffs_delallfiles(void)
int ret;
int i;
for (i = 0; i < CONFIG_EXAMPLES_NXFFS_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_NXFFS_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name)
@ -717,7 +717,7 @@ static int nxffs_delallfiles(void)
}
else
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
nxffs_freefile(file);
@ -742,14 +742,14 @@ static int nxffs_directory(void)
/* Open the directory */
dirp = opendir(CONFIG_EXAMPLES_NXFFS_MOUNTPT);
dirp = opendir(CONFIG_TESTING_NXFFS_MOUNTPT);
if (!dirp)
{
/* Failed to open the directory */
printf("ERROR: Failed to open directory '%s': %d\n",
CONFIG_EXAMPLES_NXFFS_MOUNTPT, errno);
CONFIG_TESTING_NXFFS_MOUNTPT, errno);
return ERROR;
}
@ -799,10 +799,10 @@ int nxffs_main(int argc, char *argv[])
/* Create and initialize a RAM MTD device instance */
#ifdef CONFIG_EXAMPLES_NXFFS_ARCHINIT
#ifdef CONFIG_TESTING_NXFFS_ARCHINIT
mtd = nxffs_archinitialize();
#else
mtd = rammtd_initialize(g_simflash, EXAMPLES_NXFFS_BUFSIZE);
mtd = rammtd_initialize(g_simflash, TESTING_NXFFS_BUFSIZE);
#endif
if (!mtd)
{
@ -823,7 +823,7 @@ int nxffs_main(int argc, char *argv[])
/* Mount the file system */
ret = mount(NULL, CONFIG_EXAMPLES_NXFFS_MOUNTPT, "nxffs", 0, NULL);
ret = mount(NULL, CONFIG_TESTING_NXFFS_MOUNTPT, "nxffs", 0, NULL);
if (ret < 0)
{
printf("ERROR: Failed to mount the NXFFS volume: %d\n", errno);
@ -846,10 +846,10 @@ int nxffs_main(int argc, char *argv[])
* delete, etc. This beats the FLASH very hard!
*/
#if CONFIG_EXAMPLES_NXFFS_NLOOPS == 0
#if CONFIG_TESTING_NXFFS_NLOOPS == 0
for (i = 0; ; i++)
#else
for (i = 1; i <= CONFIG_EXAMPLES_NXFFS_NLOOPS; i++)
for (i = 1; i <= CONFIG_TESTING_NXFFS_NLOOPS; i++)
#endif
{
/* Write a files to the NXFFS file system until either (1) all of the
@ -862,7 +862,7 @@ int nxffs_main(int argc, char *argv[])
printf("Filled file system\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
nxffs_dump(mtd, CONFIG_EXAMPLES_NXFFS_VERBOSE);
nxffs_dump(mtd, CONFIG_TESTING_NXFFS_VERBOSE);
/* Directory listing */
@ -879,7 +879,7 @@ int nxffs_main(int argc, char *argv[])
}
else
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
@ -902,7 +902,7 @@ int nxffs_main(int argc, char *argv[])
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
}
nxffs_dump(mtd, CONFIG_EXAMPLES_NXFFS_VERBOSE);
nxffs_dump(mtd, CONFIG_TESTING_NXFFS_VERBOSE);
/* Directory listing */
@ -919,7 +919,7 @@ int nxffs_main(int argc, char *argv[])
}
else
{
#if CONFIG_EXAMPLES_NXFFS_VERBOSE != 0
#if CONFIG_TESTING_NXFFS_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);

View File

@ -3,68 +3,68 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_SMART
config TESTING_SMART
tristate "SMART file system example"
default n
---help---
Enable the SMART file system example
if EXAMPLES_SMART
if TESTING_SMART
config EXAMPLES_SMART_ARCHINIT
config TESTING_SMART_ARCHINIT
bool "Architecture-specific initialization"
default n
---help---
The default is to use the RAM MTD device at drivers/mtd/rammtd.c.
But an architecture-specific MTD driver can be used instead by
defining EXAMPLES_SMART_ARCHINIT. In this case, the
defining TESTING_SMART_ARCHINIT. In this case, the
initialization logic will call smart_archinitialize() to obtain
the MTD driver instance.
config EXAMPLES_SMART_NEBLOCKS
config TESTING_SMART_NEBLOCKS
int "Number of erase blocks (simulated)"
default 32
depends on !EXAMPLES_SMART_ARCHINIT
depends on !TESTING_SMART_ARCHINIT
---help---
When EXAMPLES_SMART_ARCHINIT is not defined, this test will use
When TESTING_SMART_ARCHINIT is not defined, this test will use
the RAM MTD device at drivers/mtd/rammtd.c to simulate FLASH. In
this case, this value must be provided to give the nubmer of erase
blocks in MTD RAM device.
The size of the allocated RAM drive will be:
RAMMTD_ERASESIZE * EXAMPLES_SMART_NEBLOCKS
RAMMTD_ERASESIZE * TESTING_SMART_NEBLOCKS
config EXAMPLES_SMART_MAXNAME
config TESTING_SMART_MAXNAME
int "Max name size"
default 32
range 1 255
---help---
Determines the maximum size of names used in the filesystem
config EXAMPLES_SMART_MAXFILE
config TESTING_SMART_MAXFILE
int "Max file size"
default 8192
---help---
Determines the maximum size of a file
config EXAMPLES_SMART_MAXIO
config TESTING_SMART_MAXIO
int "Max I/O"
default 347
config EXAMPLES_SMART_MAXOPEN
config TESTING_SMART_MAXOPEN
int "Max open files"
default 512
config EXAMPLES_SMART_MOUNTPT
config TESTING_SMART_MOUNTPT
string "SMART mountpoint"
default "/mnt/nxffs"
config EXAMPLES_SMART_NLOOPS
config TESTING_SMART_NLOOPS
int "Number of test loops"
default 100
config EXAMPLES_SMART_VERBOSE
config TESTING_SMART_VERBOSE
bool "Verbose output"
default n

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/fstest/Make.defs
# apps/testing/smart/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
@ -34,6 +34,6 @@
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_FSTEST),)
CONFIGURED_APPS += examples/fstest
ifneq ($(CONFIG_TESTING_SMART),)
CONFIGURED_APPS += testing/smart
endif

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/smart/Makefile
# apps/testing/smart/Makefile
#
# Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@ -46,6 +46,6 @@ MAINSRC = smart_main.c
CONFIG_XYZ_PROGNAME ?= smart$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
MODULE = CONFIG_EXAMPLES_SMART
MODULE = CONFIG_TESTING_SMART
include $(APPDIR)/Application.mk

25
testing/smart/README.txt Normal file
View File

@ -0,0 +1,25 @@
README
======
This is a test of the SMART file system that derives from
testing/nxffs.
* CONFIG_TESTING_SMART: - Enable the SMART file system example
* CONFIG_TESTING_SMART_ARCHINIT: The default is to use the RAM MTD
device at drivers/mtd/rammtd.c. But an architecture-specific MTD
driver can be used instead by defining CONFIG_TESTING_SMART_ARCHINIT. In
this case, the initialization logic will call smart_archinitialize()
to obtain the MTD driver instance.
* CONFIG_TESTING_SMART_NEBLOCKS: When CONFIG_TESTING_SMART_ARCHINIT is not
defined, this test will use the RAM MTD device at drivers/mtd/rammtd.c
to simulate FLASH. In this case, this value must be provided to give
the nubmer of erase blocks in MTD RAM device. The size of the allocated
RAM drive will be: CONFIG_RAMMTD_ERASESIZE * CONFIG_TESTING_SMART_NEBLOCKS
* CONFIG_TESTING_SMART_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_TESTING_SMART_MAXFILE: Determines the maximum size of a file
* CONFIG_TESTING_SMART_MAXIO: Max I/O, default 347.
* CONFIG_TESTING_SMART_MAXOPEN: Max open files.
* CONFIG_TESTING_SMART_MOUNTPT: SMART mountpoint
* CONFIG_TESTING_SMART_NLOOPS: Number of test loops. default 100
* CONFIG_TESTING_SMART_VERBOSE: Verbose output

View File

@ -1,5 +1,5 @@
/****************************************************************************
* examples/smart/smart_main.c
* testing/smart/smart_main.c
*
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -64,11 +64,11 @@
/* Configuration ************************************************************/
/* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But
* an architecture-specific MTD driver can be used instead by defining
* CONFIG_EXAMPLES_SMART_ARCHINIT. In this case, the initialization logic
* CONFIG_TESTING_SMART_ARCHINIT. In this case, the initialization logic
* will call smart_archinitialize() to obtain the MTD driver instance.
*/
#ifndef CONFIG_EXAMPLES_SMART_ARCHINIT
#ifndef CONFIG_TESTING_SMART_ARCHINIT
/* This must exactly match the default configuration in drivers/mtd/rammtd.c */
@ -76,45 +76,45 @@
# define CONFIG_RAMMTD_ERASESIZE 4096
# endif
# ifndef CONFIG_EXAMPLES_SMART_NEBLOCKS
# define CONFIG_EXAMPLES_SMART_NEBLOCKS (256)
# ifndef CONFIG_TESTING_SMART_NEBLOCKS
# define CONFIG_TESTING_SMART_NEBLOCKS (256)
# endif
# define EXAMPLES_SMART_BUFSIZE \
(CONFIG_RAMMTD_ERASESIZE * CONFIG_EXAMPLES_SMART_NEBLOCKS)
# define TESTING_SMART_BUFSIZE \
(CONFIG_RAMMTD_ERASESIZE * CONFIG_TESTING_SMART_NEBLOCKS)
#endif
#ifndef CONFIG_EXAMPLES_SMART_MAXNAME
# define CONFIG_EXAMPLES_SMART_MAXNAME 128
#ifndef CONFIG_TESTING_SMART_MAXNAME
# define CONFIG_TESTING_SMART_MAXNAME 128
#endif
#if CONFIG_EXAMPLES_SMART_MAXNAME > 255
# undef CONFIG_EXAMPLES_SMART_MAXNAME
# define CONFIG_EXAMPLES_SMART_MAXNAME 255
#if CONFIG_TESTING_SMART_MAXNAME > 255
# undef CONFIG_TESTING_SMART_MAXNAME
# define CONFIG_TESTING_SMART_MAXNAME 255
#endif
#ifndef CONFIG_EXAMPLES_SMART_MAXFILE
# define CONFIG_EXAMPLES_SMART_MAXFILE 8192
#ifndef CONFIG_TESTING_SMART_MAXFILE
# define CONFIG_TESTING_SMART_MAXFILE 8192
#endif
#ifndef CONFIG_EXAMPLES_SMART_MAXIO
# define CONFIG_EXAMPLES_SMART_MAXIO 347
#ifndef CONFIG_TESTING_SMART_MAXIO
# define CONFIG_TESTING_SMART_MAXIO 347
#endif
#ifndef CONFIG_EXAMPLES_SMART_MAXOPEN
# define CONFIG_EXAMPLES_SMART_MAXOPEN 512
#ifndef CONFIG_TESTING_SMART_MAXOPEN
# define CONFIG_TESTING_SMART_MAXOPEN 512
#endif
#ifndef CONFIG_EXAMPLES_SMART_MOUNTPT
# define CONFIG_EXAMPLES_SMART_MOUNTPT "/mnt/smart"
#ifndef CONFIG_TESTING_SMART_MOUNTPT
# define CONFIG_TESTING_SMART_MOUNTPT "/mnt/smart"
#endif
#ifndef CONFIG_EXAMPLES_SMART_NLOOPS
# define CONFIG_EXAMPLES_SMART_NLOOPS 100
#ifndef CONFIG_TESTING_SMART_NLOOPS
# define CONFIG_TESTING_SMART_NLOOPS 100
#endif
#ifndef CONFIG_EXAMPLES_SMART_VERBOSE
# define CONFIG_EXAMPLES_SMART_VERBOSE 0
#ifndef CONFIG_TESTING_SMART_VERBOSE
# define CONFIG_TESTING_SMART_VERBOSE 0
#endif
/****************************************************************************
@ -134,13 +134,13 @@ struct smart_filedesc_s
****************************************************************************/
/* Pre-allocated simulated flash */
#ifndef CONFIG_EXAMPLES_SMART_ARCHINIT
static uint8_t g_simflash[EXAMPLES_SMART_BUFSIZE];
#ifndef CONFIG_TESTING_SMART_ARCHINIT
static uint8_t g_simflash[TESTING_SMART_BUFSIZE];
#endif
static uint8_t g_fileimage[CONFIG_EXAMPLES_SMART_MAXFILE];
static struct smart_filedesc_s g_files[CONFIG_EXAMPLES_SMART_MAXOPEN];
static const char g_mountdir[] = CONFIG_EXAMPLES_SMART_MOUNTPT "/";
static uint8_t g_fileimage[CONFIG_TESTING_SMART_MAXFILE];
static struct smart_filedesc_s g_files[CONFIG_TESTING_SMART_MAXOPEN];
static const char g_mountdir[] = CONFIG_TESTING_SMART_MOUNTPT "/";
static int g_nfiles;
static int g_ndeleted;
@ -152,7 +152,7 @@ static struct mallinfo g_mmafter;
* External Functions
****************************************************************************/
#ifdef CONFIG_EXAMPLES_SMART_ARCHINIT
#ifdef CONFIG_TESTING_SMART_ARCHINIT
extern FAR struct mtd_dev_s *smart_archinitialize(void);
#endif
@ -257,7 +257,7 @@ static inline void smart_randname(FAR struct smart_filedesc_s *file)
int i;
dirlen = strlen(g_mountdir);
maxname = CONFIG_EXAMPLES_SMART_MAXNAME - dirlen;
maxname = CONFIG_TESTING_SMART_MAXNAME - dirlen;
namelen = (rand() % maxname) + 1;
alloclen = namelen + dirlen;
@ -286,7 +286,7 @@ static inline void smart_randfile(FAR struct smart_filedesc_s *file)
{
int i;
file->len = (rand() % CONFIG_EXAMPLES_SMART_MAXFILE) + 1;
file->len = (rand() % CONFIG_TESTING_SMART_MAXFILE) + 1;
for (i = 0; i < file->len; i++)
{
g_fileimage[i] = smart_randchar();
@ -345,7 +345,7 @@ static inline int smart_wrfile(FAR struct smart_filedesc_s *file)
for (offset = 0; offset < file->len; )
{
size_t maxio = (rand() % CONFIG_EXAMPLES_SMART_MAXIO) + 1;
size_t maxio = (rand() % CONFIG_TESTING_SMART_MAXIO) + 1;
size_t nbytestowrite = file->len - offset;
ssize_t nbyteswritten;
@ -384,7 +384,7 @@ static inline int smart_wrfile(FAR struct smart_filedesc_s *file)
}
else
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf(" Successfully removed partial file\n");
#endif
}
@ -421,7 +421,7 @@ static int smart_fillfs(void)
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_SMART_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_SMART_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name == NULL)
@ -429,13 +429,13 @@ static int smart_fillfs(void)
ret = smart_wrfile(file);
if (ret < 0)
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf("ERROR: Failed to write file %d\n", i);
#endif
return ERROR;
}
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf(" Created file %s\n", file->name);
#endif
g_nfiles++;
@ -452,7 +452,7 @@ static int smart_fillfs(void)
static ssize_t smart_rdblock(int fd, FAR struct smart_filedesc_s *file,
size_t offset, size_t len)
{
size_t maxio = (rand() % CONFIG_EXAMPLES_SMART_MAXIO) + 1;
size_t maxio = (rand() % CONFIG_TESTING_SMART_MAXIO) + 1;
ssize_t nbytesread;
if (len > maxio)
@ -575,7 +575,7 @@ static int smart_verifyfs(void)
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_SMART_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_SMART_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL)
@ -585,7 +585,7 @@ static int smart_verifyfs(void)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf("Deleted file %d OK\n", i);
#endif
smart_freefile(file);
@ -604,7 +604,7 @@ static int smart_verifyfs(void)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf("Succesffully read a deleted file\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
@ -616,7 +616,7 @@ static int smart_verifyfs(void)
}
else
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf(" Verifed file %s\n", file->name);
#endif
}
@ -667,7 +667,7 @@ static int smart_delfiles(void)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
if (j >= CONFIG_TESTING_FSTEST_MAXOPEN)
{
j = 0;
}
@ -685,7 +685,7 @@ static int smart_delfiles(void)
}
else
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
file->deleted = true;
@ -709,7 +709,7 @@ static int smart_delallfiles(void)
int ret;
int i;
for (i = 0; i < CONFIG_EXAMPLES_SMART_MAXOPEN; i++)
for (i = 0; i < CONFIG_TESTING_SMART_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name)
@ -724,7 +724,7 @@ static int smart_delallfiles(void)
}
else
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
smart_freefile(file);
@ -749,14 +749,14 @@ static int smart_directory(void)
/* Open the directory */
dirp = opendir(CONFIG_EXAMPLES_SMART_MOUNTPT);
dirp = opendir(CONFIG_TESTING_SMART_MOUNTPT);
if (!dirp)
{
/* Failed to open the directory */
printf("ERROR: Failed to open directory '%s': %d\n",
CONFIG_EXAMPLES_SMART_MOUNTPT, errno);
CONFIG_TESTING_SMART_MOUNTPT, errno);
return ERROR;
}
@ -807,10 +807,10 @@ int smart_main(int argc, char *argv[])
/* Create and initialize a RAM MTD device instance */
#ifdef CONFIG_EXAMPLES_SMART_ARCHINIT
#ifdef CONFIG_TESTING_SMART_ARCHINIT
mtd = smart_archinitialize();
#else
mtd = rammtd_initialize(g_simflash, EXAMPLES_SMART_BUFSIZE);
mtd = rammtd_initialize(g_simflash, TESTING_SMART_BUFSIZE);
#endif
if (!mtd)
{
@ -840,7 +840,7 @@ int smart_main(int argc, char *argv[])
/* Mount the file system */
ret = mount("/dev/smart1", CONFIG_EXAMPLES_SMART_MOUNTPT, "smartfs", 0, NULL);
ret = mount("/dev/smart1", CONFIG_TESTING_SMART_MOUNTPT, "smartfs", 0, NULL);
if (ret < 0)
{
printf("ERROR: Failed to mount the SMART volume: %d\n", errno);
@ -863,10 +863,10 @@ int smart_main(int argc, char *argv[])
* delete, etc. This beats the FLASH very hard!
*/
#if CONFIG_EXAMPLES_SMART_NLOOPS == 0
#if CONFIG_TESTING_SMART_NLOOPS == 0
for (i = 0; ; i++)
#else
for (i = 1; i <= CONFIG_EXAMPLES_SMART_NLOOPS; i++)
for (i = 1; i <= CONFIG_TESTING_SMART_NLOOPS; i++)
#endif
{
/* Write a files to the SMART file system until either (1) all of the
@ -895,7 +895,7 @@ int smart_main(int argc, char *argv[])
}
else
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
@ -934,7 +934,7 @@ int smart_main(int argc, char *argv[])
}
else
{
#if CONFIG_EXAMPLES_SMART_VERBOSE != 0
#if CONFIG_TESTING_SMART_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);

View File

@ -3,7 +3,7 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_SMART_TEST
config TESTING_SMART_TEST
tristate "SMART filesystem test tool"
default n
depends on NSH_BUILTIN_APPS
@ -12,5 +12,5 @@ config EXAMPLES_SMART_TEST
seek, append and seek-with-write operations. This test can be built
only as an NSH command
if EXAMPLES_SMART_TEST
if TESTING_SMART_TEST
endif

View File

@ -1,5 +1,5 @@
############################################################################
# apps/examples/smart_test/Make.defs
# apps/testing/smart_test/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
@ -34,6 +34,6 @@
#
############################################################################
ifneq ($(CONFIG_EXAMPLES_SMART_TEST),)
CONFIGURED_APPS += examples/smart_test
ifneq ($(CONFIG_TESTING_SMART_TEST),)
CONFIGURED_APPS += testing/smart_test
endif

View File

@ -53,6 +53,6 @@ MAINSRC = smart_test.c
CONFIG_XYZ_PROGNAME ?= smart_test$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
MODULE = CONFIG_EXAMPLES_SMART_TEST
MODULE = CONFIG_TESTING_SMART_TEST
include $(APPDIR)/Application.mk

View File

@ -0,0 +1,27 @@
README
======
Performs a file-based test on a SMART (or any) filesystem. Validates
seek, append and seek-with-write operations.
* CONFIG_TESTING_SMART_TEST=y
Dependencies:
* CONFIG_NSH_BUILTIN_APPS=y: This test can be built only as an NSH
command
Source: NuttX
Author: Ken Pettit
Date: April 24, 2013
Performs a file-based test on a SMART (or any) filesystem. Validates seek,
append and seek-with-write operations.
Usage:
flash_test mtdblock_device
Additional options:
--force to replace existing installation

View File

@ -535,6 +535,7 @@ static int smart_circular_log_test(char *filename)
* Description: Displays usage information for the command.
*
****************************************************************************/
static void smart_usage(void)
{
fprintf(stderr, "usage: smart_test [-c COUNT] [-s SEEKCOUNT] [-w WRITECOUNT] smart_mounted_filename\n\n");