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 
10 FILE_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 */
24 struct testnet {
25  /** Network device */
26  struct net_device *netdev;
27  /** Dummy physical device */
28  struct device dev;
29  /** Initial settings */
31  /** Number of initial settings */
32  unsigned int count;
33 };
34 
35 /**
36  * Declare a test network device
37  *
38  * @v NAME Network device name
39  * @v ... Initial network device settings
40  */
41 #define TESTNET( NAME, ... ) \
42  static struct testnet_setting NAME ## _setting[] = { \
43  __VA_ARGS__ \
44  }; \
45  static struct testnet NAME = { \
46  .dev = { \
47  .name = #NAME, \
48  .driver_name = "testnet", \
49  .siblings = \
50  LIST_HEAD_INIT ( NAME.dev.siblings ), \
51  .children = \
52  LIST_HEAD_INIT ( NAME.dev.children ), \
53  }, \
54  .testset = NAME ## _setting, \
55  .count = ( sizeof ( NAME ## _setting ) / \
56  sizeof ( NAME ## _setting[0] ) ), \
57  };
58 
59 /**
60  * Report a network device creation test result
61  *
62  * @v testnet Test network device
63  */
64 #define testnet_ok( testnet ) testnet_okx ( testnet, __FILE__, __LINE__ )
65 extern void testnet_okx ( struct testnet *testnet, const char *file,
66  unsigned int line );
67 
68 /**
69  * Report a network device opening test result
70  *
71  * @v testnet Test network device
72  */
73 #define testnet_open_ok( testnet ) \
74  testnet_open_okx ( testnet, __FILE__, __LINE__ )
75 extern void testnet_open_okx ( struct testnet *testnet, const char *file,
76  unsigned int line );
77 
78 /**
79  * Report a network device setting test result
80  *
81  * @v testnet Test network device
82  * @v name Setting name (relative to network device's settings)
83  * @v value Setting value
84  */
85 #define testnet_set_ok( testnet, name, value ) \
86  testnet_set_okx ( testnet, name, value, __FILE__, __LINE__ )
87 extern void testnet_set_okx ( struct testnet *testnet, const char *name,
88  const char *value, const char *file,
89  unsigned int line );
90 
91 /**
92  * Report a network device closing test result
93  *
94  * @v testnet Test network device
95  */
96 #define testnet_close_ok( testnet ) \
97  testnet_close_okx ( testnet, __FILE__, __LINE__ )
98 extern void testnet_close_okx ( struct testnet *testnet, const char *file,
99  unsigned int line );
100 
101 /**
102  * Report a network device removal test result
103  *
104  * @v testnet Test network device
105  */
106 #define testnet_remove_ok( testnet ) \
107  testnet_remove_okx ( testnet, __FILE__, __LINE__ )
108 extern void testnet_remove_okx ( struct testnet *testnet, const char *file,
109  unsigned int line );
110 
111 #endif /* _NETDEV_TEST_H */
const char * name
Definition: ath9k_hw.c:1984
struct device dev
Dummy physical device.
Definition: netdev_test.h:28
A test network device.
Definition: netdev_test.h:24
unsigned int count
Number of initial settings.
Definition: netdev_test.h:32
struct net_device * netdev
Network device.
Definition: netdev_test.h:26
void testnet_remove_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device removal test result.
Definition: netdev_test.c:207
A hardware device.
Definition: device.h:76
struct testnet_setting * testset
Initial settings.
Definition: netdev_test.h:30
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.
Definition: netdev_test.c:157
void testnet_close_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device closing test result.
Definition: netdev_test.c:190
pseudo_bit_t value[0x00020]
Definition: arbel.h:13
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
const char * value
Value.
Definition: netdev_test.h:20
A network device.
Definition: netdevice.h:352
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
Network device management.
void testnet_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device creation test result.
Definition: netdev_test.c:104
void testnet_open_okx(struct testnet *testnet, const char *file, unsigned int line)
Report a network device opening test result.
Definition: netdev_test.c:138
Device model.