aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-10-11 23:47:34 +0300
committerMarcel Holtmann <marcel@holtmann.org>2010-10-11 23:47:34 +0300
commitdb8ab492ed63a1c6f2ab7cbc6d9c1c46de8c0685 (patch)
tree2cf30691d71c50f0479b197fa6983c41b3381827
parent6451e320fc75901e17d1f1ff548070d41e23591d (diff)
downloadpacrunner-db8ab492ed63a1c6f2ab7cbc6d9c1c46de8c0685.tar.gz
Fix unit test with new central proxy configuration
-rw-r--r--Makefile.am6
-rw-r--r--unit/test-mozjs.c20
2 files changed, 15 insertions, 11 deletions
diff --git a/Makefile.am b/Makefile.am
index 36122af..25ea449 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,10 +49,10 @@ endif
noinst_PROGRAMS = unit/test-mozjs
-unit_test_mozjs_SOURCES = unit/test-mozjs.c \
- src/pacrunner.h src/mozjs.c
+unit_test_mozjs_SOURCES = unit/test-mozjs.c src/pacrunner.h \
+ src/proxy.c src/download.c src/mozjs.c
-unit_test_mozjs_LDADD = @MOZJS_LIBS@ @GLIB_LIBS@
+unit_test_mozjs_LDADD = @MOZJS_LIBS@ @CURL_LIBS@ @GLIB_LIBS@
AM_CFLAGS = @CAPNG_CFLAGS@ @DBUS_CFLAGS@ @GLIB_CFLAGS@ \
@CURL_CFLAGS@ @MOZJS_CFLAGS@
diff --git a/unit/test-mozjs.c b/unit/test-mozjs.c
index aa3070c..dbeefa4 100644
--- a/unit/test-mozjs.c
+++ b/unit/test-mozjs.c
@@ -60,6 +60,8 @@ void pacrunner_debug(const char *format, ...)
" return \"PROXY proxy.example.com\";\n" \
"}\n"
+static struct pacrunner_proxy *proxy;
+
static void test_single_init(void)
{
g_assert(__pacrunner_mozjs_init() == 0);
@@ -111,12 +113,12 @@ static void test_single_execute_with_direct_pac(void)
g_assert(__pacrunner_mozjs_init() == 0);
- g_assert(__pacrunner_mozjs_set_script(NULL, DIRECT_PAC) == 0);
+ g_assert(pacrunner_proxy_set_script(proxy, DIRECT_PAC) == 0);
result = __pacrunner_mozjs_execute(EXAMPLE_URL, EXAMPLE_HOST);
g_test_message("result: %s\n", result);
- __pacrunner_mozjs_clear();
+ __pacrunner_mozjs_set_proxy(NULL);
__pacrunner_mozjs_cleanup();
}
@@ -128,14 +130,14 @@ static void test_multiple_execute_with_direct_pac(void)
__pacrunner_mozjs_init();
- g_assert(__pacrunner_mozjs_set_script(NULL, DIRECT_PAC) == 0);
+ g_assert(pacrunner_proxy_set_script(proxy, DIRECT_PAC) == 0);
for (i = 0; i < MULTIPLE_COUNT; i++) {
result = __pacrunner_mozjs_execute(EXAMPLE_URL, EXAMPLE_HOST);
g_test_message("result %d: %s\n", i, result);
}
- __pacrunner_mozjs_clear();
+ __pacrunner_mozjs_set_proxy(NULL);
__pacrunner_mozjs_cleanup();
}
@@ -147,14 +149,14 @@ static void test_massive_execute_with_direct_pac(void)
__pacrunner_mozjs_init();
- g_assert(__pacrunner_mozjs_set_script(NULL, DIRECT_PAC) == 0);
+ g_assert(pacrunner_proxy_set_script(proxy, DIRECT_PAC) == 0);
for (i = 0; i < MASSIVE_COUNT; i++) {
result = __pacrunner_mozjs_execute(EXAMPLE_URL, EXAMPLE_HOST);
g_test_message("result %d: %s\n", i, result);
}
- __pacrunner_mozjs_clear();
+ __pacrunner_mozjs_set_proxy(NULL);
__pacrunner_mozjs_cleanup();
}
@@ -166,14 +168,14 @@ static void test_multiple_execute_with_example_pac(void)
__pacrunner_mozjs_init();
- g_assert(__pacrunner_mozjs_set_script(NULL, EXAMPLE_PAC) == 0);
+ g_assert(pacrunner_proxy_set_script(proxy, EXAMPLE_PAC) == 0);
for (i = 0; i < MULTIPLE_COUNT; i++) {
result = __pacrunner_mozjs_execute(EXAMPLE_URL, EXAMPLE_HOST);
g_test_message("result %d: %s\n", i, result);
}
- __pacrunner_mozjs_clear();
+ __pacrunner_mozjs_set_proxy(NULL);
__pacrunner_mozjs_cleanup();
}
@@ -182,6 +184,8 @@ int main(int argc, char **argv)
{
g_test_init(&argc, &argv, NULL);
+ proxy = pacrunner_proxy_create(NULL);
+
g_test_add_func("/mozjs/single-init", test_single_init);
g_test_add_func("/mozjs/multiple-init", test_multiple_init);
g_test_add_func("/mozjs/single-execute-without-pac",