iPXE
Data Structures | Macros | Functions | Variables
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)   uri_okx ( uri, expected, __FILE__, __LINE__ )
 
#define uri_parse_ok(test)   uri_parse_okx ( test, __FILE__, __LINE__ )
 
#define uri_format_ok(test)   uri_format_okx ( test, __FILE__, __LINE__ )
 
#define uri_dup_ok(test)   uri_dup_okx ( test, __FILE__, __LINE__ )
 
#define uri_parse_format_dup_ok(test)   uri_parse_format_dup_okx ( test, __FILE__, __LINE__ )
 
#define uri_port_ok(test)   uri_port_okx ( test, __FILE__, __LINE__ )
 
#define uri_resolve_ok(test)   uri_resolve_okx ( test, __FILE__, __LINE__ )
 
#define uri_resolve_path_ok(test)   uri_resolve_path_okx ( test, __FILE__, __LINE__ )
 
#define uri_pxe_ok(test)   uri_pxe_okx ( test, __FILE__, __LINE__ )
 
#define uri_churi_ok(test)   uri_churi_okx ( test, __FILE__, __LINE__ )
 
#define uri_params_list_ok(test)   uri_params_list_okx ( test, __FILE__, __LINE__ )
 
#define uri_params_ok(test)   uri_params_okx ( test, __FILE__, __LINE__ )
 

Functions

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

Variables

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

Detailed Description

URI self-tests.

Definition in file uri_test.c.

Macro Definition Documentation

◆ uri_ok

#define uri_ok (   uri,
  expected 
)    uri_okx ( uri, expected, __FILE__, __LINE__ )

Definition at line 160 of file uri_test.c.

◆ uri_parse_ok

#define uri_parse_ok (   test)    uri_parse_okx ( test, __FILE__, __LINE__ )

Definition at line 180 of file uri_test.c.

◆ uri_format_ok

#define uri_format_ok (   test)    uri_format_okx ( test, __FILE__, __LINE__ )

Definition at line 207 of file uri_test.c.

◆ uri_dup_ok

#define uri_dup_ok (   test)    uri_dup_okx ( test, __FILE__, __LINE__ )

Definition at line 226 of file uri_test.c.

◆ uri_parse_format_dup_ok

#define uri_parse_format_dup_ok (   test)    uri_parse_format_dup_okx ( test, __FILE__, __LINE__ )

Definition at line 242 of file uri_test.c.

◆ uri_port_ok

#define uri_port_ok (   test)    uri_port_okx ( test, __FILE__, __LINE__ )

Definition at line 266 of file uri_test.c.

◆ uri_resolve_ok

#define uri_resolve_ok (   test)    uri_resolve_okx ( test, __FILE__, __LINE__ )

Definition at line 307 of file uri_test.c.

◆ uri_resolve_path_ok

#define uri_resolve_path_ok (   test)    uri_resolve_path_okx ( test, __FILE__, __LINE__ )

Definition at line 330 of file uri_test.c.

◆ uri_pxe_ok

#define uri_pxe_ok (   test)    uri_pxe_okx ( test, __FILE__, __LINE__ )

Definition at line 357 of file uri_test.c.

◆ uri_churi_ok

#define uri_churi_ok (   test)    uri_churi_okx ( test, __FILE__, __LINE__ )

Definition at line 405 of file uri_test.c.

◆ uri_params_list_ok

#define uri_params_list_ok (   test)    uri_params_list_okx ( test, __FILE__, __LINE__ )

Definition at line 439 of file uri_test.c.

◆ uri_params_ok

#define uri_params_ok (   test)    uri_params_okx ( test, __FILE__, __LINE__ )

Definition at line 489 of file uri_test.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ uristrcmp()

static 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 }
static __always_inline int off_t userptr_t second
Definition: efi_uaccess.h:80
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
uint32_t first
Length to skip in first segment.
Definition: pccrc.h:23

References first, NULL, second, and strcmp().

Referenced by uri_okx().

◆ uri_okx()

static 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 * equery
Query (with original URI encoding)
Definition: uri.h:84
const char * port
Port number.
Definition: uri.h:78
const char * scheme
Scheme.
Definition: uri.h:68
#define okx(success, file, line)
Report test result.
Definition: test.h:44
const char * path
Path (after URI decoding)
Definition: uri.h:80
struct parameters * params
Request parameters.
Definition: uri.h:88
const char * host
Host name.
Definition: uri.h:76
const char * efragment
Fragment (with original URI encoding)
Definition: uri.h:86
const char * opaque
Opaque part.
Definition: uri.h:70
const char * password
Password.
Definition: uri.h:74
const char * epath
Path (with original URI encoding)
Definition: uri.h:82
const char * user
User name.
Definition: uri.h:72
A Uniform Resource Identifier.
Definition: uri.h:64
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()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
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
#define okx(success, file, line)
Report test result.
Definition: test.h:44
A Uniform Resource Identifier.
Definition: uri.h:64
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296

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

Referenced by uri_parse_format_dup_okx().

◆ uri_format_okx()

static 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 }
unsigned long tmp
Definition: linux_pci.h:53
#define okx(success, file, line)
Report test result.
Definition: test.h:44
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition: uri.c:471
char * format_uri_alloc(const struct uri *uri)
Format URI.
Definition: uri.c:540
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
uint32_t len
Length.
Definition: ena.h:14
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73

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()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
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
#define okx(success, file, line)
Report test result.
Definition: test.h:44
struct uri * uri_dup(const struct uri *uri)
Duplicate URI.
Definition: uri.c:594
A Uniform Resource Identifier.
Definition: uri.h:64
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

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

Referenced by uri_parse_format_dup_okx().

◆ uri_parse_format_dup_okx()

static 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 }
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
static void uri_dup_okx(struct uri *uri, const char *file, unsigned int line)
Report URI duplication test result.
Definition: uri_test.c:216
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

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

◆ uri_port_okx()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
u8 port
Port number.
Definition: CIB_PRM.h:31
#define okx(success, file, line)
Report test result.
Definition: test.h:44
unsigned int uri_port(const struct uri *uri, unsigned int default_port)
Get port from URI.
Definition: uri.c:455
A Uniform Resource Identifier.
Definition: uri.h:64
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296

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

◆ uri_resolve_okx()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
static const void * base
Base address.
Definition: crypto.h:335
#define okx(success, file, line)
Report test result.
Definition: test.h:44
char * format_uri_alloc(const struct uri *uri)
Format URI.
Definition: uri.c:540
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
uint8_t formatted[5]
Formatted area.
Definition: smbios.h:29
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
A Uniform Resource Identifier.
Definition: uri.h:64
struct uri * resolve_uri(const struct uri *base_uri, struct uri *relative_uri)
Resolve base+relative URI.
Definition: uri.c:694
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296

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()

static 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 }
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
#define okx(success, file, line)
Report test result.
Definition: test.h:44
char * resolve_path(const char *base_path, const char *relative_path)
Resolve base+relative path.
Definition: uri.c:632
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73

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

◆ uri_pxe_okx()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
struct uri * pxe_uri(struct sockaddr *sa_server, const char *filename)
Construct URI from server address and filename.
Definition: uri.c:808
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
#define okx(success, file, line)
Report test result.
Definition: test.h:44
size_t format_uri(const struct uri *uri, char *buf, size_t len)
Format URI.
Definition: uri.c:471
size_t strlen(const char *src)
Get length of string.
Definition: string.c:243
uint32_t len
Length.
Definition: ena.h:14
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
A Uniform Resource Identifier.
Definition: uri.h:64
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73

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

◆ uri_churi_okx()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
static struct uri * uri_get(struct uri *uri)
Increment URI reference count.
Definition: uri.h:194
#define okx(success, file, line)
Report test result.
Definition: test.h:44
void churi(struct uri *uri)
Change working URI.
Definition: cwuri.c:45
char * format_uri_alloc(const struct uri *uri)
Format URI.
Definition: uri.c:540
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
uint8_t formatted[5]
Formatted area.
Definition: smbios.h:29
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
A Uniform Resource Identifier.
Definition: uri.h:64
struct uri * cwuri
Current working URI.
Definition: cwuri.c:38
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296

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

◆ uri_params_list_okx()

static 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 }
#define for_each_param(param, params)
Iterate over all request parameters in a list.
Definition: params.h:83
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
#define okx(success, file, line)
Report test result.
Definition: test.h:44
struct parameters * params
Request parameters.
Definition: uri.h:88
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
struct list_head list
List of request parameters.
Definition: params.h:30
int strcmp(const char *first, const char *second)
Compare strings.
Definition: string.c:173
A Uniform Resource Identifier.
Definition: uri.h:64
A request parameter.
Definition: params.h:28
A request parameter URI test list.
Definition: uri_test.c:96
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73

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

Referenced by uri_params_okx().

◆ uri_params_okx()

static 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 }
static void uri_put(struct uri *uri)
Decrement URI reference count.
Definition: uri.h:205
const char * value
Value.
Definition: uri_test.c:100
A request parameter list.
Definition: params.h:16
unsigned int flags
Flags.
Definition: uri_test.c:102
const char * key
Key.
Definition: uri_test.c:98
#define okx(success, file, line)
Report test result.
Definition: test.h:44
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
struct parameters * create_parameters(const char *name)
Create request parameter list.
Definition: params.c:86
struct parameters * params
Request parameters.
Definition: uri.h:88
struct hv_monitor_parameter param[4][32]
Parameters.
Definition: hyperv.h:24
struct uri * uri_dup(const struct uri *uri)
Duplicate URI.
Definition: uri.c:594
A Uniform Resource Identifier.
Definition: uri.h:64
A request parameter.
Definition: params.h:28
A request parameter URI test list.
Definition: uri_test.c:96
struct parameter * add_parameter(struct parameters *params, const char *key, const char *value, unsigned int flags)
Add request parameter.
Definition: params.c:129
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static int test
Definition: epic100.c:73
struct uri * parse_uri(const char *uri_string)
Parse URI.
Definition: uri.c:296

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()

static void uri_test_exec ( void  )
static

Perform URI self-test.

URI port number tests

Path resolution tests

URI resolution tests

Definition at line 960 of file uri_test.c.

960  {
961 
962  /* URI parsing, formatting, and duplication tests */
971  uri_parse_ok ( &uri_http_escaped_improper ); /* Parse only */
975  uri_parse_ok ( &uri_ipv6_local_non_conforming ); /* Parse only */
981 
982  /** URI port number tests */
985 
986  /** Path resolution tests */
992 
993  /** URI resolution tests */
999 
1000  /* PXE URI construction tests */
1004  uri_pxe_ok ( &uri_pxe_icky );
1005  uri_pxe_ok ( &uri_pxe_port );
1006 
1007  /* Current working URI tests */
1008  uri_churi_ok ( uri_churi );
1009 
1010  /* Request parameter URI tests */
1013 }
static struct uri_test uri_ipv6_local
IPv6 URI with link-local address.
Definition: uri_test.c:599
static struct uri_test uri_ipv6
IPv6 URI.
Definition: uri_test.c:576
static struct uri_resolve_test uri_absolute
Absolute URI resolution test.
Definition: uri_test.c:730
static struct uri_port_test uri_explicit_port
URI with port number.
Definition: uri_test.c:674
static struct uri_pxe_test uri_pxe_relative_path
PXE URI with relative path.
Definition: uri_test.c:796
static struct uri_test uri_http_escaped
HTTP URI with escaped characters.
Definition: uri_test.c:545
static struct uri_test uri_empty
Empty URI.
Definition: uri_test.c:492
#define uri_parse_format_dup_ok(test)
Definition: uri_test.c:242
static struct uri_pxe_test uri_pxe_absolute
PXE URI with absolute URI.
Definition: uri_test.c:758
static struct uri_params_test uri_params
Request parameter URI test.
Definition: uri_test.c:911
static struct uri_test uri_file_volume
File URI with volume name.
Definition: uri_test.c:654
static struct uri_test uri_file_relative
File URI with relative (opaque) path.
Definition: uri_test.c:635
static struct uri_pxe_test uri_pxe_port
PXE URI with custom port.
Definition: uri_test.c:834
static struct uri_resolve_test uri_fragment
Fragment URI resolution test.
Definition: uri_test.c:751
#define uri_port_ok(test)
Definition: uri_test.c:266
static struct uri_resolve_test uri_query
Query URI resolution test.
Definition: uri_test.c:744
#define uri_resolve_ok(test)
Definition: uri_test.c:307
static struct uri_resolve_test uri_relative_path
Path resolution test with "." and ".." elements.
Definition: uri_test.c:695
static struct uri_resolve_test uri_absolute_path
Path resolution test with absolute path.
Definition: uri_test.c:716
static struct uri_test uri_boot_ipxe_org
Basic HTTP URI.
Definition: uri_test.c:497
static struct uri_resolve_test uri_directory_path
Path resolution test terminating with directory.
Definition: uri_test.c:702
static struct uri_test uri_iscsi
iSCSI URI
Definition: uri_test.c:626
static struct uri_test uri_http_escaped_improper
HTTP URI with improperly escaped characters.
Definition: uri_test.c:558
static struct uri_resolve_test uri_excessive_path
Path resolution test with excessive ".." elements.
Definition: uri_test.c:709
static struct uri_churi_test uri_churi[]
Current working URI test.
Definition: uri_test.c:855
static struct uri_test uri_http_all
HTTP URI with all the trimmings.
Definition: uri_test.c:529
static struct uri_test uri_colons
Relative URI with colons in path.
Definition: uri_test.c:665
static struct uri_test uri_ipv6_port
IPv6 URI with port.
Definition: uri_test.c:587
static struct uri_resolve_test uri_absolute_uri_path
Absolute path URI resolution test.
Definition: uri_test.c:737
static struct uri_params_test uri_named_params
Named request parameter URI test.
Definition: uri_test.c:943
#define uri_params_ok(test)
Definition: uri_test.c:489
static struct uri_test uri_path
Basic path-only URI.
Definition: uri_test.c:516
static struct uri_test uri_host
Basic host-only URI.
Definition: uri_test.c:510
static struct uri_test uri_mailto
Basic opaque URI.
Definition: uri_test.c:504
static struct uri_resolve_test uri_relative
Relative URI resolution test.
Definition: uri_test.c:723
#define uri_churi_ok(test)
Definition: uri_test.c:405
static struct uri_pxe_test uri_pxe_absolute_path
PXE URI with absolute path.
Definition: uri_test.c:777
static struct uri_test uri_file_absolute
File URI with absolute path.
Definition: uri_test.c:644
#define uri_pxe_ok(test)
Definition: uri_test.c:357
static struct uri_test uri_path_escaped
Path-only URI with escaped characters.
Definition: uri_test.c:523
static struct uri_resolve_test uri_simple_path
Simple path resolution test.
Definition: uri_test.c:688
#define uri_resolve_path_ok(test)
Definition: uri_test.c:330
static struct uri_port_test uri_default_port
URI without port number.
Definition: uri_test.c:681
#define uri_parse_ok(test)
Definition: uri_test.c:180
static struct uri_pxe_test uri_pxe_icky
PXE URI with path containing special characters.
Definition: uri_test.c:815
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_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_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, 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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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 htonl(value)
Definition: byteswap.h:133
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63

PXE URI with absolute URI.

Definition at line 758 of file uri_test.c.

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",
}
#define htonl(value)
Definition: byteswap.h:133
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63

PXE URI with absolute path.

Definition at line 777 of file uri_test.c.

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",
}
#define htonl(value)
Definition: byteswap.h:133
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63

PXE URI with relative path.

Definition at line 796 of file uri_test.c.

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",
}
#define htonl(value)
Definition: byteswap.h:133
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63

PXE URI with path containing special characters.

Definition at line 815 of file uri_test.c.

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 htonl(value)
Definition: byteswap.h:133
#define htons(value)
Definition: byteswap.h:135
#define AF_INET
IPv4 Internet addresses.
Definition: socket.h:63

PXE URI with custom port.

Definition at line 834 of file uri_test.c.

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",
},
{
}
}
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

Current working URI test.

Definition at line 855 of file uri_test.c.

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_FORM
Request parameter is a form parameter.
Definition: params.h:40
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define PARAMETER_HEADER
Request parameter is a header parameter.
Definition: params.h:43

Request parameter URI test list.

Definition at line 887 of file uri_test.c.

◆ 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:887
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

Request parameter URI test.

Definition at line 911 of file uri_test.c.

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,
}
}
#define PARAMETER_FORM
Request parameter is a form parameter.
Definition: params.h:40
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

Named request parameter URI test list.

Definition at line 924 of file uri_test.c.

◆ 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:924

Named request parameter URI test.

Definition at line 943 of file uri_test.c.

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:960

URI self-test.

Definition at line 1016 of file uri_test.c.