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

573 Commits

Author SHA1 Message Date
Arseny Kapoulkine
930a701f1f tests: Disable flaky test
This test is very sensitive to the particular implementation of union
aggregation; for now lets disable this.

We need a more robust way to test union allocation failures.
2019-02-26 22:15:34 -08:00
Arseny Kapoulkine
7664bbf9af tests: Only use load_file_special_folder test on macOS
The behavior on Linux is very different between kernel versions, and it
triggers an unexpected OOM during sanitizer runs because somehow the
size is reported to be LONG_MAX. It's not clear that it helps us cover
any paths we don't cover otherwise - it would be nice to be able to test
failing to load a multi-gigabyte file on a 32-bit system, but we can't
do this easily atm anyway.
2018-11-27 08:07:31 -08:00
Arseny Kapoulkine
f9a2a7d19e Fix Wdouble-promotion warnings
We had a few places in test code and library source where we used an
implicit float->double cast; while it should preserve the value exactly,
gcc/clang implement this warning to make sure uses of double are intentional.

This change also adds the warning to Makefile to make sure we don't
regress on this warning.

Fixes #243.
2018-11-23 23:39:22 -08:00
Arseny Kapoulkine
aac75cd299 Escape TAB character in attribute values with 	
This change modifies the table entries for ctx_special_attr to treat TAB
character as special, which makes the output code escape it.

Before this change, trying to use TAB in an attribute value would output
it verbatim; during subsequent parsing, pugixml - and other compliant
parsers - would apply attribute-value normalization, turning the TAB
into a space and losing the original value.

Using 	 fixes this; if an input document has 	 in an attribute
value, that gets unescaped into \t during parsing and escaped back into
	 during output, which means we can now roundtrip values like this.

Fixes #242.
2018-11-19 22:26:21 -08:00
Arseny Kapoulkine
1a96777b11 tests: Fix XPath denorm tests on Intel compiler
Intel compiler by default sets flush-to-zero flags which causes our
denorm test to produce 0.0. So make sure that denorms work on FPU before
testing the string output.

Fixes #218.
2018-08-13 22:06:57 -07:00
Arseny Kapoulkine
6b9c07e6ed tests: Allow document_load_file_special_folder to load empty document
On some Debian systems it looks like we *can* open the current folder as
a file and read its contents, but parsing the result produces an empty
document. We now handle this case as well.

Fixes #225.
2018-07-30 07:32:09 -07:00
Arseny Kapoulkine
8436f2a69b tests: Fix PUGIXML_COMPACT build on some platforms
We need bad_alloc that lives in <new>, not <exception>.
2018-04-04 07:53:16 -07:00
Arseny Kapoulkine
474a4a3f73 tests: Fix PUGIXML_NO_XPATH,PUGIXML_COMPACT build
pugixml.hpp wasn't including the <exception> header in this build but
test code needed it.
2018-04-03 21:56:09 -07:00
Arseny Kapoulkine
5f4afe3bd2 tests: Fix PUGIXML_NO_XPATH build 2018-04-03 21:51:41 -07:00
Arseny Kapoulkine
62728d9c2e tests: Fix PUGIXML_NO_EXCEPTIONS tests 2018-04-02 21:51:04 -07:00
Arseny Kapoulkine
0c74e117b8 Update version to 1.9 2018-04-02 21:46:14 -07:00
Arseny Kapoulkine
a32585286a tests: Fix PUGIXML_NO_STL build 2018-04-02 21:33:03 -07:00
Arseny Kapoulkine
fe7b837868 tests: Fix PUGIXML_COMPACT+PUGIXML_WCHAR_MODE tests
Several tests got the buffer size wrong when sizeof(char_t)>1, and one
test didn't meet the carefully tuned allocation criteria under compact
mode due to the hash table usage and had to be changed a bit.
2018-03-16 21:33:26 -07:00
Arseny Kapoulkine
a55f575a03 tests: Fix OSX test failure
Apparently at some point OSX behavior when reading /dev/tty switched
from "can't open the file" to "the file can be opened and 0 bytes can be
read from it" which generates a wrong error and doesn't exercise the
code path we care about.
2017-12-22 11:30:15 -08:00
Arseny Kapoulkine
7c6d0010b3
Merge pull request #170 from zeux/move
This change implements move ctor and assign support for xml_document.

All node handles remain valid after the move and point to the new document; the only exception is the document node itself (that remains unmoved).

Move is O(document size) in theory because it needs to relocate immediate document children (there is just one in conformant documents) and all memory pages; in practice the memory pages only need the header adjusted, which is ~0.1% of the actual data size.

Move requires no allocations in general, except when using compact mode where some moves need to grow the hash table which can fail (throw).

Fixes #104
2017-11-13 13:24:43 -08:00
Arseny Kapoulkine
58611c8702 tests: Add compact move tests
This helps make sure our error handling logic works and is exercised.
2017-11-13 08:59:16 -08:00
Arseny Kapoulkine
492ebc22bc tests: Fix expansion-to-defined warning
This warning is new as of GCC 7 and highlights undefined behavior in the
preprocessor that ASAN detection was relying on.
2017-11-10 21:35:59 -08:00
Arseny Kapoulkine
0504fa4e90 tests: Add more tests for document move
These tests currently fail for compact mode because of ->reserve()
failing.
2017-10-26 08:36:05 -07:00
Arseny Kapoulkine
b0fc587a7f tests: Add more move tests
We now check that appending a child to a moved document performs no
allocations - this is already the case, but if we neglected to copy the
allocator state this test would fail.
2017-10-20 21:53:42 -07:00
Arseny Kapoulkine
50bc0d5a69 tests: Adjust move coverage tests
Large test wasn't testing shared parent condition properly - add one
more level of hierarchy so that it works as expected.
2017-09-25 22:54:42 -07:00
Arseny Kapoulkine
26ead385a7 tests: Add more move tests
Add a test that checks that static buffer pointer was moved correctly
by checking if offset_debug still works.
2017-09-25 22:52:26 -07:00
Arseny Kapoulkine
402b967fa9 tests: Add more move tests
Make sure we have coverage for empty documents and for large documents
that trigger compact_shared_parent != root for some pages.
2017-09-25 22:47:10 -07:00
Arseny Kapoulkine
faba4786c0 tests: Add more document move tests
Verify that move doesn't allocate and that it preserves structures
required for tree memory management and append_buffer in tact.
2017-09-25 22:38:30 -07:00
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 &quot; 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