source: rtems/testsuites/libtests/devfs02/init.c @ bb291a4a

5
Last change on this file since bb291a4a was bb291a4a, checked in by Sebastian Huber <sebastian.huber@…>, on 01/18/16 at 08:34:16

libtests/devfs: Inc max dev to support more BSPs

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2012.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  Modifications to support reference counting in the file system are
6 *  Copyright (c) 2012 embedded brains GmbH.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.org/license/LICENSE.
11 */
12
13#ifdef HAVE_CONFIG_H
14  #include "config.h"
15#endif
16
17#include "test_support.h"
18
19#include <tmacros.h>
20#include <errno.h>
21#include <unistd.h>
22#include <sys/types.h>
23#include <sys/stat.h>
24#include <fcntl.h>
25
26#include <rtems/devfs.h>
27#include <rtems/malloc.h>
28
29const char rtems_test_name[] = "DEVFS 2";
30
31/* forward declarations to avoid warnings */
32rtems_task Init(rtems_task_argument argument);
33
34rtems_task Init(
35  rtems_task_argument argument
36)
37{
38  int status;
39  rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
40  const devFS_data *data = rootloc->mt_entry->immutable_fs_info;
41  devFS_data zero_count_data = {
42    .nodes = data->nodes,
43    .count = 0
44  };
45  void *opaque;
46
47  TEST_BEGIN();
48
49  puts( "Init - attempt to create a fifo - expect ENOTSUP" );
50  status = mkfifo( "/fifo01", 0 );
51  rtems_test_assert( status == -1 );
52  rtems_test_assert( errno == ENOTSUP );
53
54  /* Manipulate the device table size */
55  puts( "Init - set device table size to zero" );
56  rootloc->mt_entry->immutable_fs_info = &zero_count_data;
57
58  puts( "Init - attempt to create a node - expect ENOSPC" );
59  status = mknod( "/node", S_IFBLK, 0LL );
60  rtems_test_assert( status == -1 );
61  rtems_test_assert( errno == ENOSPC );
62
63  /* Now restore */
64  puts( "Init - restore device table size" );
65  rootloc->mt_entry->immutable_fs_info = data;
66
67  opaque = rtems_heap_greedy_allocate( NULL, 0 );
68
69  puts( "Init - attempt to create a node - expect ENOMEM" );
70  status = mknod( "/node", S_IFBLK, 0LL );
71  rtems_test_assert( status == -1 );
72  rtems_test_assert( errno == ENOMEM );
73
74  rtems_heap_greedy_free( opaque );
75
76  puts( "Init - attempt to create /node -- OK" );
77  status = mknod( "/node", S_IFBLK, 0LL );
78  rtems_test_assert( status == 0 );
79
80  puts( "Init - attempt to create /node - expect EEXIST" );
81  status = mknod( "/node", S_IFBLK, 0LL );
82  rtems_test_assert( status == -1 );
83  rtems_test_assert( errno == EEXIST );
84
85  TEST_END();
86
87  rtems_test_exit(0);
88}
89
90/* configuration information */
91
92#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
93#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
94
95#define CONFIGURE_MAXIMUM_TASKS             1
96#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
97
98#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
99
100#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
101
102/* Make sure that we have enough devices for all BSPs */
103#define CONFIGURE_MAXIMUM_DEVICES 64
104
105#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
106
107#define CONFIGURE_INIT
108#include <rtems/confdefs.h>
109/* end of file */
Note: See TracBrowser for help on using the repository browser.