source: rtems/testsuites/libtests/devfs02/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: 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#define TEST_INIT
18
19#include "test_support.h"
20
21#define TESTS_USE_PRINTK
22#include <tmacros.h>
23#include <errno.h>
24#include <unistd.h>
25#include <sys/types.h>
26#include <sys/stat.h>
27#include <fcntl.h>
28
29#include <rtems/devfs.h>
30#include <rtems/malloc.h>
31
32const char rtems_test_name[] = "DEVFS 2";
33
34/* forward declarations to avoid warnings */
35rtems_task Init(rtems_task_argument argument);
36
37rtems_task Init(
38  rtems_task_argument argument
39)
40{
41  int status;
42  rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
43  const devFS_data *data = rootloc->mt_entry->immutable_fs_info;
44  devFS_data zero_count_data = {
45    .nodes = data->nodes,
46    .count = 0
47  };
48  void *opaque;
49
50  TEST_BEGIN();
51
52  puts( "Init - attempt to create a fifo - expect ENOTSUP" );
53  status = mkfifo( "/fifo01", 0 );
54  rtems_test_assert( status == -1 );
55  rtems_test_assert( errno == ENOTSUP );
56
57  /* Manipulate the device table size */
58  puts( "Init - set device table size to zero" );
59  rootloc->mt_entry->immutable_fs_info = &zero_count_data;
60
61  puts( "Init - attempt to create a node - expect ENOSPC" );
62  status = mknod( "/node", S_IFBLK, 0LL );
63  rtems_test_assert( status == -1 );
64  rtems_test_assert( errno == ENOSPC );
65
66  /* Now restore */
67  puts( "Init - restore device table size" );
68  rootloc->mt_entry->immutable_fs_info = data;
69
70  opaque = rtems_heap_greedy_allocate( NULL, 0 );
71
72  puts( "Init - attempt to create a node - expect ENOMEM" );
73  status = mknod( "/node", S_IFBLK, 0LL );
74  rtems_test_assert( status == -1 );
75  rtems_test_assert( errno == ENOMEM );
76
77  rtems_heap_greedy_free( opaque );
78
79  puts( "Init - attempt to create /node -- OK" );
80  status = mknod( "/node", S_IFBLK, 0LL );
81  rtems_test_assert( status == 0 );
82
83  puts( "Init - attempt to create /node - expect EEXIST" );
84  status = mknod( "/node", S_IFBLK, 0LL );
85  rtems_test_assert( status == -1 );
86  rtems_test_assert( errno == EEXIST );
87
88  TEST_END();
89
90  rtems_test_exit(0);
91}
92
93/* configuration information */
94
95#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
96
97#define CONFIGURE_MAXIMUM_TASKS             1
98#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
99
100#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
101
102#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 2
103
104/* Make sure that we have enough devices for all BSPs */
105#define CONFIGURE_MAXIMUM_DEVICES 64
106
107#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
108
109#define CONFIGURE_INIT
110#include <rtems/confdefs.h>
111/* end of file */
Note: See TracBrowser for help on using the repository browser.