summaryrefslogtreecommitdiffstats
path: root/src/tests
Commit message (Collapse)AuthorAgeFilesLines
...
* [test] Add IPv4 self-testsMichael Brown2015-02-182-0/+148
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add constant-length memset() self-testsMichael Brown2015-02-172-0/+154
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for more string functionsMichael Brown2015-02-171-0/+88
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uri] Allow tftp_uri() to construct a URI with a custom portMichael Brown2015-02-061-4/+20
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Fix parsing of OCSP responder ID key hashMichael Brown2014-11-241-0/+411
| | | | | | | | | | | | | | | | | | | | We currently compare the entirety of the KeyHash object (including the ASN.1 tag and length byte) against the raw SHA-1 hash of the certificate's public key. This causes OCSP validation to fail for any responses which identify the responder by key hash rather than by name, and hence prevents the use of X.509 certificates where any certificate in the chain has an OCSP responder which chooses to identify itself via its key hash. Fix by adding the missing asn1_enter() required to enter the ASN.1 octet string containing the key hash. Also add a corresponding test case including an OCSP response where the responder is identified by key hash, to ensure that this functionality cannot be broken in future. Debugged-by: Brian Rak <brak@gameservers.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add support for iPAddress subject alternative namesMichael Brown2014-07-111-40/+49
| | | | | Originally-implemented-by: Jarrod Johnson <jarrod.b.johnson@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv6] Fix definition of IN6_IS_ADDR_LINKLOCAL()Michael Brown2014-05-211-0/+38
| | | | | | | | Fix an erroneous htonl() in the definition of IN6_IS_ADDR_LINKLOCAL(), and add self-tests for the IN6_IS_ADDR_xxx() family of macros. Reported-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Prevent strndup() from reading beyond the end of the stringMichael Brown2014-05-181-0/+20
| | | | | | | | | | | | strndup() may be called on a string which is not NUL-terminated. Use strnlen() instead of strlen() to ensure that we do not read beyond the end of such a string. Add self-tests for strndup(), including a test case with an unterminated string. Originally-fixed-by: Marin Hannache <git@mareo.fr> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for strdup()Michael Brown2014-05-181-0/+10
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Print out profiling statistics after a successful test runMichael Brown2014-05-021-0/+2
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [profile] Add generic profiling infrastructureMichael Brown2014-04-286-29/+204
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add flsll()Michael Brown2014-04-271-0/+37
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [libc] Add isqrt() function to find integer square rootsMichael Brown2014-04-261-0/+11
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Check for correct -mrtd assumption on libgcc arithmetic functionsMichael Brown2014-04-261-4/+74
| | | | | | | | | | | | | | | | | | | | | | | | As observed in commit 082cedb ("[build] Fix __libgcc attribute for recent gcc versions"), recent versions of gcc have changed the semantics of -mrtd as applied to the implicit arithmetic functions. It is possible for tests to succeed even if our assumptions about gcc's interpretation of -mrtd are incorrect. In particular, if gcc chooses to utilise a frame pointer in the calling function, then it can tolerate a temporarily incorrect stack pointer (since the stack pointer will shortly afterwards be restored from the frame pointer anyway). Add tests designed specifically to check that our implementations of the implicit arithmetic functions manipulate the stack pointer as expected by gcc. The effect of these tests can be observed by temporarily reverting commit 082cedb ("[build] Fix __libgcc attribute for recent gcc versions"): without this fix in place, the tests will fail on gcc 4.7 and later. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add tests for 64-bit divisionMichael Brown2014-04-251-0/+122
| | | | | | | | | | On a 32-bit system, 64-bit division is implemented using the libgcc functions provided in __udivmoddi4.c etc. Calls to these functions are generated automatically by gcc, with a calling convention that is somewhat empirical in nature. Add these self-tests primarily as a check that we are using the correct calling convention. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for flsl()Michael Brown2014-04-242-0/+87
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Rewrite TCP/IP tests using okx()Michael Brown2014-04-241-38/+53
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Add support for subjectAltName and wildcard certificatesMichael Brown2014-03-311-0/+9
| | | | | Originally-implemented-by: Alex Chernyakhovsky <achernya@google.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add subject alternative names to X.509 server test certificateMichael Brown2014-03-311-69/+75
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add tests for x509_check_name()Michael Brown2014-03-311-0/+38
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Rewrite CMS tests using okx()Michael Brown2014-03-311-14/+40
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Rewrite X.509 tests using okx()Michael Brown2014-03-311-61/+145
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [crypto] Generalise X.509 cache to a full certificate storeMichael Brown2014-03-282-37/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Expand the concept of the X.509 cache to provide the functionality of a certificate store. Certificates in the store will be automatically used to complete certificate chains where applicable. The certificate store may be prepopulated at build time using the CERT=... build command line option. For example: make bin/ipxe.usb CERT=mycert1.crt,mycert2.crt Certificates within the certificate store are not implicitly trusted; the trust list is specified using TRUST=... as before. For example: make bin/ipxe.usb CERT=root.crt TRUST=root.crt This can be used to embed the full trusted root certificate within the iPXE binary, which is potentially useful in an HTTPS-only environment in which there is no HTTP server from which to automatically download cross-signed certificates or other certificate chain fragments. This usage of CERT= extends the existing use of CERT= to specify the client certificate. The client certificate is now identified automatically by checking for a match against the private key. For example: make bin/ipxe.usb CERT=root.crt,client.crt TRUST=root.crt KEY=client.key Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [uri] Refactor URI parsing and formattingMichael Brown2014-02-272-120/+833
| | | | | | | | | | | | | | | | | | | | | | | | Add support for parsing of URIs containing literal IPv6 addresses (e.g. "http://[fe80::69ff:fe50:5845%25net0]/boot.ipxe"). Duplicate URIs by directly copying the relevant fields, rather than by formatting and reparsing a URI string. This relaxes the requirements on the URI formatting code and allows it to focus on generating human-readable URIs (e.g. by not escaping ':' characters within literal IPv6 addresses). As a side-effect, this allows relative URIs containing parameter lists (e.g. "../boot.php##params") to function as expected. Add validity check for FTP paths to ensure that only printable characters are accepted (since FTP is a human-readable line-based protocol with no support for character escaping). Construct TFTP next-server+filename URIs directly, rather than parsing a constructed "tftp://..." string, Add self-tests for URI functions. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Remove "uristring" setting typeMichael Brown2014-02-271-13/+0Star
| | | | | | | | | | | | | | Commit b5f5f73 ("[cmdline] Expand settings within each command-line token individually") effectively rendered the "uristring" setting type obsolete, since strings containing whitespace no longer break the command line parser. The concept of the "uristring" type is not well defined, since URI escaping rules depend on which portion of a URI is being escaped. Remove the "uristring" type, converting it into an alias for the "string" setting type so as to avoid breaking existing scripts. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [dns] Support DNS search listsMichael Brown2014-02-052-0/+606
| | | | | | | | | | | Update the DNS resolver to support DNS search lists (as provided by DHCP option 119, DHCPv6 option 24, or NDP option 31). Add validation code to ensure that parsing of DNS packets does not overrun the input, get stuck in infinite loops, or (worse) write beyond the end of allocated buffers. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [png] Add support for PNG imagesMichael Brown2014-01-122-0/+1994
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Generalise pnm_ok() to pixbuf_ok()Michael Brown2014-01-123-88/+157
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Rewrite pnm_ok() using okx()Michael Brown2014-01-121-29/+36
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [deflate] Fix literal data length calculationMichael Brown2014-01-121-0/+7
| | | | | | | | Fix incorrect calculation used to determine length of data to be copied within a literal data block, and add a test case to prevent this bug from going undetected in future. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [deflate] Add support for DEFLATE decompressionMichael Brown2014-01-062-0/+240
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Explicitly separate the concept of a completed fetched settingMichael Brown2013-12-051-53/+54
| | | | | | | | | | The fetch_setting() family of functions may currently modify the definition of the specified setting (e.g. to add missing type information). Clean up this interface by requiring callers to provide an explicit buffer to contain the completed definition of the fetched setting, if required. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [pnm] Add support for PNM imagesMichael Brown2013-11-272-0/+297
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Include failing code within failed test result outputMichael Brown2013-11-271-3/+5
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv6] Add "ipv6" setting typeMichael Brown2013-11-141-0/+16
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv6] Add inet6_aton()Michael Brown2013-09-111-0/+66
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [ipv6] Replace IPv6 stackMichael Brown2013-09-032-0/+116
| | | | | | | | | | | | | | | | Replace the existing partially-implemented IPv6 stack with a fresh implementation. This implementation is not yet complete. The IPv6 transmit and receive datapaths are functional (including fragment reassembly and parsing of arbitrary extension headers). NDP neighbour solicitations and advertisements are supported. ICMPv6 echo is supported. At present, only link-local addresses may be used, and there is no way to specify an IPv6 address as part of a URI (either directly or via a DNS lookup). Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Allow numeric_setting_value() to handle long setting valuesMichael Brown2013-08-121-0/+6
| | | | | | | | | | | Allow numeric_setting_value() to handle e.g. the byte sequence 00:00:00:00:12:34:56:78 by returning -ERANGE only if the value actually overflows the return type. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for snprintf()Michael Brown2013-08-122-0/+103
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Introduce the generalised concept of a numeric settingMichael Brown2013-08-011-2/+89
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "busdevfn" setting typeMichael Brown2013-07-121-0/+10
| | | | | | | Allow network device's "busloc" setting to be formatted as a PCI bus:dev.fn address using e.g. ${net0/busloc:busdevfn}. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Add "hexraw" setting typeMichael Brown2013-07-121-0/+14
| | | | | Originally-implemented-by: Jeppe Toustrup <ipxe@tenzer.dk> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [settings] Use hex_decode() to parse hex settingsMichael Brown2013-07-121-7/+9
| | | | | | | | | | Use hex_decode() to parse "hex" and "hexhyp" settings. Note that this parser is stricter than the old parser; it now requires exactly two hex digits for each byte. (The old parser was based upon strtoul() and so would allow leading whitespace and a leading plus or minus sign.) Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for base16Michael Brown2013-07-122-0/+122
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for string functionsMichael Brown2012-11-122-0/+134
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Remove self-test for empty formatted setting valueMichael Brown2012-10-201-2/+0Star
| | | | | | | | | | | Commit 5ad445f ("[settings] Treat an empty formatted value as meaning "delete setting"") (re)defined the semantics of storing an empty formatted setting as meaning "delete setting". Remove the existing self-test using an empty formatted hex setting value, since it no longer conforms to the defined semantics. Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add speed tests for cipher algorithmsMichael Brown2012-09-263-4/+94
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add speed tests for digest algorithmsMichael Brown2012-09-265-0/+54
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [legal] Update FSF mailing address in GPL licence textsMichael Brown2012-07-2020-20/+40
| | | | | Suggested-by: Daniel P. Berrange <berrange@redhat.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
* [test] Add self-tests for TCP/IP checksum calculationMichael Brown2012-06-272-0/+214
| | | | Signed-off-by: Michael Brown <mcb30@ipxe.org>