diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-03-06 13:42:15 +0800 |
---|---|---|
committer | Geoff Levand <geoff@infradead.org> | 2013-03-06 06:06:36 -0800 |
commit | bf40f5fbd759241d1505c985fa02441cd6febd64 (patch) | |
tree | 30971d65cdbd70c9df43fbec6eb80464b1d17737 /test/urls/parse-url.c | |
parent | 56c142e5406160a58ee345e3e0433eb998ee046e (diff) | |
download | talos-petitboot-bf40f5fbd759241d1505c985fa02441cd6febd64.tar.gz talos-petitboot-bf40f5fbd759241d1505c985fa02441cd6febd64.zip |
test: Add URL parser test infrastructure
This change adds some simple testing infrastrcture to the URL parser.
We use a small C binary (parse-url) to run the url parser on its
argument, and compare the output with an expected datafile.
An initial test is included, to check the behaviour of URLs with
multiple slashes between host and pathname. This test currently fails.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Geoff Levand <geoff@infradead.org>
Diffstat (limited to 'test/urls/parse-url.c')
-rw-r--r-- | test/urls/parse-url.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/urls/parse-url.c b/test/urls/parse-url.c new file mode 100644 index 0000000..3e2f10f --- /dev/null +++ b/test/urls/parse-url.c @@ -0,0 +1,35 @@ + +#include <stdlib.h> +#include <stdio.h> + +#include <ui/common/url.h> +#include <log/log.h> + +int main(int argc, char **argv) +{ + struct pb_url *url; + FILE *null; + + if (argc != 2) { + fprintf(stderr, "Usage: %s <URL>\n", argv[0]); + return EXIT_FAILURE; + } + + /* discard log output */ + null = fopen("/dev/null", "w"); + pb_log_set_stream(null); + + url = pb_url_parse(NULL, argv[1]); + if (!url) + return EXIT_FAILURE; + + printf("%s\n", argv[1]); + printf("scheme\t%s\n", pb_url_scheme_name(url->scheme)); + printf("host\t%s\n", url->host); + printf("port\t%s\n", url->port); + printf("path\t%s\n", url->path); + printf("dir\t%s\n", url->dir); + printf("file\t%s\n", url->file); + + return EXIT_SUCCESS; +} |