netsurf: branch master updated. release/3.3-212-geb962f9
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/eb962f94c3247c6b64802...
...commit http://git.netsurf-browser.org/netsurf.git/commit/eb962f94c3247c6b64802f1...
...tree http://git.netsurf-browser.org/netsurf.git/tree/eb962f94c3247c6b64802f121...
The branch, master has been updated
via eb962f94c3247c6b64802f12197ac9567315f371 (commit)
from 433f47641e501d30f55c55cb0a17c0397a35fd14 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=eb962f94c3247c6b648...
commit eb962f94c3247c6b64802f12197ac9567315f371
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add some basic API assert check tests to ensure bad parameters are caught
diff --git a/test/nsurl.c b/test/nsurl.c
index 9c44f7a..66a3c8f 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -54,6 +54,8 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
lwc_string_data(str));
}
+static const char *base_str = "http://a/b/c/d;p?q";
+
static const struct test_pairs create_tests[] = {
{ "", NULL },
{ "http:", NULL },
@@ -99,6 +101,12 @@ static const struct test_pairs create_tests[] = {
{ "mailto:u@a", "mailto:u@a" },
{ "mailto:@a", "mailto:a" },
+
+ /* test case insensitivity */
+ { "HTTP://a/b", "http://a/b" },
+ { "ftp://a/b", "ftp://a/b" },
+ { "FTP://a/b", "ftp://a/b" },
+
};
static const struct test_pairs nice_tests[] = {
@@ -127,6 +135,9 @@ static const struct test_pairs nice_strip_tests[] = {
{ "http://www.f.org//index.en", "www_f_org" },
};
+/**
+ * simple joins that all use http://a/b/c/d;p?q as a base
+ */
static const struct test_pairs join_tests[] = {
/* Normal Examples rfc3986 5.4.1 */
{ "g:h", "g:h" },
@@ -196,9 +207,22 @@ static const struct test_pairs join_tests[] = {
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */
/* [2] Using the strict parsers option */
+
};
+/**
+ * more complex joins that specify a base to join to
+ */
+static const struct test_triplets join_complex_tests[] = {
+ /* problematic real world urls for regression */
+ { "http://www.bridgetmckenna.com/blog/self-editing-for-everyone-part-1-the-m...",
+ "http://The%20Old%20Organ%20Trail%20http://www.amazon.com/gp/product/B007B...",
+ "http://the old organ trail http:" },
+};
+/**
+ * query replacement tests
+ */
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
"?magical=true&result=win",
@@ -351,7 +375,7 @@ START_TEST(nsurl_join_test)
const struct test_pairs *tst = &join_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create("http://a/b/c/d;p?q", &base_url);
+ err = nsurl_create(base_str, &base_url);
ck_assert(err == NSERROR_OK);
err = nsurl_join(base_url, tst->test, &joined);
@@ -375,6 +399,268 @@ START_TEST(nsurl_join_test)
}
END_TEST
+/**
+ * complex url joining
+ */
+START_TEST(nsurl_join_complex_test)
+{
+ nserror err;
+ nsurl *base_url;
+ nsurl *joined;
+ char *string;
+ size_t len;
+ const struct test_triplets *tst = &join_complex_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &base_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_join(base_url, tst->test2, &joined);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(string, tst->res);
+
+ free(string);
+ nsurl_unref(joined);
+ }
+ nsurl_unref(base_url);
+
+}
+END_TEST
+
+
+/**
+ * url reference (copy) and unreference(free)
+ */
+START_TEST(nsurl_ref_test)
+{
+ nserror err;
+ nsurl *res1;
+ nsurl *res2;
+
+ err = nsurl_create(base_str, &res1);
+
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ res2 = nsurl_ref(res1);
+
+ ck_assert_str_eq(nsurl_access(res1), nsurl_access(res2));
+
+ nsurl_unref(res2);
+
+ nsurl_unref(res1);
+}
+END_TEST
+
+/**
+ * check creation asserts on NULL parameter
+ */
+START_TEST(nsurl_api_create_test)
+{
+ nserror err;
+ nsurl *res1;
+ err = nsurl_create(NULL, &res1);
+
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check ref asserts on NULL parameter
+ */
+START_TEST(nsurl_api_ref_test)
+{
+ nsurl_ref(NULL);
+}
+END_TEST
+
+/**
+ * check unref asserts on NULL parameter
+ */
+START_TEST(nsurl_api_unref_test)
+{
+ nsurl_unref(NULL);
+}
+END_TEST
+
+/**
+ * check compare asserts on NULL parameter
+ */
+START_TEST(nsurl_api_compare1_test)
+{
+ nserror err;
+ nsurl *res;
+ bool same;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ same = nsurl_compare(NULL, res, NSURL_PATH);
+
+ ck_assert(same == false);
+
+ nsurl_unref(res);
+}
+END_TEST
+
+/**
+ * check compare asserts on NULL parameter
+ */
+START_TEST(nsurl_api_compare2_test)
+{
+ nserror err;
+ nsurl *res;
+ bool same;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ same = nsurl_compare(res, NULL, NSURL_PATH);
+
+ ck_assert(same == false);
+}
+END_TEST
+
+/**
+ * check get asserts on NULL parameter
+ */
+START_TEST(nsurl_api_get_test)
+{
+ nserror err;
+ char *url_s = NULL;
+ size_t url_l = 0;
+
+ err = nsurl_get(NULL, NSURL_PATH, &url_s, &url_l);
+ ck_assert(err != NSERROR_OK);
+ ck_assert(url_s == NULL);
+ ck_assert(url_l == 0);
+}
+END_TEST
+
+/**
+ * check get component asserts on NULL parameter
+ */
+START_TEST(nsurl_api_get_component1_test)
+{
+ lwc_string *lwcs;
+
+ lwcs = nsurl_get_component(NULL, NSURL_PATH);
+ ck_assert(lwcs == NULL);
+}
+END_TEST
+
+/**
+ * check get component asserts on bad component parameter
+ */
+START_TEST(nsurl_api_get_component2_test)
+{
+ nserror err;
+ nsurl *res;
+ lwc_string *lwcs;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ lwcs = nsurl_get_component(res, -1);
+ ck_assert(lwcs == NULL);
+
+ nsurl_unref(res);
+}
+END_TEST
+
+/**
+ * check has component asserts on NULL parameter
+ */
+START_TEST(nsurl_api_has_component1_test)
+{
+ bool has;
+
+ has = nsurl_has_component(NULL, NSURL_PATH);
+ ck_assert(has == false);
+}
+END_TEST
+
+/**
+ * check has component asserts on bad component parameter
+ */
+START_TEST(nsurl_api_has_component2_test)
+{
+ nserror err;
+ nsurl *res;
+ bool has;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ has = nsurl_has_component(res, -1);
+ ck_assert(has == false);
+
+ nsurl_unref(res);
+}
+END_TEST
+
+
+/**
+ * check access asserts on NULL parameter
+ */
+START_TEST(nsurl_api_access_test)
+{
+ const char *res_s = NULL;
+
+ res_s = nsurl_access(NULL);
+
+ ck_assert(res_s == NULL);
+}
+END_TEST
+
+/**
+ * check access asserts on NULL parameter
+ */
+START_TEST(nsurl_api_access_leaf_test)
+{
+ const char *res_s = NULL;
+
+ res_s = nsurl_access_leaf(NULL);
+
+ ck_assert(res_s == NULL);
+}
+END_TEST
+
+/**
+ * check length asserts on NULL parameter
+ */
+START_TEST(nsurl_api_length_test)
+{
+ size_t res = 0;
+
+ res = nsurl_length(NULL);
+
+ ck_assert(res == 0);
+}
+END_TEST
+
+/**
+ * check hash asserts on NULL parameter
+ */
+START_TEST(nsurl_api_hash_test)
+{
+ uint32_t res = 0;
+
+ res = nsurl_hash(NULL);
+
+ ck_assert(res == 0);
+}
+END_TEST
+
static void corestring_create(void)
{
@@ -391,6 +677,7 @@ static void corestring_teardown(void)
Suite *nsurl_suite(void)
{
Suite *s;
+ TCase *tc_api;
TCase *tc_create;
TCase *tc_nice_nostrip;
TCase *tc_nice_strip;
@@ -399,6 +686,29 @@ Suite *nsurl_suite(void)
s = suite_create("nsurl");
+ /* Basic API operation sanity checks e.g. passing NULL parameters */
+ tc_api = tcase_create("API");
+
+ tcase_add_unchecked_fixture(tc_api,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_test_raise_signal(tc_api, nsurl_api_create_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_ref_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_unref_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_compare1_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_compare2_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_get_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_get_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_get_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_has_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_has_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_access_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_access_leaf_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_length_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_hash_test, 6);
+ suite_add_tcase(s, tc_api);
+
/* url creation */
tc_create = tcase_create("Create");
@@ -406,6 +716,7 @@ Suite *nsurl_suite(void)
corestring_create,
corestring_teardown);
+ tcase_add_test(tc_create, nsurl_ref_test);
tcase_add_loop_test(tc_create,
nsurl_create_test,
0, NELEMS(create_tests));
@@ -459,6 +770,11 @@ Suite *nsurl_suite(void)
tcase_add_loop_test(tc_join,
nsurl_join_test,
0, NELEMS(join_tests));
+
+ tcase_add_loop_test(tc_join,
+ nsurl_join_complex_test,
+ 0, NELEMS(join_complex_tests));
+
suite_add_tcase(s, tc_join);
return s;
-----------------------------------------------------------------------
Summary of changes:
test/nsurl.c | 318 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 317 insertions(+), 1 deletion(-)
diff --git a/test/nsurl.c b/test/nsurl.c
index 9c44f7a..66a3c8f 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -54,6 +54,8 @@ static void netsurf_lwc_iterator(lwc_string *str, void *pw)
lwc_string_data(str));
}
+static const char *base_str = "http://a/b/c/d;p?q";
+
static const struct test_pairs create_tests[] = {
{ "", NULL },
{ "http:", NULL },
@@ -99,6 +101,12 @@ static const struct test_pairs create_tests[] = {
{ "mailto:u@a", "mailto:u@a" },
{ "mailto:@a", "mailto:a" },
+
+ /* test case insensitivity */
+ { "HTTP://a/b", "http://a/b" },
+ { "ftp://a/b", "ftp://a/b" },
+ { "FTP://a/b", "ftp://a/b" },
+
};
static const struct test_pairs nice_tests[] = {
@@ -127,6 +135,9 @@ static const struct test_pairs nice_strip_tests[] = {
{ "http://www.f.org//index.en", "www_f_org" },
};
+/**
+ * simple joins that all use http://a/b/c/d;p?q as a base
+ */
static const struct test_pairs join_tests[] = {
/* Normal Examples rfc3986 5.4.1 */
{ "g:h", "g:h" },
@@ -196,9 +207,22 @@ static const struct test_pairs join_tests[] = {
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */
/* [2] Using the strict parsers option */
+
};
+/**
+ * more complex joins that specify a base to join to
+ */
+static const struct test_triplets join_complex_tests[] = {
+ /* problematic real world urls for regression */
+ { "http://www.bridgetmckenna.com/blog/self-editing-for-everyone-part-1-the-m...",
+ "http://The%20Old%20Organ%20Trail%20http://www.amazon.com/gp/product/B007B...",
+ "http://the old organ trail http:" },
+};
+/**
+ * query replacement tests
+ */
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
"?magical=true&result=win",
@@ -351,7 +375,7 @@ START_TEST(nsurl_join_test)
const struct test_pairs *tst = &join_tests[_i];
/* not testing create, this should always succeed */
- err = nsurl_create("http://a/b/c/d;p?q", &base_url);
+ err = nsurl_create(base_str, &base_url);
ck_assert(err == NSERROR_OK);
err = nsurl_join(base_url, tst->test, &joined);
@@ -375,6 +399,268 @@ START_TEST(nsurl_join_test)
}
END_TEST
+/**
+ * complex url joining
+ */
+START_TEST(nsurl_join_complex_test)
+{
+ nserror err;
+ nsurl *base_url;
+ nsurl *joined;
+ char *string;
+ size_t len;
+ const struct test_triplets *tst = &join_complex_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &base_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_join(base_url, tst->test2, &joined);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(string, tst->res);
+
+ free(string);
+ nsurl_unref(joined);
+ }
+ nsurl_unref(base_url);
+
+}
+END_TEST
+
+
+/**
+ * url reference (copy) and unreference(free)
+ */
+START_TEST(nsurl_ref_test)
+{
+ nserror err;
+ nsurl *res1;
+ nsurl *res2;
+
+ err = nsurl_create(base_str, &res1);
+
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ res2 = nsurl_ref(res1);
+
+ ck_assert_str_eq(nsurl_access(res1), nsurl_access(res2));
+
+ nsurl_unref(res2);
+
+ nsurl_unref(res1);
+}
+END_TEST
+
+/**
+ * check creation asserts on NULL parameter
+ */
+START_TEST(nsurl_api_create_test)
+{
+ nserror err;
+ nsurl *res1;
+ err = nsurl_create(NULL, &res1);
+
+ ck_assert(err != NSERROR_OK);
+}
+END_TEST
+
+/**
+ * check ref asserts on NULL parameter
+ */
+START_TEST(nsurl_api_ref_test)
+{
+ nsurl_ref(NULL);
+}
+END_TEST
+
+/**
+ * check unref asserts on NULL parameter
+ */
+START_TEST(nsurl_api_unref_test)
+{
+ nsurl_unref(NULL);
+}
+END_TEST
+
+/**
+ * check compare asserts on NULL parameter
+ */
+START_TEST(nsurl_api_compare1_test)
+{
+ nserror err;
+ nsurl *res;
+ bool same;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ same = nsurl_compare(NULL, res, NSURL_PATH);
+
+ ck_assert(same == false);
+
+ nsurl_unref(res);
+}
+END_TEST
+
+/**
+ * check compare asserts on NULL parameter
+ */
+START_TEST(nsurl_api_compare2_test)
+{
+ nserror err;
+ nsurl *res;
+ bool same;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ same = nsurl_compare(res, NULL, NSURL_PATH);
+
+ ck_assert(same == false);
+}
+END_TEST
+
+/**
+ * check get asserts on NULL parameter
+ */
+START_TEST(nsurl_api_get_test)
+{
+ nserror err;
+ char *url_s = NULL;
+ size_t url_l = 0;
+
+ err = nsurl_get(NULL, NSURL_PATH, &url_s, &url_l);
+ ck_assert(err != NSERROR_OK);
+ ck_assert(url_s == NULL);
+ ck_assert(url_l == 0);
+}
+END_TEST
+
+/**
+ * check get component asserts on NULL parameter
+ */
+START_TEST(nsurl_api_get_component1_test)
+{
+ lwc_string *lwcs;
+
+ lwcs = nsurl_get_component(NULL, NSURL_PATH);
+ ck_assert(lwcs == NULL);
+}
+END_TEST
+
+/**
+ * check get component asserts on bad component parameter
+ */
+START_TEST(nsurl_api_get_component2_test)
+{
+ nserror err;
+ nsurl *res;
+ lwc_string *lwcs;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ lwcs = nsurl_get_component(res, -1);
+ ck_assert(lwcs == NULL);
+
+ nsurl_unref(res);
+}
+END_TEST
+
+/**
+ * check has component asserts on NULL parameter
+ */
+START_TEST(nsurl_api_has_component1_test)
+{
+ bool has;
+
+ has = nsurl_has_component(NULL, NSURL_PATH);
+ ck_assert(has == false);
+}
+END_TEST
+
+/**
+ * check has component asserts on bad component parameter
+ */
+START_TEST(nsurl_api_has_component2_test)
+{
+ nserror err;
+ nsurl *res;
+ bool has;
+
+ err = nsurl_create(base_str, &res);
+ ck_assert(err == NSERROR_OK);
+
+ has = nsurl_has_component(res, -1);
+ ck_assert(has == false);
+
+ nsurl_unref(res);
+}
+END_TEST
+
+
+/**
+ * check access asserts on NULL parameter
+ */
+START_TEST(nsurl_api_access_test)
+{
+ const char *res_s = NULL;
+
+ res_s = nsurl_access(NULL);
+
+ ck_assert(res_s == NULL);
+}
+END_TEST
+
+/**
+ * check access asserts on NULL parameter
+ */
+START_TEST(nsurl_api_access_leaf_test)
+{
+ const char *res_s = NULL;
+
+ res_s = nsurl_access_leaf(NULL);
+
+ ck_assert(res_s == NULL);
+}
+END_TEST
+
+/**
+ * check length asserts on NULL parameter
+ */
+START_TEST(nsurl_api_length_test)
+{
+ size_t res = 0;
+
+ res = nsurl_length(NULL);
+
+ ck_assert(res == 0);
+}
+END_TEST
+
+/**
+ * check hash asserts on NULL parameter
+ */
+START_TEST(nsurl_api_hash_test)
+{
+ uint32_t res = 0;
+
+ res = nsurl_hash(NULL);
+
+ ck_assert(res == 0);
+}
+END_TEST
+
static void corestring_create(void)
{
@@ -391,6 +677,7 @@ static void corestring_teardown(void)
Suite *nsurl_suite(void)
{
Suite *s;
+ TCase *tc_api;
TCase *tc_create;
TCase *tc_nice_nostrip;
TCase *tc_nice_strip;
@@ -399,6 +686,29 @@ Suite *nsurl_suite(void)
s = suite_create("nsurl");
+ /* Basic API operation sanity checks e.g. passing NULL parameters */
+ tc_api = tcase_create("API");
+
+ tcase_add_unchecked_fixture(tc_api,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_test_raise_signal(tc_api, nsurl_api_create_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_ref_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_unref_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_compare1_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_compare2_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_get_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_get_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_get_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_has_component1_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_has_component2_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_access_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_access_leaf_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_length_test, 6);
+ tcase_add_test_raise_signal(tc_api, nsurl_api_hash_test, 6);
+ suite_add_tcase(s, tc_api);
+
/* url creation */
tc_create = tcase_create("Create");
@@ -406,6 +716,7 @@ Suite *nsurl_suite(void)
corestring_create,
corestring_teardown);
+ tcase_add_test(tc_create, nsurl_ref_test);
tcase_add_loop_test(tc_create,
nsurl_create_test,
0, NELEMS(create_tests));
@@ -459,6 +770,11 @@ Suite *nsurl_suite(void)
tcase_add_loop_test(tc_join,
nsurl_join_test,
0, NELEMS(join_tests));
+
+ tcase_add_loop_test(tc_join,
+ nsurl_join_complex_test,
+ 0, NELEMS(join_complex_tests));
+
suite_add_tcase(s, tc_join);
return s;
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-211-g433f476
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/433f47641e501d30f55c5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/433f47641e501d30f55c55c...
...tree http://git.netsurf-browser.org/netsurf.git/tree/433f47641e501d30f55c55cb0...
The branch, master has been updated
via 433f47641e501d30f55c55cb0a17c0397a35fd14 (commit)
from 6f1ed5979d9c2d775fedaa4d5defb9b1ea18f178 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=433f47641e501d30f55...
commit 433f47641e501d30f55c55cb0a17c0397a35fd14
Author: Michael Drake <tlsa(a)netsurf-browser.org>
Commit: Michael Drake <tlsa(a)netsurf-browser.org>
Fix mention of nsurl_destroy.
diff --git a/utils/nsurl.h b/utils/nsurl.h
index 13f7e5f..b84f55e 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -57,7 +57,7 @@ typedef enum nsurl_component {
*
* If return value != NSERROR_OK, nothing will be returned in url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*/
nserror nsurl_create(const char * const url_s, nsurl **url);
@@ -224,7 +224,7 @@ uint32_t nsurl_hash(const nsurl *url);
*
* If return value != NSERROR_OK, nothing will be returned in join.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*/
nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined);
@@ -239,7 +239,7 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined);
*
* If return value != NSERROR_OK, nothing will be returned in no_frag.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*/
nserror nsurl_defragment(const nsurl *url, nsurl **no_frag);
@@ -255,7 +255,7 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag);
*
* If return value != NSERROR_OK, nothing will be returned in new_url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*
* Any fragment in url is replaced with frag in new_url.
@@ -273,7 +273,7 @@ nserror nsurl_refragment(const nsurl *url, lwc_string *frag, nsurl **new_url);
*
* If return value != NSERROR_OK, nothing will be returned in new_url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*
* Any query component in url is replaced with query in new_url.
@@ -304,7 +304,7 @@ nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions);
*
* If return value != NSERROR_OK, nothing will be returned in new_url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*
* As well as stripping top most path segment, query and fragments are stripped.
-----------------------------------------------------------------------
Summary of changes:
utils/nsurl.h | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/utils/nsurl.h b/utils/nsurl.h
index 13f7e5f..b84f55e 100644
--- a/utils/nsurl.h
+++ b/utils/nsurl.h
@@ -57,7 +57,7 @@ typedef enum nsurl_component {
*
* If return value != NSERROR_OK, nothing will be returned in url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*/
nserror nsurl_create(const char * const url_s, nsurl **url);
@@ -224,7 +224,7 @@ uint32_t nsurl_hash(const nsurl *url);
*
* If return value != NSERROR_OK, nothing will be returned in join.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*/
nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined);
@@ -239,7 +239,7 @@ nserror nsurl_join(const nsurl *base, const char *rel, nsurl **joined);
*
* If return value != NSERROR_OK, nothing will be returned in no_frag.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*/
nserror nsurl_defragment(const nsurl *url, nsurl **no_frag);
@@ -255,7 +255,7 @@ nserror nsurl_defragment(const nsurl *url, nsurl **no_frag);
*
* If return value != NSERROR_OK, nothing will be returned in new_url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*
* Any fragment in url is replaced with frag in new_url.
@@ -273,7 +273,7 @@ nserror nsurl_refragment(const nsurl *url, lwc_string *frag, nsurl **new_url);
*
* If return value != NSERROR_OK, nothing will be returned in new_url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*
* Any query component in url is replaced with query in new_url.
@@ -304,7 +304,7 @@ nserror nsurl_nice(const nsurl *url, char **result, bool remove_extensions);
*
* If return value != NSERROR_OK, nothing will be returned in new_url.
*
- * It is up to the client to call nsurl_destroy when they are finished with
+ * It is up to the client to call nsurl_unref when they are finished with
* the created object.
*
* As well as stripping top most path segment, query and fragments are stripped.
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-210-g6f1ed59
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6f1ed5979d9c2d775feda...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6f1ed5979d9c2d775fedaa4...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6f1ed5979d9c2d775fedaa4d5...
The branch, master has been updated
via 6f1ed5979d9c2d775fedaa4d5defb9b1ea18f178 (commit)
from be879ad526abb72423866f63d0c4ac93ed92f886 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6f1ed5979d9c2d775fe...
commit 6f1ed5979d9c2d775fedaa4d5defb9b1ea18f178
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
remove unused sources from urldb test
diff --git a/test/Makefile b/test/Makefile
index 57a40ae..9db5030 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -9,9 +9,8 @@ nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
# url database test sources and flags
urldbtest_SRCS := content/urldb.c \
- utils/url.c utils/utils.c utils/idna.c utils/messages.c \
- utils/hashtable.c utils/bloom.c utils/nsoption.c \
- utils/filename.c utils/nsurl.c utils/corestrings.c \
+ utils/idna.c utils/bloom.c utils/nsoption.c utils/nsurl.c \
+ utils/corestrings.c \
test/log.c test/urldbtest.c
# low level cache sources and flags
-----------------------------------------------------------------------
Summary of changes:
test/Makefile | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index 57a40ae..9db5030 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -9,9 +9,8 @@ nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
# url database test sources and flags
urldbtest_SRCS := content/urldb.c \
- utils/url.c utils/utils.c utils/idna.c utils/messages.c \
- utils/hashtable.c utils/bloom.c utils/nsoption.c \
- utils/filename.c utils/nsurl.c utils/corestrings.c \
+ utils/idna.c utils/bloom.c utils/nsoption.c utils/nsurl.c \
+ utils/corestrings.c \
test/log.c test/urldbtest.c
# low level cache sources and flags
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-209-gbe879ad
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/be879ad526abb72423866...
...commit http://git.netsurf-browser.org/netsurf.git/commit/be879ad526abb72423866f6...
...tree http://git.netsurf-browser.org/netsurf.git/tree/be879ad526abb72423866f63d...
The branch, master has been updated
via be879ad526abb72423866f63d0c4ac93ed92f886 (commit)
from cb3f267d4562c0a23ebf16b758e421d77c0dc51c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=be879ad526abb724238...
commit be879ad526abb72423866f63d0c4ac93ed92f886
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
add libidn to test pkgconfig
diff --git a/test/Makefile b/test/Makefile
index 351b758..57a40ae 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -49,9 +49,9 @@ TESTCFLAGS := -std=c99 -g -Wall \
-D_XOPEN_SOURCE=600 \
-Itest -I. -I.. \
-Dnsgtk \
- $(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) \
+ $(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc libidn) \
$(COVCFLAGS)
-TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) -lz \
+TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc libidn) -lz \
$(COVLDFLAGS)
-----------------------------------------------------------------------
Summary of changes:
test/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index 351b758..57a40ae 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -49,9 +49,9 @@ TESTCFLAGS := -std=c99 -g -Wall \
-D_XOPEN_SOURCE=600 \
-Itest -I. -I.. \
-Dnsgtk \
- $(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) \
+ $(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc libidn) \
$(COVCFLAGS)
-TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) -lz \
+TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc libidn) -lz \
$(COVLDFLAGS)
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-208-gcb3f267
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/cb3f267d4562c0a23ebf1...
...commit http://git.netsurf-browser.org/netsurf.git/commit/cb3f267d4562c0a23ebf16b...
...tree http://git.netsurf-browser.org/netsurf.git/tree/cb3f267d4562c0a23ebf16b75...
The branch, master has been updated
via cb3f267d4562c0a23ebf16b758e421d77c0dc51c (commit)
from 8756793079c653e788f5932fc1d70cb35681cfc4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cb3f267d4562c0a23eb...
commit cb3f267d4562c0a23ebf16b758e421d77c0dc51c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Add coverage to the unit test makefile targets
The tests now only require that the test name is added to the TESTS
variable and a testname_SRCS is set with a list of required sources to
compile.
diff --git a/Makefile b/Makefile
index 8e1fcc3..ff36456 100644
--- a/Makefile
+++ b/Makefile
@@ -780,7 +780,7 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
#$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
# $(call dependency_generate_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.d)),$(subst /,_,$(SOURCE:.s=.o)))))
-ifeq ($(filter $(MAKECMDGOALS),clean test),)
+ifeq ($(filter $(MAKECMDGOALS),clean test coverage),)
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
-include $(D_JSAPI_BINDING)
endif
diff --git a/test/Makefile b/test/Makefile
index bfc6fb8..351b758 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,78 +1,111 @@
#
# NetSurf unit tests
-
-test_CFLAGS := -std=c99 -g -Wall \
- -D_BSD_SOURCE \
- -D_POSIX_C_SOURCE=200809L \
- -D_XOPEN_SOURCE=600 \
- -Itest -I. -I.. \
- $(shell pkg-config --cflags libcurl check)
-test_LDFLAGS := $(shell pkg-config --libs libcurl check) -lz
+TESTS := nsurl urldbtest nsoption #llcache
# nsurl sources and flags
-nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc) -O0
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
+nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
+ test/log.c test/nsurl.c
+
+# url database test sources and flags
+urldbtest_SRCS := content/urldb.c \
+ utils/url.c utils/utils.c utils/idna.c utils/messages.c \
+ utils/hashtable.c utils/bloom.c utils/nsoption.c \
+ utils/filename.c utils/nsurl.c utils/corestrings.c \
+ test/log.c test/urldbtest.c
# low level cache sources and flags
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
- content/urldb.c desktop/version.c \
+ content/urldb.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
- utils/nsurl.c utils/messages.c utils/url.c \
- utils/useragent.c utils/utils.c test/llcache.c
-llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
-llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
+ utils/nsurl.c utils/messages.c utils/url.c utils/useragent.c \
+ utils/utils.c \
+ test/log.c test/llcache.c
-# url database test sources and flags
-urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/idna.c \
- utils/messages.c utils/hashtable.c utils/bloom.c utils/nsoption.c \
- utils/filename.c utils/nsurl.c utils/corestrings.c \
- test/log.c test/urldbtest.c
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils libutf8proc) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils libutf8proc)
+# nsoption test
+nsoption_SRCS := utils/nsoption.c \
+ test/log.c test/nsoption.c
-nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
-nsoption_CFLAGS := -Dnsgtk
-CLEANS += test-clean
+# Coverage builds need additional flags
+ifeq ($(MAKECMDGOALS),coverage)
+ COVCFLAGS ?= -fprofile-arcs -ftest-coverage -O0
+ COVCXXFLAGS ?= -fprofile-arcs -ftest-coverage -O0
+ COVLDFLAGS ?= -lgcov -fprofile-arcs
+ TESTROOT := build-$(HOST)-coverage
+else
+ COVCFLAGS ?= -O0
+ COVCXXFLAGS ?= -O0
+ TESTROOT := build-$(HOST)-test
+endif
-TESTS := nsurl urldbtest
+TESTCFLAGS := -std=c99 -g -Wall \
+ -D_BSD_SOURCE \
+ -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=600 \
+ -Itest -I. -I.. \
+ -Dnsgtk \
+ $(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) \
+ $(COVCFLAGS)
+TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) -lz \
+ $(COVLDFLAGS)
-TESTROOT := build-$(HOST)-test
+# Source files for all tests being compiled
+TESTSOURCES :=
-.PHONY:test
+GCOV ?= gcov
-test: $(TESTROOT)/created $(addprefix $(TESTROOT)/,$(TESTS))
- $(TESTROOT)/nsurl
- $(TESTROOT)/urldbtest
+define gen_test_target
+$$(TESTROOT)/$(1): $$(sort $$(addprefix $$(TESTROOT)/,$$(subst /,_,$$(patsubst %.c,%.o,$$(patsubst %.cpp,%.o,$$(patsubst %.m,%.o,$$(patsubst %.s,%.o,$$($(1)_SRCS))))))))
+ $$(VQ)echo "LINKTEST: $$@"
+ $$(Q)$$(CC) $$(TESTCFLAGS) $$^ -o $$@ $$(TESTLDFLAGS)
-$(TESTROOT)/created:
- $(VQ)echo " MKDIR: $(TESTROOT)"
- $(Q)$(MKDIR) $(TESTROOT)
- $(Q)$(TOUCH) $@
+.PHONY:$(1)_test
+
+$(1)_test:$$(TESTROOT)/$(1)
+ $$(VQ)echo "RUN TEST: $(1)"
+ $$(Q)$$(TESTROOT)/$(1)
+
+TESTSOURCES += $$($(1)_SRCS)
+
+endef
-$(TESTROOT)/nsurl: $(nsurl_SRCS)
- $(CC) $(test_CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsurl_LDFLAGS)
+define compile_test_target_c
+$$(TESTROOT)/$(2): $(1) $$(TESTROOT)/created
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(TESTROOT)/$(2)
+ $$(Q)$$(CC) $$(TESTCFLAGS) -o $$(TESTROOT)/$(2) -c $(1)
+endef
-$(TESTROOT)/urldbtest: $(urldbtest_SRCS)
- $(CC) $(test_CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(urldbtest_LDFLAGS)
+# Generate target for each test program and the list of objects it needs
+$(eval $(foreach TST,$(TESTS), $(call gen_test_target,$(TST))))
-$(TESTROOT)/llcache: $(llcache_SRCS)
- $(CC) $(test_CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(llcache_LDFLAGS)
+# generate target rules for test objects
+$(eval $(foreach SOURCE,$(sort $(filter %.c,$(TESTSOURCES))), \
+ $(call compile_test_target_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),$(subst /,_,$(SOURCE:.c=.d)))))
+.PHONY:test coverage
-$(TESTROOT)/nsoption: $(addprefix ../,$(nsoption_SRCS))
- $(CC) $(test_CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsoption_LDFLAGS)
+test: $(TESTROOT)/created $(addsuffix _test,$(TESTS))
+
+coverage: test
+
+$(TESTROOT)/created:
+ $(VQ)echo " MKDIR: $(TESTROOT)"
+ $(Q)$(MKDIR) $(TESTROOT)
+ $(Q)$(TOUCH) $@
.PHONY: test-clean
test-clean:
- $(RM) $(addprefix $(TESTROOT)/,$(TESTS))
+ $(VQ)echo " CLEAN: $(TESTROOT)"
+ $(VQ)echo " CLEAN: build-$(HOST)-coverage"
+ $(Q)$(RM) -r $(TESTROOT) build-$(HOST)-coverage
+CLEANS += test-clean
diff --git a/test/nsoption.c b/test/nsoption.c
index 1c9116a..0f079e9 100644
--- a/test/nsoption.c
+++ b/test/nsoption.c
@@ -9,7 +9,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
-bool verbose_log = true;
+
nserror gui_options_init_defaults(struct nsoption_s *defaults)
{
@@ -70,9 +70,11 @@ int main(int argc, char**argv)
{
FILE *fp;
+ verbose_log = false;
+
nsoption_init(gui_options_init_defaults, NULL, NULL);
- nsoption_read("data/Choices", NULL);
+ nsoption_read("test/data/Choices", NULL);
nsoption_write("Choices-short", NULL, NULL);
-----------------------------------------------------------------------
Summary of changes:
Makefile | 2 +-
test/Makefile | 123 +++++++++++++++++++++++++++++++++++--------------------
test/nsoption.c | 6 ++-
3 files changed, 83 insertions(+), 48 deletions(-)
diff --git a/Makefile b/Makefile
index 8e1fcc3..ff36456 100644
--- a/Makefile
+++ b/Makefile
@@ -780,7 +780,7 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
#$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
# $(call dependency_generate_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.d)),$(subst /,_,$(SOURCE:.s=.o)))))
-ifeq ($(filter $(MAKECMDGOALS),clean test),)
+ifeq ($(filter $(MAKECMDGOALS),clean test coverage),)
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
-include $(D_JSAPI_BINDING)
endif
diff --git a/test/Makefile b/test/Makefile
index bfc6fb8..351b758 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,78 +1,111 @@
#
# NetSurf unit tests
-
-test_CFLAGS := -std=c99 -g -Wall \
- -D_BSD_SOURCE \
- -D_POSIX_C_SOURCE=200809L \
- -D_XOPEN_SOURCE=600 \
- -Itest -I. -I.. \
- $(shell pkg-config --cflags libcurl check)
-test_LDFLAGS := $(shell pkg-config --libs libcurl check) -lz
+TESTS := nsurl urldbtest nsoption #llcache
# nsurl sources and flags
-nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc) -O0
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
+nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c \
+ test/log.c test/nsurl.c
+
+# url database test sources and flags
+urldbtest_SRCS := content/urldb.c \
+ utils/url.c utils/utils.c utils/idna.c utils/messages.c \
+ utils/hashtable.c utils/bloom.c utils/nsoption.c \
+ utils/filename.c utils/nsurl.c utils/corestrings.c \
+ test/log.c test/urldbtest.c
# low level cache sources and flags
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
- content/urldb.c desktop/version.c \
+ content/urldb.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
- utils/nsurl.c utils/messages.c utils/url.c \
- utils/useragent.c utils/utils.c test/llcache.c
-llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
-llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
+ utils/nsurl.c utils/messages.c utils/url.c utils/useragent.c \
+ utils/utils.c \
+ test/log.c test/llcache.c
-# url database test sources and flags
-urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/idna.c \
- utils/messages.c utils/hashtable.c utils/bloom.c utils/nsoption.c \
- utils/filename.c utils/nsurl.c utils/corestrings.c \
- test/log.c test/urldbtest.c
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils libutf8proc) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils libutf8proc)
+# nsoption test
+nsoption_SRCS := utils/nsoption.c \
+ test/log.c test/nsoption.c
-nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
-nsoption_CFLAGS := -Dnsgtk
-CLEANS += test-clean
+# Coverage builds need additional flags
+ifeq ($(MAKECMDGOALS),coverage)
+ COVCFLAGS ?= -fprofile-arcs -ftest-coverage -O0
+ COVCXXFLAGS ?= -fprofile-arcs -ftest-coverage -O0
+ COVLDFLAGS ?= -lgcov -fprofile-arcs
+ TESTROOT := build-$(HOST)-coverage
+else
+ COVCFLAGS ?= -O0
+ COVCXXFLAGS ?= -O0
+ TESTROOT := build-$(HOST)-test
+endif
-TESTS := nsurl urldbtest
+TESTCFLAGS := -std=c99 -g -Wall \
+ -D_BSD_SOURCE \
+ -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=600 \
+ -Itest -I. -I.. \
+ -Dnsgtk \
+ $(shell pkg-config --cflags libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) \
+ $(COVCFLAGS)
+TESTLDFLAGS := $(shell pkg-config --libs libcurl check libparserutils libwapcaplet libdom libnsutils libutf8proc) -lz \
+ $(COVLDFLAGS)
-TESTROOT := build-$(HOST)-test
+# Source files for all tests being compiled
+TESTSOURCES :=
-.PHONY:test
+GCOV ?= gcov
-test: $(TESTROOT)/created $(addprefix $(TESTROOT)/,$(TESTS))
- $(TESTROOT)/nsurl
- $(TESTROOT)/urldbtest
+define gen_test_target
+$$(TESTROOT)/$(1): $$(sort $$(addprefix $$(TESTROOT)/,$$(subst /,_,$$(patsubst %.c,%.o,$$(patsubst %.cpp,%.o,$$(patsubst %.m,%.o,$$(patsubst %.s,%.o,$$($(1)_SRCS))))))))
+ $$(VQ)echo "LINKTEST: $$@"
+ $$(Q)$$(CC) $$(TESTCFLAGS) $$^ -o $$@ $$(TESTLDFLAGS)
-$(TESTROOT)/created:
- $(VQ)echo " MKDIR: $(TESTROOT)"
- $(Q)$(MKDIR) $(TESTROOT)
- $(Q)$(TOUCH) $@
+.PHONY:$(1)_test
+
+$(1)_test:$$(TESTROOT)/$(1)
+ $$(VQ)echo "RUN TEST: $(1)"
+ $$(Q)$$(TESTROOT)/$(1)
+
+TESTSOURCES += $$($(1)_SRCS)
+
+endef
-$(TESTROOT)/nsurl: $(nsurl_SRCS)
- $(CC) $(test_CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsurl_LDFLAGS)
+define compile_test_target_c
+$$(TESTROOT)/$(2): $(1) $$(TESTROOT)/created
+ $$(VQ)echo " COMPILE: $(1)"
+ $$(Q)$$(RM) $$(TESTROOT)/$(2)
+ $$(Q)$$(CC) $$(TESTCFLAGS) -o $$(TESTROOT)/$(2) -c $(1)
+endef
-$(TESTROOT)/urldbtest: $(urldbtest_SRCS)
- $(CC) $(test_CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(urldbtest_LDFLAGS)
+# Generate target for each test program and the list of objects it needs
+$(eval $(foreach TST,$(TESTS), $(call gen_test_target,$(TST))))
-$(TESTROOT)/llcache: $(llcache_SRCS)
- $(CC) $(test_CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(llcache_LDFLAGS)
+# generate target rules for test objects
+$(eval $(foreach SOURCE,$(sort $(filter %.c,$(TESTSOURCES))), \
+ $(call compile_test_target_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),$(subst /,_,$(SOURCE:.c=.d)))))
+.PHONY:test coverage
-$(TESTROOT)/nsoption: $(addprefix ../,$(nsoption_SRCS))
- $(CC) $(test_CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsoption_LDFLAGS)
+test: $(TESTROOT)/created $(addsuffix _test,$(TESTS))
+
+coverage: test
+
+$(TESTROOT)/created:
+ $(VQ)echo " MKDIR: $(TESTROOT)"
+ $(Q)$(MKDIR) $(TESTROOT)
+ $(Q)$(TOUCH) $@
.PHONY: test-clean
test-clean:
- $(RM) $(addprefix $(TESTROOT)/,$(TESTS))
+ $(VQ)echo " CLEAN: $(TESTROOT)"
+ $(VQ)echo " CLEAN: build-$(HOST)-coverage"
+ $(Q)$(RM) -r $(TESTROOT) build-$(HOST)-coverage
+CLEANS += test-clean
diff --git a/test/nsoption.c b/test/nsoption.c
index 1c9116a..0f079e9 100644
--- a/test/nsoption.c
+++ b/test/nsoption.c
@@ -9,7 +9,7 @@
#include "utils/log.h"
#include "utils/nsoption.h"
-bool verbose_log = true;
+
nserror gui_options_init_defaults(struct nsoption_s *defaults)
{
@@ -70,9 +70,11 @@ int main(int argc, char**argv)
{
FILE *fp;
+ verbose_log = false;
+
nsoption_init(gui_options_init_defaults, NULL, NULL);
- nsoption_read("data/Choices", NULL);
+ nsoption_read("test/data/Choices", NULL);
nsoption_write("Choices-short", NULL, NULL);
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-207-g8756793
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/8756793079c653e788f59...
...commit http://git.netsurf-browser.org/netsurf.git/commit/8756793079c653e788f5932...
...tree http://git.netsurf-browser.org/netsurf.git/tree/8756793079c653e788f5932fc...
The branch, master has been updated
via 8756793079c653e788f5932fc1d70cb35681cfc4 (commit)
from bd802e763e5c035817a62114b957ed6778ad491f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8756793079c653e788f...
commit 8756793079c653e788f5932fc1d70cb35681cfc4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
convert nsurl tests to use check unit test framework
diff --git a/test/Makefile b/test/Makefile
index ce3e274..bfc6fb8 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -7,8 +7,8 @@ test_CFLAGS := -std=c99 -g -Wall \
-D_POSIX_C_SOURCE=200809L \
-D_XOPEN_SOURCE=600 \
-Itest -I. -I.. \
- $(shell pkg-config --cflags libcurl)
-test_LDFLAGS := $(shell pkg-config --libs libcurl) -lz
+ $(shell pkg-config --cflags libcurl check)
+test_LDFLAGS := $(shell pkg-config --libs libcurl check) -lz
# nsurl sources and flags
nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
diff --git a/test/nsurl.c b/test/nsurl.c
index 2afe91b..9c44f7a 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -16,17 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Test nsurl operations.
+ */
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <check.h>
#include <libwapcaplet/libwapcaplet.h>
#include "utils/corestrings.h"
-#include "utils/log.h"
#include "utils/nsurl.h"
+#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
+
struct test_pairs {
const char* test;
const char* res;
@@ -40,7 +47,11 @@ struct test_triplets {
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
- LOG("[%3u] %.*s", str->refcnt, (int)lwc_string_length(str), lwc_string_data(str));
+ fprintf(stderr,
+ "[%3u] %.*s",
+ str->refcnt,
+ (int)lwc_string_length(str),
+ lwc_string_data(str));
}
static const struct test_pairs create_tests[] = {
@@ -61,25 +72,25 @@ static const struct test_pairs create_tests[] = {
{ "about:blank", "about:blank" },
{ "http://www.ns-b.org:8080/",
- "http://www.ns-b.org:8080/" },
- { "http://user@www.ns-b.org:8080/hello",
- "http://user@www.ns-b.org:8080/hello" },
- { "http://user:pass@www.ns-b.org:8080/hello",
- "http://user:pass@www.ns-b.org:8080/hello" },
+ "http://www.ns-b.org:8080/" },
+ { "http://user@www.ns-b.org:8080/hello",
+ "http://user@www.ns-b.org:8080/hello" },
+ { "http://user:pass@www.ns-b.org:8080/hello",
+ "http://user:pass@www.ns-b.org:8080/hello" },
{ "http://www.ns-b.org:80/",
- "http://www.ns-b.org/" },
- { "http://user@www.ns-b.org:80/hello",
- "http://user@www.ns-b.org/hello" },
- { "http://user:pass@www.ns-b.org:80/hello",
- "http://user:pass@www.ns-b.org/hello" },
+ "http://www.ns-b.org/" },
+ { "http://user@www.ns-b.org:80/hello",
+ "http://user@www.ns-b.org/hello" },
+ { "http://user:pass@www.ns-b.org:80/hello",
+ "http://user:pass@www.ns-b.org/hello" },
{ "http://www.ns-b.org:/",
- "http://www.ns-b.org/" },
- { "http://u@www.ns-b.org:/hello",
- "http://u@www.ns-b.org/hello" },
- { "http://u:p@www.ns-b.org:/hello",
- "http://u:p@www.ns-b.org/hello" },
+ "http://www.ns-b.org/" },
+ { "http://u@www.ns-b.org:/hello",
+ "http://u@www.ns-b.org/hello" },
+ { "http://u:p@www.ns-b.org:/hello",
+ "http://u:p@www.ns-b.org/hello" },
{ "http:a/", "http://a/" },
{ "http:/a/", "http://a/" },
@@ -88,8 +99,32 @@ static const struct test_pairs create_tests[] = {
{ "mailto:u@a", "mailto:u@a" },
{ "mailto:@a", "mailto:a" },
+};
- { NULL, NULL }
+static const struct test_pairs nice_tests[] = {
+ { "about:", NULL },
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about.jpg" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
+};
+
+static const struct test_pairs nice_strip_tests[] = {
+ { "about:", NULL },
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
};
static const struct test_pairs join_tests[] = {
@@ -161,34 +196,8 @@ static const struct test_pairs join_tests[] = {
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */
/* [2] Using the strict parsers option */
- { NULL, NULL }
-};
-
-static const struct test_pairs nice_tests[] = {
- { "www.foo.org", "www_foo_org" },
- { "www.foo.org/index.html", "www_foo_org" },
- { "www.foo.org/default.en", "www_foo_org" },
- { "www.foo.org/about", "about" },
- { "www.foo.org/about.jpg", "about.jpg" },
- { "www.foo.org/moose/index.en", "moose" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "http://www.f.org//index.en", "www_f_org" },
- { NULL, NULL }
};
-static const struct test_pairs nice_strip_tests[] = {
- { "www.foo.org", "www_foo_org" },
- { "www.foo.org/index.html", "www_foo_org" },
- { "www.foo.org/default.en", "www_foo_org" },
- { "www.foo.org/about", "about" },
- { "www.foo.org/about.jpg", "about" },
- { "www.foo.org/moose/index.en", "moose" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "http://www.f.org//index.en", "www_f_org" },
- { NULL, NULL }
-};
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
@@ -207,201 +216,267 @@ static const struct test_triplets replace_query_tests[] = {
"?magical=true",
"http://netsurf-browser.org/path?magical=true"},
- { NULL, NULL, NULL }
};
+
+
/**
- * Test nsurl
+ * url creation test
*/
-int main(int argc, char **argv)
+START_TEST(nsurl_create_test)
{
- nsurl *base;
- nsurl *joined;
- char *string;
- size_t len;
- const char *url;
- const struct test_pairs *test;
- const struct test_triplets *ttest;
- int passed = 0;
- int count = 0;
nserror err;
+ nsurl *res;
+ const struct test_pairs *tst = &create_tests[_i];
- verbose_log = true;
- nslog_init(NULL, &argc, argv);
+ err = nsurl_create(tst->test, &res);
+ if (tst->res == NULL) {
+ /* result must be invalid */
+ ck_assert(err != NSERROR_OK);
- if (corestrings_init() != NSERROR_OK) {
- assert(0 && "Failed to init corestrings.");
- }
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
- /* Create base URL */
- if (nsurl_create("http://a/b/c/d;p?q", &base) != NSERROR_OK) {
- assert(0 && "Failed to create base URL.");
+ ck_assert_str_eq(nsurl_access(res), tst->res);
+
+ nsurl_unref(res);
}
+}
+END_TEST
- if (nsurl_get(base, NSURL_WITH_FRAGMENT, &string, &len) != NSERROR_OK) {
- LOG("Failed to get string");
+/**
+ * url nice filename without stripping
+ */
+START_TEST(nsurl_nice_nostrip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, false);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
} else {
- LOG("Testing nsurl_join with base %s", string);
- free(string);
- }
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
- for (test = join_tests; test->test != NULL; test++) {
- if (nsurl_join(base, test->test, &joined) != NSERROR_OK) {
- LOG("Failed to join test URL.");
- } else {
- if (nsurl_get(joined, NSURL_WITH_FRAGMENT,
- &string, &len) !=
- NSERROR_OK) {
- LOG("Failed to get string");
- } else {
- if (strcmp(test->res, string) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, string);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, string);
- LOG("\t\tExpecting: %s", test->res);
- }
- free(string);
- }
- nsurl_unref(joined);
- }
- count++;
- }
+ ck_assert_str_eq(res_str, tst->res);
- nsurl_unref(base);
-
- /* Create tests */
- LOG("Testing nsurl_create");
- for (test = create_tests; test->test != NULL; test++) {
- err = nsurl_create(test->test, &base);
- if (err != NSERROR_OK || test->res == NULL) {
- if (test->res == NULL && err != NSERROR_OK) {
- LOG("\tPASS: \"%s\"\t--> BAD INPUT", test->test);
- passed++;
- } else if (test->res != NULL && err != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", test->test);
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, nsurl_access(base));
- LOG("\t\tExpecting BAD INPUT");
- }
- if (err == NSERROR_OK)
- nsurl_unref(base);
- } else {
- if (strcmp(nsurl_access(base), test->res) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, nsurl_access(base));
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, nsurl_access(base));
- LOG("\t\tExpecting %s", test->res);
- }
-
- nsurl_unref(base);
- }
- count++;
+ free(res_str);
}
+ nsurl_unref(res_url);
- /* nice filename tests */
- LOG("Testing nsurl_nice (no strip)");
- for (test = nice_tests; test->test != NULL; test++) {
- err = nsurl_create(test->test, &base);
- if (err != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", test->test);
- } else {
- char *res;
- err = nsurl_nice(base, &res, false);
- if (err == NSERROR_OK && test->res != NULL) {
- if (strcmp(res, test->res) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, res);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting %s", test->res);
- }
- free(res);
- } else {
- if (test->res == NULL && err == NSERROR_OK) {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting BAD_INPUT");
- free(res);
- } else {
- LOG("\tFAIL: \"%s\"", test->test);
- }
- }
- nsurl_unref(base);
- }
- count++;
- }
- LOG("Testing nsurl_nice (strip)");
- for (test = nice_strip_tests; test->test != NULL; test++) {
- err = nsurl_create(test->test, &base);
- if (err != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", test->test);
- } else {
- char *res;
- err = nsurl_nice(base, &res, true);
- if (err == NSERROR_OK && test->res != NULL) {
- if (strcmp(res, test->res) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, res);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting %s", test->res);
- }
- free(res);
- } else {
- if (test->res == NULL && err == NSERROR_OK) {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting BAD_INPUT");
- free(res);
- } else {
- LOG("\tFAIL: \"%s\"", test->test);
- }
- }
- nsurl_unref(base);
- }
- count++;
+}
+END_TEST
+
+/**
+ * url nice filename with stripping
+ */
+START_TEST(nsurl_nice_strip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_strip_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, true);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(res_str, tst->res);
+
+ free(res_str);
}
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+/**
+ * replace query
+ */
+START_TEST(nsurl_replace_query_test)
+{
+ nserror err;
+ nsurl *res_url;
+ nsurl *joined;
+ const struct test_triplets *tst = &replace_query_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_replace_query(res_url, tst->test2, &joined);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
- /* Replace query tests */
- LOG("Testing nsurl_replace_query");
- for (ttest = replace_query_tests; ttest->test1 != NULL; ttest++) {
- if (nsurl_create(ttest->test1, &base) != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", ttest->test1);
- } else {
- if (nsurl_replace_query(base, ttest->test2, &joined) !=
- NSERROR_OK) {
- LOG("Failed to make test URL");
- } else {
- if (strcmp(nsurl_access(joined),
- ttest->res) == 0) {
- LOG("\tPASS: \"%s\" + %s", ttest->test1, ttest->test2);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\" + %s", ttest->test1, ttest->test2);
- LOG("\t\tExpecting %s", ttest->res);
- LOG("\t\tGot %s", nsurl_access(joined));
- }
-
- nsurl_unref(joined);
- }
-
- nsurl_unref(base);
- }
- count++;
+ ck_assert_str_eq(nsurl_access(joined), tst->res);
+
+ nsurl_unref(joined);
}
+ nsurl_unref(res_url);
+
+}
+END_TEST
- if (passed == count) {
- LOG("Testing complete: SUCCESS");
+/**
+ * url joining
+ */
+START_TEST(nsurl_join_test)
+{
+ nserror err;
+ nsurl *base_url;
+ nsurl *joined;
+ char *string;
+ size_t len;
+ const struct test_pairs *tst = &join_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create("http://a/b/c/d;p?q", &base_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_join(base_url, tst->test, &joined);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
} else {
- LOG("Testing complete: FAILURE");
- LOG("Failed %d out of %d", count - passed, count);
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(string, tst->res);
+
+ free(string);
+ nsurl_unref(joined);
}
+ nsurl_unref(base_url);
+}
+END_TEST
+
+
+static void corestring_create(void)
+{
+ ck_assert(corestrings_init() == NSERROR_OK);
+}
+
+static void corestring_teardown(void)
+{
corestrings_fini();
- LOG("Remaining lwc strings:");
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
+}
+
+Suite *nsurl_suite(void)
+{
+ Suite *s;
+ TCase *tc_create;
+ TCase *tc_nice_nostrip;
+ TCase *tc_nice_strip;
+ TCase *tc_replace_query;
+ TCase *tc_join;
+
+ s = suite_create("nsurl");
+
+ /* url creation */
+ tc_create = tcase_create("Create");
+
+ tcase_add_unchecked_fixture(tc_create,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_create,
+ nsurl_create_test,
+ 0, NELEMS(create_tests));
+ suite_add_tcase(s, tc_create);
+
+ /* nice filename without strip */
+ tc_nice_nostrip = tcase_create("Nice (nostrip)");
+
+ tcase_add_unchecked_fixture(tc_nice_nostrip,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_nice_nostrip,
+ nsurl_nice_nostrip_test,
+ 0, NELEMS(nice_tests));
+ suite_add_tcase(s, tc_nice_nostrip);
+
- return 0;
+ /* nice filename with strip */
+ tc_nice_strip = tcase_create("Nice (strip)");
+
+ tcase_add_unchecked_fixture(tc_nice_strip,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_nice_strip,
+ nsurl_nice_strip_test,
+ 0, NELEMS(nice_strip_tests));
+ suite_add_tcase(s, tc_nice_strip);
+
+
+ /* replace query */
+ tc_replace_query = tcase_create("Replace Query");
+
+ tcase_add_unchecked_fixture(tc_replace_query,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_replace_query,
+ nsurl_replace_query_test,
+ 0, NELEMS(replace_query_tests));
+ suite_add_tcase(s, tc_replace_query);
+
+ /* url join */
+ tc_join = tcase_create("Join");
+
+ tcase_add_unchecked_fixture(tc_join,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_join,
+ nsurl_join_test,
+ 0, NELEMS(join_tests));
+ suite_add_tcase(s, tc_join);
+
+ return s;
}
+int main(int argc, char **argv)
+{
+ int number_failed;
+ Suite *s;
+ SRunner *sr;
+
+ s = nsurl_suite();
+
+ sr = srunner_create(s);
+ srunner_run_all(sr, CK_ENV);
+
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index f72d77f..aa3a2df 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -156,14 +156,12 @@ int main(void)
struct host_part *h;
struct path_data *p;
const struct url_data *u;
- int i;
lwc_string *scheme;
lwc_string *fragment;
nsurl *url;
nsurl *urlr;
char *path_query;
- verbose_log = true;
corestrings_init();
-----------------------------------------------------------------------
Summary of changes:
test/Makefile | 4 +-
test/nsurl.c | 501 +++++++++++++++++++++++++++++++-----------------------
test/urldbtest.c | 2 -
3 files changed, 290 insertions(+), 217 deletions(-)
diff --git a/test/Makefile b/test/Makefile
index ce3e274..bfc6fb8 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -7,8 +7,8 @@ test_CFLAGS := -std=c99 -g -Wall \
-D_POSIX_C_SOURCE=200809L \
-D_XOPEN_SOURCE=600 \
-Itest -I. -I.. \
- $(shell pkg-config --cflags libcurl)
-test_LDFLAGS := $(shell pkg-config --libs libcurl) -lz
+ $(shell pkg-config --cflags libcurl check)
+test_LDFLAGS := $(shell pkg-config --libs libcurl check) -lz
# nsurl sources and flags
nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
diff --git a/test/nsurl.c b/test/nsurl.c
index 2afe91b..9c44f7a 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -16,17 +16,24 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file
+ * Test nsurl operations.
+ */
+
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <check.h>
#include <libwapcaplet/libwapcaplet.h>
#include "utils/corestrings.h"
-#include "utils/log.h"
#include "utils/nsurl.h"
+#define NELEMS(x) (sizeof(x) / sizeof((x)[0]))
+
struct test_pairs {
const char* test;
const char* res;
@@ -40,7 +47,11 @@ struct test_triplets {
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
- LOG("[%3u] %.*s", str->refcnt, (int)lwc_string_length(str), lwc_string_data(str));
+ fprintf(stderr,
+ "[%3u] %.*s",
+ str->refcnt,
+ (int)lwc_string_length(str),
+ lwc_string_data(str));
}
static const struct test_pairs create_tests[] = {
@@ -61,25 +72,25 @@ static const struct test_pairs create_tests[] = {
{ "about:blank", "about:blank" },
{ "http://www.ns-b.org:8080/",
- "http://www.ns-b.org:8080/" },
- { "http://user@www.ns-b.org:8080/hello",
- "http://user@www.ns-b.org:8080/hello" },
- { "http://user:pass@www.ns-b.org:8080/hello",
- "http://user:pass@www.ns-b.org:8080/hello" },
+ "http://www.ns-b.org:8080/" },
+ { "http://user@www.ns-b.org:8080/hello",
+ "http://user@www.ns-b.org:8080/hello" },
+ { "http://user:pass@www.ns-b.org:8080/hello",
+ "http://user:pass@www.ns-b.org:8080/hello" },
{ "http://www.ns-b.org:80/",
- "http://www.ns-b.org/" },
- { "http://user@www.ns-b.org:80/hello",
- "http://user@www.ns-b.org/hello" },
- { "http://user:pass@www.ns-b.org:80/hello",
- "http://user:pass@www.ns-b.org/hello" },
+ "http://www.ns-b.org/" },
+ { "http://user@www.ns-b.org:80/hello",
+ "http://user@www.ns-b.org/hello" },
+ { "http://user:pass@www.ns-b.org:80/hello",
+ "http://user:pass@www.ns-b.org/hello" },
{ "http://www.ns-b.org:/",
- "http://www.ns-b.org/" },
- { "http://u@www.ns-b.org:/hello",
- "http://u@www.ns-b.org/hello" },
- { "http://u:p@www.ns-b.org:/hello",
- "http://u:p@www.ns-b.org/hello" },
+ "http://www.ns-b.org/" },
+ { "http://u@www.ns-b.org:/hello",
+ "http://u@www.ns-b.org/hello" },
+ { "http://u:p@www.ns-b.org:/hello",
+ "http://u:p@www.ns-b.org/hello" },
{ "http:a/", "http://a/" },
{ "http:/a/", "http://a/" },
@@ -88,8 +99,32 @@ static const struct test_pairs create_tests[] = {
{ "mailto:u@a", "mailto:u@a" },
{ "mailto:@a", "mailto:a" },
+};
- { NULL, NULL }
+static const struct test_pairs nice_tests[] = {
+ { "about:", NULL },
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about.jpg" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
+};
+
+static const struct test_pairs nice_strip_tests[] = {
+ { "about:", NULL },
+ { "www.foo.org", "www_foo_org" },
+ { "www.foo.org/index.html", "www_foo_org" },
+ { "www.foo.org/default.en", "www_foo_org" },
+ { "www.foo.org/about", "about" },
+ { "www.foo.org/about.jpg", "about" },
+ { "www.foo.org/moose/index.en", "moose" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "www.foo.org/a//index.en", "www_foo_org" },
+ { "http://www.f.org//index.en", "www_f_org" },
};
static const struct test_pairs join_tests[] = {
@@ -161,34 +196,8 @@ static const struct test_pairs join_tests[] = {
/* [1] Extra slash beyond rfc3986 5.4.1 example, since we're
* testing normalisation in addition to joining */
/* [2] Using the strict parsers option */
- { NULL, NULL }
-};
-
-static const struct test_pairs nice_tests[] = {
- { "www.foo.org", "www_foo_org" },
- { "www.foo.org/index.html", "www_foo_org" },
- { "www.foo.org/default.en", "www_foo_org" },
- { "www.foo.org/about", "about" },
- { "www.foo.org/about.jpg", "about.jpg" },
- { "www.foo.org/moose/index.en", "moose" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "http://www.f.org//index.en", "www_f_org" },
- { NULL, NULL }
};
-static const struct test_pairs nice_strip_tests[] = {
- { "www.foo.org", "www_foo_org" },
- { "www.foo.org/index.html", "www_foo_org" },
- { "www.foo.org/default.en", "www_foo_org" },
- { "www.foo.org/about", "about" },
- { "www.foo.org/about.jpg", "about" },
- { "www.foo.org/moose/index.en", "moose" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "www.foo.org/a//index.en", "www_foo_org" },
- { "http://www.f.org//index.en", "www_f_org" },
- { NULL, NULL }
-};
static const struct test_triplets replace_query_tests[] = {
{ "http://netsurf-browser.org/?magical=true",
@@ -207,201 +216,267 @@ static const struct test_triplets replace_query_tests[] = {
"?magical=true",
"http://netsurf-browser.org/path?magical=true"},
- { NULL, NULL, NULL }
};
+
+
/**
- * Test nsurl
+ * url creation test
*/
-int main(int argc, char **argv)
+START_TEST(nsurl_create_test)
{
- nsurl *base;
- nsurl *joined;
- char *string;
- size_t len;
- const char *url;
- const struct test_pairs *test;
- const struct test_triplets *ttest;
- int passed = 0;
- int count = 0;
nserror err;
+ nsurl *res;
+ const struct test_pairs *tst = &create_tests[_i];
- verbose_log = true;
- nslog_init(NULL, &argc, argv);
+ err = nsurl_create(tst->test, &res);
+ if (tst->res == NULL) {
+ /* result must be invalid */
+ ck_assert(err != NSERROR_OK);
- if (corestrings_init() != NSERROR_OK) {
- assert(0 && "Failed to init corestrings.");
- }
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
- /* Create base URL */
- if (nsurl_create("http://a/b/c/d;p?q", &base) != NSERROR_OK) {
- assert(0 && "Failed to create base URL.");
+ ck_assert_str_eq(nsurl_access(res), tst->res);
+
+ nsurl_unref(res);
}
+}
+END_TEST
- if (nsurl_get(base, NSURL_WITH_FRAGMENT, &string, &len) != NSERROR_OK) {
- LOG("Failed to get string");
+/**
+ * url nice filename without stripping
+ */
+START_TEST(nsurl_nice_nostrip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, false);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
} else {
- LOG("Testing nsurl_join with base %s", string);
- free(string);
- }
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
- for (test = join_tests; test->test != NULL; test++) {
- if (nsurl_join(base, test->test, &joined) != NSERROR_OK) {
- LOG("Failed to join test URL.");
- } else {
- if (nsurl_get(joined, NSURL_WITH_FRAGMENT,
- &string, &len) !=
- NSERROR_OK) {
- LOG("Failed to get string");
- } else {
- if (strcmp(test->res, string) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, string);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, string);
- LOG("\t\tExpecting: %s", test->res);
- }
- free(string);
- }
- nsurl_unref(joined);
- }
- count++;
- }
+ ck_assert_str_eq(res_str, tst->res);
- nsurl_unref(base);
-
- /* Create tests */
- LOG("Testing nsurl_create");
- for (test = create_tests; test->test != NULL; test++) {
- err = nsurl_create(test->test, &base);
- if (err != NSERROR_OK || test->res == NULL) {
- if (test->res == NULL && err != NSERROR_OK) {
- LOG("\tPASS: \"%s\"\t--> BAD INPUT", test->test);
- passed++;
- } else if (test->res != NULL && err != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", test->test);
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, nsurl_access(base));
- LOG("\t\tExpecting BAD INPUT");
- }
- if (err == NSERROR_OK)
- nsurl_unref(base);
- } else {
- if (strcmp(nsurl_access(base), test->res) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, nsurl_access(base));
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, nsurl_access(base));
- LOG("\t\tExpecting %s", test->res);
- }
-
- nsurl_unref(base);
- }
- count++;
+ free(res_str);
}
+ nsurl_unref(res_url);
- /* nice filename tests */
- LOG("Testing nsurl_nice (no strip)");
- for (test = nice_tests; test->test != NULL; test++) {
- err = nsurl_create(test->test, &base);
- if (err != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", test->test);
- } else {
- char *res;
- err = nsurl_nice(base, &res, false);
- if (err == NSERROR_OK && test->res != NULL) {
- if (strcmp(res, test->res) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, res);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting %s", test->res);
- }
- free(res);
- } else {
- if (test->res == NULL && err == NSERROR_OK) {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting BAD_INPUT");
- free(res);
- } else {
- LOG("\tFAIL: \"%s\"", test->test);
- }
- }
- nsurl_unref(base);
- }
- count++;
- }
- LOG("Testing nsurl_nice (strip)");
- for (test = nice_strip_tests; test->test != NULL; test++) {
- err = nsurl_create(test->test, &base);
- if (err != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", test->test);
- } else {
- char *res;
- err = nsurl_nice(base, &res, true);
- if (err == NSERROR_OK && test->res != NULL) {
- if (strcmp(res, test->res) == 0) {
- LOG("\tPASS: \"%s\"\t--> %s", test->test, res);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting %s", test->res);
- }
- free(res);
- } else {
- if (test->res == NULL && err == NSERROR_OK) {
- LOG("\tFAIL: \"%s\"\t--> %s", test->test, res);
- LOG("\t\tExpecting BAD_INPUT");
- free(res);
- } else {
- LOG("\tFAIL: \"%s\"", test->test);
- }
- }
- nsurl_unref(base);
- }
- count++;
+}
+END_TEST
+
+/**
+ * url nice filename with stripping
+ */
+START_TEST(nsurl_nice_strip_test)
+{
+ nserror err;
+ nsurl *res_url;
+ char *res_str;
+ const struct test_pairs *tst = &nice_strip_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_nice(res_url, &res_str, true);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(res_str, tst->res);
+
+ free(res_str);
}
+ nsurl_unref(res_url);
+
+}
+END_TEST
+
+/**
+ * replace query
+ */
+START_TEST(nsurl_replace_query_test)
+{
+ nserror err;
+ nsurl *res_url;
+ nsurl *joined;
+ const struct test_triplets *tst = &replace_query_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create(tst->test1, &res_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_replace_query(res_url, tst->test2, &joined);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
+ } else {
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
- /* Replace query tests */
- LOG("Testing nsurl_replace_query");
- for (ttest = replace_query_tests; ttest->test1 != NULL; ttest++) {
- if (nsurl_create(ttest->test1, &base) != NSERROR_OK) {
- LOG("Failed to create URL:\n\t\t%s.", ttest->test1);
- } else {
- if (nsurl_replace_query(base, ttest->test2, &joined) !=
- NSERROR_OK) {
- LOG("Failed to make test URL");
- } else {
- if (strcmp(nsurl_access(joined),
- ttest->res) == 0) {
- LOG("\tPASS: \"%s\" + %s", ttest->test1, ttest->test2);
- passed++;
- } else {
- LOG("\tFAIL: \"%s\" + %s", ttest->test1, ttest->test2);
- LOG("\t\tExpecting %s", ttest->res);
- LOG("\t\tGot %s", nsurl_access(joined));
- }
-
- nsurl_unref(joined);
- }
-
- nsurl_unref(base);
- }
- count++;
+ ck_assert_str_eq(nsurl_access(joined), tst->res);
+
+ nsurl_unref(joined);
}
+ nsurl_unref(res_url);
+
+}
+END_TEST
- if (passed == count) {
- LOG("Testing complete: SUCCESS");
+/**
+ * url joining
+ */
+START_TEST(nsurl_join_test)
+{
+ nserror err;
+ nsurl *base_url;
+ nsurl *joined;
+ char *string;
+ size_t len;
+ const struct test_pairs *tst = &join_tests[_i];
+
+ /* not testing create, this should always succeed */
+ err = nsurl_create("http://a/b/c/d;p?q", &base_url);
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_join(base_url, tst->test, &joined);
+ if (tst->res == NULL) {
+ /* result must be invalid (bad input) */
+ ck_assert(err != NSERROR_OK);
} else {
- LOG("Testing complete: FAILURE");
- LOG("Failed %d out of %d", count - passed, count);
+ /* result must be valid */
+ ck_assert(err == NSERROR_OK);
+
+ err = nsurl_get(joined, NSURL_WITH_FRAGMENT, &string, &len);
+ ck_assert(err == NSERROR_OK);
+
+ ck_assert_str_eq(string, tst->res);
+
+ free(string);
+ nsurl_unref(joined);
}
+ nsurl_unref(base_url);
+}
+END_TEST
+
+
+static void corestring_create(void)
+{
+ ck_assert(corestrings_init() == NSERROR_OK);
+}
+
+static void corestring_teardown(void)
+{
corestrings_fini();
- LOG("Remaining lwc strings:");
lwc_iterate_strings(netsurf_lwc_iterator, NULL);
+}
+
+Suite *nsurl_suite(void)
+{
+ Suite *s;
+ TCase *tc_create;
+ TCase *tc_nice_nostrip;
+ TCase *tc_nice_strip;
+ TCase *tc_replace_query;
+ TCase *tc_join;
+
+ s = suite_create("nsurl");
+
+ /* url creation */
+ tc_create = tcase_create("Create");
+
+ tcase_add_unchecked_fixture(tc_create,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_create,
+ nsurl_create_test,
+ 0, NELEMS(create_tests));
+ suite_add_tcase(s, tc_create);
+
+ /* nice filename without strip */
+ tc_nice_nostrip = tcase_create("Nice (nostrip)");
+
+ tcase_add_unchecked_fixture(tc_nice_nostrip,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_nice_nostrip,
+ nsurl_nice_nostrip_test,
+ 0, NELEMS(nice_tests));
+ suite_add_tcase(s, tc_nice_nostrip);
+
- return 0;
+ /* nice filename with strip */
+ tc_nice_strip = tcase_create("Nice (strip)");
+
+ tcase_add_unchecked_fixture(tc_nice_strip,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_nice_strip,
+ nsurl_nice_strip_test,
+ 0, NELEMS(nice_strip_tests));
+ suite_add_tcase(s, tc_nice_strip);
+
+
+ /* replace query */
+ tc_replace_query = tcase_create("Replace Query");
+
+ tcase_add_unchecked_fixture(tc_replace_query,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_replace_query,
+ nsurl_replace_query_test,
+ 0, NELEMS(replace_query_tests));
+ suite_add_tcase(s, tc_replace_query);
+
+ /* url join */
+ tc_join = tcase_create("Join");
+
+ tcase_add_unchecked_fixture(tc_join,
+ corestring_create,
+ corestring_teardown);
+
+ tcase_add_loop_test(tc_join,
+ nsurl_join_test,
+ 0, NELEMS(join_tests));
+ suite_add_tcase(s, tc_join);
+
+ return s;
}
+int main(int argc, char **argv)
+{
+ int number_failed;
+ Suite *s;
+ SRunner *sr;
+
+ s = nsurl_suite();
+
+ sr = srunner_create(s);
+ srunner_run_all(sr, CK_ENV);
+
+ number_failed = srunner_ntests_failed(sr);
+ srunner_free(sr);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index f72d77f..aa3a2df 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -156,14 +156,12 @@ int main(void)
struct host_part *h;
struct path_data *p;
const struct url_data *u;
- int i;
lwc_string *scheme;
lwc_string *fragment;
nsurl *url;
nsurl *urlr;
char *path_query;
- verbose_log = true;
corestrings_init();
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-206-gbd802e7
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/bd802e763e5c035817a62...
...commit http://git.netsurf-browser.org/netsurf.git/commit/bd802e763e5c035817a6211...
...tree http://git.netsurf-browser.org/netsurf.git/tree/bd802e763e5c035817a62114b...
The branch, master has been updated
via bd802e763e5c035817a62114b957ed6778ad491f (commit)
from ccfc2aeefa87400d506a59799933ad591e7d92ca (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bd802e763e5c035817a...
commit bd802e763e5c035817a62114b957ed6778ad491f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
Restructure test makefile to be called from main makefile
This changes the make test to be executed from the main netsurf
makefile instead of being standalone. It also fixes up the urldbtest
to run.
diff --git a/Makefile b/Makefile
index fc3225a..8e1fcc3 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,8 @@
# make docs
#
+.PHONY: all
+
all: all-program
# Determine host type
@@ -778,7 +780,7 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
#$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
# $(call dependency_generate_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.d)),$(subst /,_,$(SOURCE:.s=.o)))))
-ifneq ($(MAKECMDGOALS),clean)
+ifeq ($(filter $(MAKECMDGOALS),clean test),)
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
-include $(D_JSAPI_BINDING)
endif
@@ -797,14 +799,54 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
$(call compile_target_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.o)),$(subst /,_,$(SOURCE:.s=.d)))))
-.PHONY: all clean docs install package-$(TARGET) package install-$(TARGET)
+# ----------------------------------------------------------------------------
+# Test setup
+# ----------------------------------------------------------------------------
+
+include test/Makefile
+
+
+# ----------------------------------------------------------------------------
+# Clean setup
+# ----------------------------------------------------------------------------
+
+.PHONY: clean
clean: $(CLEANS)
-# Target builds a distribution package
+
+# ----------------------------------------------------------------------------
+# build distribution package
+# ----------------------------------------------------------------------------
+
+.PHONY: package-$(TARGET) package
+
package: all-program package-$(TARGET)
+# ----------------------------------------------------------------------------
+# local install on the host system
+# ----------------------------------------------------------------------------
+
+.PHONY: install install-$(TARGET)
+
+install: all-program install-$(TARGET)
+
+
+# ----------------------------------------------------------------------------
+# Documentation build
+# ----------------------------------------------------------------------------
+
+.PHONY: docs
+
+docs:
+ doxygen Docs/Doxyfile
+
+
+# ----------------------------------------------------------------------------
+# Transifex message processing
+# ----------------------------------------------------------------------------
+
.PHONY: messages-split-tfx messages-fetch-tfx messages-import-tfx
# split fat messages into properties files suitable for uploading to transifex
@@ -819,13 +861,3 @@ messages-fetch-tfx:
messages-import-tfx: messages-fetch-tfx
for tfxlang in $(FAT_LANGUAGES);do perl ./utils/import-messages.pl -l $${tfxlang} -p any -f transifex -o resources/FatMessages -i resources/FatMessages -I Messages.any.$${tfxlang}.tfx ; $(RM) Messages.any.$${tfxlang}.tfx; done
-# Target installs executable on the host system
-install: all-program install-$(TARGET)
-
-docs:
- doxygen Docs/Doxyfile
-
-.PHONY:test
-
-test:
- make -C test
\ No newline at end of file
diff --git a/test/Makefile b/test/Makefile
index 7327580..ce3e274 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,55 +1,78 @@
#
# NetSurf unit tests
-CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I. -I.. \
+
+test_CFLAGS := -std=c99 -g -Wall \
+ -D_BSD_SOURCE \
+ -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=600 \
+ -Itest -I. -I.. \
$(shell pkg-config --cflags libcurl)
-LDFLAGS := $(shell pkg-config --libs libcurl) -lz
+test_LDFLAGS := $(shell pkg-config --libs libcurl) -lz
-llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
-llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
+# nsurl sources and flags
+nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
+nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc) -O0
+nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
+# low level cache sources and flags
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
content/urldb.c desktop/version.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
- utils/log.c utils/nsurl.c utils/messages.c utils/url.c \
+ utils/nsurl.c utils/messages.c utils/url.c \
utils/useragent.c utils/utils.c test/llcache.c
+llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
+llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
-urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
- utils/messages.c utils/hashtable.c \
+# url database test sources and flags
+urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/idna.c \
+ utils/messages.c utils/hashtable.c utils/bloom.c utils/nsoption.c \
utils/filename.c utils/nsurl.c utils/corestrings.c \
- test/urldbtest.c
+ test/log.c test/urldbtest.c
+urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils libutf8proc) -O2
+urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils libutf8proc)
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils)
-
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c desktop/version.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc)
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
nsoption_CFLAGS := -Dnsgtk
-.PHONY: all
+CLEANS += test-clean
+
+TESTS := nsurl urldbtest
+
+TESTROOT := build-$(HOST)-test
+
+
+.PHONY:test
+
+test: $(TESTROOT)/created $(addprefix $(TESTROOT)/,$(TESTS))
+ $(TESTROOT)/nsurl
+ $(TESTROOT)/urldbtest
+
+$(TESTROOT)/created:
+ $(VQ)echo " MKDIR: $(TESTROOT)"
+ $(Q)$(MKDIR) $(TESTROOT)
+ $(Q)$(TOUCH) $@
+
+$(TESTROOT)/nsurl: $(nsurl_SRCS)
+ $(CC) $(test_CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsurl_LDFLAGS)
+
-all: nsurl
- ./nsurl
+$(TESTROOT)/urldbtest: $(urldbtest_SRCS)
+ $(CC) $(test_CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(urldbtest_LDFLAGS)
-llcache: $(addprefix ../,$(llcache_SRCS))
- $(CC) $(CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(LDFLAGS) $(llcache_LDFLAGS)
+$(TESTROOT)/llcache: $(llcache_SRCS)
+ $(CC) $(test_CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(llcache_LDFLAGS)
-urldbtest: $(addprefix ../,$(urldbtest_SRCS))
- $(CC) $(CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(LDFLAGS) $(urldbtest_LDFLAGS)
-nsurl: $(addprefix ../,$(nsurl_SRCS))
- $(CC) $(CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(LDFLAGS) $(nsurl_LDFLAGS)
-nsoption: $(addprefix ../,$(nsoption_SRCS))
- $(CC) $(CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(LDFLAGS) $(nsoption_LDFLAGS)
+$(TESTROOT)/nsoption: $(addprefix ../,$(nsoption_SRCS))
+ $(CC) $(test_CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsoption_LDFLAGS)
-.PHONY: clean
+.PHONY: test-clean
-clean:
- $(RM) llcache urldbtest nsurl nsoption
+test-clean:
+ $(RM) $(addprefix $(TESTROOT)/,$(TESTS))
diff --git a/test/log.c b/test/log.c
new file mode 100644
index 0000000..90b4379
--- /dev/null
+++ b/test/log.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2015 Vincent Sanders <vince(a)netsurf-browser.org>
+ *
+ * This file is part of NetSurf, http://www.netsurf-browser.org/
+ *
+ * NetSurf is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * NetSurf is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file
+ * Minimal unit test log implementation.
+ *
+ * It is necessary to have a logging implementation for the unit tests
+ * so other netsurf modules that assume this functionality work.
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "utils/log.h"
+
+/** flag to enable verbose logging */
+bool verbose_log = false;
+
+nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
+{
+ return NSERROR_OK;
+}
+
+
+void nslog_log(const char *file, const char *func, int ln, const char *format, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s:%i %s: ", file, ln, func);
+
+ va_start(ap, format);
+
+ vfprintf(stderr, format, ap);
+
+ va_end(ap);
+
+ fputc('\n', stderr);
+}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 4536ddd..f72d77f 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -46,7 +46,7 @@
#include "utils/utils.h"
int option_expire_url = 0;
-bool verbose_log = true;
+struct netsurf_table *guit = NULL;
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
@@ -163,6 +163,8 @@ int main(void)
nsurl *urlr;
char *path_query;
+ verbose_log = true;
+
corestrings_init();
h = urldb_add_host("127.0.0.1");
-----------------------------------------------------------------------
Summary of changes:
Makefile | 58 ++++++++++++++++++++++++-------
test/Makefile | 79 +++++++++++++++++++++++++++---------------
windows/file.h => test/log.c | 35 ++++++++++++++++---
test/urldbtest.c | 4 ++-
4 files changed, 129 insertions(+), 47 deletions(-)
copy windows/file.h => test/log.c (53%)
diff --git a/Makefile b/Makefile
index fc3225a..8e1fcc3 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,8 @@
# make docs
#
+.PHONY: all
+
all: all-program
# Determine host type
@@ -778,7 +780,7 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
#$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
# $(call dependency_generate_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.d)),$(subst /,_,$(SOURCE:.s=.o)))))
-ifneq ($(MAKECMDGOALS),clean)
+ifeq ($(filter $(MAKECMDGOALS),clean test),)
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
-include $(D_JSAPI_BINDING)
endif
@@ -797,14 +799,54 @@ $(eval $(foreach SOURCE,$(filter %.m,$(SOURCES)), \
$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
$(call compile_target_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.o)),$(subst /,_,$(SOURCE:.s=.d)))))
-.PHONY: all clean docs install package-$(TARGET) package install-$(TARGET)
+# ----------------------------------------------------------------------------
+# Test setup
+# ----------------------------------------------------------------------------
+
+include test/Makefile
+
+
+# ----------------------------------------------------------------------------
+# Clean setup
+# ----------------------------------------------------------------------------
+
+.PHONY: clean
clean: $(CLEANS)
-# Target builds a distribution package
+
+# ----------------------------------------------------------------------------
+# build distribution package
+# ----------------------------------------------------------------------------
+
+.PHONY: package-$(TARGET) package
+
package: all-program package-$(TARGET)
+# ----------------------------------------------------------------------------
+# local install on the host system
+# ----------------------------------------------------------------------------
+
+.PHONY: install install-$(TARGET)
+
+install: all-program install-$(TARGET)
+
+
+# ----------------------------------------------------------------------------
+# Documentation build
+# ----------------------------------------------------------------------------
+
+.PHONY: docs
+
+docs:
+ doxygen Docs/Doxyfile
+
+
+# ----------------------------------------------------------------------------
+# Transifex message processing
+# ----------------------------------------------------------------------------
+
.PHONY: messages-split-tfx messages-fetch-tfx messages-import-tfx
# split fat messages into properties files suitable for uploading to transifex
@@ -819,13 +861,3 @@ messages-fetch-tfx:
messages-import-tfx: messages-fetch-tfx
for tfxlang in $(FAT_LANGUAGES);do perl ./utils/import-messages.pl -l $${tfxlang} -p any -f transifex -o resources/FatMessages -i resources/FatMessages -I Messages.any.$${tfxlang}.tfx ; $(RM) Messages.any.$${tfxlang}.tfx; done
-# Target installs executable on the host system
-install: all-program install-$(TARGET)
-
-docs:
- doxygen Docs/Doxyfile
-
-.PHONY:test
-
-test:
- make -C test
\ No newline at end of file
diff --git a/test/Makefile b/test/Makefile
index 7327580..ce3e274 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,55 +1,78 @@
#
# NetSurf unit tests
-CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I. -I.. \
+
+test_CFLAGS := -std=c99 -g -Wall \
+ -D_BSD_SOURCE \
+ -D_POSIX_C_SOURCE=200809L \
+ -D_XOPEN_SOURCE=600 \
+ -Itest -I. -I.. \
$(shell pkg-config --cflags libcurl)
-LDFLAGS := $(shell pkg-config --libs libcurl) -lz
+test_LDFLAGS := $(shell pkg-config --libs libcurl) -lz
-llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
-llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
+# nsurl sources and flags
+nsurl_SRCS := utils/corestrings.c utils/nsurl.c utils/idna.c test/log.c test/nsurl.c
+nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc) -O0
+nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
+# low level cache sources and flags
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
content/urldb.c desktop/version.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
- utils/log.c utils/nsurl.c utils/messages.c utils/url.c \
+ utils/nsurl.c utils/messages.c utils/url.c \
utils/useragent.c utils/utils.c test/llcache.c
+llcache_CFLAGS := $(shell pkg-config --cflags libparserutils libwapcaplet libdom) -O2
+llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
-urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
- utils/messages.c utils/hashtable.c \
+# url database test sources and flags
+urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/idna.c \
+ utils/messages.c utils/hashtable.c utils/bloom.c utils/nsoption.c \
utils/filename.c utils/nsurl.c utils/corestrings.c \
- test/urldbtest.c
+ test/log.c test/urldbtest.c
+urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils libutf8proc) -O2
+urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils libutf8proc)
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils)
-
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c desktop/version.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc)
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
nsoption_CFLAGS := -Dnsgtk
-.PHONY: all
+CLEANS += test-clean
+
+TESTS := nsurl urldbtest
+
+TESTROOT := build-$(HOST)-test
+
+
+.PHONY:test
+
+test: $(TESTROOT)/created $(addprefix $(TESTROOT)/,$(TESTS))
+ $(TESTROOT)/nsurl
+ $(TESTROOT)/urldbtest
+
+$(TESTROOT)/created:
+ $(VQ)echo " MKDIR: $(TESTROOT)"
+ $(Q)$(MKDIR) $(TESTROOT)
+ $(Q)$(TOUCH) $@
+
+$(TESTROOT)/nsurl: $(nsurl_SRCS)
+ $(CC) $(test_CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsurl_LDFLAGS)
+
-all: nsurl
- ./nsurl
+$(TESTROOT)/urldbtest: $(urldbtest_SRCS)
+ $(CC) $(test_CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(urldbtest_LDFLAGS)
-llcache: $(addprefix ../,$(llcache_SRCS))
- $(CC) $(CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(LDFLAGS) $(llcache_LDFLAGS)
+$(TESTROOT)/llcache: $(llcache_SRCS)
+ $(CC) $(test_CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(llcache_LDFLAGS)
-urldbtest: $(addprefix ../,$(urldbtest_SRCS))
- $(CC) $(CFLAGS) $(urldbtest_CFLAGS) $^ -o $@ $(LDFLAGS) $(urldbtest_LDFLAGS)
-nsurl: $(addprefix ../,$(nsurl_SRCS))
- $(CC) $(CFLAGS) $(nsurl_CFLAGS) $^ -o $@ $(LDFLAGS) $(nsurl_LDFLAGS)
-nsoption: $(addprefix ../,$(nsoption_SRCS))
- $(CC) $(CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(LDFLAGS) $(nsoption_LDFLAGS)
+$(TESTROOT)/nsoption: $(addprefix ../,$(nsoption_SRCS))
+ $(CC) $(test_CFLAGS) $(nsoption_CFLAGS) $^ -o $@ $(test_LDFLAGS) $(nsoption_LDFLAGS)
-.PHONY: clean
+.PHONY: test-clean
-clean:
- $(RM) llcache urldbtest nsurl nsoption
+test-clean:
+ $(RM) $(addprefix $(TESTROOT)/,$(TESTS))
diff --git a/windows/file.h b/test/log.c
similarity index 53%
copy from windows/file.h
copy to test/log.c
index 5262dde..90b4379 100644
--- a/windows/file.h
+++ b/test/log.c
@@ -18,12 +18,37 @@
/**
* \file
- * Windows file operation table interface.
+ * Minimal unit test log implementation.
+ *
+ * It is necessary to have a logging implementation for the unit tests
+ * so other netsurf modules that assume this functionality work.
*/
-#ifndef _NETSURF_WINDOWS_FILE_H_
-#define _NETSURF_WINDOWS_FILE_H_
+#include <stdarg.h>
+#include <stdio.h>
+
+#include "utils/log.h"
+
+/** flag to enable verbose logging */
+bool verbose_log = false;
+
+nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv)
+{
+ return NSERROR_OK;
+}
+
+
+void nslog_log(const char *file, const char *func, int ln, const char *format, ...)
+{
+ va_list ap;
+
+ fprintf(stderr, "%s:%i %s: ", file, ln, func);
+
+ va_start(ap, format);
+
+ vfprintf(stderr, format, ap);
-struct gui_file_table *win32_file_table;
+ va_end(ap);
-#endif
+ fputc('\n', stderr);
+}
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 4536ddd..f72d77f 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -46,7 +46,7 @@
#include "utils/utils.h"
int option_expire_url = 0;
-bool verbose_log = true;
+struct netsurf_table *guit = NULL;
static void netsurf_lwc_iterator(lwc_string *str, void *pw)
{
@@ -163,6 +163,8 @@ int main(void)
nsurl *urlr;
char *path_query;
+ verbose_log = true;
+
corestrings_init();
h = urldb_add_host("127.0.0.1");
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-205-gccfc2ae
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/ccfc2aeefa87400d506a5...
...commit http://git.netsurf-browser.org/netsurf.git/commit/ccfc2aeefa87400d506a597...
...tree http://git.netsurf-browser.org/netsurf.git/tree/ccfc2aeefa87400d506a59799...
The branch, master has been updated
via ccfc2aeefa87400d506a59799933ad591e7d92ca (commit)
from c38670ade8c664fa511cebb4b5d2950b12e7bf81 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ccfc2aeefa87400d506...
commit ccfc2aeefa87400d506a59799933ad591e7d92ca
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Vincent Sanders <vince(a)kyllikki.org>
make nsurl unit test work again
diff --git a/Makefile b/Makefile
index 107e61c..fc3225a 100644
--- a/Makefile
+++ b/Makefile
@@ -824,3 +824,8 @@ install: all-program install-$(TARGET)
docs:
doxygen Docs/Doxyfile
+
+.PHONY:test
+
+test:
+ make -C test
\ No newline at end of file
diff --git a/test/Makefile b/test/Makefile
index cf0f897..7327580 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,7 @@
-CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I.. \
+#
+# NetSurf unit tests
+
+CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I. -I.. \
$(shell pkg-config --cflags libcurl)
LDFLAGS := $(shell pkg-config --libs libcurl) -lz
@@ -8,30 +11,31 @@ llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
- content/urldb.c desktop/options.c desktop/version.c \
+ content/urldb.c desktop/version.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
utils/log.c utils/nsurl.c utils/messages.c utils/url.c \
utils/useragent.c utils/utils.c test/llcache.c
urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
- desktop/options.c utils/messages.c utils/hashtable.c \
+ utils/messages.c utils/hashtable.c \
utils/filename.c utils/nsurl.c utils/corestrings.c \
test/urldbtest.c
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
+urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils) -O2
+urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils)
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c utils/utf8proc.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom)
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
+nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c desktop/version.c test/nsurl.c
+nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc)
+nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
nsoption_CFLAGS := -Dnsgtk
.PHONY: all
-all: llcache urldbtest nsurl nsoption
+all: nsurl
+ ./nsurl
llcache: $(addprefix ../,$(llcache_SRCS))
$(CC) $(CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(LDFLAGS) $(llcache_LDFLAGS)
diff --git a/test/llcache.c b/test/llcache.c
index ca9da91..42abb24 100644
--- a/test/llcache.c
+++ b/test/llcache.c
@@ -26,7 +26,6 @@
#include "content/llcache.h"
#include "utils/ring.h"
#include "utils/nsurl.h"
-#include "utils/schedule.h"
#include "utils/url.h"
#include "utils/corestrings.h"
#include "utils/utils.h"
diff --git a/test/nsurl.c b/test/nsurl.c
index 891e5c9..2afe91b 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -213,7 +213,7 @@ static const struct test_triplets replace_query_tests[] = {
/**
* Test nsurl
*/
-int main(void)
+int main(int argc, char **argv)
{
nsurl *base;
nsurl *joined;
@@ -227,6 +227,7 @@ int main(void)
nserror err;
verbose_log = true;
+ nslog_init(NULL, &argc, argv);
if (corestrings_init() != NSERROR_OK) {
assert(0 && "Failed to init corestrings.");
diff --git a/test/testament.h b/test/testament.h
new file mode 100644
index 0000000..e69de29
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 88291ce..4536ddd 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -29,6 +29,7 @@
#include <curl/curl.h>
+#include "utils/errors.h"
#include "image/bitmap.h"
#include "content/content.h"
#include "content/urldb.h"
-----------------------------------------------------------------------
Summary of changes:
Makefile | 5 +++++
test/Makefile | 22 +++++++++++++---------
test/llcache.c | 1 -
test/nsurl.c | 3 ++-
test/urldbtest.c | 1 +
5 files changed, 21 insertions(+), 11 deletions(-)
create mode 100644 test/testament.h
diff --git a/Makefile b/Makefile
index 107e61c..fc3225a 100644
--- a/Makefile
+++ b/Makefile
@@ -824,3 +824,8 @@ install: all-program install-$(TARGET)
docs:
doxygen Docs/Doxyfile
+
+.PHONY:test
+
+test:
+ make -C test
\ No newline at end of file
diff --git a/test/Makefile b/test/Makefile
index cf0f897..7327580 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,4 +1,7 @@
-CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I.. \
+#
+# NetSurf unit tests
+
+CFLAGS := -std=c99 -g -O0 -D_BSD_SOURCE -D_POSIX_C_SOURCE -I. -I.. \
$(shell pkg-config --cflags libcurl)
LDFLAGS := $(shell pkg-config --libs libcurl) -lz
@@ -8,30 +11,31 @@ llcache_LDFLAGS := $(shell pkg-config --libs libparserutils libwapcaplet libdom)
llcache_SRCS := content/fetch.c content/fetchers/curl.c \
content/fetchers/about.c content/fetchers/data.c \
content/fetchers/resource.c content/llcache.c \
- content/urldb.c desktop/options.c desktop/version.c \
+ content/urldb.c desktop/version.c \
image/image_cache.c \
utils/base64.c utils/corestrings.c utils/hashtable.c \
utils/log.c utils/nsurl.c utils/messages.c utils/url.c \
utils/useragent.c utils/utils.c test/llcache.c
urldbtest_SRCS := content/urldb.c utils/url.c utils/utils.c utils/log.c \
- desktop/options.c utils/messages.c utils/hashtable.c \
+ utils/messages.c utils/hashtable.c \
utils/filename.c utils/nsurl.c utils/corestrings.c \
test/urldbtest.c
-urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom) -O2
-urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
+urldbtest_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libnsutils) -O2
+urldbtest_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libnsutils)
-nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c utils/utf8proc.c test/nsurl.c
-nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom)
-nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom)
+nsurl_SRCS := utils/corestrings.c utils/log.c utils/nsurl.c utils/idna.c desktop/version.c test/nsurl.c
+nsurl_CFLAGS := $(shell pkg-config --cflags libwapcaplet libdom libutf8proc)
+nsurl_LDFLAGS := $(shell pkg-config --libs libwapcaplet libdom libutf8proc)
nsoption_SRCS := utils/log.c utils/nsoption.c test/nsoption.c
nsoption_CFLAGS := -Dnsgtk
.PHONY: all
-all: llcache urldbtest nsurl nsoption
+all: nsurl
+ ./nsurl
llcache: $(addprefix ../,$(llcache_SRCS))
$(CC) $(CFLAGS) $(llcache_CFLAGS) $^ -o $@ $(LDFLAGS) $(llcache_LDFLAGS)
diff --git a/test/llcache.c b/test/llcache.c
index ca9da91..42abb24 100644
--- a/test/llcache.c
+++ b/test/llcache.c
@@ -26,7 +26,6 @@
#include "content/llcache.h"
#include "utils/ring.h"
#include "utils/nsurl.h"
-#include "utils/schedule.h"
#include "utils/url.h"
#include "utils/corestrings.h"
#include "utils/utils.h"
diff --git a/test/nsurl.c b/test/nsurl.c
index 891e5c9..2afe91b 100644
--- a/test/nsurl.c
+++ b/test/nsurl.c
@@ -213,7 +213,7 @@ static const struct test_triplets replace_query_tests[] = {
/**
* Test nsurl
*/
-int main(void)
+int main(int argc, char **argv)
{
nsurl *base;
nsurl *joined;
@@ -227,6 +227,7 @@ int main(void)
nserror err;
verbose_log = true;
+ nslog_init(NULL, &argc, argv);
if (corestrings_init() != NSERROR_OK) {
assert(0 && "Failed to init corestrings.");
diff --git a/test/testament.h b/test/testament.h
new file mode 100644
index 0000000..e69de29
diff --git a/test/urldbtest.c b/test/urldbtest.c
index 88291ce..4536ddd 100644
--- a/test/urldbtest.c
+++ b/test/urldbtest.c
@@ -29,6 +29,7 @@
#include <curl/curl.h>
+#include "utils/errors.h"
#include "image/bitmap.h"
#include "content/content.h"
#include "content/urldb.h"
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-204-gc38670a
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/c38670ade8c664fa511ce...
...commit http://git.netsurf-browser.org/netsurf.git/commit/c38670ade8c664fa511cebb...
...tree http://git.netsurf-browser.org/netsurf.git/tree/c38670ade8c664fa511cebb4b...
The branch, master has been updated
via c38670ade8c664fa511cebb4b5d2950b12e7bf81 (commit)
via 8282f53880877f84b1fce05c5529e8994abcb690 (commit)
via bc3534d920f07bd30ca9281ea7f2ea3aa0767901 (commit)
from 7459d4dc93f449ad8fcf98e5fd5e0f33d857703d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c38670ade8c664fa511...
commit c38670ade8c664fa511cebb4b5d2950b12e7bf81
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Allow a fallback font for characters above 0xFFFF to be specified. There is no scanning of this range as most fonts don't have any characters here. Symbola is selected if it is installed.
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index 2ea772e..aecdb18 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -153,6 +153,8 @@ Additional fall-back fonts can be provided since NetSurf 3.0. These need to go i
NB: Since NetSurf 3.0, NetSurf will scan the provided Unicode fonts, and the rest of the system fonts, on first startup. Setting font_unicode_only:1 will prevent fonts not in the preferred Unicode fonts list from being scanned or used as fallback fonts. If the system fonts or NetSurf's fallback fonts list changes, this cache will need to be re-generated. This can be forced by deleting the font glyph cache (which defaults to Users/user/FontGlyphCache).
+Since NetSurf 3.4, Unicode glyphs above 0xFFFF are supported. These are mainly used for Emoji. The option to specify a fallback font for this range is font_surrogate - there is no scanning of system fonts. If @{"Symbola" rxs "address netsurf 'open http://users.teilar.gr/~g1951d/'"} font is installed it will be selected automatically.
+
@{b}Font sizes@{ub}
The default and minimum font sizes can also be set.
diff --git a/amiga/font.c b/amiga/font.c
index 12375ad..c39b002 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -162,7 +162,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list);
static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa);
-static inline int amiga_nsfont_utf16_char_length(uint16 *char1)
+static inline int amiga_nsfont_utf16_char_length(const uint16 *char1)
{
if (__builtin_expect(((*char1 < 0xD800) || (0xDBFF < *char1)), 1)) {
return 1;
@@ -461,7 +461,12 @@ static struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle
break;
case NSA_UNICODE_FONT:
default:
- fontname = (char *)ami_font_scan_lookup(codepoint, glypharray);
+ if(__builtin_expect((amiga_nsfont_utf16_char_length(codepoint) == 2), 0)) {
+ /* Multi-byte character */
+ fontname = nsoption_charp(font_surrogate);
+ } else {
+ fontname = (char *)ami_font_scan_lookup(codepoint, glypharray);
+ }
if(fontname == NULL) return NULL;
break;
}
@@ -604,6 +609,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
long_char_1 = amiga_nsfont_decode_surrogate(char1);
long_char_2 = amiga_nsfont_decode_surrogate(char2);
+ /**\todo use OT_GlyphCode_32 so we get an error for old font engines */
if(ESetInfo(AMI_OFONT_ENGINE,
OT_GlyphCode, long_char_1,
@@ -690,6 +696,7 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
if (*char2 < 0x0020) skip_c2 = true;
long_char_1 = amiga_nsfont_decode_surrogate(char1);
+ /**\todo use OT_GlyphCode_32 so we get an error for old font engines */
if(ESetInfo(AMI_OFONT_ENGINE,
OT_GlyphCode, long_char_1,
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index 930a150..4f4b774 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -254,7 +254,12 @@ static ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
}
#ifdef __amigaos4__
if(EObtainInfo(AMI_OFONT_ENGINE, OT_UnicodeRanges, &unicoderanges, TAG_END) == 0) {
- if(unicoderanges & UCR_SURROGATES) LOG("%s supports UTF-16 surrogates", fontname);
+ if(unicoderanges & UCR_SURROGATES) {
+ LOG("%s supports UTF-16 surrogates", fontname);
+ if (nsoption_charp(font_surrogate) == NULL) {
+ nsoption_set_charp(font_surrogate, (char *)strdup(fontname));
+ }
+ }
EReleaseInfo(AMI_OFONT_ENGINE,
OT_UnicodeRanges, unicoderanges,
TAG_END);
diff --git a/amiga/gui.c b/amiga/gui.c
index 1eb561d..b7f3285 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -604,13 +604,13 @@ static nserror ami_set_options(struct nsoption_s *defaults)
BPTR lock = 0;
/* Search for some likely candidates */
- if((lock = Lock("FONTS:Code2000.font", ACCESS_READ)))
+ if((lock = Lock("FONTS:Code2000.otag", ACCESS_READ)))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
(char *)strdup("Code2000"));
}
- else if((lock = Lock("FONTS:Bitstream Cyberbit.font", ACCESS_READ)))
+ else if((lock = Lock("FONTS:Bitstream Cyberbit.otag", ACCESS_READ)))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
@@ -618,6 +618,19 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
+ if (nsoption_charp(font_surrogate) == NULL) {
+ BPTR lock = 0;
+ /* Search for some likely candidates -
+ * Ideally we should pick a font during the scan process which announces it
+ * contains UCR_SURROGATES, but nothing appears to have the tag.
+ */
+ if((lock = Lock("FONTS:Symbola.otag", ACCESS_READ))) {
+ UnLock(lock);
+ nsoption_set_charp(font_surrogate,
+ (char *)strdup("Symbola"));
+ }
+ }
+
if(popupmenu_lib_ok == FALSE)
nsoption_set_bool(context_menu, false);
diff --git a/amiga/options.h b/amiga/options.h
index b942420..a98b1e8 100644
--- a/amiga/options.h
+++ b/amiga/options.h
@@ -60,6 +60,7 @@ NSOPTION_BOOL(startup_no_window, false)
NSOPTION_BOOL(close_no_quit, false)
NSOPTION_BOOL(hide_docky_icon, false)
NSOPTION_STRING(font_unicode, NULL)
+NSOPTION_STRING(font_surrogate, NULL)
NSOPTION_STRING(font_unicode_file, NULL)
NSOPTION_BOOL(font_unicode_only, false)
NSOPTION_BOOL(font_antialiasing, true)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8282f53880877f84b1f...
commit 8282f53880877f84b1fce05c5529e8994abcb690
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Support UTF-16 surrogates. This enables Emoji to be displayed if an appropriate font is installed.
NB: Currently surrogate glyphs are not able to use the fallback font. The wrong glyphs may be displayed if you use an "old font engine".
diff --git a/amiga/font.c b/amiga/font.c
index e32049f..12375ad 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -171,6 +171,15 @@ static inline int amiga_nsfont_utf16_char_length(uint16 *char1)
}
}
+static inline uint32 amiga_nsfont_decode_surrogate(const uint16 *char1)
+{
+ if(__builtin_expect((amiga_nsfont_utf16_char_length(char1) == 2), 0)) {
+ return ((uint32)char1[0] << 10) + char1[1] - 0x35FDC00;
+ } else {
+ return (uint32)*char1;
+ }
+}
+
static inline bool amiga_nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
@@ -564,10 +573,12 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
FIXED kern = 0;
ULONG glyphmaptag;
ULONG template_type;
+ uint32 long_char_1 = 0, long_char_2 = 0;
#ifndef __amigaos4__
struct BulletBase *BulletBase = ofont->BulletBase;
#endif
+#ifndef __amigaos4__
if (__builtin_expect(((*char1 >= 0xD800) && (*char1 <= 0xDBFF)), 0)) {
/* We don't support UTF-16 surrogates yet, so just return. */
return 0;
@@ -577,6 +588,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
/* Don't attempt to kern a UTF-16 surrogate */
*char2 = 0;
}
+#endif
if(aa == true) {
#ifdef __amigaos4__
@@ -590,9 +602,12 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
#endif
}
+ long_char_1 = amiga_nsfont_decode_surrogate(char1);
+ long_char_2 = amiga_nsfont_decode_surrogate(char2);
+
if(ESetInfo(AMI_OFONT_ENGINE,
- OT_GlyphCode, *char1,
- OT_GlyphCode2, *char2,
+ OT_GlyphCode, long_char_1,
+ OT_GlyphCode2, long_char_2,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(AMI_OFONT_ENGINE,
@@ -655,10 +670,12 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
FIXED char1w = 0;
struct GlyphWidthEntry *gwnode;
bool skip_c2 = false;
+ uint32 long_char_1 = 0;
#ifndef __amigaos4__
struct BulletBase *BulletBase = ofont->BulletBase;
#endif
+#ifndef __amigaos4__
if (__builtin_expect(((*char1 >= 0xD800) && (*char1 <= 0xDBFF)), 0)) {
/* We don't support UTF-16 surrogates yet, so just return. */
return 0;
@@ -668,14 +685,15 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
/* Don't attempt to kern a UTF-16 surrogate */
skip_c2 = true;
}
-
-
+#endif
if (*char2 < 0x0020) skip_c2 = true;
+ long_char_1 = amiga_nsfont_decode_surrogate(char1);
+
if(ESetInfo(AMI_OFONT_ENGINE,
- OT_GlyphCode, *char1,
- OT_GlyphCode2, *char1,
+ OT_GlyphCode, long_char_1,
+ OT_GlyphCode2, long_char_1,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(AMI_OFONT_ENGINE,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bc3534d920f07bd30ca...
commit bc3534d920f07bd30ca9281ea7f2ea3aa0767901
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Split UTF-16 char length check into a separate function
diff --git a/amiga/font.c b/amiga/font.c
index 6d5200f..e32049f 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -162,6 +162,15 @@ static void ami_font_cleanup(struct MinList *ami_font_list);
static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa);
+static inline int amiga_nsfont_utf16_char_length(uint16 *char1)
+{
+ if (__builtin_expect(((*char1 < 0xD800) || (0xDBFF < *char1)), 1)) {
+ return 1;
+ } else {
+ return 2;
+ }
+}
+
static inline bool amiga_nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
@@ -206,11 +215,7 @@ static inline bool amiga_nsfont_position_in_string(const plot_font_style_t *fsty
*actual_x = 0;
while (utf8_pos < length) {
- if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
- else
- utf16charlen = 2;
-
+ utf16charlen = amiga_nsfont_utf16_char_length(utf16);
utf16next = &utf16[utf16charlen];
tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
@@ -664,6 +669,8 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
skip_c2 = true;
}
+
+
if (*char2 < 0x0020) skip_c2 = true;
if(ESetInfo(AMI_OFONT_ENGINE,
@@ -746,11 +753,7 @@ ULONG ami_font_unicode_text(struct RastPort *rp, const char *string, ULONG lengt
while(*utf16 != 0)
{
- if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
- else
- utf16charlen = 2;
-
+ utf16charlen = amiga_nsfont_utf16_char_length(utf16);
utf16next = &utf16[utf16charlen];
if(fstyle->flags & FONTF_SMALLCAPS)
@@ -811,11 +814,7 @@ static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
while(*utf16 != 0)
{
- if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
- else
- utf16charlen = 2;
-
+ utf16charlen = amiga_nsfont_utf16_char_length(utf16);
utf16next = &utf16[utf16charlen];
if(fstyle->flags & FONTF_SMALLCAPS)
@@ -915,7 +914,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list)
SubTime(&curtime, &fnode->lastused);
if(curtime.Seconds > 300)
{
- LOG("Freeing %s not used for %d seconds", node->dtz_Node.ln_Name, curtime.Seconds);
+ LOG("Freeing %s not used for %ld seconds", node->dtz_Node.ln_Name, curtime.Seconds);
DelObject(node);
}
} while((node=nnode));
@@ -958,7 +957,7 @@ void ami_font_setdevicedpi(int id)
xdpi = (yres * ydpi) / xres;
- LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %ld x %ld, corrected %ld x %ld)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres);
+ LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %d x %d, corrected %d x %d)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres);
}
}
}
-----------------------------------------------------------------------
Summary of changes:
amiga/dist/NetSurf.guide | 2 ++
amiga/font.c | 68 +++++++++++++++++++++++++++++++---------------
amiga/font_scan.c | 7 ++++-
amiga/gui.c | 17 ++++++++++--
amiga/options.h | 1 +
5 files changed, 70 insertions(+), 25 deletions(-)
diff --git a/amiga/dist/NetSurf.guide b/amiga/dist/NetSurf.guide
index 2ea772e..aecdb18 100755
--- a/amiga/dist/NetSurf.guide
+++ b/amiga/dist/NetSurf.guide
@@ -153,6 +153,8 @@ Additional fall-back fonts can be provided since NetSurf 3.0. These need to go i
NB: Since NetSurf 3.0, NetSurf will scan the provided Unicode fonts, and the rest of the system fonts, on first startup. Setting font_unicode_only:1 will prevent fonts not in the preferred Unicode fonts list from being scanned or used as fallback fonts. If the system fonts or NetSurf's fallback fonts list changes, this cache will need to be re-generated. This can be forced by deleting the font glyph cache (which defaults to Users/user/FontGlyphCache).
+Since NetSurf 3.4, Unicode glyphs above 0xFFFF are supported. These are mainly used for Emoji. The option to specify a fallback font for this range is font_surrogate - there is no scanning of system fonts. If @{"Symbola" rxs "address netsurf 'open http://users.teilar.gr/~g1951d/'"} font is installed it will be selected automatically.
+
@{b}Font sizes@{ub}
The default and minimum font sizes can also be set.
diff --git a/amiga/font.c b/amiga/font.c
index 6d5200f..c39b002 100644
--- a/amiga/font.c
+++ b/amiga/font.c
@@ -162,6 +162,24 @@ static void ami_font_cleanup(struct MinList *ami_font_list);
static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
const plot_font_style_t *fstyle, ULONG x, ULONG y, bool aa);
+static inline int amiga_nsfont_utf16_char_length(const uint16 *char1)
+{
+ if (__builtin_expect(((*char1 < 0xD800) || (0xDBFF < *char1)), 1)) {
+ return 1;
+ } else {
+ return 2;
+ }
+}
+
+static inline uint32 amiga_nsfont_decode_surrogate(const uint16 *char1)
+{
+ if(__builtin_expect((amiga_nsfont_utf16_char_length(char1) == 2), 0)) {
+ return ((uint32)char1[0] << 10) + char1[1] - 0x35FDC00;
+ } else {
+ return (uint32)*char1;
+ }
+}
+
static inline bool amiga_nsfont_width(const plot_font_style_t *fstyle,
const char *string, size_t length,
int *width)
@@ -206,11 +224,7 @@ static inline bool amiga_nsfont_position_in_string(const plot_font_style_t *fsty
*actual_x = 0;
while (utf8_pos < length) {
- if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
- else
- utf16charlen = 2;
-
+ utf16charlen = amiga_nsfont_utf16_char_length(utf16);
utf16next = &utf16[utf16charlen];
tempx = ami_font_width_glyph(ofont, utf16, utf16next, emwidth);
@@ -447,7 +461,12 @@ static struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle
break;
case NSA_UNICODE_FONT:
default:
- fontname = (char *)ami_font_scan_lookup(codepoint, glypharray);
+ if(__builtin_expect((amiga_nsfont_utf16_char_length(codepoint) == 2), 0)) {
+ /* Multi-byte character */
+ fontname = nsoption_charp(font_surrogate);
+ } else {
+ fontname = (char *)ami_font_scan_lookup(codepoint, glypharray);
+ }
if(fontname == NULL) return NULL;
break;
}
@@ -559,10 +578,12 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
FIXED kern = 0;
ULONG glyphmaptag;
ULONG template_type;
+ uint32 long_char_1 = 0, long_char_2 = 0;
#ifndef __amigaos4__
struct BulletBase *BulletBase = ofont->BulletBase;
#endif
+#ifndef __amigaos4__
if (__builtin_expect(((*char1 >= 0xD800) && (*char1 <= 0xDBFF)), 0)) {
/* We don't support UTF-16 surrogates yet, so just return. */
return 0;
@@ -572,6 +593,7 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
/* Don't attempt to kern a UTF-16 surrogate */
*char2 = 0;
}
+#endif
if(aa == true) {
#ifdef __amigaos4__
@@ -585,9 +607,13 @@ static inline int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPo
#endif
}
+ long_char_1 = amiga_nsfont_decode_surrogate(char1);
+ long_char_2 = amiga_nsfont_decode_surrogate(char2);
+ /**\todo use OT_GlyphCode_32 so we get an error for old font engines */
+
if(ESetInfo(AMI_OFONT_ENGINE,
- OT_GlyphCode, *char1,
- OT_GlyphCode2, *char2,
+ OT_GlyphCode, long_char_1,
+ OT_GlyphCode2, long_char_2,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(AMI_OFONT_ENGINE,
@@ -650,10 +676,12 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
FIXED char1w = 0;
struct GlyphWidthEntry *gwnode;
bool skip_c2 = false;
+ uint32 long_char_1 = 0;
#ifndef __amigaos4__
struct BulletBase *BulletBase = ofont->BulletBase;
#endif
+#ifndef __amigaos4__
if (__builtin_expect(((*char1 >= 0xD800) && (*char1 <= 0xDBFF)), 0)) {
/* We don't support UTF-16 surrogates yet, so just return. */
return 0;
@@ -663,12 +691,16 @@ static inline int32 ami_font_width_glyph(struct OutlineFont *ofont,
/* Don't attempt to kern a UTF-16 surrogate */
skip_c2 = true;
}
+#endif
if (*char2 < 0x0020) skip_c2 = true;
+ long_char_1 = amiga_nsfont_decode_surrogate(char1);
+ /**\todo use OT_GlyphCode_32 so we get an error for old font engines */
+
if(ESetInfo(AMI_OFONT_ENGINE,
- OT_GlyphCode, *char1,
- OT_GlyphCode2, *char1,
+ OT_GlyphCode, long_char_1,
+ OT_GlyphCode2, long_char_1,
TAG_END) == OTERR_Success)
{
if(EObtainInfo(AMI_OFONT_ENGINE,
@@ -746,11 +778,7 @@ ULONG ami_font_unicode_text(struct RastPort *rp, const char *string, ULONG lengt
while(*utf16 != 0)
{
- if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
- else
- utf16charlen = 2;
-
+ utf16charlen = amiga_nsfont_utf16_char_length(utf16);
utf16next = &utf16[utf16charlen];
if(fstyle->flags & FONTF_SMALLCAPS)
@@ -811,11 +839,7 @@ static inline ULONG ami_font_unicode_width(const char *string, ULONG length,
while(*utf16 != 0)
{
- if ((*utf16 < 0xD800) || (0xDBFF < *utf16))
- utf16charlen = 1;
- else
- utf16charlen = 2;
-
+ utf16charlen = amiga_nsfont_utf16_char_length(utf16);
utf16next = &utf16[utf16charlen];
if(fstyle->flags & FONTF_SMALLCAPS)
@@ -915,7 +939,7 @@ static void ami_font_cleanup(struct MinList *ami_font_list)
SubTime(&curtime, &fnode->lastused);
if(curtime.Seconds > 300)
{
- LOG("Freeing %s not used for %d seconds", node->dtz_Node.ln_Name, curtime.Seconds);
+ LOG("Freeing %s not used for %ld seconds", node->dtz_Node.ln_Name, curtime.Seconds);
DelObject(node);
}
} while((node=nnode));
@@ -958,7 +982,7 @@ void ami_font_setdevicedpi(int id)
xdpi = (yres * ydpi) / xres;
- LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %ld x %ld, corrected %ld x %ld)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres);
+ LOG("XDPI = %ld, YDPI = %ld (DisplayInfo resolution %d x %d, corrected %d x %d)", xdpi, ydpi, dinfo.Resolution.x, dinfo.Resolution.y, xres, yres);
}
}
}
diff --git a/amiga/font_scan.c b/amiga/font_scan.c
index 930a150..4f4b774 100644
--- a/amiga/font_scan.c
+++ b/amiga/font_scan.c
@@ -254,7 +254,12 @@ static ULONG ami_font_scan_font(const char *fontname, lwc_string **glypharray)
}
#ifdef __amigaos4__
if(EObtainInfo(AMI_OFONT_ENGINE, OT_UnicodeRanges, &unicoderanges, TAG_END) == 0) {
- if(unicoderanges & UCR_SURROGATES) LOG("%s supports UTF-16 surrogates", fontname);
+ if(unicoderanges & UCR_SURROGATES) {
+ LOG("%s supports UTF-16 surrogates", fontname);
+ if (nsoption_charp(font_surrogate) == NULL) {
+ nsoption_set_charp(font_surrogate, (char *)strdup(fontname));
+ }
+ }
EReleaseInfo(AMI_OFONT_ENGINE,
OT_UnicodeRanges, unicoderanges,
TAG_END);
diff --git a/amiga/gui.c b/amiga/gui.c
index 1eb561d..b7f3285 100644
--- a/amiga/gui.c
+++ b/amiga/gui.c
@@ -604,13 +604,13 @@ static nserror ami_set_options(struct nsoption_s *defaults)
BPTR lock = 0;
/* Search for some likely candidates */
- if((lock = Lock("FONTS:Code2000.font", ACCESS_READ)))
+ if((lock = Lock("FONTS:Code2000.otag", ACCESS_READ)))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
(char *)strdup("Code2000"));
}
- else if((lock = Lock("FONTS:Bitstream Cyberbit.font", ACCESS_READ)))
+ else if((lock = Lock("FONTS:Bitstream Cyberbit.otag", ACCESS_READ)))
{
UnLock(lock);
nsoption_set_charp(font_unicode,
@@ -618,6 +618,19 @@ static nserror ami_set_options(struct nsoption_s *defaults)
}
}
+ if (nsoption_charp(font_surrogate) == NULL) {
+ BPTR lock = 0;
+ /* Search for some likely candidates -
+ * Ideally we should pick a font during the scan process which announces it
+ * contains UCR_SURROGATES, but nothing appears to have the tag.
+ */
+ if((lock = Lock("FONTS:Symbola.otag", ACCESS_READ))) {
+ UnLock(lock);
+ nsoption_set_charp(font_surrogate,
+ (char *)strdup("Symbola"));
+ }
+ }
+
if(popupmenu_lib_ok == FALSE)
nsoption_set_bool(context_menu, false);
diff --git a/amiga/options.h b/amiga/options.h
index b942420..a98b1e8 100644
--- a/amiga/options.h
+++ b/amiga/options.h
@@ -60,6 +60,7 @@ NSOPTION_BOOL(startup_no_window, false)
NSOPTION_BOOL(close_no_quit, false)
NSOPTION_BOOL(hide_docky_icon, false)
NSOPTION_STRING(font_unicode, NULL)
+NSOPTION_STRING(font_surrogate, NULL)
NSOPTION_STRING(font_unicode_file, NULL)
NSOPTION_BOOL(font_unicode_only, false)
NSOPTION_BOOL(font_antialiasing, true)
--
NetSurf Browser
7 years, 11 months
netsurf: branch master updated. release/3.3-201-g7459d4d
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/7459d4dc93f449ad8fcf9...
...commit http://git.netsurf-browser.org/netsurf.git/commit/7459d4dc93f449ad8fcf98e...
...tree http://git.netsurf-browser.org/netsurf.git/tree/7459d4dc93f449ad8fcf98e5f...
The branch, master has been updated
via 7459d4dc93f449ad8fcf98e5fd5e0f33d857703d (commit)
from 8e26870e15b46db20634fdef4815e6acdc8beb4b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7459d4dc93f449ad8fc...
commit 7459d4dc93f449ad8fcf98e5fd5e0f33d857703d
Author: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Commit: Chris Young <chris(a)unsatisfactorysoftware.co.uk>
Correct broken ifdef
diff --git a/amiga/schedule.c b/amiga/schedule.c
index 39b4fd9..cb53d2f 100755
--- a/amiga/schedule.c
+++ b/amiga/schedule.c
@@ -456,7 +456,7 @@ void ami_schedule_handle(struct MsgPort *nsmsgport)
#endif
}
-#ifdef NSA_NO_SYNC
+#ifdef AMIGA_NS_ASYNC
static int32 ami_scheduler_process(STRPTR args, int32 length, APTR execbase)
{
struct Process *proc = (struct Process *)FindTask(NULL);
-----------------------------------------------------------------------
Summary of changes:
amiga/schedule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/amiga/schedule.c b/amiga/schedule.c
index 39b4fd9..cb53d2f 100755
--- a/amiga/schedule.c
+++ b/amiga/schedule.c
@@ -456,7 +456,7 @@ void ami_schedule_handle(struct MsgPort *nsmsgport)
#endif
}
-#ifdef NSA_NO_SYNC
+#ifdef AMIGA_NS_ASYNC
static int32 ami_scheduler_process(STRPTR args, int32 length, APTR execbase)
{
struct Process *proc = (struct Process *)FindTask(NULL);
--
NetSurf Browser
7 years, 11 months