From 858e013f5aa4f41bc6da7b22368044b4bae7d7ed Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 1 Aug 2011 20:54:15 +0000 Subject: 2011-08-01 Xiang Cui * Makefile.am, configure.ac, fslink/fslink.doc, fslink/test.c, fssymlink/test.c, imfs_fslink/Makefile.am, imfs_fssymlink/Makefile.am, imfs_support/fs_config.h, imfs_support/fs_support.c, mdosfs_support/fs_config.h, mdosfs_support/fs_support.c, mimfs_fslink/Makefile.am, mimfs_fssymlink/Makefile.am, mimfs_support/fs_config.h, mimfs_support/fs_support.c, mrfs_fslink/Makefile.am, mrfs_fssymlink/Makefile.am, mrfs_support/fs_config.h, mrfs_support/fs_support.c, support/fstest.h, support/fstest_support.c, support/fstest_support.h, support/ramdisk_support.c, support/ramdisk_support.h: Submit correct tarball of current work. * fs01/init.c, fsfchx/fsfchx.doc, fsfchx/init.c, fsfile01/fsfile01.doc, fsfile01/test.c, fsfile01/test_cat.c, fsfile01/test_extend.c, fsfile01/test_write.c, fsfile02/fsfile02.doc, fsfile02/init.c, fsfstest/fs-test.c, fsfstest/fsfstest.doc, fsimfs01/fsimfs01.doc, fsimfs01/init.c, fsimfs02/fsimfs02.doc, fsimfs02/init.c, fsmkdir/fsmkdir.doc, fsmkdir/test.c, fsopen/fsopen.doc, fsopen/test.c, fsrdwrv/fsrdwrv.doc, fsrdwrv/test.c, fsreaddir/fsreaddir.doc, fsreaddir/test.c, fsrename/fsrename.doc, fsrename/test.c, fsrmdir/test.c, fsrwfile/fsrwfile.doc, fsrwfile/init.c, fsstat/fsstat.doc, fsstat/test.c, fstruncate/fstruncate.doc, fstruncate/test.c, imfs_fs01/.cvsignore, imfs_fs01/Makefile.am, imfs_fs01/imfs_fs01.scn, imfs_fsfchx/.cvsignore, imfs_fsfchx/Makefile.am, imfs_fsfile01/.cvsignore, imfs_fsfile01/Makefile.am, imfs_fsfile02/.cvsignore, imfs_fsfile02/Makefile.am, imfs_fsfstest/.cvsignore, imfs_fsfstest/Makefile.am, imfs_fsimfs01/.cvsignore, imfs_fsimfs01/Makefile.am, imfs_fsimfs02/.cvsignore, imfs_fsimfs02/Makefile.am, imfs_fslink/.cvsignore, imfs_fsmkdir/.cvsignore, imfs_fsmkdir/Makefile.am, imfs_fsopen/.cvsignore, imfs_fsopen/Makefile.am, imfs_fsrdwrv/.cvsignore, imfs_fsrdwrv/Makefile.am, imfs_fsreaddir/.cvsignore, imfs_fsreaddir/Makefile.am, imfs_fsrename/.cvsignore, imfs_fsrename/Makefile.am, imfs_fsrmdir/.cvsignore, imfs_fsrmdir/Makefile.am, imfs_fsrwfile/.cvsignore, imfs_fsrwfile/Makefile.am, imfs_fsstat/.cvsignore, imfs_fsstat/Makefile.am, imfs_fssymlink/.cvsignore, imfs_fstruncate/.cvsignore, imfs_fstruncate/Makefile.am, mdosfs_fsfchx/.cvsignore, mdosfs_fsfchx/Makefile.am, mdosfs_fsfile01/.cvsignore, mdosfs_fsfile01/Makefile.am, mdosfs_fsfile02/.cvsignore, mdosfs_fsfile02/Makefile.am, mdosfs_fsfstest/.cvsignore, mdosfs_fsfstest/Makefile.am, mdosfs_fsimfs01/.cvsignore, mdosfs_fsimfs01/Makefile.am, mdosfs_fsimfs02/.cvsignore, mdosfs_fsimfs02/Makefile.am, mdosfs_fslink/.cvsignore, mdosfs_fslink/Makefile.am, mdosfs_fsmkdir/.cvsignore, mdosfs_fsmkdir/Makefile.am, mdosfs_fsopen/.cvsignore, mdosfs_fsopen/Makefile.am, mdosfs_fsrdwrv/.cvsignore, mdosfs_fsrdwrv/Makefile.am, mdosfs_fsreaddir/.cvsignore, mdosfs_fsreaddir/Makefile.am, mdosfs_fsrename/.cvsignore, mdosfs_fsrename/Makefile.am, mdosfs_fsrmdir/.cvsignore, mdosfs_fsrmdir/Makefile.am, mdosfs_fsrwfile/.cvsignore, mdosfs_fsrwfile/Makefile.am, mdosfs_fsstat/.cvsignore, mdosfs_fsstat/Makefile.am, mdosfs_fssymlink/.cvsignore, mdosfs_fssymlink/Makefile.am, mdosfs_fstruncate/.cvsignore, mdosfs_fstruncate/Makefile.am, mimfs_fs01/.cvsignore, mimfs_fs01/Makefile.am, mimfs_fs01/mimfs_fs01.scn, mimfs_fsfchx/.cvsignore, mimfs_fsfchx/Makefile.am, mimfs_fsfile01/.cvsignore, mimfs_fsfile01/Makefile.am, mimfs_fsfile02/.cvsignore, mimfs_fsfile02/Makefile.am, mimfs_fsfstest/.cvsignore, mimfs_fsfstest/Makefile.am, mimfs_fsimfs01/.cvsignore, mimfs_fsimfs01/Makefile.am, mimfs_fsimfs02/.cvsignore, mimfs_fsimfs02/Makefile.am, mimfs_fslink/.cvsignore, mimfs_fsmkdir/.cvsignore, mimfs_fsmkdir/Makefile.am, mimfs_fsopen/.cvsignore, mimfs_fsopen/Makefile.am, mimfs_fsrdwrv/.cvsignore, mimfs_fsrdwrv/Makefile.am, mimfs_fsreaddir/.cvsignore, mimfs_fsreaddir/Makefile.am, mimfs_fsrename/.cvsignore, mimfs_fsrename/Makefile.am, mimfs_fsrmdir/.cvsignore, mimfs_fsrmdir/Makefile.am, mimfs_fsrwfile/.cvsignore, mimfs_fsrwfile/Makefile.am, mimfs_fsstat/.cvsignore, mimfs_fsstat/Makefile.am, mimfs_fssymlink/.cvsignore, mimfs_fstruncate/.cvsignore, mimfs_fstruncate/Makefile.am, mrfs_fsfchx/.cvsignore, mrfs_fsfchx/Makefile.am, mrfs_fsfile01/.cvsignore, mrfs_fsfile01/Makefile.am, mrfs_fsfile02/.cvsignore, mrfs_fsfile02/Makefile.am, mrfs_fsfstest/.cvsignore, mrfs_fsfstest/Makefile.am, mrfs_fsimfs01/.cvsignore, mrfs_fsimfs01/Makefile.am, mrfs_fsimfs02/.cvsignore, mrfs_fsimfs02/Makefile.am, mrfs_fslink/.cvsignore, mrfs_fsmkdir/.cvsignore, mrfs_fsmkdir/Makefile.am, mrfs_fsopen/.cvsignore, mrfs_fsopen/Makefile.am, mrfs_fsrdwrv/.cvsignore, mrfs_fsrdwrv/Makefile.am, mrfs_fsreaddir/.cvsignore, mrfs_fsreaddir/Makefile.am, mrfs_fsrename/.cvsignore, mrfs_fsrename/Makefile.am, mrfs_fsrmdir/.cvsignore, mrfs_fsrmdir/Makefile.am, mrfs_fsrwfile/.cvsignore, mrfs_fsrwfile/Makefile.am, mrfs_fsstat/.cvsignore, mrfs_fsstat/Makefile.am, mrfs_fssymlink/.cvsignore, mrfs_fstruncate/.cvsignore, mrfs_fstruncate/Makefile.am: Removed. --- testsuites/fstests/fslink/fslink.doc | 6 +- testsuites/fstests/fslink/test.c | 261 ++++++++++++----------------------- 2 files changed, 93 insertions(+), 174 deletions(-) (limited to 'testsuites/fstests/fslink') diff --git a/testsuites/fstests/fslink/fslink.doc b/testsuites/fstests/fslink/fslink.doc index 93b256c1f9..008e671130 100644 --- a/testsuites/fstests/fslink/fslink.doc +++ b/testsuites/fstests/fslink/fslink.doc @@ -15,10 +15,8 @@ test set name: fslink directives: -+ link -+ chmod -+ chown - ++link ++stat concepts: diff --git a/testsuites/fstests/fslink/test.c b/testsuites/fstests/fslink/test.c index 50ec89d48a..a9df8ffd4b 100644 --- a/testsuites/fstests/fslink/test.c +++ b/testsuites/fstests/fslink/test.c @@ -1,4 +1,3 @@ - /* * COPYRIGHT (c) 1989-2011. * On-Line Applications Research Corporation (OAR). @@ -23,215 +22,137 @@ #include "fstest.h" -mode_t mode = 0644; /* * Test if the successful call works as expect */ -void link_test01(void ) +void link_test01 (void) { - char *name0="t0"; - char *name1="t1"; - char *name2="t2"; - char *name3="t3"; + char *name0 = "t0"; + char *name1 = "t1"; + char *name2 = "t2"; + int status; int fd; + mode_t mode = 0644; struct stat statbuf; - mode_t tmp_mode; - - time_t ctime1,dctime1,dmtime1; - time_t ctime2,dctime2,dmtime2; - - puts("link creates hardlinks"); - - status=mkdir(name3,0755); - rtems_test_assert(status==0); - - status=chdir(name3); - rtems_test_assert(status==0); - fd=creat(name0,mode); - status=close(fd); - rtems_test_assert(status==0); - - status=stat(name0,&statbuf); - rtems_test_assert(status==0); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0644); - rtems_test_assert(statbuf.st_nlink==1); - printf("the arg is %04o and the is %04o \n",tmp_mode,mode); - puts("test if the stat is the same"); - status=link(name0,name1); - rtems_test_assert(status==0); - status=stat(name0,&statbuf); - rtems_test_assert(status==0); + puts ("link creates hardlinks"); + fd = creat (name0, mode); + status = close (fd); + rtems_test_assert (status == 0); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0644); - rtems_test_assert(statbuf.st_nlink==2); + status = stat (name0, &statbuf); + rtems_test_assert (status == 0); + rtems_test_assert (statbuf.st_nlink == 1); - status=stat(name1,&statbuf); - rtems_test_assert(status==0); + puts ("test if the stat is the same"); + status = link (name0, name1); + rtems_test_assert (status == 0); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0644); - rtems_test_assert(statbuf.st_nlink==2); + status = stat (name0, &statbuf); + rtems_test_assert (status == 0); - status=link(name1,name2); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 2); - status=stat(name0,&statbuf); - rtems_test_assert(status==0); - - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0644); - rtems_test_assert(statbuf.st_nlink==3); - - status=stat(name1,&statbuf); - rtems_test_assert(status==0); - - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0644); - rtems_test_assert(statbuf.st_nlink==3); - - - status=stat(name2,&statbuf); - rtems_test_assert(status==0); - - rtems_test_assert(S_ISREG(statbuf.st_mode)); - rtems_test_assert(statbuf.st_nlink==3); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0644); -/* - * call chmod and chown and test. - */ + status = stat (name1, &statbuf); + rtems_test_assert (status == 0); - puts("chmod and chown"); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 2); - chmod(name1,0201); - chown(name1,65534,65533); + /* + * link the file and check the nlink + */ + status = link (name1, name2); + rtems_test_assert (status == 0); + status = stat (name0, &statbuf); + rtems_test_assert (status == 0); - status=stat(name0,&statbuf); - rtems_test_assert(status==0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 3); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - rtems_test_assert(statbuf.st_nlink==3); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0201); - rtems_test_assert(statbuf.st_uid=65534); - rtems_test_assert(statbuf.st_gid=65533); + status = stat (name1, &statbuf); + rtems_test_assert (status == 0); - status=stat(name1,&statbuf); - rtems_test_assert(status==0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 3); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0201); - rtems_test_assert(statbuf.st_nlink==3); - rtems_test_assert(statbuf.st_uid=65534); - rtems_test_assert(statbuf.st_gid=65533); + status = stat (name2, &statbuf); + rtems_test_assert (status == 0); - status=stat(name2,&statbuf); - rtems_test_assert(status==0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 3); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0201); - rtems_test_assert(statbuf.st_nlink==3); - rtems_test_assert(statbuf.st_nlink==3); - rtems_test_assert(statbuf.st_uid=65534); - rtems_test_assert(statbuf.st_gid=65533); -/* - * - * unlink then test if the nlink changes - */ + /* + * call chmod and chown and test. + */ + puts ("chmod and chown"); - puts("unlink then stat the file "); + chown (name1, 65534, 65533); - status=unlink(name0); - rtems_test_assert(status==0); + status = stat (name0, &statbuf); + rtems_test_assert (status == 0); - status=stat(name0,&statbuf); - rtems_test_assert(status==-1); - rtems_test_assert(errno=ENOENT); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 3); + rtems_test_assert (statbuf.st_uid = 65534); + rtems_test_assert (statbuf.st_gid = 65533); + status = stat (name1, &statbuf); + rtems_test_assert (status == 0); - status=stat(name1,&statbuf); - rtems_test_assert(status==0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 3); + rtems_test_assert (statbuf.st_uid = 65534); + rtems_test_assert (statbuf.st_gid = 65533); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0201); - rtems_test_assert(statbuf.st_nlink==2); + status = stat (name2, &statbuf); + rtems_test_assert (status == 0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 3); + rtems_test_assert (statbuf.st_uid = 65534); + rtems_test_assert (statbuf.st_gid = 65533); - status=stat(name2,&statbuf); - rtems_test_assert(status==0); + /* + * + * unlink then test if the nlink changes + */ + puts ("unlink then stat the file "); - rtems_test_assert(S_ISREG(statbuf.st_mode)); - tmp_mode=(statbuf.st_mode)&ALLPERMS; - rtems_test_assert(tmp_mode==0201); - rtems_test_assert(statbuf.st_nlink==2); + status = unlink (name0); + rtems_test_assert (status == 0); + status = stat (name0, &statbuf); + rtems_test_assert (status == -1); + rtems_test_assert (errno = ENOENT); - status=unlink(name1); - rtems_test_assert(status==0); + status = stat (name1, &statbuf); + rtems_test_assert (status == 0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 2); - status=unlink(name2); - rtems_test_assert(status==0); + status = stat (name2, &statbuf); + rtems_test_assert (status == 0); + rtems_test_assert (S_ISREG (statbuf.st_mode)); + rtems_test_assert (statbuf.st_nlink == 2); + status = unlink (name1); + rtems_test_assert (status == 0); - /* - * successful link() updates ctime - * and the ctime and mtime of the - * directory. - */ - fd=creat(name0,0644); - status=close(fd); - rtems_test_assert(status==0); - - status=stat(name0,&statbuf); - ctime1=statbuf.st_ctime; - status=stat(".",&statbuf); - rtems_test_assert(status==0); - dctime1=statbuf.st_ctime; - dmtime1=statbuf.st_mtime; - - puts("sleep a few seconds"); - sleep(TIME_PRECISION ); - - status=link(name0,name1); - rtems_test_assert(status==0); - status=stat(name0,&statbuf); - ctime2=statbuf.st_ctime; - status=stat(".",&statbuf); - dctime2=statbuf.st_ctime; - dmtime2=statbuf.st_mtime; - - puts("test if the time changes"); - rtems_test_assert(!time_equal(ctime1,ctime2)); -#if !defined(IMFS_TEST) && !defined(MIMFS_TEST) - rtems_test_assert(!time_equal(dctime1,dctime2)); -#endif -#if !defined(IMFS_TEST) && !defined(MIMFS_TEST) - rtems_test_assert(!time_equal(dmtime1,dmtime2)); -#endif + status = unlink (name2); + rtems_test_assert (status == 0); } -void test(void) + +void test (void) { - puts( "\n\n*** LINK TEST ***" ); -#if defined(MDOSFS_TEST) -#else - link_test01(); -#endif - puts( "*** END OF LINK TEST ***" ); + puts ("\n\n*** LINK TEST ***"); + link_test01 (); + puts ("*** END OF LINK TEST ***"); } - -- cgit v1.2.3