diff --git a/Makefile b/Makefile
index 897bcbb..b50ff69 100644
--- a/Makefile
+++ b/Makefile
@@ -3,10 +3,10 @@ defines=standard
BUILD=build/make-$(CXX)-$(config)-$(defines)
-SOURCES=src/pugixml.cpp $(wildcard tests/*.cpp)
+SOURCES=src/pugixml.cpp tests/main.cpp tests/allocator.cpp tests/test.cpp tests/writer_string.cpp $(wildcard tests/test_*.cpp)
EXECUTABLE=$(BUILD)/test
-CXXFLAGS=-c -g -Wall -Wextra -Werror -pedantic
+CXXFLAGS=-g -Wall -Wextra -Werror -pedantic
LDFLAGS=
ifeq ($(config),release)
@@ -39,6 +39,11 @@ test: $(EXECUTABLE)
./$(EXECUTABLE)
endif
+fuzz:
+ @mkdir -p $(BUILD)
+ $(AFL)/afl-clang++ tests/fuzz_parse.cpp tests/allocator.cpp src/pugixml.cpp $(CXXFLAGS) -o $(BUILD)/fuzz_parse
+ $(AFL)/afl-fuzz -i tests/data_fuzz_parse -o $(BUILD)/fuzz_parse_out -x $(AFL)/testcases/_extras/xml/ -- $(BUILD)/fuzz_parse @@
+
clean:
rm -rf $(BUILD)
@@ -47,7 +52,7 @@ $(EXECUTABLE): $(OBJECTS)
$(BUILD)/%.o: %
@mkdir -p $(dir $@)
- $(CXX) $< $(CXXFLAGS) -MMD -MP -o $@
+ $(CXX) $< $(CXXFLAGS) -c -MMD -MP -o $@
-include $(OBJECTS:.o=.d)
diff --git a/tests/data_fuzz_parse/basic.xml b/tests/data_fuzz_parse/basic.xml
new file mode 100644
index 0000000..a8eaa09
--- /dev/null
+++ b/tests/data_fuzz_parse/basic.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/tests/data_fuzz_parse/doctype.xml b/tests/data_fuzz_parse/doctype.xml
new file mode 100644
index 0000000..dd1831d
--- /dev/null
+++ b/tests/data_fuzz_parse/doctype.xml
@@ -0,0 +1 @@
+
]>
]]> ]>
]>
\ No newline at end of file
diff --git a/tests/data_fuzz_parse/refs.xml b/tests/data_fuzz_parse/refs.xml
new file mode 100644
index 0000000..e42df5f
--- /dev/null
+++ b/tests/data_fuzz_parse/refs.xml
@@ -0,0 +1 @@
+
pcdata < > & " ' «
&unknown; %entity;
\ No newline at end of file
diff --git a/tests/data_fuzz_parse/types.xml b/tests/data_fuzz_parse/types.xml
new file mode 100644
index 0000000..dc6369a
--- /dev/null
+++ b/tests/data_fuzz_parse/types.xml
@@ -0,0 +1 @@
+
pcdata
\ No newline at end of file
diff --git a/tests/data_fuzz_parse/utf16.xml b/tests/data_fuzz_parse/utf16.xml
new file mode 100644
index 0000000..3847a93
Binary files /dev/null and b/tests/data_fuzz_parse/utf16.xml differ
diff --git a/tests/data_fuzz_parse/utf32.xml b/tests/data_fuzz_parse/utf32.xml
new file mode 100644
index 0000000..51b8a89
Binary files /dev/null and b/tests/data_fuzz_parse/utf32.xml differ
diff --git a/tests/fuzz_parse.cpp b/tests/fuzz_parse.cpp
new file mode 100644
index 0000000..e758196
--- /dev/null
+++ b/tests/fuzz_parse.cpp
@@ -0,0 +1,16 @@
+#include "../src/pugixml.hpp"
+#include "allocator.hpp"
+
+int main(int argc, const char** argv)
+{
+ pugi::set_memory_management_functions(memory_allocate, memory_deallocate);
+
+ pugi::xml_document doc;
+
+ for (int i = 1; i < argc; ++i)
+ {
+ doc.load_file(argv[i]);
+ doc.load_file(argv[i], pugi::parse_minimal);
+ doc.load_file(argv[i], pugi::parse_full);
+ }
+}