From a7c39d3d3fb4a529b29d432b81769617093965d8 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 1 Aug 2011 21:54:19 +0000 Subject: 2011-08-01 Xiang Cui * 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. --- testsuites/fstests/fspatheval/test.c | 187 +++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 testsuites/fstests/fspatheval/test.c (limited to 'testsuites/fstests/fspatheval/test.c') 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 +#include +#include +#include +#include +#include +#include +#include + +#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 ***" ); +} -- cgit v1.2.3