[poppler] unit test for GLib bindings

Carlos Garcia Campos carlosgc at gnome.org
Sat Apr 25 07:43:32 PDT 2009


El sáb, 25-04-2009 a las 19:51 +0900, Kouhei Sutou escribió:
> Hi,
> 
> In <1240653388.4223.4.camel at charmaleon>
>   "Re: [poppler] unit test for GLib bindings" on Sat, 25 Apr 2009 11:56:28 +0200,
>   Carlos Garcia Campos <carlosgc at gnome.org> wrote:
> 
> > $ CUTTER_DEBUG=yes glib/test/run-test.sh
> > GNU gdb 6.8-debian
> > Copyright (C) 2008 Free Software Foundation, Inc.
> > License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
> > This is free software: you are free to change and redistribute it.
> > There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
> > and "show warranty" for details.
> > This GDB was configured as "i486-linux-gnu"...
> > (gdb) r
> > Starting program: /home/carlos/gnome-cvs/bin/cutter --keep-opening-modules --verbose=verbose -s glib/test --exclude-directory lib --exclude-directory fixtures glib/test
> > [Thread debugging using libthread_db enabled]
> > [New Thread 0xb7b2e6c0 (LWP 4786)]
> > test-layer:
> >   test_nested:						.: (0.157269)
> >   test_title:						.: (0.041168)
> >   test_visible:						.: (0.001041)
> > test-form-field:
> >   test_multi_line_text:					.: (0.019235)
> >   test_combo_choice:					.: (0.003372)
> >   test_list_choice:					.: (0.003441)
> >   test_check_button:					.: (0.002642)
> >   test_radio_button:					.: (0.002585)
> >   test_general:						.: (0.007316)
> >   test_normal_text:					.: (0.002999)
> >   test_file_select_text:				.: (0.002970)
> >   test_push_button:					.: (0.004597)
> >   test_normal_password_text:				.: (0.003065)
> > test-page:
> >   test_index_multi_pages:				.: (0.000808)
> >   test_get_size:					.: (0.000602)
> >   test_render_pixbuf:					.: (0.034766)
> >   test_transition:					.: (0.000963)
> >   test_index_single_page:				.: (0.000533)
> >   test_get_form_field_mapping:				.: (0.006280)
> >   test_get_text:					.: (0.045406)
> > test-document:
> >   test_attachment:					
> > Program received signal SIGSEGV, Segmentation fault.
> > [Switching to Thread 0xb7b2e6c0 (LWP 4786)]
> > 0xb7dd8613 in strlen () from /lib/tls/i686/cmov/libc.so.6
> > (gdb) bt
> > #0  0xb7dd8613 in strlen () from /lib/tls/i686/cmov/libc.so.6
> > #1  0xb7da46d8 in vfprintf () from /lib/tls/i686/cmov/libc.so.6
> > #2  0xb7e5e95a in __vasprintf_chk () from /lib/tls/i686/cmov/libc.so.6
> > #3  0xb7ca66ff in IA__g_vasprintf (string=0x90b1e70, format=0xb77e638a "checksum=<%s>", args=0xbff5df68 "test����0^\b\t�<\006\t�����H���<\006\t ^\b\t")
> >     at /usr/include/bits/stdio2.h:199
> > #4  0xb7c933d2 in IA__g_string_append_vprintf (string=0x9063cb0, format=0xb77e638a "checksum=<%s>", 
> >     args=0xbff5df68 "test����0^\b\t�<\006\t�����H���<\006\t ^\b\t") at gstring.c:1375
> > #5  0xb7c9346f in IA__g_string_append_printf (string=0x9063cb0, format=0xb77e638a "checksum=<%s>") at gstring.c:1479
> > #6  0xb77e4a74 in attachment_inspect (string=0x9063cb0, data=0x9085e20, user_data=0x0) at test-document.c:521
> > #7  0xb7f348ab in gcut_list_inspect (list=0x9063cd0, inspect_func=0xb77e49b0 <attachment_inspect>, user_data=0x0) at gcut-list.c:57
> > #8  0xb7f369e7 in gcut_assert_equal_list_helper (expected=0x9063cd0, actual=0x9089270, equal_function=0xb77e4a90 <attachment_equal>, 
> >     inspect_function=0xb77e49b0 <attachment_inspect>, inspect_user_data=0x0, expression_expected=0xb77e6327 "expected", 
> >     expression_actual=0xb77e6320 "actual", expression_equal_function=0xb77e630f "attachment_equal") at gcut-assertions-helper.c:98
> > #9  0xb77e4990 in test_attachment () at test-document.c:558
> > #10 0xb7f16039 in invoke (test=0x907b150, test_context=0x907f740, run_context=0x906d800) at cut-test.c:403
> > #11 0xb7f1672b in run (test=0x907b150, test_context=0x907f740, run_context=0x906d800) at cut-test.c:429
> > #12 0xb7f156af in cut_test_run (test=0x907b150, test_context=0x907f740, run_context=0x906d800) at cut-test.c:461
> > #13 0xb7f193bb in cut_test_case_run_with_filter (test_case=0x9079d40, run_context=0x906d800, test_names=0x0) at cut-test-case.c:338
> > #14 0xb7f19c5a in run (data=0x907d358, user_data=0xbff5e4b8) at cut-test-suite.c:244
> > #15 0xb7f1a4af in cut_test_suite_run_test_cases (test_suite=0x9070018, run_context=0x906d800, test_cases=0x907fdb0, test_names=0x0) at cut-test-suite.c:290
> > #16 0xb7f1a759 in cut_test_suite_run_with_filter (test_suite=0x9070018, run_context=0x906d800, test_case_names=0x0, test_names=0x0) at cut-test-suite.c:582
> > #17 0xb7f1a7e6 in cut_test_suite_run (suite=0x9070018, run_context=0x906d800) at cut-test-suite.c:505
> > #18 0xb7f12769 in cut_test_runner_run_test_suite (runner=0x906d800, test_suite=0x9070018) at cut-test-runner.c:767
> > #19 0xb7f1495c in runner_run (runner=0x906d800) at cut-test-runner.c:722
> > #20 0xb7f1253e in cut_runner_run (runner=0x906d800) at cut-runner.c:68
> > #21 0xb7f0f0a4 in cut_run_context_start (context=0x906d800) at cut-run-context.c:1758
> > #22 0xb7ee5f1d in run (ui=0x9064a00, run_context=0x906d800) at cut-console-ui.c:912
> > #23 0xb7f22546 in cut_ui_run (ui=0x9064a00, run_context=0x906d800) at cut-ui.c:103
> > #24 0xb7f14d8a in cut_start_run_context (run_context=0x906d800) at cut-main.c:411
> > #25 0xb7f14f72 in cut_run () at cut-main.c:439
> > #26 0x080485aa in main (argc=Cannot access memory at address 0x0
> > ) at main.c:35
> > (gdb)
> 
> Hmm, I don't know why expected attachments had been
> destroyed when gcut_assert_equal_list() at test-document.c:558.

I don't think expected is destroyed, the problem is that checksum is
optional, so it might be NULL. In this case since checksum is a GString
->str is what is NULL. So in the test we are passing NULL to
g_string_append_printf:

g_string_append_printf (string, "checksum=<%s>",
attachment->checksum->str);

> If you apply the patch, is the test passed?

yes.

> diff --git a/glib/test/test-document.c b/glib/test/test-document.c
> index 117b314..06a4cc6 100644
> --- a/glib/test/test-document.c
> +++ b/glib/test/test-document.c
> @@ -553,7 +553,7 @@ test_attachment (void)
>        actual = g_list_append (actual, g_object_ref (attachment));
>      }
>  
> -  gcut_take_list (expected, g_object_unref);
> +  /* gcut_take_list (expected, g_object_unref); */
>    gcut_take_list (actual, g_object_unref);
>    gcut_assert_equal_list (expected,
>                            actual,
> 
> Thanks,
> --
> kou
-- 
Carlos Garcia Campos
   elkalmail at yahoo.es
   carlosgc at gnome.org
   http://carlosgc.linups.org
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada
 digitalmente
Url : http://lists.freedesktop.org/archives/poppler/attachments/20090425/6e3dac20/attachment-0001.pgp 


More information about the poppler mailing list