summaryrefslogtreecommitdiffstats
path: root/testsuites/fstests/fslink
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2011-08-01 14:29:54 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2011-08-01 14:29:54 +0000
commit7336d4af629928eb8549d8d817fc76c1124188d9 (patch)
tree7f0603745cc7e78a6b0f7238ab32b6294e681a4f /testsuites/fstests/fslink
parent2011-08-01 Jennifer Averett <Jennifer.Averett@OARcorp.com> (diff)
downloadrtems-7336d4af629928eb8549d8d817fc76c1124188d9.tar.bz2
2011-08-01 Xiang Cui <medivhc@gmail.com>
* Makefile.am, configure.ac, imfs_support/fs_config.h, imfs_support/fs_support.c, mimfs_support/fs_config.h, mimfs_support/fs_support.c: Add initial version of new filesystem tests. There are multiple failures which need to be addressed by the community. * 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, fslink/fslink.doc, fslink/test.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, fssymlink/fssymlink.doc, fssymlink/test.c, fstruncate/fstruncate.doc, fstruncate/test.c, 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_fslink/Makefile.am, 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_fssymlink/Makefile.am, 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, mdosfs_support/fs_config.h, mdosfs_support/fs_support.c, 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_fslink/Makefile.am, 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_fssymlink/Makefile.am, 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_fslink/Makefile.am, 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_fssymlink/Makefile.am, mrfs_fstruncate/.cvsignore, mrfs_fstruncate/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: New files.
Diffstat (limited to 'testsuites/fstests/fslink')
-rw-r--r--testsuites/fstests/fslink/fslink.doc26
-rw-r--r--testsuites/fstests/fslink/test.c237
2 files changed, 263 insertions, 0 deletions
diff --git a/testsuites/fstests/fslink/fslink.doc b/testsuites/fstests/fslink/fslink.doc
new file mode 100644
index 0000000000..93b256c1f9
--- /dev/null
+++ b/testsuites/fstests/fslink/fslink.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: fslink
+
+directives:
+
++ link
++ chmod
++ chown
+
+
+concepts:
+
++ Exercise successful link operation
+
diff --git a/testsuites/fstests/fslink/test.c b/testsuites/fstests/fslink/test.c
new file mode 100644
index 0000000000..50ec89d48a
--- /dev/null
+++ b/testsuites/fstests/fslink/test.c
@@ -0,0 +1,237 @@
+
+/*
+ * 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 <unistd.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <stdint.h>
+#include <math.h>
+
+#include "fstest.h"
+
+mode_t mode = 0644;
+/*
+ * Test if the successful call works as expect
+ */
+void link_test01(void )
+{
+ char *name0="t0";
+ char *name1="t1";
+ char *name2="t2";
+ char *name3="t3";
+
+ int status;
+ int fd;
+
+ 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);
+
+ 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(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==2);
+
+ status=link(name1,name2);
+
+ 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.
+ */
+
+ puts("chmod and chown");
+
+ chmod(name1,0201);
+ chown(name1,65534,65533);
+
+
+ status=stat(name0,&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==0201);
+ rtems_test_assert(statbuf.st_uid=65534);
+ rtems_test_assert(statbuf.st_gid=65533);
+
+ 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==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);
+
+ 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
+ */
+
+ puts("unlink then stat the file ");
+
+ status=unlink(name0);
+ rtems_test_assert(status==0);
+
+ status=stat(name0,&statbuf);
+ rtems_test_assert(status==-1);
+ rtems_test_assert(errno=ENOENT);
+
+
+ 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==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));
+ tmp_mode=(statbuf.st_mode)&ALLPERMS;
+ rtems_test_assert(tmp_mode==0201);
+ rtems_test_assert(statbuf.st_nlink==2);
+
+
+ status=unlink(name1);
+ rtems_test_assert(status==0);
+
+ status=unlink(name2);
+ 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
+
+}
+void test(void)
+{
+ puts( "\n\n*** LINK TEST ***" );
+#if defined(MDOSFS_TEST)
+#else
+ link_test01();
+#endif
+ puts( "*** END OF LINK TEST ***" );
+}
+