source: rtems/testsuites/fstests/fsimfsconfig03/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.0 KB
RevLine 
[12eee4fd]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
[12eee4fd]22#include "tmacros.h"
23
24#include <sys/stat.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 3";
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
53  TEST_BEGIN();
54
55  rv = IMFS_make_generic_node(
56    generic,
57    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
58    &node_control,
59    NULL
60  );
61  rtems_test_assert(rv == 0);
62
63  errno = 0;
64  rv = chown(generic, 0, 0);
65  rtems_test_assert(rv == -1);
66  rtems_test_assert(errno == ENOTSUP);
67
68  errno = 0;
69  rv = chmod(generic, 0);
70  rtems_test_assert(rv == -1);
71  rtems_test_assert(errno == ENOTSUP);
72
73  errno = 0;
74  rv = link(generic, "link");
75  rtems_test_assert(rv == -1);
76  rtems_test_assert(errno == ENOTSUP);
77
78  rv = mkdir(mnt, S_IRWXU);
79  rtems_test_assert(rv == 0);
80
81  rv = mknod(dev, S_IFCHR | S_IRWXU, 0);
82  rtems_test_assert(rv == 0);
83
84  fd = creat(file, S_IRWXU);
[caf4064]85  rtems_test_assert(fd == 0);
[12eee4fd]86
87  rv = close(fd);
88  rtems_test_assert(rv == 0);
89
90  errno = 0;
91  rv = mkfifo(fifo, S_IRWXU);
92  rtems_test_assert(rv == -1);
93  rtems_test_assert(errno == ENOSYS);
94
95  rv = mount(
96    "",
97    mnt,
98    RTEMS_FILESYSTEM_TYPE_IMFS,
99    RTEMS_FILESYSTEM_READ_ONLY,
100    NULL
101  );
102  rtems_test_assert(rv == 0);
103
104  errno = 0;
105  rv = unmount(mnt);
106  rtems_test_assert(rv == -1);
107  rtems_test_assert(errno == ENOTSUP);
108
109  errno = 0;
110  rv = rename(generic, "new");
111  rtems_test_assert(rv == -1);
112  rtems_test_assert(errno == ENOTSUP);
113
114  errno = 0;
115  rv = symlink(generic, "link");
116  rtems_test_assert(rv == -1);
117  rtems_test_assert(errno == ENOTSUP);
118
119  errno = 0;
120  rv = utime(generic, &times);
121  rtems_test_assert(rv == -1);
122  rtems_test_assert(errno == ENOTSUP);
123
124  rv = unlink(generic);
125  rtems_test_assert(rv == 0);
126
127  TEST_END();
128  rtems_test_exit(0);
129}
130
131#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
132
[caf4064]133#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 1
[12eee4fd]134
135#define CONFIGURE_FILESYSTEM_IMFS
136
137#define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
138
139#define CONFIGURE_MAXIMUM_TASKS 1
140
141#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
142
143#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
144
145#define CONFIGURE_INIT
146
147#include <rtems/confdefs.h>
Note: See TracBrowser for help on using the repository browser.