source: rtems/testsuites/fstests/fsimfsconfig01/init.c @ acc9d064

Last change on this file since acc9d064 was acc9d064, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 26, 2017 at 11:59:10 AM

tests: Remove obsolete TESTS_USE_PRINTK

Update #3170.
Update #3199.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 * Copyright (c) 2015 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifdef HAVE_CONFIG_H
16  #include "config.h"
17#endif
18
19#define TEST_INIT
20
21#include "tmacros.h"
22
23#include <sys/stat.h>
24#include <dirent.h>
25#include <errno.h>
26#include <fcntl.h>
27#include <stdio.h>
28#include <unistd.h>
29#include <utime.h>
30
31#include <rtems/imfs.h>
32#include <rtems/libio.h>
33
34const char rtems_test_name[] = "FSIMFSCONFIG 1";
35
36static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER(
37  &rtems_filesystem_handlers_default,
38  IMFS_node_initialize_generic,
39  IMFS_node_destroy_default
40);
41
42static void Init(rtems_task_argument arg)
43{
44  struct utimbuf times;
45  const char *generic = "generic";
46  const char *mnt = "mnt";
47  const char *dev = "device";
48  const char *file = "file";
49  const char *fifo = "fifo";
50  int rv;
51  int fd;
52  DIR *dirp;
53  struct dirent *dire;
54  struct stat st;
55
56  TEST_BEGIN();
57
58  rv = IMFS_make_generic_node(
59    generic,
60    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
61    &node_control,
62    NULL
63  );
64  rtems_test_assert(rv == 0);
65
66  errno = 0;
67  rv = chown(generic, 0, 0);
68  rtems_test_assert(rv == -1);
69  rtems_test_assert(errno == ENOTSUP);
70
71  errno = 0;
72  rv = chmod(generic, 0);
73  rtems_test_assert(rv == -1);
74  rtems_test_assert(errno == ENOTSUP);
75
76  errno = 0;
77  rv = link(generic, "link");
78  rtems_test_assert(rv == -1);
79  rtems_test_assert(errno == ENOTSUP);
80
81  rv = mkdir(mnt, S_IRWXU);
82  rtems_test_assert(rv == 0);
83
84  rv = mknod(dev, S_IFCHR | S_IRWXU, 0);
85  rtems_test_assert(rv == 0);
86
87  errno = 0;
88  fd = creat(file, S_IRWXU);
89  rtems_test_assert(fd == -1);
90  rtems_test_assert(errno == ENOSYS);
91
92  errno = 0;
93  rv = mkfifo(fifo, S_IRWXU);
94  rtems_test_assert(rv == -1);
95  rtems_test_assert(errno == ENOSYS);
96
97  dirp = opendir(mnt);
98  rtems_test_assert(dirp != NULL);
99
100  errno = 0;
101  dire = readdir(dirp);
102  rtems_test_assert(dire == NULL);
103  rtems_test_assert(errno == ENOTSUP);
104
105  rv = closedir(dirp);
106  rtems_test_assert(rv == 0);
107
108  rv = stat(mnt, &st);
109  rtems_test_assert(rv == 0);
110  rtems_test_assert(st.st_size == 0);
111
112  errno = 0;
113  rv = mount(
114    "",
115    mnt,
116    RTEMS_FILESYSTEM_TYPE_IMFS,
117    RTEMS_FILESYSTEM_READ_ONLY,
118    NULL
119  );
120  rtems_test_assert(rv == -1);
121  rtems_test_assert(errno == ENOTSUP);
122
123  errno = 0;
124  rv = rename(generic, "new");
125  rtems_test_assert(rv == -1);
126  rtems_test_assert(errno == ENOTSUP);
127
128  errno = 0;
129  rv = symlink(generic, "link");
130  rtems_test_assert(rv == -1);
131  rtems_test_assert(errno == ENOTSUP);
132
133  errno = 0;
134  rv = utime(generic, &times);
135  rtems_test_assert(rv == -1);
136  rtems_test_assert(errno == ENOTSUP);
137
138  errno = 0;
139  rv = unlink(generic);
140  rtems_test_assert(rv == -1);
141  rtems_test_assert(errno == ENOTSUP);
142
143  TEST_END();
144  rtems_test_exit(0);
145}
146
147#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
148
149#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 4
150
151#define CONFIGURE_FILESYSTEM_IMFS
152
153#define CONFIGURE_IMFS_DISABLE_CHOWN
154#define CONFIGURE_IMFS_DISABLE_CHMOD
155#define CONFIGURE_IMFS_DISABLE_LINK
156
157#if 0
158/*
159 * This would lead to a fatal error since rtems_filesystem_initialize() creates
160 * a "/dev" directory.
161 */
162#define CONFIGURE_IMFS_DISABLE_MKNOD
163#endif
164
165#define CONFIGURE_IMFS_DISABLE_MKNOD_FILE
166#define CONFIGURE_IMFS_DISABLE_MOUNT
167#define CONFIGURE_IMFS_DISABLE_RENAME
168#define CONFIGURE_IMFS_DISABLE_READDIR
169#define CONFIGURE_IMFS_DISABLE_RMNOD
170#define CONFIGURE_IMFS_DISABLE_SYMLINK
171#define CONFIGURE_IMFS_DISABLE_UTIME
172
173#define CONFIGURE_MAXIMUM_TASKS 1
174
175#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
176
177#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
178
179#define CONFIGURE_INIT
180
181#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.