From 6fed43eabc0e78606cf80439c536a00be18fd743 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 2 Aug 2011 14:24:59 +0000 Subject: 2011-08-02 Xiang Cui * configure.ac, fserror/test.c, fslink/test.c, fspermission/test.c, fsrdwr/init.c, fssymlink/test.c, fstime/test.c, mdosfs_support/fs_config.h, mdosfs_support/fs_support.c, mimfs_support/fs_support.c, mrfs_support/fs_config.h, support/fstest.h, support/fstest_support.c, support/ramdisk_support.c, support/ramdisk_support.h: Perform first phase of clean up. --- testsuites/fstests/support/fstest.h | 6 +- testsuites/fstests/support/fstest_support.c | 98 ++++++++++++++-------------- testsuites/fstests/support/ramdisk_support.c | 49 +++++++------- testsuites/fstests/support/ramdisk_support.h | 2 +- 4 files changed, 78 insertions(+), 77 deletions(-) (limited to 'testsuites/fstests/support') diff --git a/testsuites/fstests/support/fstest.h b/testsuites/fstests/support/fstest.h index 94bf87b45c..b23a9d0a6b 100644 --- a/testsuites/fstests/support/fstest.h +++ b/testsuites/fstests/support/fstest.h @@ -22,7 +22,9 @@ #define FS_PASS() do {puts("PASS");} while (0) -#define FS_FAIL() do {printf( "FAIL %s: %d \n", __FILE__, __LINE__ ); } while (0) +#define FS_FAIL() do {\ + printf( "FAIL %s: %d \n", __FILE__, __LINE__ );\ + } while (0) #define SHOW_MESSAGE(e, func, ...) printf(\ @@ -55,6 +57,6 @@ #define BASE_FOR_TEST "/mnt" -#endif +#endif diff --git a/testsuites/fstests/support/fstest_support.c b/testsuites/fstests/support/fstest_support.c index 4202a1040f..6c678891f7 100644 --- a/testsuites/fstests/support/fstest_support.c +++ b/testsuites/fstests/support/fstest_support.c @@ -8,14 +8,13 @@ * * $Id Exp $ */ - -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include "rtems.h" @@ -24,57 +23,57 @@ #include "fstest.h" -#define TEMP_DIR "waterbuffalo" +#define TEMP_DIR "waterbuffalo" -/* Break out of a chroot() environment in C */ +/* Break out of a chroot() environment in C */ void break_out_of_chroot(void) { - int dir_fd; /* File descriptor to directory */ - struct stat sbuf; /* The stat() buffer */ + int dir_fd; /* File descriptor to directory */ + struct stat sbuf; /* The stat() buffer */ chdir("/"); - if (stat(TEMP_DIR,&sbuf)<0) { - if (errno==ENOENT) { - if (mkdir(TEMP_DIR,0755)<0) { - fprintf(stderr,"Failed to create %s - %s\n", TEMP_DIR, - strerror(errno)); - exit(1); - } - } else { - fprintf(stderr,"Failed to stat %s - %s\n", TEMP_DIR, - strerror(errno)); - exit(1); - } - } else if (!S_ISDIR(sbuf.st_mode)) { - fprintf(stderr,"Error - %s is not a directory!\n",TEMP_DIR); - exit(1); - } - - if ((dir_fd=open(".",O_RDONLY))<0) { - fprintf(stderr,"Failed to open \".\" for reading - %s\n", strerror(errno)); - exit(1); - } - - if (chroot(TEMP_DIR)<0) { - fprintf(stderr,"Failed to chroot to %s - %s\n",TEMP_DIR, - strerror(errno)); - exit(1); - } - - if (fchdir(dir_fd)<0) { - fprintf(stderr,"Failed to fchdir - %s\n", - strerror(errno)); - exit(1); - } - close(dir_fd); - chdir(".."); - chroot("."); + if (stat(TEMP_DIR,&sbuf)<0) { + if (errno==ENOENT) { + if (mkdir(TEMP_DIR,0755)<0) { + fprintf(stderr,"Failed to create %s - %s\n", TEMP_DIR, + strerror(errno)); + exit(1); + } + } else { + fprintf(stderr,"Failed to stat %s - %s\n", TEMP_DIR, + strerror(errno)); + exit(1); + } + } else if (!S_ISDIR(sbuf.st_mode)) { + fprintf(stderr,"Error - %s is not a directory!\n",TEMP_DIR); + exit(1); + } + + if ((dir_fd=open(".",O_RDONLY))<0) { + fprintf(stderr,"Failed to open ""." + " for reading - %s\n", strerror(errno)); + exit(1); + } + + if (chroot(TEMP_DIR)<0) { + fprintf(stderr,"Failed to chroot to %s - %s\n",TEMP_DIR, + strerror(errno)); + exit(1); + } + + if (fchdir(dir_fd)<0) { + fprintf(stderr,"Failed to fchdir - %s\n", + strerror(errno)); + exit(1); + } + close(dir_fd); + chdir(".."); + chroot("."); } - /* * Main entry point of every filesystem test */ @@ -103,5 +102,4 @@ rtems_task Init( puts( "*** END OF FILE SYSTEM TEST ( " FILESYSTEM " ) ***" ); rtems_test_exit(0); - } diff --git a/testsuites/fstests/support/ramdisk_support.c b/testsuites/fstests/support/ramdisk_support.c index dba0b32a4c..79389bb80f 100644 --- a/testsuites/fstests/support/ramdisk_support.c +++ b/testsuites/fstests/support/ramdisk_support.c @@ -15,42 +15,43 @@ #include "ramdisk_support.h" #include "fstest.h" /* - * Ramdisk information + * Ramdisk information */ dev_t dev = 0; -void init_ramdisk(void) +void +init_ramdisk (void) { - int rc=0; - rc =rtems_disk_io_initialize(); - rtems_test_assert( rc == 0 ); - rc =ramdisk_register(RAMDISK_BLOCK_SIZE,RAMDISK_BLOCK_COUNT,\ - false,RAMDISK_PATH,&dev); - rtems_test_assert( rc == 0 ); + int rc = 0; + rc = rtems_disk_io_initialize (); + rtems_test_assert (rc == 0); + rc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT, + false, RAMDISK_PATH, &dev); + rtems_test_assert (rc == 0); } -void del_ramdisk(void ) +void +del_ramdisk (void) { - int rc=0; - rtems_device_major_number major=0; - rtems_device_minor_number minor=0; - rc=rtems_disk_delete (dev); - rtems_test_assert( rc == 0 ); + int rc = 0; + rtems_device_major_number major = 0; + rtems_device_minor_number minor = 0; - rtems_filesystem_split_dev_t(dev,major,minor); - - rtems_test_assert(major>=0); - rtems_test_assert(minor>=0); - - rc=rtems_io_unregister_driver(major); - rtems_test_assert( rc == 0 ); + rc = rtems_disk_delete (dev); + rtems_test_assert (rc == 0); - rc=rtems_disk_io_done(); - rtems_test_assert( rc == 0 ); + rtems_filesystem_split_dev_t (dev, major, minor); -} + rtems_test_assert (major >= 0); + rtems_test_assert (minor >= 0); + + rc = rtems_io_unregister_driver (major); + rtems_test_assert (rc == 0); + rc = rtems_disk_io_done (); + rtems_test_assert (rc == 0); +} diff --git a/testsuites/fstests/support/ramdisk_support.h b/testsuites/fstests/support/ramdisk_support.h index 82f732f539..7c06c1e896 100644 --- a/testsuites/fstests/support/ramdisk_support.h +++ b/testsuites/fstests/support/ramdisk_support.h @@ -13,7 +13,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" -#endif +#endif #define RAMDISK_BLOCK_SIZE (512) #define RAMDISK_BLOCK_COUNT (1024) -- cgit v1.2.3