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

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

tests: Remove TEST_INIT

The TEST_EXTERN is a used only by the system.h style tests and they use
CONFIGURE_INIT appropriately.

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