source: rtems/testsuites/fstests/support/fstest_support.c

Last change on this file was e2ffe95, checked in by Joel Sherrill <joel@…>, on 04/01/22 at 19:32:30

testsuites/fstests/*: Change license to BSD-2

Updates #3053.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 *  COPYRIGHT (c) 1989-2011.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifdef HAVE_CONFIG_H
30#include "config.h"
31#endif
32
33#include <stdio.h>
34#include <errno.h>
35#include <fcntl.h>
36#include <string.h>
37#include <unistd.h>
38#include <stdlib.h>
39#include <sys/stat.h>
40#include <sys/types.h>
41
42#include <rtems.h>
43#include <rtems/userenv.h>
44
45#include "fstest_support.h"
46#include "fs_config.h"
47
48#include "fstest.h"
49#include <tmacros.h>
50
51void *volatile prevent_compiler_optimizations;
52
53/* Break out of a chroot() environment in C */
54static void break_out_of_chroot(void)
55{
56  int rv;
57  struct stat st;
58
59  rtems_libio_use_global_env();
60
61  /* Perform deferred global location releases */
62  rv = stat(".", &st);
63  rtems_test_assert(rv == 0);
64
65  /* Perform deferred memory frees */
66  prevent_compiler_optimizations = malloc(1);
67  free(prevent_compiler_optimizations);
68}
69
70/*
71 *  Main entry point of every filesystem test
72 */
73
74rtems_task Init(
75    rtems_task_argument ignored)
76{
77  int rc=0;
78
79  TEST_BEGIN();
80
81  puts( "Initializing filesystem " FILESYSTEM );
82  test_initialize_filesystem();
83
84  rc=chroot(BASE_FOR_TEST);
85  rtems_test_assert(rc==0);
86
87  test();
88
89  break_out_of_chroot();
90
91  puts( "\n\nShutting down filesystem " FILESYSTEM );
92  test_shutdown_filesystem();
93
94  TEST_END();
95  rtems_test_exit(0);
96}
Note: See TracBrowser for help on using the repository browser.