Errors gnuPDF
1. pdf_time_init() -->pdf_time_context_init()
pdf_dealloc(time_struct) cause an error.
From man localtime
"The return value points to a statically allocated struct which
might be overwritten by subsequent calls to any of the date and time
functions."
so line
pdf_dealloc(time_struct);
is not necessary.
Patch fixing this error(by deleting this line) -->pdf_time_init.patch
2. pdf_i64_div
Division 1 by 86400 cause floating point exception
I have added another testcase to base/types/pdf-i64-div.c
which is in patch file pdf_i64_div_newTest.patch
This is that testcase
/*
* Test: pdf_i64_div_005
* Description:
* Checks if the division 1/86400 gives 0.
* Success conditions:
* The call should not produce an error
*/
START_TEST(pdf_i64_div_005)
{
pdf_status_t p_status = PDF_OK;
pdf_i64_t div1,div2,dest;
div1 = pdf_i64_new(0,1);
div2 = pdf_i64_new(0,24*3600);
#ifndef PDF_USE_BUILTIN_64BIT_SUPPORT
pdf_i64_div(&dest,div1,div2, &p_status);
fail_if(p_status != PDF_OK);
fail_if(dest.low != 0);
fail_if(dest.high != 0);
#else
pdf_i64_div(&dest,div1,div2, &p_status);
fail_if(dest != 0);
#endif
}
END_TEST
patch name with that testcase is pdf_i64_div_newTest.patch
3. Functions :
pdf_status_t pdf_time_add_span()
pdf_status_t pdf_time_sub_span()
pdf_status_t pdf_time_diff()
and other functions in file src/base/pdf-time.c doesn't propagete status
variable, but always return PDF_OK.
Some of them don't check if pointer argument is null.
4. Patch which adds 22 of 38 files with testcases of pdf_time module to
Makefile.am and runtests.c .
Patch name is pdf_time_22of32_tests.patch
To this mail are also appended archive time.tar.gz with that testcases,
which schould be put in
trunk/torture/unit/base/time/
5. pdf_time_add_cal_span
Both test from base/time/pdf_time_add_cal_span fails because of this
same error.
In test case 002 there is:
/* test objects */
pdf_time_t time27, time28,time29, time30;
struct pdf_time_cal_span_s calspan;
/* initializing
....
*/
calspan.sign = PDF_FALSE;
calspan.years=0;
calspan.months=1;
calspan.hours=0;
calspan.minutes=0;
calspan.seconds=0;
calspan.days=27;
pdf_time_add_cal_span(time27, &calspan);
calspan.days=28;
pdf_time_add_cal_span(time28, &calspan);
calspan.days=29;
pdf_time_add_cal_span(time29, &calspan);
calspan.days=30;
pdf_time_add_cal_span(time30, &calspan);
fail_if(pdf_time_cmp(time27, time28) == 0);
fail_if(pdf_time_cmp(time28, time29) == 0);
fail_if(pdf_time_cmp(time29, time30) == 0);
All of pdf_time_t objects have the same time, where only time27 schould
be valid and point to 1970-02-28 00:00:00. time28 schould point to
1970-03-01 00:00:00 and so on.
6. pdf_time_from_string
6 of 13 test fails. This are mainly easy to fix bugs. I had put some
comments in tests that fails.
Thats is all rest of test schould be added in 2-3 weeks. However fixing bug
in pdf_time_add_cal_span would be handful since it can broke other tests.
BTW if you agree with bugs from point 3 and 6 i can write a patch for that
functions too.
thanks
Luke
=== modified file 'src/base/pdf-time-context.c'
--- src/base/pdf-time-context.c 2008-10-12 19:28:11 +0000
+++ src/base/pdf-time-context.c 2009-04-16 13:21:29 +0000
@@ -74,7 +74,6 @@
PDF_DEBUG_BASE("Daylight saving? %s",time_context.local_time_daylight_save ? \
"yes":"no");
- pdf_dealloc (time_struct);
return PDF_OK;
}
=== modified file 'torture/unit/base/types/pdf-i64-div.c'
--- torture/unit/base/types/pdf-i64-div.c 2008-07-18 07:45:04 +0000
+++ torture/unit/base/types/pdf-i64-div.c 2009-04-16 13:32:12 +0000
@@ -158,6 +158,36 @@
}
END_TEST
+/*
+ * Test: pdf_i64_div_005
+ * Description:
+ * Checks if the division 1/86400 gives 0.
+ * Success conditions:
+ * The call should not produce an error
+ */
+START_TEST(pdf_i64_div_005)
+{
+ pdf_status_t p_status = PDF_OK;
+ pdf_i64_t div1,div2,dest;
+ div1 = pdf_i64_new(0,1);
+ div2 = pdf_i64_new(0,24*3600);
+
+
+
+#ifndef PDF_USE_BUILTIN_64BIT_SUPPORT
+ pdf_i64_div(&dest,div1,div2, &p_status);
+ fail_if(p_status != PDF_OK);
+ fail_if(dest.low != 0);
+ fail_if(dest.high != 0);
+#else
+ pdf_i64_div(&dest,div1,div2, &p_status);
+ fail_if(dest != 0);
+#endif
+
+}
+END_TEST
+
+
/*
@@ -171,6 +201,7 @@
tcase_add_test(tc, pdf_i64_div_002);
tcase_add_test(tc, pdf_i64_div_003);
tcase_add_test(tc, pdf_i64_div_004);
+ tcase_add_test(tc, pdf_i64_div_005);
return tc;
}
=== modified file 'torture/unit/Makefile.am'
--- torture/unit/Makefile.am 2009-02-11 15:15:27 +0000
+++ torture/unit/Makefile.am 2009-04-16 14:02:33 +0000
@@ -164,6 +164,32 @@
base/types/pdf-i64-mod.c \
base/types/pdf-i64-subtraction.c
+TEST_SUITE_TIME = base/time/pdf-time-init.c \
+ base/time/pdf-time-new.c \
+ base/time/pdf-time-dup.c \
+ base/time/pdf-time-destroy.c \
+ base/time/pdf-time-copy.c \
+ base/time/pdf-time-clear.c \
+ base/time/pdf-time-set-from-u32.c \
+ base/time/pdf-time-set-from-i64.c \
+ base/time/pdf-time-add-cal-span.c \
+ base/time/pdf-time-from-cal.c \
+ base/time/pdf-time-from-string.c \
+ base/time/pdf-time-span-new.c \
+ base/time/pdf-time-span-dup.c \
+ base/time/pdf-time-span-destroy.c \
+ base/time/pdf-time-span-set.c \
+ base/time/pdf-time-span-set-from-i32.c \
+ base/time/pdf-time-span-negate.c \
+ base/time/pdf-time-span-add.c \
+ base/time/pdf-time-span-cmp.c \
+ base/time/pdf-time-span-copy.c \
+ base/time/pdf-time-span-diff.c \
+ base/time/pdf-time-span-to-secs.c \
+ base/time/pdf-time-testdata.c \
+ base/time/pdf-time-test-common.c
+
+
TEST_SUITE_CRYPT = base/crypt/pdf-crypt-init.c \
base/crypt/pdf-crypt-cipher-new.c \
base/crypt/pdf-crypt-cipher-setkey.c \
@@ -188,7 +214,8 @@
$(TEST_SUITE_TEXT) \
$(TEST_SUITE_HASH) \
$(TEST_SUITE_ERROR) \
- $(TEST_SUITE_TYPES) \
+ $(TEST_SUITE_TYPES) \
+ $(TEST_SUITE_TIME) \
$(TEST_SUITE_CRYPT) \
$(TEST_SUITE_ALLOC) \
$(TEST_SUITE_STM) \
@@ -199,7 +226,8 @@
base/text/tsuite-text.c \
base/hash/tsuite-hash.c \
base/error/tsuite-error.c \
- base/types/tsuite-types.c \
+ base/types/tsuite-types.c \
+ base/time/tsuite-time.c \
base/crypt/tsuite-crypt.c \
base/stm/tsuite-stm.c \
base/fp/tsuite-fp.c
=== modified file 'torture/unit/runtests.c'
--- torture/unit/runtests.c 2008-12-10 20:45:27 +0000
+++ torture/unit/runtests.c 2009-04-16 13:58:12 +0000
@@ -15,6 +15,7 @@
extern Suite *tsuite_text (void);
extern Suite *tsuite_hash (void);
extern Suite *tsuite_types (void);
+extern Suite *tsuite_time (void);
extern Suite *tsuite_crypt (void);
extern Suite *tsuite_error (void);
extern Suite *tsuite_fp (void);
@@ -33,6 +34,7 @@
srunner_add_suite (sr, tsuite_text ());
srunner_add_suite (sr, tsuite_hash ());
srunner_add_suite (sr, tsuite_types ());
+ srunner_add_suite (sr, tsuite_time ());
srunner_add_suite (sr, tsuite_crypt ());
srunner_add_suite (sr, tsuite_error ());
srunner_add_suite (sr, tsuite_stm ());
time.tar.gz
Description: GNU Zip compressed data
