iPXE
Data Structures | Defines | 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 form parameter URI test list. More...
struct  uri_params_test
 A form parameter URI test. More...

Defines

#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.
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 form parameter URI test list result.
static void uri_params_okx (struct uri_params_test *test, const char *file, unsigned int line)
 Report form 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_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_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_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 []
 Form parameter URI test list.
static struct uri_params_test uri_params
 Form parameter URI test.
static struct uri_params_test_list uri_named_params_list []
 Named form parameter URI test list.
static struct uri_params_test uri_named_params
 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.


Define Documentation

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

Definition at line 156 of file uri_test.c.

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

Definition at line 176 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 203 of file uri_test.c.

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

Definition at line 222 of file uri_test.c.

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

Definition at line 238 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 262 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 303 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 326 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 353 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 401 of file uri_test.c.

Referenced by uri_test_exec().

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

Definition at line 434 of file uri_test.c.

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

Definition at line 483 of file uri_test.c.

Referenced by uri_test_exec().


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
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 122 of file uri_test.c.

References NULL, and strcmp().

Referenced by uri_okx().

                                                               {

        /* Compare strings, allowing for either to be NULL */
        if ( first == second ) {
                return 0;
        } else if ( ( first == NULL ) || ( second == NULL ) ) {
                return -1;
        } else {
                return strcmp ( first, second );
        }
}
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 142 of file uri_test.c.

References uri::fragment, uri::host, okx, uri::opaque, uri::params, uri::password, uri::path, uri::port, uri::query, uri::scheme, uristrcmp(), and uri::user.

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

                                          {

        okx ( uristrcmp ( uri->scheme, expected->scheme ) == 0, file, line );
        okx ( uristrcmp ( uri->opaque, expected->opaque ) == 0, file, line );
        okx ( uristrcmp ( uri->user, expected->user ) == 0, file, line );
        okx ( uristrcmp ( uri->password, expected->password ) == 0, file, line);
        okx ( uristrcmp ( uri->host, expected->host ) == 0, file, line );
        okx ( uristrcmp ( uri->port, expected->port ) == 0, file, line );
        okx ( uristrcmp ( uri->path, expected->path ) == 0, file, line );
        okx ( uristrcmp ( uri->query, expected->query ) == 0, file, line );
        okx ( uristrcmp ( uri->fragment, expected->fragment ) == 0, file, line);
        okx ( uri->params == expected->params, file, line );
}
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 165 of file uri_test.c.

References NULL, okx, parse_uri(), uri_test::string, uri_test::uri, uri_okx(), and uri_put().

Referenced by uri_parse_format_dup_okx().

                                                {
        struct uri *uri;

        /* Parse URI */
        uri = parse_uri ( test->string );
        okx ( uri != NULL, file, line );
        if ( uri )
                uri_okx ( uri, &test->uri, file, line );
        uri_put ( uri );
}
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 185 of file uri_test.c.

References format_uri(), format_uri_alloc(), free, len, NULL, okx, strcmp(), uri_test::string, strlen(), and uri_test::uri.

Referenced by uri_parse_format_dup_okx().

                                                 {
        char buf[ strlen ( test->string ) + 1 /* NUL */ ];
        char *tmp;
        size_t len;

        /* Format into fixed-size buffer */
        len = format_uri ( &test->uri, buf, sizeof ( buf ) );
        okx ( len == ( sizeof ( buf ) - 1 /* NUL */ ), file, line );
        okx ( strcmp ( buf, test->string ) == 0, file, line );

        /* Format into temporarily allocated buffer */
        tmp = format_uri_alloc ( &test->uri );
        okx ( tmp != NULL, file, line );
        if ( tmp )
                okx ( strcmp ( tmp, test->string ) == 0, file, line );
        free ( tmp );
}
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 212 of file uri_test.c.

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

Referenced by uri_parse_format_dup_okx().

                                              {
        struct uri *dup;

        dup = uri_dup ( uri );
        okx ( dup != NULL, file, line );
        if ( dup )
                uri_okx ( dup, uri, file, line );
        uri_put ( dup );
}
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 231 of file uri_test.c.

References uri_test::uri, uri_dup_okx(), uri_format_okx(), and uri_parse_okx().

                                                           {

        uri_parse_okx ( test, file, line );
        uri_format_okx ( test, file, line );
        uri_dup_okx ( &test->uri, file, line );
}
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 248 of file uri_test.c.

References uri_port_test::default_port, NULL, okx, parse_uri(), uri_port_test::port, port, uri_port_test::string, uri_port(), and uri_put().

                                               {
        struct uri *uri;
        unsigned int port;

        /* Parse URI */
        uri = parse_uri ( test->string );
        okx ( uri != NULL, file, line );
        if ( uri ) {
                port = uri_port ( uri, test->default_port );
                okx ( port == test->port, file, line );
        }
        uri_put ( uri );
}
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 271 of file uri_test.c.

References uri_resolve_test::base, base, format_uri_alloc(), formatted, free, NULL, okx, parse_uri(), uri_resolve_test::relative, resolve_uri(), uri_resolve_test::resolved, strcmp(), and uri_put().

Referenced by uri_resolve_path_okx().

                                                                    {
        struct uri *base;
        struct uri *relative;
        struct uri *resolved = NULL;
        char *formatted;

        /* Parse URIs */
        base = parse_uri ( test->base );
        okx ( base != NULL, file, line );
        relative = parse_uri ( test->relative );
        okx ( relative != NULL, file, line );

        /* Resolve URI  */
        if ( base && relative ) {
                resolved = resolve_uri ( base, relative );
                okx ( resolved != NULL, file, line );
        }

        /* Format resolved URI */
        formatted = format_uri_alloc ( resolved );
        okx ( formatted != NULL, file, line );

        /* Check resolved URI */
        if ( formatted )
                okx ( strcmp ( formatted, test->resolved ) == 0, file, line );

        free ( formatted );
        uri_put ( resolved );
        uri_put ( relative );
        uri_put ( base );
}
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 312 of file uri_test.c.

References uri_resolve_test::base, free, NULL, okx, uri_resolve_test::relative, resolve_path(), uri_resolve_test::resolved, strcmp(), and uri_resolve_okx().

                                                                         {
        char *resolved;

        /* Resolve paths using resolve_path() directly */
        resolved = resolve_path ( test->base, test->relative );
        okx ( resolved != NULL, file, line );
        if ( resolved )
                okx ( strcmp ( resolved, test->resolved ) == 0, file, line );
        free ( resolved );

        /* Resolve paths as URIs (since all paths are valid URIs) */
        uri_resolve_okx ( test, file, line );
}
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 336 of file uri_test.c.

References uri_pxe_test::filename, format_uri(), len, NULL, okx, pxe_uri(), uri_pxe_test::sa, uri_pxe_test::server, strcmp(), uri_pxe_test::string, strlen(), uri_pxe_test::uri, uri_okx(), and uri_put().

                                              {
        char buf[ strlen ( test->string ) + 1 /* NUL */ ];
        struct uri *uri;
        size_t len;

        /* Construct URI */
        uri = pxe_uri ( &test->server.sa, test->filename );
        okx ( uri != NULL, file, line );
        if ( uri ) {
                uri_okx ( uri, &test->uri, file, line );
                len = format_uri ( uri, buf, sizeof ( buf ) );
                okx ( len == ( sizeof ( buf ) - 1 /* NUL */ ), file, line );
                okx ( strcmp ( buf, test->string ) == 0, file, line );
        }
        uri_put ( uri );
}
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 362 of file uri_test.c.

References churi(), cwuri, uri_churi_test::expected, format_uri_alloc(), formatted, free, NULL, okx, parse_uri(), uri_churi_test::relative, strcmp(), uri_get(), and uri_put().

                                                {
        struct uri *old_cwuri;
        struct uri *uri;
        char *formatted;

        /* Preserve original current working URI */
        old_cwuri = uri_get ( cwuri );

        /* Perform sequence of current working URI changes */
        do {
                /* Parse relative URI */
                uri = parse_uri ( test->relative );
                okx ( uri != NULL, file, line );

                /* Move to this URI */
                churi ( uri );

                /* Format new current working URI */
                formatted = format_uri_alloc ( cwuri );
                okx ( formatted != NULL, file, line );
                if ( formatted ) {
                        okx ( strcmp ( formatted, test->expected ) == 0,
                              file, line );
                }

                /* Free temporary storage */
                free ( formatted );
                uri_put ( uri );

                /* Move to next current working URI test */
                test++;

        } while ( test->relative != NULL );

        /* Restore original current working URI */
        churi ( old_cwuri );
        uri_put ( old_cwuri );
}
static void uri_params_list_okx ( struct uri_params_test test,
struct uri uri,
const char *  file,
unsigned int  line 
) [static]

Report form parameter URI test list result.

Parameters:
testForm parameter URI test
uriURI
fileTest code file
lineTest code line

Definition at line 411 of file uri_test.c.

References for_each_param, parameter::key, uri_params_test_list::key, uri_params_test::list, NULL, okx, param, uri::params, strcmp(), uri_params_test::uri, uri_okx(), parameter::value, and uri_params_test_list::value.

Referenced by uri_params_okx().

                                                      {
        struct uri_params_test_list *list;
        struct parameter *param;

        /* Check URI */
        uri_okx ( uri, &test->uri, file, line );

        /* Check URI parameters */
        okx ( uri->params != NULL, file, line );
        if ( uri->params ) {
                list = test->list;
                for_each_param ( param, uri->params ) {
                        okx ( strcmp ( param->key, list->key ) == 0,
                              file, line );
                        okx ( strcmp ( param->value, list->value ) == 0,
                              file, line );
                        list++;
                }
                okx ( list->key == NULL, file, line );
        }
}
static void uri_params_okx ( struct uri_params_test test,
const char *  file,
unsigned int  line 
) [static]

Report form parameter URI test result.

Parameters:
testForm parameter URI test
fileTest code file
lineTest code line

Definition at line 444 of file uri_test.c.

References add_parameter(), create_parameters(), uri_params_test_list::key, uri_params_test::list, uri_params_test::name, NULL, okx, param, uri::params, params, parse_uri(), uri_params_test::string, uri_params_test::uri, uri_dup(), uri_params_list_okx(), uri_put(), and uri_params_test_list::value.

                                                 {
        struct uri_params_test_list *list;
        struct parameters *params;
        struct parameter *param;
        struct uri *uri;
        struct uri *dup;

        /* Create parameter list */
        params = create_parameters ( test->name );
        okx ( params != NULL, file, line );
        if ( params ) {
                for ( list = test->list ; list->key ; list++ ) {
                        param = add_parameter ( params, list->key, list->value);
                        okx ( param != NULL, file, line );
                }
        }

        /* Record parameter list as part of expected URI */
        test->uri.params = params;

        /* Parse URI */
        uri = parse_uri ( test->string );
        okx ( uri != NULL, file, line );
        if ( uri )
                uri_params_list_okx ( test, uri, file, line );

        /* Duplicate URI */
        dup = uri_dup ( uri );
        okx ( dup != NULL, file, line );
        if ( dup )
                uri_params_list_okx ( test, dup, file, line );

        /* Clear parameter list in expected URI */
        test->uri.params = NULL;

        uri_put ( uri );
        uri_put ( dup );
}
static void uri_test_exec ( void  ) [static]

Perform URI self-test.

URI port number tests

Path resolution tests

URI resolution tests

Definition at line 914 of file uri_test.c.

References uri_churi_ok, uri_params_ok, uri_parse_format_dup_ok, uri_parse_ok, uri_port_ok, uri_pxe_ok, uri_resolve_ok, and uri_resolve_path_ok.

                                   {

        /* URI parsing, formatting, and duplication tests */
        uri_parse_format_dup_ok ( &uri_empty );
        uri_parse_format_dup_ok ( &uri_boot_ipxe_org );
        uri_parse_format_dup_ok ( &uri_mailto );
        uri_parse_format_dup_ok ( &uri_path );
        uri_parse_format_dup_ok ( &uri_path_escaped );
        uri_parse_format_dup_ok ( &uri_http_all );
        uri_parse_format_dup_ok ( &uri_http_escaped );
        uri_parse_ok ( &uri_http_escaped_improper ); /* Parse only */
        uri_parse_format_dup_ok ( &uri_ipv6 );
        uri_parse_format_dup_ok ( &uri_ipv6_port );
        uri_parse_format_dup_ok ( &uri_ipv6_local );
        uri_parse_ok ( &uri_ipv6_local_non_conforming ); /* Parse only */
        uri_parse_format_dup_ok ( &uri_iscsi );
        uri_parse_format_dup_ok ( &uri_file_relative );
        uri_parse_format_dup_ok ( &uri_file_absolute );
        uri_parse_format_dup_ok ( &uri_file_volume );

        /** URI port number tests */
        uri_port_ok ( &uri_explicit_port );
        uri_port_ok ( &uri_default_port );

        /** Path resolution tests */
        uri_resolve_path_ok ( &uri_simple_path );
        uri_resolve_path_ok ( &uri_relative_path );
        uri_resolve_path_ok ( &uri_directory_path );
        uri_resolve_path_ok ( &uri_excessive_path );
        uri_resolve_path_ok ( &uri_absolute_path );

        /** URI resolution tests */
        uri_resolve_ok ( &uri_relative );
        uri_resolve_ok ( &uri_absolute );
        uri_resolve_ok ( &uri_absolute_uri_path );
        uri_resolve_ok ( &uri_query );
        uri_resolve_ok ( &uri_fragment );

        /* PXE URI construction tests */
        uri_pxe_ok ( &uri_pxe_absolute );
        uri_pxe_ok ( &uri_pxe_absolute_path );
        uri_pxe_ok ( &uri_pxe_relative_path );
        uri_pxe_ok ( &uri_pxe_icky );
        uri_pxe_ok ( &uri_pxe_port );

        /* Current working URI tests */
        uri_churi_ok ( uri_churi );

        /* Form parameter URI tests */
        uri_params_ok ( &uri_params );
        uri_params_ok ( &uri_named_params );
}

Variable Documentation

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

Empty URI.

Definition at line 486 of file uri_test.c.

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" }
}

Basic HTTP URI.

Definition at line 491 of file uri_test.c.

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 497 of file uri_test.c.

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

Basic path-only URI.

Definition at line 503 of file uri_test.c.

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

Path-only URI with escaped characters.

Definition at line 509 of file uri_test.c.

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",
                .query = "a=b&c=d",
                .fragment = "bit",
        },
}

HTTP URI with all the trimmings.

Definition at line 515 of file uri_test.c.

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",
                .query = "kind#of/uri is",
                .fragment = "this?",
        },
}

HTTP URI with escaped characters.

Definition at line 530 of file uri_test.c.

Initial value:
 {
        
        "https://test%2eipxe.org/wt%66%3f\n?kind%23of/uri is#this?",
        {
                .scheme = "https",
                .host = "test.ipxe.org",
                .path = "/wtf?\n",
                .query = "kind#of/uri is",
                .fragment = "this?",
        },
}

HTTP URI with improperly escaped characters.

Definition at line 542 of file uri_test.c.

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 = "/",
        },
}

IPv6 URI.

Definition at line 559 of file uri_test.c.

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",
        },
}

IPv6 URI with port.

Definition at line 569 of file uri_test.c.

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",
        },
}

IPv6 URI with link-local address.

Definition at line 580 of file uri_test.c.

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

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

Definition at line 590 of file uri_test.c.

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 605 of file uri_test.c.

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 614 of file uri_test.c.

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

File URI with absolute path.

Definition at line 623 of file uri_test.c.

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

File URI with volume name.

Definition at line 632 of file uri_test.c.

Initial value:
 {
        "http://192.168.0.1:8080/boot.php",
        80,
        8080,
}

URI with port number.

Definition at line 642 of file uri_test.c.

Initial value:
 {
        "http://192.168.0.1/boot.php",
        80,
        80,
}

URI without port number.

Definition at line 649 of file uri_test.c.

Initial value:
 {
        "/etc/passwd",
        "group",
        "/etc/group",
}

Simple path resolution test.

Definition at line 656 of file uri_test.c.

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 663 of file uri_test.c.

Initial value:
 {
        "/test/cgi-bin.pl/boot.ipxe",
        "..",
        "/test/",
}

Path resolution test terminating with directory.

Definition at line 670 of file uri_test.c.

Initial value:
 {
        "/var/lib/tftpboot/ipxe.pxe",
        "../../../../../../../foo",
        "/foo",
}

Path resolution test with excessive ".." elements.

Definition at line 677 of file uri_test.c.

Initial value:
 {
        "/var/lib/tftpboot",
        "/etc/hostname",
        "/etc/hostname",
}

Path resolution test with absolute path.

Definition at line 684 of file uri_test.c.

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 691 of file uri_test.c.

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 698 of file uri_test.c.

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 705 of file uri_test.c.

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 712 of file uri_test.c.

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 719 of file uri_test.c.

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",
        },
        "http://not.a.tftp/uri",
}

PXE URI with absolute URI.

Definition at line 726 of file uri_test.c.

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",
        },
        "tftp://192.168.0.2//absolute/path",
}

PXE URI with absolute path.

Definition at line 744 of file uri_test.c.

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",
        },
        "tftp://192.168.0.3/relative/path",
}

PXE URI with relative path.

Definition at line 762 of file uri_test.c.

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",
        },
        "tftp://10.0.0.6/C%3A\\tftpboot\\icky%23path",
}

PXE URI with path containing special characters.

Definition at line 780 of file uri_test.c.

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",
        },
        "tftp://192.168.0.1:4069//another/path",
}

PXE URI with custom port.

Definition at line 798 of file uri_test.c.

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",
        },
        {
                NULL,
                NULL,
        }
}

Current working URI test.

Definition at line 818 of file uri_test.c.

Initial value:
 {
        {
                "vendor",
                "10ec",
        },
        {
                "device",
                "8139",
        },
        {
                "uuid",
                "f59fac00-758f-498f-9fe5-87d790045d94",
        },
        {
                NULL,
                NULL,
        }
}

Form parameter URI test list.

Definition at line 850 of file uri_test.c.

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",
        },
        NULL,
        uri_params_list,
}

Form parameter URI test.

Definition at line 870 of file uri_test.c.

Initial value:
 {
        {
                "mac",
                "00:1e:65:80:d3:b6",
        },
        {
                "serial",
                "LXTQ20Z1139322762F2000",
        },
        {
                NULL,
                NULL,
        }
}

Named form parameter URI test list.

Definition at line 882 of file uri_test.c.

Initial value:
 {
        "http://192.168.100.4:3001/register##params=foo",
        {
                .scheme = "http",
                .host = "192.168.100.4",
                .port = "3001",
                .path = "/register",
        },
        "foo",
        uri_named_params_list,
}

Named form parameter URI test.

Definition at line 898 of file uri_test.c.

Initial value:
 {
        .name = "uri",
        .exec = uri_test_exec,
}

URI self-test.

Definition at line 968 of file uri_test.c.