/*****************************************************************************/
/* LibreDWG - free implementation of the DWG file format */
/* */
/* Copyright (C) 2019-2024 Free Software Foundation, Inc. */
/* */
/* This library is free software, licensed under the terms of the GNU */
/* General Public License as published by the Free Software Foundation, */
/* either version 3 of the License, or (at your option) any later version. */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/*****************************************************************************/
/* dynapi coverage tests, generated by gen-dynapi.pl from dynapi_test.c.in
do not modify */
/* written by: Reini Urban */
#line 16 "dynapi_test.c.in"
#define DYNAPI_TEST_C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "config.h"
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "../../programs/my_stat.h"
#include "common.h"
#include "classes.h"
#include "dwg.h"
#include "tests_common.h"
#include "dwg_api.h"
/* for all objects/entities/header_vars:
compare direct api vs dynapi values
*/
static int
test_header (Dwg_Data *dwg)
{
int error = 0;
BITCODE_RL rl;
BITCODE_RC rc;
BITCODE_BLL bll;
BITCODE_BD bd;
BITCODE_TV tv;
#line 46 "dynapi_test.c"
/* @@for test_HEADER@@ */
#line 47 "dynapi_test.c.in"
return error;
}
#line 5379 "dynapi_test.c"
/* @@for test_OBJECT@@ */
#line 53 "dynapi_test.c.in"
static int
test_object (const Dwg_Data *restrict dwg, const Dwg_Object *restrict obj)
{
int error = 0;
#line 62158 "dynapi_test.c"
/* @@for if_test_OBJECT@@ */
#line 60 "dynapi_test.c.in"
return error + failed;
}
/* for all fields, checks its sizeof vs _fields_size_sum */
static int
test_sizes (void)
{
int error = 0;
int size1, size2;
#line 63386 "dynapi_test.c"
/* @@for test_SIZES@@ */
#line 72 "dynapi_test.c.in"
return error;
}
static int
test_dynapi (const char *filename)
{
int error;
Dwg_Data dwg;
BITCODE_BL i;
num = passed = failed = 0;
dwg.opts = 0;
error = test_sizes ();
if (dwg_read_file (filename, &dwg) >= DWG_ERR_CRITICAL)
{
dwg_free (&dwg);
return error + 1;
}
/* On cygwin32 the dynapi works fine, but the dwg->header_vars.VARS
reference is broken somehow (some wrong offset) */
#if !defined(__CYGWIN__) || defined(__amd64__)
error += test_header (&dwg);
#endif
for (i = 0; i < dwg.num_objects; i++)
{
error += test_object (&dwg, &dwg.object[i]);
}
dwg_free (&dwg);
/* This value is the return value for `main',
so clamp it to either 0 or 1. */
return error ? 1 : 0;
}
int
main (int argc, char *argv[])
{
char *input = getenv ("INPUT");
loglevel = is_make_silent() ? 0 : 2;
if (input == NULL)
{
int error = 0;
char **ptr;
const char *const files[] =
{
"example_2000.dwg",
"example_2004.dwg",
"example_2007.dwg",
"example_2010.dwg",
"example_2013.dwg",
"example_2018.dwg",
"example_r14.dwg",
"2007/PolyLine3D.dwg",
//"2018/Dynblocks.dwg",
//"example_r13.dwg",
//"r12/work.dwg",
//"r11/ACEB10.dwg",
//"r11/entities-3d.dwg",
//"r10/entities.dwg",
//"r9/entities.dwg",
//"r2.10/entities.dwg",
//"r2.6/entities.dwg",
//"r1.4/entities.dwg",
NULL
};
for (ptr = (char**)&files[0]; *ptr; ptr++)
{
struct stat attrib;
if (stat (*ptr, &attrib))
{
char tmp[80];
strncpy (tmp, "../test-data/", sizeof (tmp));
strncat (tmp, *ptr, sizeof (tmp) - sizeof ("../test-data/") - 1);
if (stat (tmp, &attrib))
LOG_ERROR ("Env var INPUT not defined, %s not found", tmp)
else
error += test_dynapi (tmp);
}
else
error += test_dynapi (*ptr);
}
return error;
}
else
return test_dynapi (input);
}