12e724bc9Sbluhm /* Run the Expat test suite
22e724bc9Sbluhm __ __ _
32e724bc9Sbluhm ___\ \/ /_ __ __ _| |_
42e724bc9Sbluhm / _ \\ /| '_ \ / _` | __|
52e724bc9Sbluhm | __// \| |_) | (_| | |_
62e724bc9Sbluhm \___/_/\_\ .__/ \__,_|\__|
72e724bc9Sbluhm |_| XML parser
833ab7b2bSbluhm
908819b41Sbluhm Copyright (c) 2001-2006 Fred L. Drake, Jr. <fdrake@users.sourceforge.net>
1008819b41Sbluhm Copyright (c) 2003 Greg Stein <gstein@users.sourceforge.net>
11253fd6bfSbluhm Copyright (c) 2005-2007 Steven Solie <steven@solie.ca>
1208819b41Sbluhm Copyright (c) 2005-2012 Karl Waclawek <karl@waclawek.net>
13bd8f1dc3Sbluhm Copyright (c) 2016-2023 Sebastian Pipping <sebastian@pipping.org>
14751a8f41Sbluhm Copyright (c) 2017-2022 Rhodri James <rhodri@wildebeest.org.uk>
1508819b41Sbluhm Copyright (c) 2017 Joe Orton <jorton@redhat.com>
1608819b41Sbluhm Copyright (c) 2017 José Gutiérrez de la Concha <jose@zeroc.com>
1708819b41Sbluhm Copyright (c) 2018 Marco Maggi <marco.maggi-ipsu@poste.it>
1808819b41Sbluhm Copyright (c) 2019 David Loffredo <loffredo@steptools.com>
1908819b41Sbluhm Copyright (c) 2020 Tim Gates <tim.gates@iress.com>
20bd8f1dc3Sbluhm Copyright (c) 2021 Donghee Na <donghee.na@python.org>
21bd8f1dc3Sbluhm Copyright (c) 2022 Sean McBride <sean@rogue-research.com>
22bd8f1dc3Sbluhm Copyright (c) 2023 Sony Corporation / Snild Dolkow <snild@sony.com>
232e724bc9Sbluhm Licensed under the MIT license:
242e724bc9Sbluhm
252e724bc9Sbluhm Permission is hereby granted, free of charge, to any person obtaining
262e724bc9Sbluhm a copy of this software and associated documentation files (the
272e724bc9Sbluhm "Software"), to deal in the Software without restriction, including
282e724bc9Sbluhm without limitation the rights to use, copy, modify, merge, publish,
292e724bc9Sbluhm distribute, sublicense, and/or sell copies of the Software, and to permit
302e724bc9Sbluhm persons to whom the Software is furnished to do so, subject to the
312e724bc9Sbluhm following conditions:
322e724bc9Sbluhm
332e724bc9Sbluhm The above copyright notice and this permission notice shall be included
342e724bc9Sbluhm in all copies or substantial portions of the Software.
352e724bc9Sbluhm
362e724bc9Sbluhm THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
372e724bc9Sbluhm EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
382e724bc9Sbluhm MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
392e724bc9Sbluhm NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
402e724bc9Sbluhm DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
412e724bc9Sbluhm OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
422e724bc9Sbluhm USE OR OTHER DEALINGS IN THE SOFTWARE.
4333ab7b2bSbluhm */
4433ab7b2bSbluhm
45bd8f1dc3Sbluhm #include "expat_config.h"
462c19dcf8Sbluhm
4733ab7b2bSbluhm #include <stdio.h>
4833ab7b2bSbluhm #include <string.h>
499b8e2351Sbluhm
5033ab7b2bSbluhm #include "expat.h"
5108819b41Sbluhm #include "internal.h"
5233ab7b2bSbluhm #include "minicheck.h"
53bd8f1dc3Sbluhm #include "common.h"
5433ab7b2bSbluhm
55bd8f1dc3Sbluhm #include "basic_tests.h"
56bd8f1dc3Sbluhm #include "ns_tests.h"
57bd8f1dc3Sbluhm #include "misc_tests.h"
58bd8f1dc3Sbluhm #include "alloc_tests.h"
59bd8f1dc3Sbluhm #include "nsalloc_tests.h"
60bd8f1dc3Sbluhm #include "acc_tests.h"
6133ab7b2bSbluhm
62bd8f1dc3Sbluhm XML_Parser g_parser = NULL;
6308819b41Sbluhm
6433ab7b2bSbluhm static Suite *
make_suite(void)6528ce3119Sbluhm make_suite(void) {
6633ab7b2bSbluhm Suite *s = suite_create("basic");
6733ab7b2bSbluhm
68bd8f1dc3Sbluhm make_basic_test_case(s);
69bd8f1dc3Sbluhm make_namespace_test_case(s);
70bd8f1dc3Sbluhm make_miscellaneous_test_case(s);
71bd8f1dc3Sbluhm make_alloc_test_case(s);
72bd8f1dc3Sbluhm make_nsalloc_test_case(s);
73bd8f1dc3Sbluhm #if XML_GE == 1
74bd8f1dc3Sbluhm make_accounting_test_case(s);
7508819b41Sbluhm #endif
7608819b41Sbluhm
7733ab7b2bSbluhm return s;
7833ab7b2bSbluhm }
7933ab7b2bSbluhm
8033ab7b2bSbluhm int
main(int argc,char * argv[])8128ce3119Sbluhm main(int argc, char *argv[]) {
8233ab7b2bSbluhm int i, nf;
8333ab7b2bSbluhm int verbosity = CK_NORMAL;
8433ab7b2bSbluhm Suite *s = make_suite();
8533ab7b2bSbluhm SRunner *sr = srunner_create(s);
8633ab7b2bSbluhm
8733ab7b2bSbluhm for (i = 1; i < argc; ++i) {
8833ab7b2bSbluhm char *opt = argv[i];
8933ab7b2bSbluhm if (strcmp(opt, "-v") == 0 || strcmp(opt, "--verbose") == 0)
9033ab7b2bSbluhm verbosity = CK_VERBOSE;
9133ab7b2bSbluhm else if (strcmp(opt, "-q") == 0 || strcmp(opt, "--quiet") == 0)
9233ab7b2bSbluhm verbosity = CK_SILENT;
9333ab7b2bSbluhm else {
9433ab7b2bSbluhm fprintf(stderr, "runtests: unknown option '%s'\n", opt);
9533ab7b2bSbluhm return 2;
9633ab7b2bSbluhm }
9733ab7b2bSbluhm }
9833ab7b2bSbluhm if (verbosity != CK_SILENT)
999b8e2351Sbluhm printf("Expat version: %" XML_FMT_STR "\n", XML_ExpatVersion());
100bd8f1dc3Sbluhm
101bd8f1dc3Sbluhm for (g_chunkSize = 0; g_chunkSize <= 5; g_chunkSize++) {
102bd8f1dc3Sbluhm for (int enabled = 0; enabled <= 1; ++enabled) {
103bd8f1dc3Sbluhm char context[100];
104*f558d286Sbluhm #if defined(XML_TESTING)
105bd8f1dc3Sbluhm g_reparseDeferralEnabledDefault = enabled;
106*f558d286Sbluhm #endif
107bd8f1dc3Sbluhm snprintf(context, sizeof(context), "chunksize=%d deferral=%d",
108bd8f1dc3Sbluhm g_chunkSize, enabled);
109bd8f1dc3Sbluhm context[sizeof(context) - 1] = '\0';
110bd8f1dc3Sbluhm srunner_run_all(sr, context, verbosity);
111bd8f1dc3Sbluhm }
112bd8f1dc3Sbluhm }
113bd8f1dc3Sbluhm srunner_summarize(sr, verbosity);
11433ab7b2bSbluhm nf = srunner_ntests_failed(sr);
11533ab7b2bSbluhm srunner_free(sr);
11633ab7b2bSbluhm
11733ab7b2bSbluhm return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
11833ab7b2bSbluhm }
119