summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests/spconfig01/init.c
blob: 6979d2eafd57d13a87bf5356ceb9badec55b2da1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
 *
 *  embedded brains GmbH
 *  Dornierstr. 4
 *  82178 Puchheim
 *  Germany
 *  <rtems@embedded-brains.de>
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.com/license/LICENSE.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <sys/stat.h>
#include <errno.h>

#include <bsp.h>

#include <tmacros.h>

const char rtems_test_name[] = "SPCONFIG 1";

static int counter;

static void checkpoint(int expected_counter)
{
  int current_counter;

  current_counter = counter;
  rtems_test_assert(current_counter == expected_counter);
  counter = current_counter + 1;
}

static rtems_status_code bsp_prerequisite_drivers_init(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
  TEST_BEGIN();
  checkpoint(0);
  return RTEMS_SUCCESSFUL;
}

static rtems_status_code app_prerequisite_drivers_init(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
  struct stat st;
  int rv;

  checkpoint(1);

  errno = 0;
  rv = stat("/dev/null", &st);
  rtems_test_assert(rv == -1);
  rtems_test_assert(errno == ENOENT);

  return RTEMS_SUCCESSFUL;
}

static rtems_status_code app_extra_drivers_init(
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  void *arg
)
{
  struct stat st;
  int rv;

  checkpoint(2);

  rv = stat("/dev/null", &st);
  rtems_test_assert(rv == 0);

  return RTEMS_SUCCESSFUL;
}

static void Init(rtems_task_argument arg)
{
  checkpoint(3);
  TEST_END();
  rtems_test_exit(0);
}

#ifdef CONFIGURE_BSP_PREREQUISITE_DRIVERS
#warning "CONFIGURE_BSP_PREREQUISITE_DRIVERS will be #undef for this test"
#undef CONFIGURE_BSP_PREREQUISITE_DRIVERS
#endif

#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER

#define CONFIGURE_BSP_PREREQUISITE_DRIVERS \
  { bsp_prerequisite_drivers_init, NULL, NULL, NULL, NULL, NULL }

#define CONFIGURE_APPLICATION_PREREQUISITE_DRIVERS \
  { app_prerequisite_drivers_init, NULL, NULL, NULL, NULL, NULL }

#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER

#define CONFIGURE_APPLICATION_EXTRA_DRIVERS \
  { app_extra_drivers_init, NULL, NULL, NULL, NULL, NULL }

#define CONFIGURE_MAXIMUM_TASKS 1

#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_INIT

#include <rtems/confdefs.h>