iPXE
uri_test.c File Reference

URI self-tests. More...

#include <string.h>
#include <byteswap.h>
#include <ipxe/uri.h>
#include <ipxe/tcpip.h>
#include <ipxe/params.h>
#include <ipxe/test.h>

Go to the source code of this file.

Data Structures

struct  uri_test
 A URI parsing/formatting test. More...
struct  uri_port_test
 A URI port number test. More...
struct  uri_resolve_test
 A URI or path resolution test. More...
struct  uri_pxe_test
 A PXE URI test. More...
struct  uri_churi_test
 A current working URI test. More...
struct  uri_params_test_list
 A request parameter URI test list. More...
struct  uri_params_test
 A request parameter URI test. More...

Macros

#define uri_ok(uri, expected)
#define uri_parse_ok(test)
#define uri_format_ok(test)
#define uri_dup_ok(test)
#define uri_parse_format_dup_ok(test)
#define uri_port_ok(test)
#define uri_resolve_ok(test)
#define uri_resolve_path_ok(test)
#define uri_pxe_ok(test)
#define uri_churi_ok(test)
#define uri_params_list_ok(test)
#define uri_params_ok(test)

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
static int uristrcmp (const char *first, const char *second)
 Compare two URI component strings.
static void uri_okx (struct uri *uri, struct uri *expected, const char *file, unsigned int line)
 Report URI equality test result.
static void uri_parse_okx (struct uri_test *test, const char *file, unsigned int line)
 Report URI parsing test result.
static void uri_format_okx (struct uri_test *test, const char *file, unsigned int line)
 Report URI formatting test result.
static void uri_dup_okx (struct uri *uri, const char *file, unsigned int line)
 Report URI duplication test result.
static void uri_parse_format_dup_okx (struct uri_test *test, const char *file, unsigned int line)
 Report URI combined parsing and formatting test result.
static void uri_port_okx (struct uri_port_test *test, const char *file, unsigned int line)
 Report URI port number test result.
static void uri_resolve_okx (struct uri_resolve_test *test, const char *file, unsigned int line)
 Report URI resolution test result.
static void uri_resolve_path_okx (struct uri_resolve_test *test, const char *file, unsigned int line)
 Report path resolution test result.
static void uri_pxe_okx (struct uri_pxe_test *test, const char *file, unsigned int line)
 Report URI PXE test result.
static void uri_churi_okx (struct uri_churi_test *test, const char *file, unsigned int line)
 Report current working URI test result.
static void uri_params_list_okx (struct uri_params_test *test, struct uri *uri, const char *file, unsigned int line)
 Report request parameter URI test list result.
static void uri_params_okx (struct uri_params_test *test, const char *file, unsigned int line)
 Report request parameter URI test result.
static void uri_test_exec (void)
 Perform URI self-test.

Variables

static struct uri_test uri_empty
 Empty URI.
static struct uri_test uri_boot_ipxe_org
 Basic HTTP URI.
static struct uri_test uri_mailto
 Basic opaque URI.
static struct uri_test uri_host
 Basic host-only URI.
static struct uri_test uri_path
 Basic path-only URI.
static struct uri_test uri_path_escaped
 Path-only URI with escaped characters.
static struct uri_test uri_http_all
 HTTP URI with all the trimmings.
static struct uri_test uri_http_escaped
 HTTP URI with escaped characters.
static struct uri_test uri_http_escaped_improper
 HTTP URI with improperly escaped characters.
static struct uri_test uri_ipv6
 IPv6 URI.
static struct uri_test uri_ipv6_port
 IPv6 URI with port.
static struct uri_test uri_ipv6_local
 IPv6 URI with link-local address.
static struct uri_test uri_ipv6_local_non_conforming
 IPv6 URI with link-local address not conforming to RFC 6874.
static struct uri_test uri_iscsi
 iSCSI URI
static struct uri_test uri_file_relative
 File URI with relative (opaque) path.
static struct uri_test uri_file_absolute
 File URI with absolute path.
static struct uri_test uri_file_volume
 File URI with volume name.
static struct uri_test uri_colons
 Relative URI with colons in path.
static struct uri_port_test uri_explicit_port
 URI with port number.
static struct uri_port_test uri_default_port
 URI without port number.
static struct uri_resolve_test uri_simple_path
 Simple path resolution test.
static struct uri_resolve_test uri_relative_path
 Path resolution test with "." and ".." elements.
static struct uri_resolve_test uri_directory_path
 Path resolution test terminating with directory.
static struct uri_resolve_test uri_excessive_path
 Path resolution test with excessive ".." elements.
static struct uri_resolve_test uri_absolute_path
 Path resolution test with absolute path.
static struct uri_resolve_test uri_relative
 Relative URI resolution test.
static struct uri_resolve_test uri_absolute
 Absolute URI resolution test.
static struct uri_resolve_test uri_absolute_uri_path
 Absolute path URI resolution test.
static struct uri_resolve_test uri_query
 Query URI resolution test.
static struct uri_resolve_test uri_fragment
 Fragment URI resolution test.
static struct uri_resolve_test uri_self
 Empty relative URI resolution test.
static struct uri_resolve_test uri_cwd
 Current directory URI resolution test.
static struct uri_pxe_test uri_pxe_absolute
 PXE URI with absolute URI.
static struct uri_pxe_test uri_pxe_absolute_path
 PXE URI with absolute path.
static struct uri_pxe_test uri_pxe_relative_path
 PXE URI with relative path.
static struct uri_pxe_test uri_pxe_icky
 PXE URI with path containing special characters.
static struct uri_pxe_test uri_pxe_port
 PXE URI with custom port.
static struct uri_churi_test uri_churi []
 Current working URI test.
static struct uri_params_test_list uri_params_list []
 Request parameter URI test list.
static struct uri_params_test uri_params
 Request parameter URI test.
static struct uri_params_test_list uri_named_params_list []
 Named request parameter URI test list.
static struct uri_params_test uri_named_params
 Named request parameter URI test.
static struct uri_params_test uri_invalid_named_params
 Invalid named form parameter URI test.
struct self_test uri_test __self_test
 URI self-test.

Detailed Description

URI self-tests.

Definition in file uri_test.c.

Macro Definition Documentation

◆ uri_ok

#define uri_ok ( uri,
expected )
Value:
uri_okx ( uri, expected, __FILE__, __LINE__ )
A Uniform Resource Identifier.
Definition uri.h:65
static void uri_okx(struct uri *uri, struct uri *expected, const char *file, unsigned int line)
Report URI equality test result.
Definition uri_test.c:144

Definition at line 160 of file uri_test.c.

◆ uri_parse_ok

#define uri_parse_ok ( test)
Value:
uri_parse_okx ( test, __FILE__, __LINE__ )
static int test
Definition epic100.c:73
static void uri_parse_okx(struct uri_test *test, const char *file, unsigned int line)
Report URI parsing test result.
Definition uri_test.c:169

Definition at line 180 of file uri_test.c.

Referenced by uri_test_exec().

◆ uri_format_ok

#define uri_format_ok ( test)
Value:
uri_format_okx ( test, __FILE__, __LINE__ )
static void uri_format_okx(struct uri_test *test, const char *file, unsigned int line)
Report URI formatting test result.
Definition uri_test.c:189

Definition at line 207 of file uri_test.c.

◆ uri_dup_ok

#define uri_dup_ok ( test)
Value:
uri_dup_okx ( test, __FILE__, __LINE__ )
static void uri_dup_okx(struct uri *uri, const char *file, unsigned int line)
Report URI duplication test result.
Definition uri_test.c:216

Definition at line 226 of file uri_test.c.

◆ uri_parse_format_dup_ok

#define uri_parse_format_dup_ok ( test)
Value:
uri_parse_format_dup_okx ( test, __FILE__, __LINE__ )
static void uri_parse_format_dup_okx(struct uri_test *test, const char *file, unsigned int line)
Report URI combined parsing and formatting test result.
Definition uri_test.c:235

Definition at line 242 of file uri_test.c.

242#define uri_parse_format_dup_ok( test ) \
243 uri_parse_format_dup_okx ( test, __FILE__, __LINE__ )

Referenced by uri_test_exec().

◆ uri_port_ok

#define uri_port_ok ( test)
Value:
uri_port_okx ( test, __FILE__, __LINE__ )
static void uri_port_okx(struct uri_port_test *test, const char *file, unsigned int line)
Report URI port number test result.
Definition uri_test.c:252

Definition at line 266 of file uri_test.c.

Referenced by uri_test_exec().

◆ uri_resolve_ok

#define uri_resolve_ok ( test)
Value:
uri_resolve_okx ( test, __FILE__, __LINE__ )
static void uri_resolve_okx(struct uri_resolve_test *test, const char *file, unsigned int line)
Report URI resolution test result.
Definition uri_test.c:275

Definition at line 307 of file uri_test.c.

Referenced by uri_test_exec().

◆ uri_resolve_path_ok

#define uri_resolve_path_ok ( test)
Value:
uri_resolve_path_okx ( test, __FILE__, __LINE__ )
static void uri_resolve_path_okx(struct uri_resolve_test *test, const char *file, unsigned int line)
Report path resolution test result.
Definition uri_test.c:316

Definition at line 330 of file uri_test.c.

330#define uri_resolve_path_ok( test ) \
331 uri_resolve_path_okx ( test, __FILE__, __LINE__ )

Referenced by uri_test_exec().

◆ uri_pxe_ok

#define uri_pxe_ok ( test)
Value:
uri_pxe_okx ( test, __FILE__, __LINE__ )
static void uri_pxe_okx(struct uri_pxe_test *test, const char *file, unsigned int line)
Report URI PXE test result.
Definition uri_test.c:340

Definition at line 357 of file uri_test.c.

Referenced by uri_test_exec().

◆ uri_churi_ok

#define uri_churi_ok ( test)
Value:
uri_churi_okx ( test, __FILE__, __LINE__ )
static void uri_churi_okx(struct uri_churi_test *test, const char *file, unsigned int line)
Report current working URI test result.
Definition uri_test.c:366

Definition at line 405 of file uri_test.c.

Referenced by uri_test_exec().

◆ uri_params_list_ok

#define uri_params_list_ok ( test)
Value:
uri_params_list_okx ( test, __FILE__, __LINE__ )
static void uri_params_list_okx(struct uri_params_test *test, struct uri *uri, const char *file, unsigned int line)
Report request parameter URI test list result.
Definition uri_test.c:415

Definition at line 439 of file uri_test.c.

439#define uri_params_list_ok( test ) \
440 uri_params_list_okx ( test, __FILE__, __LINE__ )

◆ uri_params_ok

#define uri_params_ok ( test)
Value:
uri_params_okx ( test, __FILE__, __LINE__ )
static void uri_params_okx(struct uri_params_test *test, const char *file, unsigned int line)
Report request parameter URI test result.
Definition uri_test.c:449

Definition at line 489 of file uri_test.c.

Referenced by uri_test_exec().

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ uristrcmp()

int uristrcmp ( const char * first,
const char * second )
static

Compare two URI component strings.

Parameters
firstFirst string, or NULL
secondSecond string, or NULL
differenceDifference

Definition at line 124 of file uri_test.c.

124 {
125
126 /* Compare strings, allowing for either to be NULL */
127 if ( first == second ) {
128 return 0;
129 } else if ( ( first == NULL ) || ( second == NULL ) ) {
130 return -1;
131 } else {
132 return strcmp ( first, second );
133 }
134}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
uint32_t first
First block in range.
Definition pccrr.h:1
int strcmp(const char *first, const char *second)
Compare strings.
Definition string.c:174

References first, NULL, and strcmp().

Referenced by uri_okx().

◆ uri_okx()

void uri_okx ( struct uri * uri,
struct uri * expected,
const char * file,
unsigned int line )
static

Report URI equality test result.

Parameters
uriURI
expectedExpected URI
fileTest code file
lineTest code line

Definition at line 144 of file uri_test.c.

145 {
146
147 okx ( uristrcmp ( uri->scheme, expected->scheme ) == 0, file, line );
148 okx ( uristrcmp ( uri->opaque, expected->opaque ) == 0, file, line );
149 okx ( uristrcmp ( uri->user, expected->user ) == 0, file, line );
150 okx ( uristrcmp ( uri->password, expected->password ) == 0, file, line);
151 okx ( uristrcmp ( uri->host, expected->host ) == 0, file, line );
152 okx ( uristrcmp ( uri->port, expected->port ) == 0, file, line );
153 okx ( uristrcmp ( uri->path, expected->path ) == 0, file, line );
154 okx ( uristrcmp ( uri->epath, expected->epath ) == 0, file, line );
155 okx ( uristrcmp ( uri->equery, expected->equery ) == 0, file, line );
156 okx ( uristrcmp ( uri->efragment, expected->efragment ) == 0,
157 file, line);
158 okx ( uri->params == expected->params, file, line );
159}
const char * epath
Path (with original URI encoding)
Definition uri.h:83
const char * path
Path (after URI decoding)
Definition uri.h:81
const char * user
User name.
Definition uri.h:73
struct parameters * params
Request parameters.
Definition uri.h:89
const char * host
Host name.
Definition uri.h:77
const char * password
Password.
Definition uri.h:75
const char * efragment
Fragment (with original URI encoding)
Definition uri.h:87
const char * scheme
Scheme.
Definition uri.h:69
const char * equery
Query (with original URI encoding)
Definition uri.h:85
const char * port
Port number.
Definition uri.h:79
const char * opaque
Opaque part.
Definition uri.h:71
#define okx(success, file, line)
Report test result.
Definition test.h:44
static int uristrcmp(const char *first, const char *second)
Compare two URI component strings.
Definition uri_test.c:124

References uri::efragment, uri::epath, uri::equery, uri::host, okx, uri::opaque, uri::params, uri::password, uri::path, uri::port, uri::scheme, uristrcmp(), and uri::user.

Referenced by uri_dup_okx(), uri_params_list_okx(), uri_parse_okx(), and uri_pxe_okx().

◆ uri_parse_okx()

void uri_parse_okx ( struct uri_test * test,
const char * file,
unsigned int line )
static

Report URI parsing test result.

Parameters
testURI test
fileTest code file
lineTest code line

Definition at line 169 of file uri_test.c.

170 {
171 struct uri *uri;
172
173 /* Parse URI */
174 uri = parse_uri ( test->string );
175 okx ( uri != NULL, file, line );
176 if ( uri )
177 uri_okx ( uri, &test->uri, file, line );
178 uri_put ( uri );
179}
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition uri.c:297
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition uri.h:206

References NULL, okx, parse_uri(), test, uri_okx(), and uri_put().

Referenced by uri_parse_format_dup_okx().

◆ uri_format_okx()

void uri_format_okx ( struct uri_test * test,
const char * file,
unsigned int line )
static

Report URI formatting test result.

Parameters
testURI test
fileTest code file
lineTest code line

Definition at line 189 of file uri_test.c.

190 {
191 char buf[ strlen ( test->string ) + 1 /* NUL */ ];
192 char *tmp;
193 size_t len;
194
195 /* Format into fixed-size buffer */
196 len = format_uri ( &test->uri, buf, sizeof ( buf ) );
197 okx ( len == ( sizeof ( buf ) - 1 /* NUL */ ), file, line );
198 okx ( strcmp ( buf, test->string ) == 0, file, line );
199
200 /* Format into temporarily allocated buffer */
201 tmp = format_uri_alloc ( &test->uri );
202 okx ( tmp != NULL, file, line );
203 if ( tmp )
204 okx ( strcmp ( tmp, test->string ) == 0, file, line );
205 free ( tmp );
206}
ring len
Length.
Definition dwmac.h:226
unsigned long tmp
Definition linux_pci.h:65
static void(* free)(struct refcnt *refcnt))
Definition refcnt.h:55
size_t strlen(const char *src)
Get length of string.
Definition string.c:244
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition uri.c:473
char * format_uri_alloc(const struct uri *uri)
Format URI.
Definition uri.c:542

References format_uri(), format_uri_alloc(), free, len, NULL, okx, strcmp(), strlen(), test, and tmp.

Referenced by uri_parse_format_dup_okx().

◆ uri_dup_okx()

void uri_dup_okx ( struct uri * uri,
const char * file,
unsigned int line )
static

Report URI duplication test result.

Parameters
testURI
fileTest code file
lineTest code line

Definition at line 216 of file uri_test.c.

217 {
218 struct uri *dup;
219
220 dup = uri_dup ( uri );
221 okx ( dup != NULL, file, line );
222 if ( dup )
223 uri_okx ( dup, uri, file, line );
224 uri_put ( dup );
225}
struct uri * uri_dup(const struct uri *uri)
Duplicate URI.
Definition uri.c:596

References NULL, okx, uri_dup(), uri_okx(), and uri_put().

Referenced by uri_parse_format_dup_okx().

◆ uri_parse_format_dup_okx()

void uri_parse_format_dup_okx ( struct uri_test * test,
const char * file,
unsigned int line )
static

Report URI combined parsing and formatting test result.

Parameters
testURI test
fileTest code file
lineTest code line

Definition at line 235 of file uri_test.c.

236 {
237
238 uri_parse_okx ( test, file, line );
239 uri_format_okx ( test, file, line );
240 uri_dup_okx ( &test->uri, file, line );
241}

References test, uri_dup_okx(), uri_format_okx(), and uri_parse_okx().

◆ uri_port_okx()

void uri_port_okx ( struct uri_port_test * test,
const char * file,
unsigned int line )
static

Report URI port number test result.

Parameters
testURI port number test
fileTest code file
lineTest code line

Definition at line 252 of file uri_test.c.

253 {
254 struct uri *uri;
255 unsigned int port;
256
257 /* Parse URI */
258 uri = parse_uri ( test->string );
259 okx ( uri != NULL, file, line );
260 if ( uri ) {
261 port = uri_port ( uri, test->default_port );
262 okx ( port == test->port, file, line );
263 }
264 uri_put ( uri );
265}
u8 port
Port number.
Definition CIB_PRM.h:3
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
Definition uri.c:457

References NULL, okx, parse_uri(), port, test, uri_port(), and uri_put().

◆ uri_resolve_okx()

void uri_resolve_okx ( struct uri_resolve_test * test,
const char * file,
unsigned int line )
static

Report URI resolution test result.

Parameters
testPath resolution test
fileTest code file
lineTest code line

Definition at line 275 of file uri_test.c.

276 {
277 struct uri *base;
278 struct uri *relative;
279 struct uri *resolved = NULL;
280 char *formatted;
281
282 /* Parse URIs */
283 base = parse_uri ( test->base );
284 okx ( base != NULL, file, line );
285 relative = parse_uri ( test->relative );
286 okx ( relative != NULL, file, line );
287
288 /* Resolve URI */
289 if ( base && relative ) {
290 resolved = resolve_uri ( base, relative );
291 okx ( resolved != NULL, file, line );
292 }
293
294 /* Format resolved URI */
295 formatted = format_uri_alloc ( resolved );
296 okx ( formatted != NULL, file, line );
297
298 /* Check resolved URI */
299 if ( formatted )
300 okx ( strcmp ( formatted, test->resolved ) == 0, file, line );
301
302 free ( formatted );
303 uri_put ( resolved );
304 uri_put ( relative );
305 uri_put ( base );
306}
uint8_t formatted[5]
Formatted area.
Definition smbios.h:18
uint32_t base
Base.
Definition librm.h:3
struct uri * resolve_uri(const struct uri *base_uri, struct uri *relative_uri)
Resolve base+relative URI.
Definition uri.c:696

References base, format_uri_alloc(), formatted, free, NULL, okx, parse_uri(), resolve_uri(), strcmp(), test, and uri_put().

Referenced by uri_resolve_path_okx().

◆ uri_resolve_path_okx()

void uri_resolve_path_okx ( struct uri_resolve_test * test,
const char * file,
unsigned int line )
static

Report path resolution test result.

Parameters
testPath resolution test
fileTest code file
lineTest code line

Definition at line 316 of file uri_test.c.

317 {
318 char *resolved;
319
320 /* Resolve paths using resolve_path() directly */
321 resolved = resolve_path ( test->base, test->relative );
322 okx ( resolved != NULL, file, line );
323 if ( resolved )
324 okx ( strcmp ( resolved, test->resolved ) == 0, file, line );
325 free ( resolved );
326
327 /* Resolve paths as URIs (since all paths are valid URIs) */
328 uri_resolve_okx ( test, file, line );
329}
char * resolve_path(const char *base_path, const char *relative_path)
Resolve base+relative path.
Definition uri.c:634

References free, NULL, okx, resolve_path(), strcmp(), test, and uri_resolve_okx().

◆ uri_pxe_okx()

void uri_pxe_okx ( struct uri_pxe_test * test,
const char * file,
unsigned int line )
static

Report URI PXE test result.

Parameters
testURI PXE test
fileTest code file
lineTest code line

Definition at line 340 of file uri_test.c.

341 {
342 char buf[ strlen ( test->string ) + 1 /* NUL */ ];
343 struct uri *uri;
344 size_t len;
345
346 /* Construct URI */
347 uri = pxe_uri ( &test->server.sa, test->filename );
348 okx ( uri != NULL, file, line );
349 if ( uri ) {
350 uri_okx ( uri, &test->uri, file, line );
351 len = format_uri ( uri, buf, sizeof ( buf ) );
352 okx ( len == ( sizeof ( buf ) - 1 /* NUL */ ), file, line );
353 okx ( strcmp ( buf, test->string ) == 0, file, line );
354 }
355 uri_put ( uri );
356}
struct uri * pxe_uri(struct sockaddr *sa_server, const char *filename)
Construct URI from server address and filename.
Definition uri.c:810

References format_uri(), len, NULL, okx, pxe_uri(), strcmp(), strlen(), test, uri_okx(), and uri_put().

◆ uri_churi_okx()

void uri_churi_okx ( struct uri_churi_test * test,
const char * file,
unsigned int line )
static

Report current working URI test result.

Parameters
testsList of current working URI tests
fileTest code file
lineTest code line

Definition at line 366 of file uri_test.c.

367 {
368 struct uri *old_cwuri;
369 struct uri *uri;
370 char *formatted;
371
372 /* Preserve original current working URI */
373 old_cwuri = uri_get ( cwuri );
374
375 /* Perform sequence of current working URI changes */
376 do {
377 /* Parse relative URI */
378 uri = parse_uri ( test->relative );
379 okx ( uri != NULL, file, line );
380
381 /* Move to this URI */
382 churi ( uri );
383
384 /* Format new current working URI */
386 okx ( formatted != NULL, file, line );
387 if ( formatted ) {
388 okx ( strcmp ( formatted, test->expected ) == 0,
389 file, line );
390 }
391
392 /* Free temporary storage */
393 free ( formatted );
394 uri_put ( uri );
395
396 /* Move to next current working URI test */
397 test++;
398
399 } while ( test->relative != NULL );
400
401 /* Restore original current working URI */
402 churi ( old_cwuri );
403 uri_put ( old_cwuri );
404}
void churi(struct uri *uri)
Change working URI.
Definition cwuri.c:46
struct uri * cwuri
Current working URI.
Definition cwuri.c:39
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition uri.h:195

References churi(), cwuri, format_uri_alloc(), formatted, free, NULL, okx, parse_uri(), strcmp(), test, uri_get(), and uri_put().

◆ uri_params_list_okx()

void uri_params_list_okx ( struct uri_params_test * test,
struct uri * uri,
const char * file,
unsigned int line )
static

Report request parameter URI test list result.

Parameters
testRequest parameter URI test
uriURI
fileTest code file
lineTest code line

Definition at line 415 of file uri_test.c.

417 {
418 struct uri_params_test_list *list;
419 struct parameter *param;
420
421 /* Check URI */
422 uri_okx ( uri, &test->uri, file, line );
423
424 /* Check URI parameters */
425 okx ( uri->params != NULL, file, line );
426 if ( uri->params ) {
427 list = test->list;
429 okx ( strcmp ( param->key, list->key ) == 0,
430 file, line );
431 okx ( strcmp ( param->value, list->value ) == 0,
432 file, line );
433 okx ( param->flags == list->flags, file, line );
434 list++;
435 }
436 okx ( list->key == NULL, file, line );
437 }
438}
struct hv_monitor_parameter param[4][32]
Parameters.
Definition hyperv.h:13
#define for_each_param(param, params)
Iterate over all request parameters in a list.
Definition params.h:84
A request parameter.
Definition params.h:29
struct list_head list
List of request parameters.
Definition params.h:31
A request parameter URI test list.
Definition uri_test.c:96

References for_each_param, parameter::list, NULL, okx, param, uri::params, strcmp(), test, and uri_okx().

Referenced by uri_params_okx().

◆ uri_params_okx()

void uri_params_okx ( struct uri_params_test * test,
const char * file,
unsigned int line )
static

Report request parameter URI test result.

Parameters
testRequest parameter URI test
fileTest code file
lineTest code line

Definition at line 449 of file uri_test.c.

450 {
451 struct uri_params_test_list *list;
452 struct parameters *params;
453 struct parameter *param;
454 struct uri *uri;
455 struct uri *dup;
456
457 /* Create parameter list */
458 params = create_parameters ( test->name );
459 okx ( params != NULL, file, line );
460 if ( params ) {
461 for ( list = test->list ; list->key ; list++ ) {
462 param = add_parameter ( params, list->key, list->value,
463 list->flags );
464 okx ( param != NULL, file, line );
465 }
466 }
467
468 /* Record parameter list as part of expected URI */
469 test->uri.params = params;
470
471 /* Parse URI */
472 uri = parse_uri ( test->string );
473 okx ( uri != NULL, file, line );
474 if ( uri )
475 uri_params_list_okx ( test, uri, file, line );
476
477 /* Duplicate URI */
478 dup = uri_dup ( uri );
479 okx ( dup != NULL, file, line );
480 if ( dup )
481 uri_params_list_okx ( test, dup, file, line );
482
483 /* Clear parameter list in expected URI */
484 test->uri.params = NULL;
485
486 uri_put ( uri );
487 uri_put ( dup );
488}
struct parameters * create_parameters(const char *name)
Create request parameter list.
Definition params.c:87
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value, unsigned int flags)
Add request parameter.
Definition params.c:130
A request parameter list.
Definition params.h:17
const char * key
Key.
Definition uri_test.c:98
const char * value
Value.
Definition uri_test.c:100
unsigned int flags
Flags.
Definition uri_test.c:102

References add_parameter(), create_parameters(), uri_params_test_list::flags, uri_params_test_list::key, NULL, okx, param, uri::params, parse_uri(), test, uri_dup(), uri_params_list_okx(), uri_put(), and uri_params_test_list::value.

◆ uri_test_exec()

void uri_test_exec ( void )
static

Perform URI self-test.

URI port number tests

Path resolution tests

URI resolution tests

Definition at line 987 of file uri_test.c.

987 {
988
989 /* URI parsing, formatting, and duplication tests */
998 uri_parse_ok ( &uri_http_escaped_improper ); /* Parse only */
1002 uri_parse_ok ( &uri_ipv6_local_non_conforming ); /* Parse only */
1008
1009 /** URI port number tests */
1012
1013 /** Path resolution tests */
1019
1020 /** URI resolution tests */
1028
1029 /* PXE URI construction tests */
1035
1036 /* Current working URI tests */
1038
1039 /* Request parameter URI tests */
1043}
static struct uri_pxe_test uri_pxe_icky
PXE URI with path containing special characters.
Definition uri_test.c:829
#define uri_parse_format_dup_ok(test)
Definition uri_test.c:242
static struct uri_test uri_empty
Empty URI.
Definition uri_test.c:492
#define uri_params_ok(test)
Definition uri_test.c:489
static struct uri_params_test uri_named_params
Named request parameter URI test.
Definition uri_test.c:957
static struct uri_churi_test uri_churi[]
Current working URI test.
Definition uri_test.c:869
static struct uri_resolve_test uri_directory_path
Path resolution test terminating with directory.
Definition uri_test.c:702
static struct uri_resolve_test uri_self
Empty relative URI resolution test.
Definition uri_test.c:758
#define uri_parse_ok(test)
Definition uri_test.c:180
static struct uri_resolve_test uri_absolute_uri_path
Absolute path URI resolution test.
Definition uri_test.c:737
static struct uri_test uri_path
Basic path-only URI.
Definition uri_test.c:516
static struct uri_resolve_test uri_cwd
Current directory URI resolution test.
Definition uri_test.c:765
static struct uri_pxe_test uri_pxe_relative_path
PXE URI with relative path.
Definition uri_test.c:810
static struct uri_resolve_test uri_simple_path
Simple path resolution test.
Definition uri_test.c:688
static struct uri_test uri_path_escaped
Path-only URI with escaped characters.
Definition uri_test.c:523
#define uri_churi_ok(test)
Definition uri_test.c:405
#define uri_pxe_ok(test)
Definition uri_test.c:357
#define uri_port_ok(test)
Definition uri_test.c:266
static struct uri_test uri_file_absolute
File URI with absolute path.
Definition uri_test.c:644
static struct uri_pxe_test uri_pxe_absolute_path
PXE URI with absolute path.
Definition uri_test.c:791
static struct uri_resolve_test uri_fragment
Fragment URI resolution test.
Definition uri_test.c:751
static struct uri_test uri_iscsi
iSCSI URI
Definition uri_test.c:626
static struct uri_test uri_http_all
HTTP URI with all the trimmings.
Definition uri_test.c:529
static struct uri_test uri_ipv6
IPv6 URI.
Definition uri_test.c:576
static struct uri_test uri_file_relative
File URI with relative (opaque) path.
Definition uri_test.c:635
static struct uri_test uri_http_escaped
HTTP URI with escaped characters.
Definition uri_test.c:545
static struct uri_resolve_test uri_absolute
Absolute URI resolution test.
Definition uri_test.c:730
static struct uri_resolve_test uri_query
Query URI resolution test.
Definition uri_test.c:744
static struct uri_test uri_host
Basic host-only URI.
Definition uri_test.c:510
static struct uri_test uri_http_escaped_improper
HTTP URI with improperly escaped characters.
Definition uri_test.c:558
#define uri_resolve_path_ok(test)
Definition uri_test.c:330
static struct uri_pxe_test uri_pxe_absolute
PXE URI with absolute URI.
Definition uri_test.c:772
static struct uri_resolve_test uri_relative
Relative URI resolution test.
Definition uri_test.c:723
static struct uri_resolve_test uri_excessive_path
Path resolution test with excessive ".." elements.
Definition uri_test.c:709
static struct uri_params_test uri_params
Request parameter URI test.
Definition uri_test.c:925
static struct uri_pxe_test uri_pxe_port
PXE URI with custom port.
Definition uri_test.c:848
static struct uri_test uri_boot_ipxe_org
Basic HTTP URI.
Definition uri_test.c:497
#define uri_resolve_ok(test)
Definition uri_test.c:307
static struct uri_test uri_colons
Relative URI with colons in path.
Definition uri_test.c:665
static struct uri_test uri_ipv6_local
IPv6 URI with link-local address.
Definition uri_test.c:599
static struct uri_port_test uri_default_port
URI without port number.
Definition uri_test.c:681
static struct uri_resolve_test uri_relative_path
Path resolution test with "." and ".." elements.
Definition uri_test.c:695
static struct uri_params_test uri_invalid_named_params
Invalid named form parameter URI test.
Definition uri_test.c:971
static struct uri_port_test uri_explicit_port
URI with port number.
Definition uri_test.c:674
static struct uri_resolve_test uri_absolute_path
Path resolution test with absolute path.
Definition uri_test.c:716
static struct uri_test uri_mailto
Basic opaque URI.
Definition uri_test.c:504
static struct uri_test uri_ipv6_port
IPv6 URI with port.
Definition uri_test.c:587
static struct uri_test uri_file_volume
File URI with volume name.
Definition uri_test.c:654
static struct uri_test uri_ipv6_local_non_conforming
IPv6 URI with link-local address not conforming to RFC 6874.
Definition uri_test.c:610

References uri_absolute, uri_absolute_path, uri_absolute_uri_path, uri_boot_ipxe_org, uri_churi, uri_churi_ok, uri_colons, uri_cwd, uri_default_port, uri_directory_path, uri_empty, uri_excessive_path, uri_explicit_port, uri_file_absolute, uri_file_relative, uri_file_volume, uri_fragment, uri_host, uri_http_all, uri_http_escaped, uri_http_escaped_improper, uri_invalid_named_params, uri_ipv6, uri_ipv6_local, uri_ipv6_local_non_conforming, uri_ipv6_port, uri_iscsi, uri_mailto, uri_named_params, uri_params, uri_params_ok, uri_parse_format_dup_ok, uri_parse_ok, uri_path, uri_path_escaped, uri_port_ok, uri_pxe_absolute, uri_pxe_absolute_path, uri_pxe_icky, uri_pxe_ok, uri_pxe_port, uri_pxe_relative_path, uri_query, uri_relative, uri_relative_path, uri_resolve_ok, uri_resolve_path_ok, uri_self, and uri_simple_path.

Variable Documentation

◆ uri_empty

struct uri_test uri_empty
static
Initial value:
= {
.string = "",
}

Empty URI.

Definition at line 492 of file uri_test.c.

492 {
493 .string = "",
494};

Referenced by uri_test_exec().

◆ uri_boot_ipxe_org

struct uri_test uri_boot_ipxe_org
static
Initial value:
= {
"http://boot.ipxe.org/demo/boot.php",
{ .scheme = "http", .host = "boot.ipxe.org",
.path = "/demo/boot.php", .epath = "/demo/boot.php" },
}

Basic HTTP URI.

Definition at line 497 of file uri_test.c.

497 {
498 "http://boot.ipxe.org/demo/boot.php",
499 { .scheme = "http", .host = "boot.ipxe.org",
500 .path = "/demo/boot.php", .epath = "/demo/boot.php" },
501};

Referenced by uri_test_exec().

◆ uri_mailto

struct uri_test uri_mailto
static
Initial value:
= {
"mailto:ipxe-devel@lists.ipxe.org",
{ .scheme = "mailto", .opaque = "ipxe-devel@lists.ipxe.org" },
}

Basic opaque URI.

Definition at line 504 of file uri_test.c.

504 {
505 "mailto:ipxe-devel@lists.ipxe.org",
506 { .scheme = "mailto", .opaque = "ipxe-devel@lists.ipxe.org" },
507};

Referenced by uri_test_exec().

◆ uri_host

struct uri_test uri_host
static
Initial value:
= {
"http://boot.ipxe.org",
{ .scheme = "http", .host = "boot.ipxe.org" },
}

Basic host-only URI.

Definition at line 510 of file uri_test.c.

510 {
511 "http://boot.ipxe.org",
512 { .scheme = "http", .host = "boot.ipxe.org" },
513};

Referenced by uri_test_exec().

◆ uri_path

struct uri_test uri_path
static
Initial value:
= {
"/var/lib/tftpboot/pxelinux.0",
{ .path = "/var/lib/tftpboot/pxelinux.0",
.epath ="/var/lib/tftpboot/pxelinux.0" },
}

Basic path-only URI.

Definition at line 516 of file uri_test.c.

516 {
517 "/var/lib/tftpboot/pxelinux.0",
518 { .path = "/var/lib/tftpboot/pxelinux.0",
519 .epath ="/var/lib/tftpboot/pxelinux.0" },
520};

Referenced by uri_test_exec().

◆ uri_path_escaped

struct uri_test uri_path_escaped
static
Initial value:
= {
"/hello%20world%3F",
{ .path = "/hello world?", .epath = "/hello%20world%3F" },
}

Path-only URI with escaped characters.

Definition at line 523 of file uri_test.c.

523 {
524 "/hello%20world%3F",
525 { .path = "/hello world?", .epath = "/hello%20world%3F" },
526};

Referenced by uri_test_exec().

◆ uri_http_all

struct uri_test uri_http_all
static
Initial value:
= {
"http://anon:password@example.com:3001/~foo/cgi-bin/foo.pl?a=b&c=d#bit",
{
.scheme = "http",
.user = "anon",
.password = "password",
.host = "example.com",
.port = "3001",
.path = "/~foo/cgi-bin/foo.pl",
.epath = "/~foo/cgi-bin/foo.pl",
.equery = "a=b&c=d",
.efragment = "bit",
},
}

HTTP URI with all the trimmings.

Definition at line 529 of file uri_test.c.

529 {
530 "http://anon:password@example.com:3001/~foo/cgi-bin/foo.pl?a=b&c=d#bit",
531 {
532 .scheme = "http",
533 .user = "anon",
534 .password = "password",
535 .host = "example.com",
536 .port = "3001",
537 .path = "/~foo/cgi-bin/foo.pl",
538 .epath = "/~foo/cgi-bin/foo.pl",
539 .equery = "a=b&c=d",
540 .efragment = "bit",
541 },
542};

Referenced by uri_test_exec().

◆ uri_http_escaped

struct uri_test uri_http_escaped
static
Initial value:
= {
"https://test.ipxe.org/wtf%3F%0A?kind%23of/uri%20is#this%3F",
{
.scheme = "https",
.host = "test.ipxe.org",
.path = "/wtf?\n",
.epath = "/wtf%3F%0A",
.equery = "kind%23of/uri%20is",
.efragment = "this%3F",
},
}

HTTP URI with escaped characters.

Definition at line 545 of file uri_test.c.

545 {
546 "https://test.ipxe.org/wtf%3F%0A?kind%23of/uri%20is#this%3F",
547 {
548 .scheme = "https",
549 .host = "test.ipxe.org",
550 .path = "/wtf?\n",
551 .epath = "/wtf%3F%0A",
552 .equery = "kind%23of/uri%20is",
553 .efragment = "this%3F",
554 },
555};

Referenced by uri_test_exec().

◆ uri_http_escaped_improper

struct uri_test uri_http_escaped_improper
static
Initial value:
= {
"https://test%2eipxe.org/wt%66%3f\n?kind%23of/uri is#this?",
{
.scheme = "https",
.host = "test.ipxe.org",
.path = "/wtf?\n",
.epath = "/wt%66%3f\n",
.equery = "kind%23of/uri is",
.efragment = "this?",
},
}

HTTP URI with improperly escaped characters.

Definition at line 558 of file uri_test.c.

558 {
559 /* We accept for parsing improperly escaped characters.
560 * (Formatting the parsed URI would produce the properly
561 * encoded form, and so would not exactly match the original
562 * URI string.)
563 */
564 "https://test%2eipxe.org/wt%66%3f\n?kind%23of/uri is#this?",
565 {
566 .scheme = "https",
567 .host = "test.ipxe.org",
568 .path = "/wtf?\n",
569 .epath = "/wt%66%3f\n",
570 .equery = "kind%23of/uri is",
571 .efragment = "this?",
572 },
573};

Referenced by uri_test_exec().

◆ uri_ipv6

struct uri_test uri_ipv6
static
Initial value:
= {
"http://[2001:ba8:0:1d4::6950:5845]/",
{
.scheme = "http",
.host = "[2001:ba8:0:1d4::6950:5845]",
.path = "/",
.epath = "/",
},
}

IPv6 URI.

Definition at line 576 of file uri_test.c.

576 {
577 "http://[2001:ba8:0:1d4::6950:5845]/",
578 {
579 .scheme = "http",
580 .host = "[2001:ba8:0:1d4::6950:5845]",
581 .path = "/",
582 .epath = "/",
583 },
584};

Referenced by uri_test_exec().

◆ uri_ipv6_port

struct uri_test uri_ipv6_port
static
Initial value:
= {
"http://[2001:ba8:0:1d4::6950:5845]:8001/boot",
{
.scheme = "http",
.host = "[2001:ba8:0:1d4::6950:5845]",
.port = "8001",
.path = "/boot",
.epath = "/boot",
},
}

IPv6 URI with port.

Definition at line 587 of file uri_test.c.

587 {
588 "http://[2001:ba8:0:1d4::6950:5845]:8001/boot",
589 {
590 .scheme = "http",
591 .host = "[2001:ba8:0:1d4::6950:5845]",
592 .port = "8001",
593 .path = "/boot",
594 .epath = "/boot",
595 },
596};

Referenced by uri_test_exec().

◆ uri_ipv6_local

struct uri_test uri_ipv6_local
static
Initial value:
= {
"http://[fe80::69ff:fe50:5845%25net0]/ipxe",
{
.scheme = "http",
.host = "[fe80::69ff:fe50:5845%net0]",
.path = "/ipxe",
.epath = "/ipxe",
},
}

IPv6 URI with link-local address.

Definition at line 599 of file uri_test.c.

599 {
600 "http://[fe80::69ff:fe50:5845%25net0]/ipxe",
601 {
602 .scheme = "http",
603 .host = "[fe80::69ff:fe50:5845%net0]",
604 .path = "/ipxe",
605 .epath = "/ipxe",
606 },
607};

Referenced by uri_test_exec().

◆ uri_ipv6_local_non_conforming

struct uri_test uri_ipv6_local_non_conforming
static
Initial value:
= {
"http://[fe80::69ff:fe50:5845%net0]/ipxe",
{
.scheme = "http",
.host = "[fe80::69ff:fe50:5845%net0]",
.path = "/ipxe",
.epath = "/ipxe",
},
}

IPv6 URI with link-local address not conforming to RFC 6874.

Definition at line 610 of file uri_test.c.

610 {
611 /* We accept for parsing a single "%" in "%net0" (rather than
612 * the properly encoded form "%25net0"). (Formatting the
613 * parsed URI would produce the properly encoded form, and so
614 * would not exactly match the original URI string.)
615 */
616 "http://[fe80::69ff:fe50:5845%net0]/ipxe",
617 {
618 .scheme = "http",
619 .host = "[fe80::69ff:fe50:5845%net0]",
620 .path = "/ipxe",
621 .epath = "/ipxe",
622 },
623};

Referenced by uri_test_exec().

◆ uri_iscsi

struct uri_test uri_iscsi
static
Initial value:
= {
"iscsi:10.253.253.1::::iqn.2010-04.org.ipxe:rabbit",
{
.scheme = "iscsi",
.opaque = "10.253.253.1::::iqn.2010-04.org.ipxe:rabbit",
},
}

iSCSI URI

Definition at line 626 of file uri_test.c.

626 {
627 "iscsi:10.253.253.1::::iqn.2010-04.org.ipxe:rabbit",
628 {
629 .scheme = "iscsi",
630 .opaque = "10.253.253.1::::iqn.2010-04.org.ipxe:rabbit",
631 },
632};

Referenced by uri_test_exec().

◆ uri_file_relative

struct uri_test uri_file_relative
static
Initial value:
= {
"file:boot/script.ipxe",
{
.scheme = "file",
.opaque = "boot/script.ipxe",
},
}

File URI with relative (opaque) path.

Definition at line 635 of file uri_test.c.

635 {
636 "file:boot/script.ipxe",
637 {
638 .scheme = "file",
639 .opaque = "boot/script.ipxe",
640 },
641};

Referenced by uri_test_exec().

◆ uri_file_absolute

struct uri_test uri_file_absolute
static
Initial value:
= {
"file:/boot/script.ipxe",
{
.scheme = "file",
.path = "/boot/script.ipxe",
.epath = "/boot/script.ipxe",
},
}

File URI with absolute path.

Definition at line 644 of file uri_test.c.

644 {
645 "file:/boot/script.ipxe",
646 {
647 .scheme = "file",
648 .path = "/boot/script.ipxe",
649 .epath = "/boot/script.ipxe",
650 },
651};

Referenced by uri_test_exec().

◆ uri_file_volume

struct uri_test uri_file_volume
static
Initial value:
= {
"file://hpilo/boot/script.ipxe",
{
.scheme = "file",
.host = "hpilo",
.path = "/boot/script.ipxe",
.epath = "/boot/script.ipxe",
},
}

File URI with volume name.

Definition at line 654 of file uri_test.c.

654 {
655 "file://hpilo/boot/script.ipxe",
656 {
657 .scheme = "file",
658 .host = "hpilo",
659 .path = "/boot/script.ipxe",
660 .epath = "/boot/script.ipxe",
661 },
662};

Referenced by uri_test_exec().

◆ uri_colons

struct uri_test uri_colons
static
Initial value:
= {
"/boot/52:54:00:12:34:56/boot.ipxe",
{
.path = "/boot/52:54:00:12:34:56/boot.ipxe",
.epath = "/boot/52:54:00:12:34:56/boot.ipxe",
},
}

Relative URI with colons in path.

Definition at line 665 of file uri_test.c.

665 {
666 "/boot/52:54:00:12:34:56/boot.ipxe",
667 {
668 .path = "/boot/52:54:00:12:34:56/boot.ipxe",
669 .epath = "/boot/52:54:00:12:34:56/boot.ipxe",
670 },
671};

Referenced by uri_test_exec().

◆ uri_explicit_port

struct uri_port_test uri_explicit_port
static
Initial value:
= {
"http://192.168.0.1:8080/boot.php",
80,
8080,
}

URI with port number.

Definition at line 674 of file uri_test.c.

674 {
675 "http://192.168.0.1:8080/boot.php",
676 80,
677 8080,
678};

Referenced by uri_test_exec().

◆ uri_default_port

struct uri_port_test uri_default_port
static
Initial value:
= {
"http://192.168.0.1/boot.php",
80,
80,
}

URI without port number.

Definition at line 681 of file uri_test.c.

681 {
682 "http://192.168.0.1/boot.php",
683 80,
684 80,
685};

Referenced by uri_test_exec().

◆ uri_simple_path

struct uri_resolve_test uri_simple_path
static
Initial value:
= {
"/etc/passwd",
"group",
"/etc/group",
}

Simple path resolution test.

Definition at line 688 of file uri_test.c.

688 {
689 "/etc/passwd",
690 "group",
691 "/etc/group",
692};

Referenced by uri_test_exec().

◆ uri_relative_path

struct uri_resolve_test uri_relative_path
static
Initial value:
= {
"/var/lib/tftpboot/pxe/pxelinux.0",
"./../ipxe/undionly.kpxe",
"/var/lib/tftpboot/ipxe/undionly.kpxe",
}

Path resolution test with "." and ".." elements.

Definition at line 695 of file uri_test.c.

695 {
696 "/var/lib/tftpboot/pxe/pxelinux.0",
697 "./../ipxe/undionly.kpxe",
698 "/var/lib/tftpboot/ipxe/undionly.kpxe",
699};

Referenced by uri_test_exec().

◆ uri_directory_path

struct uri_resolve_test uri_directory_path
static
Initial value:
= {
"/test/cgi-bin.pl/boot.ipxe",
"..",
"/test/",
}

Path resolution test terminating with directory.

Definition at line 702 of file uri_test.c.

702 {
703 "/test/cgi-bin.pl/boot.ipxe",
704 "..",
705 "/test/",
706};

Referenced by uri_test_exec().

◆ uri_excessive_path

struct uri_resolve_test uri_excessive_path
static
Initial value:
= {
"/var/lib/tftpboot/ipxe.pxe",
"../../../../../../../foo",
"/foo",
}

Path resolution test with excessive ".." elements.

Definition at line 709 of file uri_test.c.

709 {
710 "/var/lib/tftpboot/ipxe.pxe",
711 "../../../../../../../foo",
712 "/foo",
713};

Referenced by uri_test_exec().

◆ uri_absolute_path

struct uri_resolve_test uri_absolute_path
static
Initial value:
= {
"/var/lib/tftpboot",
"/etc/hostname",
"/etc/hostname",
}

Path resolution test with absolute path.

Definition at line 716 of file uri_test.c.

716 {
717 "/var/lib/tftpboot",
718 "/etc/hostname",
719 "/etc/hostname",
720};

Referenced by uri_test_exec().

◆ uri_relative

struct uri_resolve_test uri_relative
static
Initial value:
= {
"http://boot.ipxe.org/demo/boot.php?vendor=10ec&device=8139",
"initrd.img",
"http://boot.ipxe.org/demo/initrd.img",
}

Relative URI resolution test.

Definition at line 723 of file uri_test.c.

723 {
724 "http://boot.ipxe.org/demo/boot.php?vendor=10ec&device=8139",
725 "initrd.img",
726 "http://boot.ipxe.org/demo/initrd.img",
727};

Referenced by uri_test_exec().

◆ uri_absolute

struct uri_resolve_test uri_absolute
static
Initial value:
= {
"http://boot.ipxe.org/demo/boot.php",
"ftp://192.168.0.1/boot.ipxe",
"ftp://192.168.0.1/boot.ipxe",
}

Absolute URI resolution test.

Definition at line 730 of file uri_test.c.

730 {
731 "http://boot.ipxe.org/demo/boot.php",
732 "ftp://192.168.0.1/boot.ipxe",
733 "ftp://192.168.0.1/boot.ipxe",
734};

Referenced by uri_test_exec().

◆ uri_absolute_uri_path

struct uri_resolve_test uri_absolute_uri_path
static
Initial value:
= {
"http://boot.ipxe.org/demo/boot.php#test",
"/demo/vmlinuz",
"http://boot.ipxe.org/demo/vmlinuz",
}

Absolute path URI resolution test.

Definition at line 737 of file uri_test.c.

737 {
738 "http://boot.ipxe.org/demo/boot.php#test",
739 "/demo/vmlinuz",
740 "http://boot.ipxe.org/demo/vmlinuz",
741};

Referenced by uri_test_exec().

◆ uri_query

struct uri_resolve_test uri_query
static
Initial value:
= {
"http://10.253.253.1/test.pl?mac=02-00-69-50-58-45",
"?mac=00-1f-16-bc-fe-2f",
"http://10.253.253.1/test.pl?mac=00-1f-16-bc-fe-2f",
}

Query URI resolution test.

Definition at line 744 of file uri_test.c.

744 {
745 "http://10.253.253.1/test.pl?mac=02-00-69-50-58-45",
746 "?mac=00-1f-16-bc-fe-2f",
747 "http://10.253.253.1/test.pl?mac=00-1f-16-bc-fe-2f",
748};

Referenced by uri_test_exec().

◆ uri_fragment

struct uri_resolve_test uri_fragment
static
Initial value:
= {
"http://192.168.0.254/test#foo",
"#bar",
"http://192.168.0.254/test#bar",
}

Fragment URI resolution test.

Definition at line 751 of file uri_test.c.

751 {
752 "http://192.168.0.254/test#foo",
753 "#bar",
754 "http://192.168.0.254/test#bar",
755};

Referenced by uri_test_exec().

◆ uri_self

struct uri_resolve_test uri_self
static
Initial value:
= {
"http://192.168.0.1/path/to/me",
"",
"http://192.168.0.1/path/to/me",
}

Empty relative URI resolution test.

Definition at line 758 of file uri_test.c.

758 {
759 "http://192.168.0.1/path/to/me",
760 "",
761 "http://192.168.0.1/path/to/me",
762};

Referenced by uri_test_exec().

◆ uri_cwd

struct uri_resolve_test uri_cwd
static
Initial value:
= {
"http://192.168.0.1/path/to/me",
".",
"http://192.168.0.1/path/to/",
}

Current directory URI resolution test.

Definition at line 765 of file uri_test.c.

765 {
766 "http://192.168.0.1/path/to/me",
767 ".",
768 "http://192.168.0.1/path/to/",
769};

Referenced by uri_test_exec().

◆ uri_pxe_absolute

struct uri_pxe_test uri_pxe_absolute
static
Initial value:
= {
{
.sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl ( 0xc0a80003 ) },
},
},
"http://not.a.tftp/uri",
{
.scheme = "http",
.host = "not.a.tftp",
.path = "/uri",
.epath = "/uri",
},
"http://not.a.tftp/uri",
}
#define AF_INET
IPv4 Internet addresses.
Definition socket.h:64
#define htonl(value)
Definition byteswap.h:134

PXE URI with absolute URI.

Definition at line 772 of file uri_test.c.

772 {
773 {
774 /* 192.168.0.3 */
775 .sin = {
776 .sin_family = AF_INET,
777 .sin_addr = { .s_addr = htonl ( 0xc0a80003 ) },
778 },
779 },
780 "http://not.a.tftp/uri",
781 {
782 .scheme = "http",
783 .host = "not.a.tftp",
784 .path = "/uri",
785 .epath = "/uri",
786 },
787 "http://not.a.tftp/uri",
788};

Referenced by uri_test_exec().

◆ uri_pxe_absolute_path

struct uri_pxe_test uri_pxe_absolute_path
static
Initial value:
= {
{
.sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl ( 0xc0a80002 ) },
},
},
"/absolute/path",
{
.scheme = "tftp",
.host = "192.168.0.2",
.path = "//absolute/path",
.epath = "//absolute/path",
},
"tftp://192.168.0.2//absolute/path",
}

PXE URI with absolute path.

Definition at line 791 of file uri_test.c.

791 {
792 {
793 /* 192.168.0.2 */
794 .sin = {
795 .sin_family = AF_INET,
796 .sin_addr = { .s_addr = htonl ( 0xc0a80002 ) },
797 },
798 },
799 "/absolute/path",
800 {
801 .scheme = "tftp",
802 .host = "192.168.0.2",
803 .path = "//absolute/path",
804 .epath = "//absolute/path",
805 },
806 "tftp://192.168.0.2//absolute/path",
807};

Referenced by uri_test_exec().

◆ uri_pxe_relative_path

struct uri_pxe_test uri_pxe_relative_path
static
Initial value:
= {
{
.sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl ( 0xc0a80003 ) },
},
},
"relative/path",
{
.scheme = "tftp",
.host = "192.168.0.3",
.path = "/relative/path",
.epath = "/relative/path",
},
"tftp://192.168.0.3/relative/path",
}

PXE URI with relative path.

Definition at line 810 of file uri_test.c.

810 {
811 {
812 /* 192.168.0.3 */
813 .sin = {
814 .sin_family = AF_INET,
815 .sin_addr = { .s_addr = htonl ( 0xc0a80003 ) },
816 },
817 },
818 "relative/path",
819 {
820 .scheme = "tftp",
821 .host = "192.168.0.3",
822 .path = "/relative/path",
823 .epath = "/relative/path",
824 },
825 "tftp://192.168.0.3/relative/path",
826};

Referenced by uri_test_exec().

◆ uri_pxe_icky

struct uri_pxe_test uri_pxe_icky
static
Initial value:
= {
{
.sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl ( 0x0a000006 ) },
},
},
"C:\\tftpboot\\icky#path",
{
.scheme = "tftp",
.host = "10.0.0.6",
.path = "/C:\\tftpboot\\icky#path",
.epath = "/C:\\tftpboot\\icky#path",
},
"tftp://10.0.0.6/C:\\tftpboot\\icky#path",
}

PXE URI with path containing special characters.

Definition at line 829 of file uri_test.c.

829 {
830 {
831 /* 10.0.0.6 */
832 .sin = {
833 .sin_family = AF_INET,
834 .sin_addr = { .s_addr = htonl ( 0x0a000006 ) },
835 },
836 },
837 "C:\\tftpboot\\icky#path",
838 {
839 .scheme = "tftp",
840 .host = "10.0.0.6",
841 .path = "/C:\\tftpboot\\icky#path",
842 .epath = "/C:\\tftpboot\\icky#path",
843 },
844 "tftp://10.0.0.6/C:\\tftpboot\\icky#path",
845};

Referenced by uri_test_exec().

◆ uri_pxe_port

struct uri_pxe_test uri_pxe_port
static
Initial value:
= {
{
.sin = {
.sin_family = AF_INET,
.sin_addr = { .s_addr = htonl ( 0xc0a80001 ) },
.sin_port = htons ( 4069 ),
},
},
"/another/path",
{
.scheme = "tftp",
.host = "192.168.0.1",
.port = "4069",
.path = "//another/path",
.epath = "//another/path",
},
"tftp://192.168.0.1:4069//another/path",
}
#define htons(value)
Definition byteswap.h:136

PXE URI with custom port.

Definition at line 848 of file uri_test.c.

848 {
849 {
850 /* 192.168.0.1:4069 */
851 .sin = {
852 .sin_family = AF_INET,
853 .sin_addr = { .s_addr = htonl ( 0xc0a80001 ) },
854 .sin_port = htons ( 4069 ),
855 },
856 },
857 "/another/path",
858 {
859 .scheme = "tftp",
860 .host = "192.168.0.1",
861 .port = "4069",
862 .path = "//another/path",
863 .epath = "//another/path",
864 },
865 "tftp://192.168.0.1:4069//another/path",
866};

Referenced by uri_test_exec().

◆ uri_churi

struct uri_churi_test uri_churi[]
static
Initial value:
= {
{
"http://boot.ipxe.org/demo/boot.php",
"http://boot.ipxe.org/demo/boot.php",
},
{
"?vendor=10ec&device=8139",
"http://boot.ipxe.org/demo/boot.php?vendor=10ec&device=8139",
},
{
"fedora/fedora.ipxe",
"http://boot.ipxe.org/demo/fedora/fedora.ipxe",
},
{
"vmlinuz",
"http://boot.ipxe.org/demo/fedora/vmlinuz",
},
{
"http://local/boot/initrd.img",
"http://local/boot/initrd.img",
},
{
"modules/8139too.ko",
"http://local/boot/modules/8139too.ko",
},
{
}
}

Current working URI test.

Definition at line 869 of file uri_test.c.

869 {
870 {
871 "http://boot.ipxe.org/demo/boot.php",
872 "http://boot.ipxe.org/demo/boot.php",
873 },
874 {
875 "?vendor=10ec&device=8139",
876 "http://boot.ipxe.org/demo/boot.php?vendor=10ec&device=8139",
877 },
878 {
879 "fedora/fedora.ipxe",
880 "http://boot.ipxe.org/demo/fedora/fedora.ipxe",
881 },
882 {
883 "vmlinuz",
884 "http://boot.ipxe.org/demo/fedora/vmlinuz",
885 },
886 {
887 "http://local/boot/initrd.img",
888 "http://local/boot/initrd.img",
889 },
890 {
891 "modules/8139too.ko",
892 "http://local/boot/modules/8139too.ko",
893 },
894 {
895 NULL,
896 NULL,
897 }
898};

Referenced by uri_test_exec().

◆ uri_params_list

struct uri_params_test_list uri_params_list[]
static
Initial value:
= {
{
"vendor",
"10ec",
},
{
"device",
"8139",
},
{
"uuid",
"f59fac00-758f-498f-9fe5-87d790045d94",
},
{
0,
}
}
#define PARAMETER_HEADER
Request parameter is a header parameter.
Definition params.h:44
#define PARAMETER_FORM
Request parameter is a form parameter.
Definition params.h:41

Request parameter URI test list.

Definition at line 901 of file uri_test.c.

901 {
902 {
903 "vendor",
904 "10ec",
906 },
907 {
908 "device",
909 "8139",
911 },
912 {
913 "uuid",
914 "f59fac00-758f-498f-9fe5-87d790045d94",
916 },
917 {
918 NULL,
919 NULL,
920 0,
921 }
922};

◆ uri_params

struct uri_params_test uri_params
static
Initial value:
= {
"http://boot.ipxe.org/demo/boot.php##params",
{
.scheme = "http",
.host = "boot.ipxe.org",
.path = "/demo/boot.php",
.epath = "/demo/boot.php",
},
}
static struct uri_params_test_list uri_params_list[]
Request parameter URI test list.
Definition uri_test.c:901

Request parameter URI test.

Definition at line 925 of file uri_test.c.

925 {
926 "http://boot.ipxe.org/demo/boot.php##params",
927 {
928 .scheme = "http",
929 .host = "boot.ipxe.org",
930 .path = "/demo/boot.php",
931 .epath = "/demo/boot.php",
932 },
933 NULL,
935};

Referenced by uri_test_exec().

◆ uri_named_params_list

struct uri_params_test_list uri_named_params_list[]
static
Initial value:
= {
{
"mac",
"00:1e:65:80:d3:b6",
},
{
"serial",
"LXTQ20Z1139322762F2000",
},
{
0,
}
}

Named request parameter URI test list.

Definition at line 938 of file uri_test.c.

938 {
939 {
940 "mac",
941 "00:1e:65:80:d3:b6",
943 },
944 {
945 "serial",
946 "LXTQ20Z1139322762F2000",
948 },
949 {
950 NULL,
951 NULL,
952 0,
953 }
954};

◆ uri_named_params

struct uri_params_test uri_named_params
static
Initial value:
= {
"http://192.168.100.4:3001/register##params=foo",
{
.scheme = "http",
.host = "192.168.100.4",
.port = "3001",
.path = "/register",
.epath = "/register",
},
"foo",
}
static struct uri_params_test_list uri_named_params_list[]
Named request parameter URI test list.
Definition uri_test.c:938

Named request parameter URI test.

Definition at line 957 of file uri_test.c.

957 {
958 "http://192.168.100.4:3001/register##params=foo",
959 {
960 .scheme = "http",
961 .host = "192.168.100.4",
962 .port = "3001",
963 .path = "/register",
964 .epath = "/register",
965 },
966 "foo",
968};

Referenced by uri_test_exec().

◆ uri_invalid_named_params

struct uri_params_test uri_invalid_named_params
static
Initial value:
= {
"http://boot.ipxe.org/register##paramsXfoo",
{
.scheme = "http",
.host = "boot.ipxe.org",
.path = "/register",
.epath = "/register",
},
}

Invalid named form parameter URI test.

Definition at line 971 of file uri_test.c.

971 {
972 "http://boot.ipxe.org/register##paramsXfoo",
973 {
974 .scheme = "http",
975 .host = "boot.ipxe.org",
976 .path = "/register",
977 .epath = "/register",
978 },
979 NULL,
981};

Referenced by uri_test_exec().

◆ __self_test

struct self_test uri_test __self_test
Initial value:
= {
.name = "uri",
.exec = uri_test_exec,
}
static void uri_test_exec(void)
Perform URI self-test.
Definition uri_test.c:987

URI self-test.

Definition at line 1046 of file uri_test.c.

1046 {
1047 .name = "uri",
1048 .exec = uri_test_exec,
1049};