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

Last change on this file since caf4064 was caf4064, checked in by Sebastian Huber <sebastian.huber@…>, on Sep 16, 2016 at 12:54:12 PM

fstests: Use printk() for IMFS configuration tests

This avoids problems with console drivers that require a more complete
IMFS.

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