mirror of git://gcc.gnu.org/git/gcc.git
checksums and test-text
* fixincl.tpl: add a check sum acceptance test * fixlib.h: enumerate it * fixincl.c: handle it * README: document it and document the handling of test_text From-SVN: r220215
This commit is contained in:
parent
040968a88a
commit
11c3a68e35
|
|
@ -1,3 +1,18 @@
|
||||||
|
2015-01-24 Bruce Korb <bkorb@gnu.org>
|
||||||
|
|
||||||
|
* README: add some clarification on use of test_text
|
||||||
|
|
||||||
|
2014-12-21 Bruce Korb <bkorb@gnu.org>
|
||||||
|
|
||||||
|
* fixincludes/fixincl.tpl: add handling for "sum" selection
|
||||||
|
criteria and clean up layout
|
||||||
|
* fixincludes/fixlib.h: enumerate TT_CKSUM test type
|
||||||
|
* fixincludes/fixincl.c (fix_applies): add code to handle
|
||||||
|
the new test type
|
||||||
|
(cksum_test): function to handle it
|
||||||
|
* fixincludes/README: doc it and remove explanations from
|
||||||
|
more than a decade ago.
|
||||||
|
|
||||||
2014-12-15 Uros Bizjak <ubizjak@gmail.com>
|
2014-12-15 Uros Bizjak <ubizjak@gmail.com>
|
||||||
|
|
||||||
* server.c (server_setup): Check return value of
|
* server.c (server_setup): Check return value of
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,4 @@
|
||||||
|
|
||||||
FIXINCLUDES OPERATION
|
|
||||||
=====================
|
|
||||||
|
|
||||||
See also: http://autogen.SourceForge.net/fixinc.html
|
|
||||||
|
|
||||||
The set of fixes required was distilled down to just the data required
|
|
||||||
to specify what needed to happen for each fix. Those data were edited
|
|
||||||
into a file named fixincludes/inclhack.def. A program called AutoGen
|
|
||||||
(http://autogen.SourceForge.net) uses these definitions to instantiate
|
|
||||||
several different templates that then produces code for a fixinclude
|
|
||||||
program (fixincl.x) and a shell script to test its functioning. On
|
|
||||||
certain platforms (viz. those that do not have functional bidirectional
|
|
||||||
pipes), the fixincl program is split into two. This should only concern
|
|
||||||
you on DOS and BeOS.
|
|
||||||
|
|
||||||
Regards,
|
|
||||||
Bruce <bkorb@gnu.org>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GCC MAINTAINER INFORMATION
|
GCC MAINTAINER INFORMATION
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
|
|
@ -48,6 +28,15 @@ To make your fix, you will need to do several things:
|
||||||
There is no real possibility that these fixes will fail.
|
There is no real possibility that these fixes will fail.
|
||||||
If they do, you will surely know straight away.
|
If they do, you will surely know straight away.
|
||||||
|
|
||||||
|
NOTE: "test_text" is interpreted by the shell as it gets
|
||||||
|
copied into the test header. THEREFORE you must quote
|
||||||
|
dollar sign characters and back quotes -- unless you mean
|
||||||
|
for them to be interpreted by the shell.
|
||||||
|
|
||||||
|
e.g. the math_huge_val_from_dbl_max test_text needs to
|
||||||
|
put text into both float.h and math.h, so it includes a
|
||||||
|
back-quoted script to add text to float.h.
|
||||||
|
|
||||||
5. Go into the fixincludes build directory and type, "make check".
|
5. Go into the fixincludes build directory and type, "make check".
|
||||||
You are guaranteed to have issues printed out as a result.
|
You are guaranteed to have issues printed out as a result.
|
||||||
Look at the diffs produced. Make sure you have not clobbered
|
Look at the diffs produced. Make sure you have not clobbered
|
||||||
|
|
@ -82,7 +71,7 @@ MAKING CHANGES TO INCLHACK.DEF
|
||||||
3. It is relatively expensive to fire off a process to fix a source
|
3. It is relatively expensive to fire off a process to fix a source
|
||||||
file, therefore write apply tests to avoid unnecessary fix
|
file, therefore write apply tests to avoid unnecessary fix
|
||||||
processes. The preferred apply tests are "select", "bypass", "mach"
|
processes. The preferred apply tests are "select", "bypass", "mach"
|
||||||
and "c-test" because they are performed internally:
|
"sum", and "c-test" because they are performed internally:
|
||||||
|
|
||||||
* select - Run a regex on the contents of the file being considered.
|
* select - Run a regex on the contents of the file being considered.
|
||||||
All such regex-es must match. Matching is done with
|
All such regex-es must match. Matching is done with
|
||||||
|
|
@ -91,6 +80,19 @@ MAKING CHANGES TO INCLHACK.DEF
|
||||||
* bypass - Run a regex on the contents of the file being considered.
|
* bypass - Run a regex on the contents of the file being considered.
|
||||||
No such regex may match.
|
No such regex may match.
|
||||||
|
|
||||||
|
* sum - Select a specific version of a file that has a matching
|
||||||
|
check sum. The BSD version of checksum ["sum(1BSD)"]
|
||||||
|
is used. Each "sum" entry should contain exactly three
|
||||||
|
space separated tokens: the sum, some number and the
|
||||||
|
basename of the file. The "some number" is ignored.
|
||||||
|
If there are multiple "sum" entries, only one needs to
|
||||||
|
match in order to pass. For example:
|
||||||
|
|
||||||
|
sum = '1234 3 foobar.h';
|
||||||
|
|
||||||
|
specifies that the "foobar.h" header in any directory
|
||||||
|
will match if it has the checksum 1234.
|
||||||
|
|
||||||
* c_test - call a function in fixtests.c. See that file.
|
* c_test - call a function in fixtests.c. See that file.
|
||||||
|
|
||||||
* files - the "fnmatch" pattern of the file(s) to examine for
|
* files - the "fnmatch" pattern of the file(s) to examine for
|
||||||
|
|
|
||||||
|
|
@ -597,6 +597,63 @@ egrep_test (char* pz_data, tTestDesc* p_test)
|
||||||
return SKIP_FIX;
|
return SKIP_FIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* * * * * * * * * * * * *
|
||||||
|
|
||||||
|
cksum_test check the sum of the candidate file
|
||||||
|
Input: the original file contents and the file name
|
||||||
|
Result: APPLY_FIX if the check sum matches, SKIP_FIX otherwise
|
||||||
|
|
||||||
|
The caller may choose to reverse meaning if the sense of the test
|
||||||
|
is inverted. */
|
||||||
|
|
||||||
|
static int
|
||||||
|
cksum_test (char * pz_data, tTestDesc * p_test, char * fname)
|
||||||
|
{
|
||||||
|
unsigned int cksum;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Testing is off in normal operation mode.
|
||||||
|
* So, in testing mode, APPLY_FIX is always returned.
|
||||||
|
*/
|
||||||
|
if (fixinc_mode != TESTING_OFF)
|
||||||
|
return APPLY_FIX;
|
||||||
|
|
||||||
|
{
|
||||||
|
char * fnm = strrchr(fname, '/');
|
||||||
|
if (fnm != NULL)
|
||||||
|
fname = fnm + 1;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
cksum = (unsigned int)strtoul(p_test->pz_test_text, &fnm, 10);
|
||||||
|
if (errno != 0)
|
||||||
|
return SKIP_FIX;
|
||||||
|
|
||||||
|
if (! ISSPACE(*fnm++))
|
||||||
|
return SKIP_FIX;
|
||||||
|
while (ISSPACE(*fnm)) fnm++;
|
||||||
|
|
||||||
|
if (! ISDIGIT(*fnm++))
|
||||||
|
return SKIP_FIX;
|
||||||
|
while (ISDIGIT(*fnm)) fnm++;
|
||||||
|
|
||||||
|
if (! ISSPACE(*fnm++))
|
||||||
|
return SKIP_FIX;
|
||||||
|
while (ISSPACE(*fnm)) fnm++;
|
||||||
|
|
||||||
|
if (strcmp(fnm, fname) != 0)
|
||||||
|
return SKIP_FIX;
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
unsigned int sum = 0;
|
||||||
|
while (*pz_data != NUL) {
|
||||||
|
sum = (sum >> 1) + ((sum & 1) << 15) + (unsigned)(*pz_data++);
|
||||||
|
sum &= 0xFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (sum == cksum) ? APPLY_FIX : SKIP_FIX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* * * * * * * * * * * * *
|
/* * * * * * * * * * * * *
|
||||||
|
|
||||||
|
|
@ -1007,7 +1064,15 @@ start_fixer (int read_fd, tFixDesc* p_fixd, char* pz_fix_file)
|
||||||
return read_fd;
|
return read_fd;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef DEBUG
|
||||||
|
# define NOTE_SKIP(_ttyp) do { \
|
||||||
|
if (VLEVEL( VERB_EVERYTHING )) \
|
||||||
|
fprintf (stderr, z_failed, _ttyp, p_fixd->fix_name, \
|
||||||
|
pz_fname, p_fixd->test_ct - test_ct); \
|
||||||
|
} while (0)
|
||||||
|
#else
|
||||||
|
# define NOTE_SKIP(_ttyp)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* * * * * * * * * * * * *
|
/* * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
|
|
@ -1022,6 +1087,8 @@ fix_applies (tFixDesc* p_fixd)
|
||||||
const char *pz_scan = p_fixd->file_list;
|
const char *pz_scan = p_fixd->file_list;
|
||||||
int test_ct;
|
int test_ct;
|
||||||
tTestDesc *p_test;
|
tTestDesc *p_test;
|
||||||
|
t_bool saw_sum_test = BOOL_FALSE;
|
||||||
|
t_bool one_sum_passed = BOOL_FALSE;
|
||||||
|
|
||||||
#ifdef SEPARATE_FIX_PROC
|
#ifdef SEPARATE_FIX_PROC
|
||||||
/*
|
/*
|
||||||
|
|
@ -1055,6 +1122,7 @@ fix_applies (tFixDesc* p_fixd)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FOR each test, see if it fails.
|
/* FOR each test, see if it fails.
|
||||||
|
"sum" fails only if all "sum" tests fail.
|
||||||
IF it does fail, then we go on to the next test */
|
IF it does fail, then we go on to the next test */
|
||||||
|
|
||||||
for (p_test = p_fixd->p_test_desc, test_ct = p_fixd->test_ct;
|
for (p_test = p_fixd->p_test_desc, test_ct = p_fixd->test_ct;
|
||||||
|
|
@ -1065,52 +1133,51 @@ fix_applies (tFixDesc* p_fixd)
|
||||||
{
|
{
|
||||||
case TT_TEST:
|
case TT_TEST:
|
||||||
if (test_test (p_test, pz_curr_file) != APPLY_FIX) {
|
if (test_test (p_test, pz_curr_file) != APPLY_FIX) {
|
||||||
#ifdef DEBUG
|
NOTE_SKIP("TEST");
|
||||||
if (VLEVEL( VERB_EVERYTHING ))
|
|
||||||
fprintf (stderr, z_failed, "TEST", p_fixd->fix_name,
|
|
||||||
pz_fname, p_fixd->test_ct - test_ct);
|
|
||||||
#endif
|
|
||||||
return BOOL_FALSE;
|
return BOOL_FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TT_EGREP:
|
case TT_EGREP:
|
||||||
if (egrep_test (pz_curr_data, p_test) != APPLY_FIX) {
|
if (egrep_test (pz_curr_data, p_test) != APPLY_FIX) {
|
||||||
#ifdef DEBUG
|
NOTE_SKIP("EGREP");
|
||||||
if (VLEVEL( VERB_EVERYTHING ))
|
|
||||||
fprintf (stderr, z_failed, "EGREP", p_fixd->fix_name,
|
|
||||||
pz_fname, p_fixd->test_ct - test_ct);
|
|
||||||
#endif
|
|
||||||
return BOOL_FALSE;
|
return BOOL_FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TT_NEGREP:
|
case TT_NEGREP:
|
||||||
if (egrep_test (pz_curr_data, p_test) == APPLY_FIX) {
|
if (egrep_test (pz_curr_data, p_test) == APPLY_FIX) {
|
||||||
#ifdef DEBUG
|
NOTE_SKIP("NEGREP");
|
||||||
if (VLEVEL( VERB_EVERYTHING ))
|
|
||||||
fprintf (stderr, z_failed, "NEGREP", p_fixd->fix_name,
|
|
||||||
pz_fname, p_fixd->test_ct - test_ct);
|
|
||||||
#endif
|
|
||||||
/* Negated sense */
|
/* Negated sense */
|
||||||
return BOOL_FALSE;
|
return BOOL_FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case TT_CKSUM:
|
||||||
|
if (one_sum_passed)
|
||||||
|
break; // no need to check any more.
|
||||||
|
|
||||||
|
saw_sum_test = BOOL_TRUE;
|
||||||
|
if (cksum_test (pz_curr_data, p_test, pz_curr_file) != APPLY_FIX) {
|
||||||
|
NOTE_SKIP("CKSUM");
|
||||||
|
} else {
|
||||||
|
one_sum_passed = BOOL_TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case TT_FUNCTION:
|
case TT_FUNCTION:
|
||||||
if (run_test (p_test->pz_test_text, pz_curr_file, pz_curr_data)
|
if (run_test (p_test->pz_test_text, pz_curr_file, pz_curr_data)
|
||||||
!= APPLY_FIX) {
|
!= APPLY_FIX) {
|
||||||
#ifdef DEBUG
|
NOTE_SKIP("FTEST");
|
||||||
if (VLEVEL( VERB_EVERYTHING ))
|
|
||||||
fprintf (stderr, z_failed, "FTEST", p_fixd->fix_name,
|
|
||||||
pz_fname, p_fixd->test_ct - test_ct);
|
|
||||||
#endif
|
|
||||||
return BOOL_FALSE;
|
return BOOL_FALSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (saw_sum_test)
|
||||||
|
return one_sum_passed;
|
||||||
|
|
||||||
return BOOL_TRUE;
|
return BOOL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
[= AutoGen5 Template -*- Mode: C -*-
|
[= AutoGen5 Template -*- Mode: C -*-
|
||||||
x=fixincl.x =]
|
x=fixincl.x =]
|
||||||
[= (dne " * " "/* ")=]
|
[=
|
||||||
|
(if (version-compare >= autogen-version "5.18")
|
||||||
|
(dne "-D" " * " "/* ")
|
||||||
|
(dne " * " "/* ") ) =]
|
||||||
*/
|
*/
|
||||||
/* DO NOT SVN-MERGE THIS FILE, EITHER [=
|
/* DO NOT SVN-MERGE THIS FILE, EITHER [=
|
||||||
(define re-ct 0) (define max-mach 0) (define ct 0)
|
(define re-ct 0) (define max-mach 0) (define ct 0)
|
||||||
|
|
@ -114,6 +117,20 @@ tSCC z[=(. Hack)=]Bypass[=(for-index)=][] =
|
||||||
ENDFOR bypass =][=
|
ENDFOR bypass =][=
|
||||||
ENDIF =][=
|
ENDIF =][=
|
||||||
|
|
||||||
|
IF (exist? "sum")=][=
|
||||||
|
(if (not (exist? "files"))
|
||||||
|
(error "specifying a 'sum' requires specifying 'files'"))
|
||||||
|
=]
|
||||||
|
|
||||||
|
/*
|
||||||
|
* file selection - do fix if checksum matches
|
||||||
|
*/[=
|
||||||
|
FOR sum =]
|
||||||
|
tSCC z[=(. Hack)=]Sum[=(for-index)=][] =
|
||||||
|
[=(kr-string (get "sum"))=];[=
|
||||||
|
ENDFOR sum =][=
|
||||||
|
ENDIF =][=
|
||||||
|
|
||||||
IF (exist? "test") =]
|
IF (exist? "test") =]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -162,7 +179,11 @@ static tTestDesc a[=(. Hack)=]Tests[] = {[=
|
||||||
|
|
||||||
FOR select =]
|
FOR select =]
|
||||||
{ TT_EGREP, z[=(. Hack)=]Select[=(for-index)=], (regex_t*)NULL },[=
|
{ TT_EGREP, z[=(. Hack)=]Select[=(for-index)=], (regex_t*)NULL },[=
|
||||||
ENDFOR select =] };[=
|
ENDFOR select =][=
|
||||||
|
|
||||||
|
FOR sum =]
|
||||||
|
{ TT_CKSUM, z[=(. Hack)=]Sum[=(for-index)=], 0 /* unused */ },[=
|
||||||
|
ENDFOR sum =] };[=
|
||||||
ENDIF =]
|
ENDIF =]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@
|
||||||
*
|
*
|
||||||
* DO NOT EDIT THIS FILE (fixincl.x)
|
* DO NOT EDIT THIS FILE (fixincl.x)
|
||||||
*
|
*
|
||||||
* It has been AutoGen-ed October 21, 2014 at 10:18:16 AM by AutoGen 5.16.2
|
* It has been AutoGen-ed December 20, 2014 at 03:22:33 PM by AutoGen 5.18.5pre6
|
||||||
* From the definitions inclhack.def
|
* From the definitions inclhack.def
|
||||||
* and the template file fixincl
|
* and the template file fixincl
|
||||||
*/
|
*/
|
||||||
/* DO NOT SVN-MERGE THIS FILE, EITHER Tue Oct 21 10:18:17 CEST 2014
|
/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Dec 20 15:22:33 PST 2014
|
||||||
*
|
*
|
||||||
* You must regenerate it. Use the ./genfixes script.
|
* You must regenerate it. Use the ./genfixes script.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -161,7 +161,7 @@ ENV_TABLE
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION
|
TT_TEST, TT_EGREP, TT_NEGREP, TT_FUNCTION, TT_CKSUM
|
||||||
} te_test_type;
|
} te_test_type;
|
||||||
|
|
||||||
typedef struct test_desc tTestDesc;
|
typedef struct test_desc tTestDesc;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue