0
0
mirror of https://github.com/zeux/pugixml.git synced 2024-12-27 13:33:17 +08:00

550 Commits

Author SHA1 Message Date
Arseny Kapoulkine
6eb7519dba tests: Add basic move tests
These just verify that move ctor/assignment operator work as expected in
simple cases - there are a number of ways in which the internal
structure can be incorrect...
2017-09-25 21:37:56 -07:00
Arseny Kapoulkine
f3e0f4249c tests: Add more stream coverage tests
These new tests test that tellg() can fail when being called the second
time, which leads to seekable implementation failing.
2017-06-23 08:44:52 -07:00
Arseny Kapoulkine
4564d31c76 tests: Add stream coverage tests
These tests simulate various error conditions when reading data from
streams - seeks failing in seekable streams, underflow throwing an
exception causing read to set badbit, etc.

This change also adjusts memory thresholds to cause a reliable out of
memory during construction of a final buffer for non-seekable streams.
2017-06-23 07:48:09 -07:00
Arseny Kapoulkine
20a8eced3b tests: Fix PUGIXML_WCHAR_MODE build 2017-06-22 22:18:16 -07:00
Arseny Kapoulkine
3870217381 tests: Add more XPath out of memory tests
This fixes missing coverage in translate_table_generate and
xpath_node_set_raw::append.
2017-06-22 22:11:43 -07:00
Arseny Kapoulkine
5867aff943 tests: Make using namespace more explicit
Hiding using namespace in common.hpp is somewhat surprising so remove
common.hpp and move using namespace into all .cpp files that need it.
2017-06-22 20:41:08 -07:00
Arseny Kapoulkine
4b371e10ee tests: Remove redundant pugi:: qualifier
Most tests have `using namespace pugi` which makes explicit
qualifications unnecessary.
2017-06-22 20:33:02 -07:00
Arseny Kapoulkine
2252927c04 Deprecate xml_document::load(const char*) and xml_node::select_single_node
These functions were deprecated via comments in 1.5 but never got the
deprecated attribute; now is the time!

Using deprecated functions produces a warning; to silence it, this
change moves the relevant tests to a separate translation unit that has
deprecation disabled.
2017-06-22 09:13:10 -07:00
Arseny Kapoulkine
9357837d2e Add VS2017 to AppVeyor test run
This requires moving the list of VS versions out of
autotest-appveyor.ps1 and into appveyor.yml.
2017-06-18 22:20:13 -07:00
Arseny Kapoulkine
0027b6ac79 tests: Improve XPath coverage
Add memory allocation failure test for concact with a very large list
and make sure we have every single axis covered with and without a
predicate, with and without a previous step.
2017-06-16 22:45:42 -07:00
Arseny Kapoulkine
08f102f14c tests: Add even more stream coverage tests
Apparently only narrow character streams had out of memory coverage -
fix that and also split this into a separate test.
2017-06-16 21:38:55 -07:00
Arseny Kapoulkine
86593c0999 tests: Add more stream coverage tests
Cover both char and wchar_t stream loading in a single run instead of
using pugi::char_t.
2017-06-16 17:08:00 -07:00
Arseny Kapoulkine
3aa2b40354 tests: Add more coverage tests for stream loading
Cover more failure cases and simplify the streambuf implementation a
bit.
2017-06-16 16:41:08 -07:00
Arseny Kapoulkine
b6995f06b9 Fix BorlandC compilation
Rename partition to partition3 to resolve conflicts with std::partition.
2017-06-16 00:32:01 -07:00
Arseny Kapoulkine
bd23216420 tests: Improve XPath test coverage
Add more memory allocation failure tests.
2017-06-16 00:29:14 -07:00
Arseny Kapoulkine
a3664ea971 tests: Expand write_flush coverage
Adjust the buffer size to be right on the edge of the overflow, make
sure we actually output " instead of ".
2017-06-16 00:09:32 -07:00
Arseny Kapoulkine
d2892be902 tests: Add xml_buffered_writer coverage test
This test triggers flush() condition for each optimized write() method.
2017-06-15 23:52:56 -07:00
Arseny Kapoulkine
c40fd364ce tests: Add tests for loading special files
New tests try to load a folder as an XML document, and a device. Both
are intended to exercise some otherwise non-hittable error paths in
load_file implementation.
2017-06-15 07:23:49 -07:00
Arseny Kapoulkine
0fbc043183 tests: Increase compact_pointer coverage
This adds tests that complete branch coverage in compact pointer
encoding/decoding code (previously first_attribute was always encoded
using compact encoding in the entire test suite).
2017-06-14 23:50:21 -07:00
Arseny Kapoulkine
24d1a4562b Move libFuzzer build to Makefile
Now the only thing fuzz_setup.sh does is installing new clang; if system
clang supports -fsanitize-coverage then fuzz_setup.sh is not required.
2017-04-03 21:09:37 -07:00
Arseny Kapoulkine
0eb1ddb975 tests: Fix fuzz_setup.sh
The script only worked if clang folder was already created.
2017-04-03 20:36:33 -07:00
Arseny Kapoulkine
acfe47ba52 tests: Do not use unsigned underflow in test code
This triggers a runtime error under integer sanitizer
2017-03-21 21:47:22 -07:00
Arseny Kapoulkine
c29940ca72 tests: Fix invalid buffer size
This was triggering an buffer read overflow with asan.
2017-03-21 10:33:20 -07:00
Arseny Kapoulkine
ec984370fb tests: Fix fuzz_setup.sh
Make the file executable, fix Windows newlines and fix clang setup.
2017-02-11 13:17:27 -08:00
Arseny Kapoulkine
ea544eb48b tests: Add fuzzing dictionaries
Hopefully this will allow for better fuzzing coverage
2017-02-11 13:17:02 -08:00
Arseny Kapoulkine
8c62fa9121 tests: Add XPath fuzzing
Only fuzz the parser for now.
2017-02-09 07:37:38 -08:00
Arseny Kapoulkine
8b15ae8015 tests: Add a script to set up fuzzing tools
This downloads a clang build that has support for instrumentation, and also
downloads and compiles libFuzzer.a.
2017-02-09 07:37:04 -08:00
Arseny Kapoulkine
00ef791078 fuzz: Use libFuzzer instead of afl-fuzz
This allows us to have faster fuzz cycles since the fuzzer is in-process.
2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
e748f435e5 tests: Increase the number of translate calls
This should make the test fail on a 32-bit target.
2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
4bab082a27 tests: Fix clang build 2017-02-09 07:36:32 -08:00
Arseny Kapoulkine
ba39838ab5 tests: Add more XPath out of memory tests 2017-02-09 07:36:31 -08:00
Arseny Kapoulkine
10676b6b85 tests: Add more XPath sorting tests
Cover empty node case - no XPath query can result in that but it's
possible to create a node set with empty nodes manually.
2017-02-05 21:12:55 -08:00
Arseny Kapoulkine
faadd460c4 tests: Add more out of memory tests for XPath evaluation 2017-02-02 08:57:02 -08:00
Arseny Kapoulkine
c28ff128d8 tests: Add more embed_pcdata tests 2017-02-02 08:40:34 -08:00
Arseny Kapoulkine
f9f1c86716 tests: Improve parsing coverage
Add tests for PI erroring exactly at the buffer boundary with
non-zero-terminated buffers (so we have to clear the last character
which changes the parsing flow slightly) and a test that makes sure
parse_embed_pcdata works properly with XML fragments where PCDATA can be
at the root level but can't be embedded into the document node.
2017-02-01 21:07:46 -08:00
Arseny Kapoulkine
e56686f1e5 tests: Remove redundant coverage test
The only point was to try to test all paths where we can run out of
memory while decoding something. It seems like it may be impossible to
actually do this given that we can't run all paths as wchar_t size
detection is done at runtime...
2017-02-01 20:21:14 -08:00
Arseny Kapoulkine
1a3e92a7cc tests: Add more tests to increase coverage
This change adds more thorough tests for attribute conversion as well as
some assorted tests that fix gaps in coverage.
2017-01-31 20:40:50 -08:00
Arseny Kapoulkine
094a0c8ebe tests: Add compact hash table reserve test
This makes sure all .reserve calls failure paths are covered. These
tests don't explicitly test if reserve is present on all paths - this is
much harder to test since not all modifications require reserve to be
called, so we'll have to rely on a combination of automated testing and
sanity checking for this.

Also add more parsing out of memory coverage tests.
2017-01-31 19:19:04 -08:00
Arseny Kapoulkine
41fb880bf0 tests: Add coverage tests for encoding detection
Enumerate successfull cases and also cases where the detection stops
half-way and results in a different detected encoding.
2017-01-31 07:50:39 -08:00
Arseny Kapoulkine
ef64bef5c3 tests: More XPath coverage tests 2017-01-31 00:35:15 -08:00
Arseny Kapoulkine
6ffd2ffc41 tests: Add more DOM coverage tests
Add tests for various corner cases of DOM inspection and modification
routines.
2017-01-31 00:10:20 -08:00
Arseny Kapoulkine
a1bc15c8d5 tests: Add more coverage tests
Expand out of memory coverage during XPath parsing and evaluation and
add some other small tests.
2017-01-30 23:52:32 -08:00
Arseny Kapoulkine
60d5688a87 tests: Make predicate out-of-memory test less aggressive
Currently this test has very large runtime and relies on the fact that
the first memory allocation error causes the test to terminate. This
does not work with new behavior of running the query through and
reporting the error at the end, so make the runtime reasonable but still
generate enough memory to blow past the budget.
2017-01-30 22:27:48 -08:00
Arseny Kapoulkine
02cee98492 tests: Add more tests for branch coverage
gcov -b surfaced many lines with partial coverage, where branch is only
ever taken or not taken, or one of the expressions in a complex
conditional is always either true or false. This change adds a series of
tests (mostly focusing on XPath) to reduce the number of partially
covered lines.
2017-01-30 21:58:48 -08:00
Arseny Kapoulkine
cac1d8ad9f tests: Add an error propagation test for XPath
This test is supposed to test error coverage in different expressions
that are nested in other expressions to reduce the number of never-taken
branches in tests (and make sure we aren't missing any).
2017-01-30 11:51:07 -08:00
Arseny Kapoulkine
8aa8e11ba6 tests: Add query out of memory test 2017-01-29 21:53:40 -08:00
Arseny Kapoulkine
86ed1cf3b9 scripts: Move archive.py from tests 2016-11-27 17:55:41 -08:00
Arseny Kapoulkine
d2deb420bc Fix archive script to set timestamps properly for .tar.gz
By default they are set to Jan 1 1970 which breaks homebrew.

Fixes #124.
2016-11-27 12:09:12 -08:00
Arseny Kapoulkine
5115db7409 tests: Fix unused variable warning in some compilers
The variable is being assigned to but never read when exceptions are
disabled.
2016-11-19 00:19:29 -08:00
Arseny Kapoulkine
1e23402eb2 Change status_end_element_mismatch to point to closing tag name
Previously the error offset pointed to the first mismatching character, which
can be confusing especially if the start tag name is a prefix of the end tag
name. Instead, move the offset to the first character of the name - that way
it should be more obvious that the problem is that the entire name mismatches.

Fixes #112.
2016-11-13 16:59:14 -08:00
Arseny Kapoulkine
5ca7e7cffc Rewrite archive script into Python
Perl version needed Archive::Zip that for some reason is not installed on WSL by
default. Use this as an opportunity to remove the last Perl script.
2016-11-13 16:52:38 -08:00
Arseny Kapoulkine
c5223be434 tests: Fix MSVC warnings 2016-11-09 21:42:56 -08:00
Arseny Kapoulkine
2d47cde5d6 tests: Add a generalized write-roundtrip test
This test tests two important invariants:

- Every combination of write flags has to result in a valid document
- Parsing that document and saving the result has to result in identical output

We don't test all flags since parse_no_escapes can intentionally result in
malformed documents and other flags aren't relevant for node output.

Also note that we test both no-whitespace and whitespace version to make sure
we don't have unnecessary whitespace added during formatting.
2016-11-09 20:12:25 -08:00
Arseny Kapoulkine
1649b2e6b8 tests: Add a test for format_no_empty_element_tags 2016-11-09 09:12:36 -08:00
Arseny Kapoulkine
c75e3c45e5 Update version to 1.8 everywhere 2016-11-09 09:02:44 -08:00
Arseny Kapoulkine
70f57fab6d tests: Don't use ranged for loop in move tests
Some compilers support move semantics but don't support ranged for.
2016-11-06 12:14:58 -08:00
Arseny Kapoulkine
aa117cce42 Refactor move semantics support detection
Do it in one place and set PUGIXML_HAS_MOVE if it's available.
2016-11-06 11:49:10 -08:00
Pavel Kryukov
c7c7349cb7 Add PUGIXML_OVERRIDE to headers of tests 2016-10-13 01:36:12 +03:00
Arseny Kapoulkine
5b102d108d tests: Fix clang warning 2016-07-15 18:53:59 -05:00
Arseny Kapoulkine
525b2fe5c3 tests: Add tests for latin1 detection 2016-07-14 23:04:17 -07:00
Arseny Kapoulkine
2e0ed8284b Remove extra space in an empty tag for format_raw
When using format_raw the space in the empty tag (<node />) is the only
character that does not have to be there; so format_raw almost results in
a minimal XML but not quite.

It's pretty unlikely that this is crucial for any users - the formatting
change should be benign, and it's better to improve format_raw than to add
yet another flag.

Fixes #87.
2016-04-14 00:30:24 -07:00
Arseny Kapoulkine
d2e72ee05a tests: Add tests for long setters 2016-02-02 08:49:32 -08:00
Stephan Beyer
fc9073289f test_parse.cpp: add newline to last line
This is necessary in order to comply with the C++03 standard.
2016-01-24 19:47:06 +01:00
Stephan Beyer
f7aa65db8a Fix whitespace issues
Git warns when it finds "whitespace errors". This commit gets
rid of these whitespace errors for code and adoc files.
2016-01-24 14:05:44 +01:00
Arseny Kapoulkine
fc6c8633dd tests: Add test for parse_embed_pcdata 2016-01-12 20:16:29 -08:00
Arseny Kapoulkine
94c08f27c6 tests: Fix Borland C++ 5.4 compilation
The tests now compile fine but crash on the first floating-point exception
despite our attempts to disable them in main()...
2015-10-25 13:44:26 -07:00
Arseny Kapoulkine
fd605bc9a7 tests: Fix GCC warning
Fix "this decimal constant is unsigned only in ISO C90".
2015-10-17 12:20:21 -07:00
Arseny Kapoulkine
0e09571f21 Fix integer overflow detection with leading zeros
Since they don't contribute to the resulting value just skip them before
parsing. This matches the behavior of strtol/strtoll and results in more
intuitive behavior.
2015-10-17 10:33:50 -07:00
Arseny Kapoulkine
537aea56c6 tests: Fix version check :) 2015-10-10 13:07:53 -07:00
Arseny Kapoulkine
3e9cf53ea7 tests: Add a test for empty xpath_query ctor 2015-10-09 20:53:02 -07:00
Arseny Kapoulkine
6e5163ba3e tests: Add a copy of header-only test
This makes sure we get linking errors whenever a symbol is not marked as inline
in header-only mode.
2015-10-06 07:26:24 -07:00
Arseny Kapoulkine
3229e67712 Fix parsing of integers that start with +
This matches the format strtol supports.
2015-09-21 00:35:57 -07:00
Arseny Kapoulkine
5b86a8f612 tests: Add tests for integer overflow during conversion
These tests are only testing attribute as_int in hopes that xml_text uses the
same underlying implementation (which it does).
2015-09-20 10:48:30 -07:00
Arseny Kapoulkine
234c2f3657 tests: Convert several files to Unix line endings
They were still using Windows EOL by mistake
2015-09-19 00:14:18 -07:00
Arseny Kapoulkine
e8fdd1303c tests: Fix test allocator to provide fundamental alignment
Previously test allocator only guaranteed alignment enough for a pointer.

On some platforms (e.g. SPARC) double has to be aligned to 8 bytes but pointers
can have a size of 4 bytes. This commit increases allocation header to fix that.

In practical terms the allocation header is now always 8 bytes.
2015-07-25 17:04:17 -04:00
Arseny Kapoulkine
a562bf6d3c tests: Only enable page heap on x86/x64
This fixes tests in PUGIXML_NO_XPATH mode on SPARC64 (#48).

SPARC does not allow unaligned accesses - e.g. you can't read an unaligned int.
Normally pugixml does not perform unaligned integer/pointer accesses, but page
heap can allocate blocks that are not aligned so that we can detect a single-
byte read/write overrun.

Additionally, the hardcoded page size we're currently using is really system
specific - on SPARC the page size can be 8 Kb instead of 4 Kb so mprotect can
fail.
2015-07-25 14:19:08 -04:00
Arseny Kapoulkine
97afc16ef2 tests: Add newline at the end of file 2015-05-22 20:20:03 -07:00
Arseny Kapoulkine
fc1dcab79d tests: Fix MSVC6 compilation 2015-05-22 08:43:36 -07:00
Arseny Kapoulkine
e2358e5e3b tests: Split fp roundtrip test into float and double 2015-05-20 08:05:43 -07:00
Arseny Kapoulkine
f828eae3ea Implement xml_node::attribute with a hint
Extra argument 'hint' is used to start the attribute lookup; if the attribute
is not found the lookup is restarted from the beginning of the attriubte list.

This allows to optimize attribute lookups if you need to get many attributes
from the node and can make assumptions about the likely ordering. The code is
correct regardless of the order, but it is faster than using vanilla lookups
if the order matches the calling order.

Fixes #30.
2015-05-14 08:04:06 -07:00
Arseny Kapoulkine
01f627a4d7 tests: Fix address sanitizer detection for GCC 2015-05-12 21:49:44 -07:00
Arseny Kapoulkine
59ce480f96 Add Visual Studio 2015 to AppVeyor 2015-05-12 20:55:59 -07:00
Arseny Kapoulkine
7342c5ed8c tests: Disable page allocator if address sanitizer is active
Address sanitizer can detect underflows so we don't really need the custom
allocator.

Additionally, custom allocator can return memory that is not pointer-aligned;
this causes undefined behavior sanitizer to complain.
2015-05-12 20:16:51 -07:00
Arseny Kapoulkine
9f7994ed71 tests: Fix clang 3.7 warning
Work around -Wself-move using ref-deref.
2015-05-12 20:02:53 -07:00
Arseny Kapoulkine
cff35dfa31 tests: Fix MSVC6 compatibility
Apply the usual workaround for for scoping issues. Also fix integer conversion
warning for BorlandC.
2015-05-03 17:58:20 -07:00
Arseny Kapoulkine
19d43d39fc tests: Add one more page reclamation test 2015-05-02 09:45:26 -07:00
Arseny Kapoulkine
dede617d9f tests: Fix spurious failures in compact mode
The memory_large_allocations test sometimes classified hash allocations
as page allocations since hash table could reach 512 entries.
2015-04-29 09:21:04 -07:00
Arseny Kapoulkine
3643b505a6 Fix node_pi memory leak 2015-04-22 08:38:52 -07:00
Arseny Kapoulkine
52bcb4ecd6 tests: Adjust allocation thresholds to fix tests 2015-04-21 21:35:54 -07:00
Arseny Kapoulkine
f9983ea2ed Merge branch 'master' into compact 2015-04-21 21:27:44 -07:00
Arseny Kapoulkine
a6cc636a6b tests: Fix MSVC warnings 2015-04-21 21:07:58 -07:00
Arseny Kapoulkine
4eadece45f tests: Add move semantics tests
Also test ranged for and copying big xpath_variable_set objects (to make
sure we actually handle hash collisions properly)
2015-04-21 19:44:19 -07:00
Arseny Kapoulkine
cbf3807ad4 Implement copy ctor/assignment for xpath_variable_set
xpath_variable_set is essentially an associative container; it's about time it
became copyable.

Implementation is slightly tricky due to out of memory handling. Both copy ctor
and assignment operator have strong exception guarantee (even if exceptions are
disabled! which translates to "roll back on allocation errors").
2015-04-15 23:22:31 -07:00
Arseny Kapoulkine
70a78b2fa5 tests: Fix Linux build 2015-04-15 22:11:13 -07:00
Arseny Kapoulkine
bb3aee447b tests: Use malloc for OSX/Linux page heap
Switch to malloc and manually aligning the pointer to the page boundary.

mmap is much slower than malloc; this change makes tests ~4x faster.
2015-04-15 21:44:52 -07:00
Arseny Kapoulkine
5158ee903b Fix xpath_node_set assignment to provide strong exception guarantee
Since the type of the set was updated before assignment, assigning in
out-of-memory condition could change the type to not match the content.
2015-04-14 19:23:36 -07:00
Arseny Kapoulkine
2a3435274f Refactor format_indent_attributes implementation
Fix code style and revert redundant parameters/whitespace changes.

Also remove format_each_attribute_on_new_line - we're only introducing one
extra formatting flag. The flag implies format_indent but does not include its
bitmask.

Also add a few more tests.

Fixes #14.
2015-04-13 21:49:08 -07:00
Arseny Kapoulkine
950693be7f Merge branch 'AlignAttributesEachOnSeparateLine' of git://github.com/halex2005/pugixml into indent_attributes 2015-04-13 20:56:18 -07:00
Arseny Kapoulkine
cb786665d4 tests: Add PUGIXML_COMPACT to AppVeyor 2015-04-13 20:36:04 -07:00
Arseny Kapoulkine
ed2c822643 Merge branch 'master' into compact 2015-04-13 20:35:26 -07:00