summaryrefslogtreecommitdiffstats
path: root/testsuites/psxtests/psximfs02/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuites/psxtests/psximfs02/init.c')
-rw-r--r--testsuites/psxtests/psximfs02/init.c55
1 files changed, 51 insertions, 4 deletions
diff --git a/testsuites/psxtests/psximfs02/init.c b/testsuites/psxtests/psximfs02/init.c
index 15b9137121..1d196aa6ba 100644
--- a/testsuites/psxtests/psximfs02/init.c
+++ b/testsuites/psxtests/psximfs02/init.c
@@ -1,10 +1,29 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
/*
* COPYRIGHT (c) 1989-2015.
* On-Line Applications Research Corporation (OAR).
*
- * The license and distribution terms for this file may be
- * found in the file LICENSE in this distribution or at
- * http://www.rtems.org/license/LICENSE.
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
@@ -23,6 +42,8 @@
#include <rtems/malloc.h>
#include <rtems/libcsupport.h>
+#define MEMFILE_BYTES_PER_BLOCK 16
+
const char rtems_test_name[] = "PSXIMFS 2";
/* forward declarations to avoid warnings */
@@ -43,12 +64,17 @@ rtems_task Init(
static const uintptr_t slink_2_name_size [] = {
sizeof( slink_2_name )
};
+ static const uintptr_t some_blocks [] = {
+ MEMFILE_BYTES_PER_BLOCK * 10
+ };
+ static const char some_data[MEMFILE_BYTES_PER_BLOCK * 11];
int status = 0;
void *opaque;
char linkname_n[32] = {0};
char linkname_p[32] = {0};
int i;
+ int fd;
struct stat stat_buf;
TEST_BEGIN();
@@ -102,6 +128,27 @@ rtems_task Init(
rtems_test_assert( status == -1 );
rtems_test_assert( errno == EACCES );
+ puts( "Allocate most of heap with a little bit left" );
+ opaque = rtems_heap_greedy_allocate( some_blocks, 1 );
+
+ puts( "Create an empty file.");
+ status = mknod( "/foo", S_IFREG | S_IRWXU, 0LL );
+ rtems_test_assert( status == 0 );
+
+ puts( "Then increase it's size to more than remaining space" );
+ fd = open( "/foo", O_WRONLY | O_TRUNC);
+ rtems_test_assert( fd >= 0 );
+ status = write(fd, some_data, sizeof(some_data));
+ rtems_test_assert( status == -1);
+ rtems_test_assert( errno == ENOSPC );
+
+ puts( "Clean up again" );
+ status = close(fd);
+ rtems_test_assert( status == 0);
+ status = remove( "/foo" );
+ rtems_test_assert( status == 0);
+ rtems_heap_greedy_free( opaque );
+
puts( "Allocate most of heap" );
opaque = rtems_heap_greedy_allocate( mount_table_entry_size, 1 );
@@ -202,7 +249,7 @@ rtems_task Init(
#define CONFIGURE_FILESYSTEM_IMFS
#define CONFIGURE_MAXIMUM_TASKS 1
-#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK 16
+#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK MEMFILE_BYTES_PER_BLOCK
#define CONFIGURE_IMFS_ENABLE_MKFIFO
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION