Commit bcb7591e authored by Alexandre Julliard's avatar Alexandre Julliard

Converted the make_ctests script to C (based on a patch by Royce

Mitchell III).
parent 705909ac
...@@ -64,6 +64,7 @@ C2MAN = $(TOPSRCDIR)/tools/c2man.pl ...@@ -64,6 +64,7 @@ C2MAN = $(TOPSRCDIR)/tools/c2man.pl
RUNTEST = $(TOPSRCDIR)/tools/runtest RUNTEST = $(TOPSRCDIR)/tools/runtest
WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild WINEBUILD = $(TOOLSDIR)/tools/winebuild/winebuild
MAKEDEP = $(TOOLSDIR)/tools/makedep MAKEDEP = $(TOOLSDIR)/tools/makedep
MAKECTESTS = $(TOOLSDIR)/tools/make_ctests
WRC = $(TOOLSDIR)/tools/wrc/wrc WRC = $(TOOLSDIR)/tools/wrc/wrc
BIN2RES = $(TOOLSDIR)/tools/bin2res BIN2RES = $(TOOLSDIR)/tools/bin2res
WMC = $(TOOLSDIR)/tools/wmc/wmc WMC = $(TOOLSDIR)/tools/wmc/wmc
......
...@@ -46,8 +46,8 @@ $(MODULE): $(OBJS) $(RCOBJS) Makefile.in ...@@ -46,8 +46,8 @@ $(MODULE): $(OBJS) $(RCOBJS) Makefile.in
# Rules for building test list # Rules for building test list
$(TESTLIST): Makefile.in $(TOPSRCDIR)/tools/make_ctests $(TESTLIST): Makefile.in $(MAKECTESTS)
$(TOPSRCDIR)/tools/make_ctests $(CTESTS) >$(TESTLIST) || $(RM) $(TESTLIST) $(MAKECTESTS) -o $@ $(CTESTS)
depend: $(TESTLIST) depend: $(TESTLIST)
......
...@@ -2,6 +2,7 @@ Makefile ...@@ -2,6 +2,7 @@ Makefile
bin2res bin2res
fnt2bdf fnt2bdf
fnt2fon fnt2fon
make_ctests
makedep makedep
sfnt2fnt sfnt2fnt
wineprefixcreate wineprefixcreate
...@@ -11,6 +11,7 @@ PROGRAMS = \ ...@@ -11,6 +11,7 @@ PROGRAMS = \
bin2res \ bin2res \
fnt2bdf \ fnt2bdf \
fnt2fon \ fnt2fon \
make_ctests \
makedep \ makedep \
sfnt2fnt \ sfnt2fnt \
wineprefixcreate wineprefixcreate
...@@ -19,6 +20,7 @@ C_SRCS = \ ...@@ -19,6 +20,7 @@ C_SRCS = \
bin2res.c \ bin2res.c \
fnt2bdf.c \ fnt2bdf.c \
fnt2fon.c \ fnt2fon.c \
make_ctests.c \
makedep.c \ makedep.c \
sfnt2fnt.c \ sfnt2fnt.c \
...@@ -43,6 +45,9 @@ all: $(PROGRAMS) $(SUBDIRS) ...@@ -43,6 +45,9 @@ all: $(PROGRAMS) $(SUBDIRS)
makedep: makedep.o makedep: makedep.o
$(CC) $(CFLAGS) -o makedep makedep.o $(CC) $(CFLAGS) -o makedep makedep.o
make_ctests: make_ctests.o
$(CC) $(CFLAGS) -o make_ctests make_ctests.o
fnt2bdf: fnt2bdf.o fnt2bdf: fnt2bdf.o
$(CC) $(CFLAGS) -o fnt2bdf fnt2bdf.o $(LIBPORT) $(CC) $(CFLAGS) -o fnt2bdf fnt2bdf.o $(LIBPORT)
......
#!/bin/sh
#
# Script to generate a C file containing a list of tests
#
# Copyright 2002 Alexandre Julliard
# Copyright 2002 Dimitrie O. Paun
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ***** Keep in sync with tools/winapi/msvcmaker:_generate_testlist_c *****
cat <<EOF
/* Automatically generated file; DO NOT EDIT!! */
/* stdarg.h is needed for Winelib */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
EOF
for file in "$@"; do
test=`basename "$file" .c`
echo "extern void func_$test(void);"
done
cat <<EOF
struct test
{
const char *name;
void (*func)(void);
};
static const struct test winetest_testlist[] =
{
EOF
for file in "$@"; do
test=`basename "$file" .c`
echo " { \"$test\", func_$test },"
done
cat <<EOF
{ 0, 0 }
};
#define WINETEST_WANT_MAIN
#include "wine/test.h"
EOF
/*
* Generate a C file containing a list of tests
*
* Copyright 2002, 2005 Alexandre Julliard
* Copyright 2002 Dimitrie O. Paun
* Copyright 2005 Royce Mitchell III for the ReactOS Project
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
****** Keep in sync with tools/winapi/msvcmaker:_generate_testlist_c *****
*/
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
static const char *output_file;
static void fatal_error( const char *msg, ... )
{
va_list valist;
va_start( valist, msg );
fprintf( stderr, "make_ctests: " );
vfprintf( stderr, msg, valist );
va_end( valist );
if (output_file) unlink( output_file );
exit(1);
}
static void fatal_perror( const char *msg, ... )
{
va_list valist;
va_start( valist, msg );
fprintf( stderr, "make_ctests: " );
vfprintf( stderr, msg, valist );
perror( " " );
va_end( valist );
exit(1);
}
static void *xmalloc( size_t size )
{
void *res = malloc (size ? size : 1);
if (!res) fatal_error( "virtual memory exhausted.\n" );
return res;
}
static char* basename( const char* filename )
{
const char *p, *p2;
char *out;
size_t out_len;
p = strrchr ( filename, '/' );
if ( !p )
p = filename;
else
++p;
/* look for backslashes, too... */
p2 = strrchr ( p, '\\' );
if ( p2 ) p = p2 + 1;
/* find extension... */
p2 = strrchr ( p, '.' );
if ( !p2 )
p2 = p + strlen(p);
/* malloc a copy */
out_len = p2-p;
out = xmalloc ( out_len+1 );
memcpy ( out, p, out_len );
out[out_len] = '\0';
return out;
}
int main( int argc, const char** argv )
{
int i, count = 0;
FILE *out = stdout;
char **tests = xmalloc( argc * sizeof(*tests) );
for (i = 1; i < argc; i++)
{
if (!strcmp( argv[i], "-o" ) && i < argc-1)
{
output_file = argv[++i];
continue;
}
tests[count++] = basename( argv[i] );
}
if (output_file)
{
if (!(out = fopen( output_file, "w" )))
fatal_perror( "cannot create %s", output_file );
}
fprintf( out,
"/* Automatically generated file; DO NOT EDIT!! */\n"
"\n"
"/* stdarg.h is needed for Winelib */\n"
"#include <stdarg.h>\n"
"#include <stdio.h>\n"
"#include <stdlib.h>\n"
"#include \"windef.h\"\n"
"#include \"winbase.h\"\n"
"\n" );
for (i = 0; i < count; i++) fprintf( out, "extern void func_%s(void);\n", tests[i] );
fprintf( out,
"\n"
"struct test\n"
"{\n"
" const char *name;\n"
" void (*func)(void);\n"
"};\n"
"\n"
"static const struct test winetest_testlist[] =\n"
"{\n" );
for (i = 0; i < count; i++) fprintf( out, " { \"%s\", func_%s },\n", tests[i], tests[i] );
fprintf( out,
" { 0, 0 }\n"
"};\n"
"\n"
"#define WINETEST_WANT_MAIN\n"
"#include \"wine/test.h\"\n" );
if (output_file && fclose( out ))
fatal_perror( "error writing to %s", output_file );
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment