source: rtems/testsuites/fstests/fsimfsconfig01/init.c @ 98c6d50

5
Last change on this file since 98c6d50 was 98c6d50, checked in by Chris Johns <chrisj@…>, on 10/19/17 at 05:39:16

testsuite: Use printk for all test output where possible.

  • Remove the printf support leaving the direct printk support configured with TESTS_USE_PRINTK and all other output goes via a buffered vsniprintf call to printk.
  • Control the test's single init for functions and global data with TEST_INIT and not CONFIGURE_INIT. They are now separate.

Updates #3170.

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