diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-08-01 21:54:19 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2011-08-01 21:54:19 +0000 |
commit | a7c39d3d3fb4a529b29d432b81769617093965d8 (patch) | |
tree | d63d59fe676604f9095b3b742a1759c28d220f68 /testsuites/fstests/fspatheval | |
parent | 2011-08-01 Xiang Cui <medivhc@gmail.com> (diff) | |
download | rtems-a7c39d3d3fb4a529b29d432b81769617093965d8.tar.bz2 |
2011-08-01 Xiang Cui <medivhc@gmail.com>
* imfs_fslink/Makefile.am, imfs_fssymlink/Makefile.am,
mimfs_fslink/Makefile.am, mimfs_fssymlink/Makefile.am,
mrfs_fslink/Makefile.am, mrfs_fssymlink/Makefile.am,
mrfs_support/fs_config.h: Correcting from previous commit of
incorrect tarball.
* fserror/fserror.doc, fserror/test.c, fspatheval/patheval.doc,
fspatheval/test.c, fspermission/fspermission.doc,
fspermission/test.c, fsrdwr/fsrdwr.doc, fsrdwr/init.c,
fstime/fstime.doc, fstime/test.c, imfs_fserror/.cvsignore,
imfs_fserror/Makefile.am, imfs_fslink/.cvsignore,
imfs_fspatheval/.cvsignore, imfs_fspatheval/Makefile.am,
imfs_fspermission/.cvsignore, imfs_fspermission/Makefile.am,
imfs_fsrdwr/.cvsignore, imfs_fsrdwr/Makefile.am,
imfs_fssymlink/.cvsignore, imfs_fstime/.cvsignore,
imfs_fstime/Makefile.am, imfs_support/fs_supprot.h,
mdosfs_fserror/.cvsignore, mdosfs_fserror/Makefile.am,
mdosfs_fspatheval/.cvsignore, mdosfs_fspatheval/Makefile.am,
mdosfs_fsrdwr/.cvsignore, mdosfs_fsrdwr/Makefile.am,
mdosfs_fstime/.cvsignore, mdosfs_fstime/Makefile.am,
mimfs_fserror/.cvsignore, mimfs_fserror/Makefile.am,
mimfs_fslink/.cvsignore, mimfs_fspatheval/.cvsignore,
mimfs_fspatheval/Makefile.am, mimfs_fspermission/.cvsignore,
mimfs_fspermission/Makefile.am, mimfs_fsrdwr/.cvsignore,
mimfs_fsrdwr/Makefile.am, mimfs_fssymlink/.cvsignore,
mimfs_fstime/.cvsignore, mimfs_fstime/Makefile.am,
mrfs_fserror/.cvsignore, mrfs_fserror/Makefile.am,
mrfs_fslink/.cvsignore, mrfs_fspatheval/.cvsignore,
mrfs_fspatheval/Makefile.am, mrfs_fspermission/.cvsignore,
mrfs_fspermission/Makefile.am, mrfs_fsrdwr/.cvsignore,
mrfs_fsrdwr/Makefile.am, mrfs_fssymlink/.cvsignore,
mrfs_fstime/.cvsignore, mrfs_fstime/Makefile.am: New files.
Diffstat (limited to 'testsuites/fstests/fspatheval')
-rw-r--r-- | testsuites/fstests/fspatheval/patheval.doc | 26 | ||||
-rw-r--r-- | testsuites/fstests/fspatheval/test.c | 187 |
2 files changed, 213 insertions, 0 deletions
diff --git a/testsuites/fstests/fspatheval/patheval.doc b/testsuites/fstests/fspatheval/patheval.doc new file mode 100644 index 0000000000..cd031ad4b1 --- /dev/null +++ b/testsuites/fstests/fspatheval/patheval.doc @@ -0,0 +1,26 @@ +# +# $Id$ +# +# COPYRIGHT (c) 1989-2009. +# On-Line Applications Research Corporation (OAR). +# +# The license and distribution terms for this file may be +# found in the file LICENSE in this distribution or at +# http://www.rtems.com/license/LICENSE. +# + +This file describes the directives and concepts tested by this test set. + +test set name: fspatheval + +directives: + ++ open ++ unlink ++ mkdir ++ rmdir + +concepts: + ++ Create directories and files to check the path evaluation + diff --git a/testsuites/fstests/fspatheval/test.c b/testsuites/fstests/fspatheval/test.c new file mode 100644 index 0000000000..ffe0a311fa --- /dev/null +++ b/testsuites/fstests/fspatheval/test.c @@ -0,0 +1,187 @@ +/* + * COPYRIGHT (c) 1989-2011. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id Exp $ + */ +#include <sys/stat.h> +#include <fcntl.h> +#include <errno.h> +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#include "fstest.h" + +#define BUF_SIZE 100 + +void make_multiple_files (char **files,int is_directory) +{ + int i; + int status; + int fd; + + i = 0; + if (is_directory){ + while (files[i]) { + printf ("Making directory %s\n", files[i]); + status = mkdir (files[i], S_IRWXU); + rtems_test_assert (!status); + i++; + } + }else { + while (files[i]) { + printf ("Create file %s\n", files[i]); + fd=creat(files[i],S_IRWXU); + status=close(fd); + rtems_test_assert (!status); + i++; + } + } + + puts (""); +} + +void remove_multiple_files (char **files,int is_directory) +{ + int i; + int status; + + i = 0; + while (files[i]) { + i++; + } + + if (is_directory){ + while (i) { + i--; + printf ("Removing directory %s\n", files[i]); + status = rmdir (files[i]); + rtems_test_assert (!status); + } + }else { + while (i) { + i--; + printf ("Removing file %s\n", files[i]); + status = unlink (files[i]); + rtems_test_assert (!status); + } + } + + puts (""); +} + +void path_eval_test01 (void) +{ + char *valid_path[] = { + "/test1/", + "tets2", + "///test3", + "test4////", + "../../test5", + "/test1/../test6", + "./test7/", + ".././test8", + "test8/./../test9", + "///test9/../test10", + 0 + }; + char *valid_file[]={ + "/test1", + "tets2", + "///test3", + "test4", + "../../test5", + "/../test6", + "./test7", + ".././test8", + "/./../test9", + "//../test10", + 0 + }; + + char *valid_relative_path[]={ + "test1", + "tets2", + "test3", + "test4", + "test5", + "test6", + "test7", + "test8", + "test9", + "test10", + 0 + + }; + + char *valid_name[] = { + "!#$%&()-@^_`{}~'", + "0_1_A", + "aaa bbb", + "ccc....ddd", + " fff", + 0 + }; + + + make_multiple_files(valid_path,1); + make_multiple_files (valid_name,1); + + remove_multiple_files(valid_relative_path,1); + remove_multiple_files(valid_name,1); + + make_multiple_files(valid_file,0); + make_multiple_files (valid_name,0); + + remove_multiple_files(valid_relative_path,0); + remove_multiple_files(valid_name,0); + +} +void path_eval_test02(void ) +{ + + int status; + char buf[BUF_SIZE]; + char* cwd; + + mode_t mode = S_IRWXU|S_IRWXG|S_IRWXO; + puts("mkdir /tmp/a/b"); + status=mkdir("/tmp",mode); + rtems_test_assert(status==0); + status=mkdir("/tmp/a",mode); + rtems_test_assert(status==0); + status=mkdir("/tmp/a/b",mode); + rtems_test_assert(status==0); + + cwd=getcwd(buf,BUF_SIZE); + rtems_test_assert(cwd!=NULL); + + puts("cd /tmp"); + status=chdir("/tmp"); + rtems_test_assert(status==0); + + status=chdir("a/b"); + rtems_test_assert(status==0); + + status=chdir("../b"); + rtems_test_assert(status==0); + + status=chdir("../b/."); + rtems_test_assert(status==0); + +} + +void test (void ) +{ + puts( "\n\n*** PATH EVALUATION TEST ***" ); + path_eval_test01(); + path_eval_test02(); + puts( "*** END OF PATH EVALUATION TEST ***" ); +} |