mirror of
https://github.com/thunderbrewhq/common.git
synced 2025-12-12 11:12:29 +00:00
feat(xml): add XML functions
This commit is contained in:
parent
125ffec928
commit
4e43886e37
142 changed files with 68501 additions and 0 deletions
14
vendor/expat-2.0.1/tests/README.txt
vendored
Executable file
14
vendor/expat-2.0.1/tests/README.txt
vendored
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
This directory contains the (fledgling) test suite for Expat. The
|
||||
tests provide general unit testing and regression coverage. The tests
|
||||
are not expected to be useful examples of Expat usage; see the
|
||||
examples/ directory for that.
|
||||
|
||||
The Expat tests use a partial internal implementation of the "Check"
|
||||
unit testing framework for C. More information on Check can be found at:
|
||||
|
||||
http://check.sourceforge.net/
|
||||
|
||||
Expat must be built and installed before "make check" can be executed.
|
||||
|
||||
Since both Check and this test suite are young, it can all change in a
|
||||
later version.
|
||||
16
vendor/expat-2.0.1/tests/benchmark/README.txt
vendored
Executable file
16
vendor/expat-2.0.1/tests/benchmark/README.txt
vendored
Executable file
|
|
@ -0,0 +1,16 @@
|
|||
Use this benchmark command line utility as follows:
|
||||
|
||||
benchmark [-n] <file name> <buffer size> <# iterations>
|
||||
|
||||
The command line arguments are:
|
||||
|
||||
-n ... optional; if supplied, namespace processing is turned on
|
||||
<file name> ... name/path of test xml file
|
||||
<buffer size> ... size of processing buffer;
|
||||
the file is parsed in chunks of this size
|
||||
<# iterations> ... how often will the file be parsed
|
||||
|
||||
Returns:
|
||||
|
||||
The time (in seconds) it takes to parse the test file,
|
||||
averaged over the number of iterations.
|
||||
114
vendor/expat-2.0.1/tests/benchmark/benchmark.c
vendored
Executable file
114
vendor/expat-2.0.1/tests/benchmark/benchmark.c
vendored
Executable file
|
|
@ -0,0 +1,114 @@
|
|||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "expat.h"
|
||||
|
||||
#if defined(__amigaos__) && defined(__USE_INLINE__)
|
||||
#include <proto/expat.h>
|
||||
#endif
|
||||
|
||||
#ifdef XML_LARGE_SIZE
|
||||
#define XML_FMT_INT_MOD "ll"
|
||||
#else
|
||||
#define XML_FMT_INT_MOD "l"
|
||||
#endif
|
||||
|
||||
static void
|
||||
usage(const char *prog, int rc)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-n] filename bufferSize nr_of_loops\n", prog);
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
XML_Parser parser;
|
||||
char *XMLBuf, *XMLBufEnd, *XMLBufPtr;
|
||||
FILE *fd;
|
||||
struct stat fileAttr;
|
||||
int nrOfLoops, bufferSize, fileSize, i, isFinal;
|
||||
int j = 0, ns = 0;
|
||||
clock_t tstart, tend;
|
||||
double cpuTime = 0.0;
|
||||
|
||||
if (argc > 1) {
|
||||
if (argv[1][0] == '-') {
|
||||
if (argv[1][1] == 'n' && argv[1][2] == '\0') {
|
||||
ns = 1;
|
||||
j = 1;
|
||||
}
|
||||
else
|
||||
usage(argv[0], 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc != j + 4)
|
||||
usage(argv[0], 1);
|
||||
|
||||
if (stat (argv[j + 1], &fileAttr) != 0) {
|
||||
fprintf (stderr, "could not access file '%s'\n", argv[j + 1]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
fd = fopen (argv[j + 1], "r");
|
||||
if (!fd) {
|
||||
fprintf (stderr, "could not open file '%s'\n", argv[j + 1]);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
bufferSize = atoi (argv[j + 2]);
|
||||
nrOfLoops = atoi (argv[j + 3]);
|
||||
if (bufferSize <= 0 || nrOfLoops <= 0) {
|
||||
fprintf (stderr,
|
||||
"buffer size and nr of loops must be greater than zero.\n");
|
||||
exit(3);
|
||||
}
|
||||
|
||||
XMLBuf = malloc (fileAttr.st_size);
|
||||
fileSize = fread (XMLBuf, sizeof (char), fileAttr.st_size, fd);
|
||||
fclose (fd);
|
||||
|
||||
if (ns)
|
||||
parser = XML_ParserCreateNS(NULL, '!');
|
||||
else
|
||||
parser = XML_ParserCreate(NULL);
|
||||
|
||||
i = 0;
|
||||
XMLBufEnd = XMLBuf + fileSize;
|
||||
while (i < nrOfLoops) {
|
||||
XMLBufPtr = XMLBuf;
|
||||
isFinal = 0;
|
||||
tstart = clock();
|
||||
do {
|
||||
int parseBufferSize = XMLBufEnd - XMLBufPtr;
|
||||
if (parseBufferSize <= bufferSize)
|
||||
isFinal = 1;
|
||||
else
|
||||
parseBufferSize = bufferSize;
|
||||
if (!XML_Parse (parser, XMLBufPtr, parseBufferSize, isFinal)) {
|
||||
fprintf (stderr, "error '%s' at line %" XML_FMT_INT_MOD \
|
||||
"u character %" XML_FMT_INT_MOD "u\n",
|
||||
XML_ErrorString (XML_GetErrorCode (parser)),
|
||||
XML_GetCurrentLineNumber (parser),
|
||||
XML_GetCurrentColumnNumber (parser));
|
||||
free (XMLBuf);
|
||||
XML_ParserFree (parser);
|
||||
exit (4);
|
||||
}
|
||||
XMLBufPtr += bufferSize;
|
||||
} while (!isFinal);
|
||||
tend = clock();
|
||||
cpuTime += ((double) (tend - tstart)) / CLOCKS_PER_SEC;
|
||||
XML_ParserReset(parser, NULL);
|
||||
i++;
|
||||
}
|
||||
|
||||
XML_ParserFree (parser);
|
||||
free (XMLBuf);
|
||||
|
||||
printf ("%d loops, with buffer size %d. Average time per loop: %f\n",
|
||||
nrOfLoops, bufferSize, cpuTime / (double) nrOfLoops);
|
||||
return 0;
|
||||
}
|
||||
88
vendor/expat-2.0.1/tests/benchmark/benchmark.dsp
vendored
Executable file
88
vendor/expat-2.0.1/tests/benchmark/benchmark.dsp
vendored
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
# Microsoft Developer Studio Project File - Name="benchmark" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Console Application" 0x0103
|
||||
|
||||
CFG=benchmark - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "benchmark.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "benchmark.mak" CFG="benchmark - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "benchmark - Win32 Release" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE "benchmark - Win32 Debug" (based on "Win32 (x86) Console Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "benchmark - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\lib" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE RSC /l 0x1009 /d "NDEBUG"
|
||||
# ADD RSC /l 0x1009 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "benchmark - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\lib" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD BASE RSC /l 0x1009 /d "_DEBUG"
|
||||
# ADD RSC /l 0x1009 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "benchmark - Win32 Release"
|
||||
# Name "benchmark - Win32 Debug"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\benchmark.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
44
vendor/expat-2.0.1/tests/benchmark/benchmark.dsw
vendored
Executable file
44
vendor/expat-2.0.1/tests/benchmark/benchmark.dsw
vendored
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "benchmark"=.\benchmark.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
Begin Project Dependency
|
||||
Project_Dep_Name expat
|
||||
End Project Dependency
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "expat"=..\..\lib\expat.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
131
vendor/expat-2.0.1/tests/chardata.c
vendored
Executable file
131
vendor/expat-2.0.1/tests/chardata.c
vendored
Executable file
|
|
@ -0,0 +1,131 @@
|
|||
/* Copyright (c) 1998-2003 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
|
||||
chardata.c
|
||||
*/
|
||||
|
||||
#ifdef HAVE_EXPAT_CONFIG_H
|
||||
#include <expat_config.h>
|
||||
#endif
|
||||
#ifdef HAVE_CHECK_H
|
||||
#include <check.h>
|
||||
#else
|
||||
#include "minicheck.h"
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "chardata.h"
|
||||
|
||||
|
||||
static int
|
||||
xmlstrlen(const XML_Char *s)
|
||||
{
|
||||
int len = 0;
|
||||
assert(s != NULL);
|
||||
while (s[len] != 0)
|
||||
++len;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CharData_Init(CharData *storage)
|
||||
{
|
||||
assert(storage != NULL);
|
||||
storage->count = -1;
|
||||
}
|
||||
|
||||
void
|
||||
CharData_AppendString(CharData *storage, const char *s)
|
||||
{
|
||||
int maxchars = sizeof(storage->data) / sizeof(storage->data[0]);
|
||||
int len;
|
||||
|
||||
assert(s != NULL);
|
||||
len = strlen(s);
|
||||
if (storage->count < 0)
|
||||
storage->count = 0;
|
||||
if ((len + storage->count) > maxchars) {
|
||||
len = (maxchars - storage->count);
|
||||
}
|
||||
if (len + storage->count < sizeof(storage->data)) {
|
||||
memcpy(storage->data + storage->count, s, len);
|
||||
storage->count += len;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CharData_AppendXMLChars(CharData *storage, const XML_Char *s, int len)
|
||||
{
|
||||
int maxchars;
|
||||
|
||||
assert(storage != NULL);
|
||||
assert(s != NULL);
|
||||
maxchars = sizeof(storage->data) / sizeof(storage->data[0]);
|
||||
if (storage->count < 0)
|
||||
storage->count = 0;
|
||||
if (len < 0)
|
||||
len = xmlstrlen(s);
|
||||
if ((len + storage->count) > maxchars) {
|
||||
len = (maxchars - storage->count);
|
||||
}
|
||||
if (len + storage->count < sizeof(storage->data)) {
|
||||
memcpy(storage->data + storage->count, s,
|
||||
len * sizeof(storage->data[0]));
|
||||
storage->count += len;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
CharData_CheckString(CharData *storage, const char *expected)
|
||||
{
|
||||
char buffer[1280];
|
||||
int len;
|
||||
int count;
|
||||
|
||||
assert(storage != NULL);
|
||||
assert(expected != NULL);
|
||||
count = (storage->count < 0) ? 0 : storage->count;
|
||||
len = strlen(expected);
|
||||
if (len != count) {
|
||||
if (sizeof(XML_Char) == 1)
|
||||
sprintf(buffer, "wrong number of data characters:"
|
||||
" got %d, expected %d:\n%s", count, len, storage->data);
|
||||
else
|
||||
sprintf(buffer,
|
||||
"wrong number of data characters: got %d, expected %d",
|
||||
count, len);
|
||||
fail(buffer);
|
||||
return 0;
|
||||
}
|
||||
if (memcmp(expected, storage->data, len) != 0) {
|
||||
fail("got bad data bytes");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
CharData_CheckXMLChars(CharData *storage, const XML_Char *expected)
|
||||
{
|
||||
char buffer[1024];
|
||||
int len = xmlstrlen(expected);
|
||||
int count;
|
||||
|
||||
assert(storage != NULL);
|
||||
count = (storage->count < 0) ? 0 : storage->count;
|
||||
if (len != count) {
|
||||
sprintf(buffer, "wrong number of data characters: got %d, expected %d",
|
||||
count, len);
|
||||
fail(buffer);
|
||||
return 0;
|
||||
}
|
||||
if (memcmp(expected, storage->data, len * sizeof(storage->data[0])) != 0) {
|
||||
fail("got bad data bytes");
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
40
vendor/expat-2.0.1/tests/chardata.h
vendored
Executable file
40
vendor/expat-2.0.1/tests/chardata.h
vendored
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
/* chardata.h
|
||||
|
||||
Interface to some helper routines used to accumulate and check text
|
||||
and attribute content.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef XML_CHARDATA_H
|
||||
#define XML_CHARDATA_H 1
|
||||
|
||||
#ifndef XML_VERSION
|
||||
#include "expat.h" /* need XML_Char */
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct {
|
||||
int count; /* # of chars, < 0 if not set */
|
||||
XML_Char data[1024];
|
||||
} CharData;
|
||||
|
||||
|
||||
void CharData_Init(CharData *storage);
|
||||
|
||||
void CharData_AppendString(CharData *storage, const char *s);
|
||||
|
||||
void CharData_AppendXMLChars(CharData *storage, const XML_Char *s, int len);
|
||||
|
||||
int CharData_CheckString(CharData *storage, const char *s);
|
||||
|
||||
int CharData_CheckXMLChars(CharData *storage, const XML_Char *s);
|
||||
|
||||
|
||||
#endif /* XML_CHARDATA_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
182
vendor/expat-2.0.1/tests/minicheck.c
vendored
Executable file
182
vendor/expat-2.0.1/tests/minicheck.c
vendored
Executable file
|
|
@ -0,0 +1,182 @@
|
|||
/* Miniature re-implementation of the "check" library.
|
||||
*
|
||||
* This is intended to support just enough of check to run the Expat
|
||||
* tests. This interface is based entirely on the portion of the
|
||||
* check library being used.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "minicheck.h"
|
||||
|
||||
Suite *
|
||||
suite_create(char *name)
|
||||
{
|
||||
Suite *suite = (Suite *) calloc(1, sizeof(Suite));
|
||||
if (suite != NULL) {
|
||||
suite->name = name;
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
|
||||
TCase *
|
||||
tcase_create(char *name)
|
||||
{
|
||||
TCase *tc = (TCase *) calloc(1, sizeof(TCase));
|
||||
if (tc != NULL) {
|
||||
tc->name = name;
|
||||
}
|
||||
return tc;
|
||||
}
|
||||
|
||||
void
|
||||
suite_add_tcase(Suite *suite, TCase *tc)
|
||||
{
|
||||
assert(suite != NULL);
|
||||
assert(tc != NULL);
|
||||
assert(tc->next_tcase == NULL);
|
||||
|
||||
tc->next_tcase = suite->tests;
|
||||
suite->tests = tc;
|
||||
}
|
||||
|
||||
void
|
||||
tcase_add_checked_fixture(TCase *tc,
|
||||
tcase_setup_function setup,
|
||||
tcase_teardown_function teardown)
|
||||
{
|
||||
assert(tc != NULL);
|
||||
tc->setup = setup;
|
||||
tc->teardown = teardown;
|
||||
}
|
||||
|
||||
void
|
||||
tcase_add_test(TCase *tc, tcase_test_function test)
|
||||
{
|
||||
assert(tc != NULL);
|
||||
if (tc->allocated == tc->ntests) {
|
||||
int nalloc = tc->allocated + 100;
|
||||
size_t new_size = sizeof(tcase_test_function) * nalloc;
|
||||
tcase_test_function *new_tests = realloc(tc->tests, new_size);
|
||||
assert(new_tests != NULL);
|
||||
if (new_tests != tc->tests) {
|
||||
free(tc->tests);
|
||||
tc->tests = new_tests;
|
||||
}
|
||||
tc->allocated = nalloc;
|
||||
}
|
||||
tc->tests[tc->ntests] = test;
|
||||
tc->ntests++;
|
||||
}
|
||||
|
||||
SRunner *
|
||||
srunner_create(Suite *suite)
|
||||
{
|
||||
SRunner *runner = calloc(1, sizeof(SRunner));
|
||||
if (runner != NULL) {
|
||||
runner->suite = suite;
|
||||
}
|
||||
return runner;
|
||||
}
|
||||
|
||||
static jmp_buf env;
|
||||
|
||||
static char const *_check_current_function = NULL;
|
||||
static int _check_current_lineno = -1;
|
||||
static char const *_check_current_filename = NULL;
|
||||
|
||||
void
|
||||
_check_set_test_info(char const *function, char const *filename, int lineno)
|
||||
{
|
||||
_check_current_function = function;
|
||||
_check_current_lineno = lineno;
|
||||
_check_current_filename = filename;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
add_failure(SRunner *runner, int verbosity)
|
||||
{
|
||||
runner->nfailures++;
|
||||
if (verbosity >= CK_VERBOSE) {
|
||||
printf("%s:%d: %s\n", _check_current_filename,
|
||||
_check_current_lineno, _check_current_function);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
srunner_run_all(SRunner *runner, int verbosity)
|
||||
{
|
||||
Suite *suite;
|
||||
TCase *tc;
|
||||
assert(runner != NULL);
|
||||
suite = runner->suite;
|
||||
tc = suite->tests;
|
||||
while (tc != NULL) {
|
||||
int i;
|
||||
for (i = 0; i < tc->ntests; ++i) {
|
||||
runner->nchecks++;
|
||||
|
||||
if (tc->setup != NULL) {
|
||||
/* setup */
|
||||
if (setjmp(env)) {
|
||||
add_failure(runner, verbosity);
|
||||
continue;
|
||||
}
|
||||
tc->setup();
|
||||
}
|
||||
/* test */
|
||||
if (setjmp(env)) {
|
||||
add_failure(runner, verbosity);
|
||||
continue;
|
||||
}
|
||||
(tc->tests[i])();
|
||||
|
||||
/* teardown */
|
||||
if (tc->teardown != NULL) {
|
||||
if (setjmp(env)) {
|
||||
add_failure(runner, verbosity);
|
||||
continue;
|
||||
}
|
||||
tc->teardown();
|
||||
}
|
||||
}
|
||||
tc = tc->next_tcase;
|
||||
}
|
||||
if (verbosity) {
|
||||
int passed = runner->nchecks - runner->nfailures;
|
||||
double percentage = ((double) passed) / runner->nchecks;
|
||||
int display = (int) (percentage * 100);
|
||||
printf("%d%%: Checks: %d, Failed: %d\n",
|
||||
display, runner->nchecks, runner->nfailures);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
_fail_unless(int condition, const char *file, int line, char *msg)
|
||||
{
|
||||
/* Always print the error message so it isn't lost. In this case,
|
||||
we have a failure, so there's no reason to be quiet about what
|
||||
it is.
|
||||
*/
|
||||
if (msg != NULL)
|
||||
printf("%s", msg);
|
||||
longjmp(env, 1);
|
||||
}
|
||||
|
||||
int
|
||||
srunner_ntests_failed(SRunner *runner)
|
||||
{
|
||||
assert(runner != NULL);
|
||||
return runner->nfailures;
|
||||
}
|
||||
|
||||
void
|
||||
srunner_free(SRunner *runner)
|
||||
{
|
||||
free(runner->suite);
|
||||
free(runner);
|
||||
}
|
||||
89
vendor/expat-2.0.1/tests/minicheck.h
vendored
Executable file
89
vendor/expat-2.0.1/tests/minicheck.h
vendored
Executable file
|
|
@ -0,0 +1,89 @@
|
|||
/* Miniature re-implementation of the "check" library.
|
||||
*
|
||||
* This is intended to support just enough of check to run the Expat
|
||||
* tests. This interface is based entirely on the portion of the
|
||||
* check library being used.
|
||||
*
|
||||
* This is *source* compatible, but not necessary *link* compatible.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CK_NOFORK 0
|
||||
#define CK_FORK 1
|
||||
|
||||
#define CK_SILENT 0
|
||||
#define CK_NORMAL 1
|
||||
#define CK_VERBOSE 2
|
||||
|
||||
/* Workaround for Tru64 Unix systems where the C compiler has a working
|
||||
__func__, but the C++ compiler only has a working __FUNCTION__. This
|
||||
could be fixed in configure.in, but it's not worth it right now. */
|
||||
#if defined(__osf__) && defined(__cplusplus)
|
||||
#define __func__ __FUNCTION__
|
||||
#endif
|
||||
|
||||
#define START_TEST(testname) static void testname(void) { \
|
||||
_check_set_test_info(__func__, __FILE__, __LINE__); \
|
||||
{
|
||||
#define END_TEST } }
|
||||
|
||||
#define fail(msg) _fail_unless(0, __FILE__, __LINE__, msg)
|
||||
|
||||
typedef void (*tcase_setup_function)(void);
|
||||
typedef void (*tcase_teardown_function)(void);
|
||||
typedef void (*tcase_test_function)(void);
|
||||
|
||||
typedef struct SRunner SRunner;
|
||||
typedef struct Suite Suite;
|
||||
typedef struct TCase TCase;
|
||||
|
||||
struct SRunner {
|
||||
Suite *suite;
|
||||
int nchecks;
|
||||
int nfailures;
|
||||
};
|
||||
|
||||
struct Suite {
|
||||
char *name;
|
||||
TCase *tests;
|
||||
};
|
||||
|
||||
struct TCase {
|
||||
char *name;
|
||||
tcase_setup_function setup;
|
||||
tcase_teardown_function teardown;
|
||||
tcase_test_function *tests;
|
||||
int ntests;
|
||||
int allocated;
|
||||
TCase *next_tcase;
|
||||
};
|
||||
|
||||
|
||||
/* Internal helper. */
|
||||
void _check_set_test_info(char const *function,
|
||||
char const *filename, int lineno);
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes for the actual implementation.
|
||||
*/
|
||||
|
||||
void _fail_unless(int condition, const char *file, int line, char *msg);
|
||||
Suite *suite_create(char *name);
|
||||
TCase *tcase_create(char *name);
|
||||
void suite_add_tcase(Suite *suite, TCase *tc);
|
||||
void tcase_add_checked_fixture(TCase *,
|
||||
tcase_setup_function,
|
||||
tcase_teardown_function);
|
||||
void tcase_add_test(TCase *tc, tcase_test_function test);
|
||||
SRunner *srunner_create(Suite *suite);
|
||||
void srunner_run_all(SRunner *runner, int verbosity);
|
||||
int srunner_ntests_failed(SRunner *runner);
|
||||
void srunner_free(SRunner *runner);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
1514
vendor/expat-2.0.1/tests/runtests.c
vendored
Executable file
1514
vendor/expat-2.0.1/tests/runtests.c
vendored
Executable file
File diff suppressed because it is too large
Load diff
6
vendor/expat-2.0.1/tests/runtestspp.cpp
vendored
Executable file
6
vendor/expat-2.0.1/tests/runtestspp.cpp
vendored
Executable file
|
|
@ -0,0 +1,6 @@
|
|||
// C++ compilation harness for the test suite.
|
||||
//
|
||||
// This is used to ensure the Expat headers can be included from C++
|
||||
// and have everything work as expected.
|
||||
//
|
||||
#include "runtests.c"
|
||||
141
vendor/expat-2.0.1/tests/xmltest.sh
vendored
Executable file
141
vendor/expat-2.0.1/tests/xmltest.sh
vendored
Executable file
|
|
@ -0,0 +1,141 @@
|
|||
#! /bin/sh
|
||||
|
||||
# EXPAT TEST SCRIPT FOR W3C XML TEST SUITE
|
||||
|
||||
# This script can be used to exercise Expat against the
|
||||
# w3c.org xml test suite, available from
|
||||
# http://www.w3.org/XML/Test/xmlts20020606.zip.
|
||||
|
||||
# To run this script, first set XMLWF so that xmlwf can be
|
||||
# found, then set the output directory with OUTPUT.
|
||||
|
||||
# The script lists all test cases where Expat shows a discrepancy
|
||||
# from the expected result. Test cases where only the canonical
|
||||
# output differs are prefixed with "Output differs:", and a diff file
|
||||
# is generated in the appropriate subdirectory under $OUTPUT.
|
||||
|
||||
# If there are output files provided, the script will use
|
||||
# output from xmlwf and compare the desired output against it.
|
||||
# However, one has to take into account that the canonical output
|
||||
# produced by xmlwf conforms to an older definition of canonical XML
|
||||
# and does not generate notation declarations.
|
||||
|
||||
MYDIR="`dirname \"$0\"`"
|
||||
cd "$MYDIR"
|
||||
MYDIR="`pwd`"
|
||||
XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
|
||||
# XMLWF=/usr/local/bin/xmlwf
|
||||
TS="$MYDIR/XML-Test-Suite"
|
||||
# OUTPUT must terminate with the directory separator.
|
||||
OUTPUT="$TS/out/"
|
||||
# OUTPUT=/home/tmp/xml-testsuite-out/
|
||||
|
||||
|
||||
# RunXmlwfNotWF file reldir
|
||||
# reldir includes trailing slash
|
||||
RunXmlwfNotWF() {
|
||||
file="$1"
|
||||
reldir="$2"
|
||||
$XMLWF -p "$file" > outfile || return $?
|
||||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
echo "Expected well-formed: $reldir$file"
|
||||
return 1
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
# RunXmlwfWF file reldir
|
||||
# reldir includes trailing slash
|
||||
RunXmlwfWF() {
|
||||
file="$1"
|
||||
reldir="$2"
|
||||
$XMLWF -p -d "$OUTPUT$reldir" "$file" > outfile || return $?
|
||||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
if [ -f "out/$file" ] ; then
|
||||
diff "$OUTPUT$reldir$file" "out/$file" > outfile
|
||||
if [ -s outfile ] ; then
|
||||
cp outfile "$OUTPUT$reldir$file.diff"
|
||||
echo "Output differs: $reldir$file"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
else
|
||||
echo "In $reldir: $outdata"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
SUCCESS=0
|
||||
ERROR=0
|
||||
|
||||
UpdateStatus() {
|
||||
if [ "$1" -eq 0 ] ; then
|
||||
SUCCESS=`expr $SUCCESS + 1`
|
||||
else
|
||||
ERROR=`expr $ERROR + 1`
|
||||
fi
|
||||
}
|
||||
|
||||
##########################
|
||||
# well-formed test cases #
|
||||
##########################
|
||||
|
||||
cd "$TS/xmlconf"
|
||||
for xmldir in ibm/valid/P* \
|
||||
ibm/invalid/P* \
|
||||
xmltest/valid/ext-sa \
|
||||
xmltest/valid/not-sa \
|
||||
xmltest/invalid \
|
||||
xmltest/invalid/not-sa \
|
||||
xmltest/valid/sa \
|
||||
sun/valid \
|
||||
sun/invalid ; do
|
||||
cd "$TS/xmlconf/$xmldir"
|
||||
mkdir -p "$OUTPUT$xmldir"
|
||||
for xmlfile in *.xml ; do
|
||||
RunXmlwfWF "$xmlfile" "$xmldir/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
done
|
||||
|
||||
cd "$TS/xmlconf/oasis"
|
||||
mkdir -p "$OUTPUT"oasis
|
||||
for xmlfile in *pass*.xml ; do
|
||||
RunXmlwfWF "$xmlfile" "oasis/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
|
||||
##############################
|
||||
# not well-formed test cases #
|
||||
##############################
|
||||
|
||||
cd "$TS/xmlconf"
|
||||
for xmldir in ibm/not-wf/P* \
|
||||
ibm/not-wf/misc \
|
||||
xmltest/not-wf/ext-sa \
|
||||
xmltest/not-wf/not-sa \
|
||||
xmltest/not-wf/sa \
|
||||
sun/not-wf ; do
|
||||
cd "$TS/xmlconf/$xmldir"
|
||||
for xmlfile in *.xml ; do
|
||||
RunXmlwfNotWF "$xmlfile" "$xmldir/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
done
|
||||
|
||||
cd "$TS/xmlconf/oasis"
|
||||
for xmlfile in *fail*.xml ; do
|
||||
RunXmlwfNotWF "$xmlfile" "oasis/"
|
||||
UpdateStatus $?
|
||||
done
|
||||
rm outfile
|
||||
|
||||
echo "Passed: $SUCCESS"
|
||||
echo "Failed: $ERROR"
|
||||
Loading…
Add table
Add a link
Reference in a new issue