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 /** 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__ )
65extern 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__ )
75extern 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__ )
87extern 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__ )
98extern 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__ )
108extern void testnet_remove_okx ( struct testnet *testnet, const char *file,
109 unsigned int line );
110
111#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
unsigned int count
Number of initial settings.
Definition netdev_test.h:32
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:30