summaryrefslogtreecommitdiff
path: root/lwip/test/telnetd01/init.c
blob: e9c312a3b50c6720c588e834f8c493aeb5442ee0 (plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
 * 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.org/license/LICENSE.
 */

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

#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>

#include <rtems.h>
//#include <rtems/rtems_bsdnet.h>
#include <rtems/telnetd.h>
#include <lwip/init.h>
#include <lwip/sockets.h>

#include "lwiplib.h"
#include "lwipopts.h"
#include "soc_AM335x.h"
#include "beaglebone.h"
#include "lwip/ports/drivers/eth_lwip.h"

#include <tmacros.h>

const char rtems_test_name[] = "TELNETD 1";

//struct rtems_bsdnet_config rtems_bsdnet_config;

static void command(char *device_name, void *arg)
{
}

static void test_command_null(void)
{
  static const rtems_telnetd_config_table config = {
    .command = NULL
  };
  rtems_status_code sc;

  sc = rtems_telnetd_start(&config);
  rtems_test_assert(sc == RTEMS_INVALID_ADDRESS);
}

static void test_cannot_start_server_task(void)
{
  static const rtems_telnetd_config_table config = {
    .command = command,
    .priority = UINT32_MAX
  };
  rtems_status_code sc;

  sc = rtems_telnetd_start(&config);
  rtems_test_assert(sc == RTEMS_UNSATISFIED);
}

static void test_successful_start(void)
{
  static const rtems_telnetd_config_table config = {
    .command = command,
    .stack_size = RTEMS_MINIMUM_STACK_SIZE
  };
  rtems_status_code sc;

  sc = rtems_telnetd_start(&config);
  rtems_test_assert(sc == RTEMS_SUCCESSFUL);
}

static void test_already_started(void)
{
  static const rtems_telnetd_config_table config = {
    .command = command
  };
  rtems_status_code sc;

  sc = rtems_telnetd_start(&config);
  rtems_test_assert(sc == RTEMS_RESOURCE_IN_USE);
}

static rtems_task Init(rtems_task_argument argument)
{
  TEST_BEGIN();

  //rv = rtems_bsdnet_initialize_network();
  /*
  LWIP_IF lwipIfPort1;

  lwipIfPort1.ipMode = IPADDR_USE_DHCP;
  LwipInit(&lwipIfPort1);
  */
  lwip_init();

  test_command_null();
  test_cannot_start_server_task();
  test_successful_start();
  test_already_started();

  TEST_END();
  rtems_test_exit(0);
}

#define CONFIGURE_INIT

#define CONFIGURE_MICROSECONDS_PER_TICK 10000

#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER

#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS (3 + 1 + 5 * 4)

#define CONFIGURE_MAXIMUM_TASKS 8

#define CONFIGURE_MAXIMUM_POSIX_KEYS 1

#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION

#define CONFIGURE_RTEMS_INIT_TASKS_TABLE

#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT

#include <rtems/confdefs.h>