source: rtems/testsuites/libtests/devfs02/init.c @ 4c86e3d

4.115
Last change on this file since 4c86e3d was 4c86e3d, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/12 at 17:20:47

libtmtests - Eliminate missing prototype warnings

  • Property mode set to 100644
File size: 2.7 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.com/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
29/* forward declarations to avoid warnings */
30rtems_task Init(rtems_task_argument argument);
31
32rtems_task Init(
33  rtems_task_argument argument
34)
35{
36  int status;
37  rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
38  const devFS_data *data = rootloc->mt_entry->immutable_fs_info;
39  devFS_data zero_count_data = {
40    .nodes = data->nodes,
41    .count = 0
42  };
43  void *opaque;
44
45  puts( "\n\n*** TEST DEVFS02 ***" );
46
47  puts( "Init - attempt to create a fifo - expect ENOTSUP" );
48  status = mkfifo( "/fifo01", 0 );
49  rtems_test_assert( status == -1 );
50  rtems_test_assert( errno == ENOTSUP );
51
52  /* Manipulate the device table size */
53  puts( "Init - set device table size to zero" );
54  rootloc->mt_entry->immutable_fs_info = &zero_count_data;
55
56  puts( "Init - attempt to create a node - expect ENOSPC" );
57  status = mknod( "/node", S_IFBLK, 0LL );
58  rtems_test_assert( status == -1 );
59  rtems_test_assert( errno == ENOSPC );
60
61  /* Now restore */
62  puts( "Init - restore device table size" );
63  rootloc->mt_entry->immutable_fs_info = data;
64
65  opaque = rtems_heap_greedy_allocate( 0 );
66
67  puts( "Init - attempt to create a node - expect ENOMEM" );
68  status = mknod( "/node", S_IFBLK, 0LL );
69  rtems_test_assert( status == -1 );
70  rtems_test_assert( errno == ENOMEM );
71
72  rtems_heap_greedy_free( opaque );
73
74  puts( "Init - attempt to create /node -- OK" );
75  status = mknod( "/node", S_IFBLK, 0LL );
76  rtems_test_assert( status == 0 );
77
78  puts( "Init - attempt to create /node - expect EEXIST" );
79  status = mknod( "/node", S_IFBLK, 0LL );
80  rtems_test_assert( status == -1 );
81  rtems_test_assert( errno == EEXIST );
82
83  puts( "*** END OF TEST DEVFS02 ***" );
84
85  rtems_test_exit(0);
86}
87
88/* configuration information */
89
90#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
91#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
92
93#define CONFIGURE_MAXIMUM_TASKS             1
94#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
95
96#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5
97
98#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
99
100#define CONFIGURE_INIT
101#include <rtems/confdefs.h>
102/* end of file */
Note: See TracBrowser for help on using the repository browser.