iPXE
netdev_test.h
Go to the documentation of this file.
1#ifndef _NETDEV_TEST_H
2#define _NETDEV_TEST_H
3
4/** @file
5 *
6 * Network device tests
7 *
8 */
9
10FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11
12#include <ipxe/device.h>
13#include <ipxe/netdevice.h>
14
15/** A test network device setting */
17 /** Setting name (relative to network device's settings) */
18 const char *name;
19 /** Value */
20 const char *value;
21};
22
23/** A test network device */
24struct testnet {
25 /** Network device */
27 /** Dummy physical device */
28 struct device dev;
29 /** MAC address */
30 const char *hwaddr;
31 /** Initial settings */
33 /** Number of initial settings */
34 unsigned int count;
35};
36
37/**
38 * Declare a test network device
39 *
40 * @v NAME Network device name
41 * @v HWADDR MAC address
42 * @v ... Initial network device settings
43 */
44#define TESTNET( NAME, HWADDR, ... ) \
45 static struct testnet_setting NAME ## _setting[] = { \
46 __VA_ARGS__ \
47 }; \
48 static struct testnet NAME = { \
49 .dev = { \
50 .name = #NAME, \
51 .driver_name = "testnet", \
52 .siblings = \
53 LIST_HEAD_INIT ( NAME.dev.siblings ), \
54 .children = \
55 LIST_HEAD_INIT ( NAME.dev.children ), \
56 }, \
57 .hwaddr= HWADDR, \
58 .testset = NAME ## _setting, \
59 .count = ( sizeof ( NAME ## _setting ) / \
60 sizeof ( NAME ## _setting[0] ) ), \
61 };
62
63/**
64 * Report a network device creation test result
65 *
66 * @v testnet Test network device
67 */
68#define testnet_ok( testnet ) testnet_okx ( testnet, __FILE__, __LINE__ )
69extern void testnet_okx ( struct testnet *testnet, const char *file,
70 unsigned int line );
71
72/**
73 * Report a network device opening test result
74 *
75 * @v testnet Test network device
76 */
77#define testnet_open_ok( testnet ) \
78 testnet_open_okx ( testnet, __FILE__, __LINE__ )
79extern void testnet_open_okx ( struct testnet *testnet, const char *file,
80 unsigned int line );
81
82/**
83 * Report a network device setting test result
84 *
85 * @v testnet Test network device
86 * @v name Setting name (relative to network device's settings)
87 * @v value Setting value
88 */
89#define testnet_set_ok( testnet, name, value ) \
90 testnet_set_okx ( testnet, name, value, __FILE__, __LINE__ )
91extern void testnet_set_okx ( struct testnet *testnet, const char *name,
92 const char *value, const char *file,
93 unsigned int line );
94
95/**
96 * Report a network device closing test result
97 *
98 * @v testnet Test network device
99 */
100#define testnet_close_ok( testnet ) \
101 testnet_close_okx ( testnet, __FILE__, __LINE__ )
102extern void testnet_close_okx ( struct testnet *testnet, const char *file,
103 unsigned int line );
104
105/**
106 * Report a network device removal test result
107 *
108 * @v testnet Test network device
109 */
110#define testnet_remove_ok( testnet ) \
111 testnet_remove_okx ( testnet, __FILE__, __LINE__ )
112extern void testnet_remove_okx ( struct testnet *testnet, const char *file,
113 unsigned int line );
114
115#endif /* _NETDEV_TEST_H */
pseudo_bit_t value[0x00020]
Definition arbel.h:2
const char * name
Definition ath9k_hw.c:1986
Device model.
#define FILE_LICENCE(_licence)
Declare a particular licence as applying to a file.
Definition compiler.h:896
void testnet_remove_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device removal test result.
void testnet_set_okx(struct testnet *testnet, const char *name, const char *value, const char *file, unsigned int line)
Report a network device setting test result.
void testnet_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device creation test result.
void testnet_open_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device opening test result.
void testnet_close_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device closing test result.
Network device management.
A hardware device.
Definition device.h:77
A network device.
Definition netdevice.h:353
A test network device setting.
Definition netdev_test.h:16
const char * name
Setting name (relative to network device's settings)
Definition netdev_test.h:18
const char * value
Value.
Definition netdev_test.h:20
A test network device.
Definition netdev_test.h:24
const char * hwaddr
MAC address.
Definition netdev_test.h:30
unsigned int count
Number of initial settings.
Definition netdev_test.h:34
struct net_device * netdev
Network device.
Definition netdev_test.h:26
struct device dev
Dummy physical device.
Definition netdev_test.h:28
struct testnet_setting * testset
Initial settings.
Definition netdev_test.h:32