Index: trunk/src/regression/strflags/tester.ref =================================================================== --- trunk/src/regression/strflags/tester.ref (revision 2203) +++ trunk/src/regression/strflags/tester.ref (nonexistent) @@ -1,17 +0,0 @@ - 0 : (0) = 1 - 1 : (0) = 1 - 2 : (0,2) = 1 0 1 - 3 : (0,2,3) = 1 0 1 1 - 4 : (0,2,3) = 1 0 1 1 - 5 : (0,2,3) = 1 0 1 1 - 6 : (0,2,3,6) = 1 0 1 1 0 0 1 - 7 : (0,2,3,6,7) = 1 0 1 1 0 0 1 1 - 8 : (0,2,3,6-8) = 1 0 1 1 0 0 1 1 1 - 9 : (0,2,3,6-8) = 1 0 1 1 0 0 1 1 1 -10 : (0,2,3,6-8,10) = 1 0 1 1 0 0 1 1 1 0 1 -11 : (0,2,3,6-8,10,11) = 1 0 1 1 0 0 1 1 1 0 1 1 -12 : (0,2,3,6-8,10-12) = 1 0 1 1 0 0 1 1 1 0 1 1 1 -13 : (0,2,3,6-8,10-13) = 1 0 1 1 0 0 1 1 1 0 1 1 1 1 -14 : (0,2,3,6-8,10-14) = 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 -15 : (0,2,3,6-8,10-15) = 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 -0 out of 1000000 failed Index: trunk/src/regression/strflags/tester.c =================================================================== --- trunk/src/regression/strflags/tester.c (revision 2203) +++ trunk/src/regression/strflags/tester.c (nonexistent) @@ -1,160 +0,0 @@ -/* $Id$ */ -/* - * COPYRIGHT - * - * PCB, interactive printed circuit board design - * Copyright (C) 2005 DJ Delorie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Contact addresses for paper mail and Email: - * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA - * dj@delorie.com - * - */ -#include -#include -#include -#include -#include - -#define FLAG_TEST -#include "strflags.c" - -static void dump_flag(FlagType * f) -{ - int l; - printf("F:%08x T:[", f->f); - for (l = 0; l < (MAX_LAYER + 7) / 8; l++) - printf(" %02x", f->t[l]); - printf("]"); -} - - -int mem_any_set(unsigned char *ptr, int bytes) -{ - while (bytes--) - if (*ptr++) - return 1; - return 0; -} - -int main() -{ - time_t now; - int i; - int errors = 0, count = 0; - - time(&now); - srandom((unsigned int) now + getpid()); - - grow_layer_list(0); - for (i = 0; i < 16; i++) { - int j; - char *p; - if (i != 1 && i != 4 && i != 5 && i != 9) - set_layer_list(i, 1); - else - set_layer_list(i, 0); - p = print_layer_list(); - printf("%2d : %20s =", i, p); - parse_layer_list(p + 1, 0); - for (j = 0; j < num_layers; j++) - printf(" %d", layers[j]); - printf("\n"); - } - - while (count < 1000000) { - FlagHolder fh; - char *str; - FlagType new_flags; - int i; - int otype; - - otype = ALL_TYPES; - fh.Flags = empty_flags; - for (i = 0; i < ENTRIES(object_flagbits); i++) { - if (TEST_FLAG(object_flagbits[i].mask, &fh)) - continue; - if ((otype & object_flagbits[i].object_types) == 0) - continue; - if ((random() & 4) == 0) - continue; - - otype &= object_flagbits[i].object_types; - SET_FLAG(object_flagbits[i].mask, &fh); - } - - if (otype & PIN_TYPES) - for (i = 0; i < MAX_LAYER; i++) - if (random() & 4) - ASSIGN_THERM(i, 3, &fh); - - str = flags_to_string(fh.Flags, otype); - new_flags = string_to_flags(str, 0); - - count++; - if (FLAGS_EQUAL(fh.Flags, new_flags)) - continue; - dump_flag(&fh.Flags); - printf(" "); - dump_flag(&new_flags); - printf("\n"); - if (++errors == 5) - goto bad; - } - - while (count < 1000000) { - FlagHolder fh; - char *str; - FlagType new_flags; - int i; - int otype; - - otype = ALL_TYPES; - fh.Flags = empty_flags; - for (i = 0; i < ENTRIES(pcb_flagbits); i++) { - if (TEST_FLAG(pcb_flagbits[i].mask, &fh)) - continue; - if ((random() & 4) == 0) - continue; - - otype &= pcb_flagbits[i].object_types; - SET_FLAG(pcb_flagbits[i].mask, &fh); - } - - str = pcbflags_to_string(fh.Flags); - new_flags = string_to_pcbflags(str, 0); - - count++; - if (FLAGS_EQUAL(fh.Flags, new_flags)) - continue; - - dump_flag(&fh.Flags); - printf(" "); - dump_flag(&new_flags); - printf("\n"); - - if (++errors == 5) - goto bad; - } - printf("%d out of %d failed\n", errors, count); - return errors; - - bad:; - printf("%d out of %d FAILED\n", errors, count); - return errors; -} - Index: trunk/src/regression/strflags/Makefile =================================================================== --- trunk/src/regression/strflags/Makefile (revision 2203) +++ trunk/src/regression/strflags/Makefile (nonexistent) @@ -1,27 +0,0 @@ -CFLAGS_OP = -O3 -CFLAGS = -g \ - -I../.. -I../../.. -I../../../src_3rd - -GDS= ../../../src_3rd/genvector/gds_char.o - -all: test - -test: tester.diff - @echo "*** all ok, QC PASS ***" - -tester: tester.o $(GDS) - -tester.o: tester.c - $(CC) -c $(CFLAGS) -o $@ tester.c - -tester.stdout: tester - ./tester > tester.stdout && rm tester.stdout - -tester.diff: tester.stdout - diff -u tester.ref tester.stdout - -../../strflags.o: ../../strflags.c ../../strflags.h - -clean: - rm tester tester.o 2>/dev/null ; true - Index: trunk/tests/Makefile =================================================================== --- trunk/tests/Makefile (revision 2203) +++ trunk/tests/Makefile (revision 2204) @@ -1,4 +1,4 @@ test: - cd pcbflags && make test - cd conf && make test - \ No newline at end of file + cd pcbflags && make all && make test + cd conf && make all && make test + cd strflags && make all && make test Index: trunk/tests/pcbflags/Makefile =================================================================== --- trunk/tests/pcbflags/Makefile (revision 2203) +++ trunk/tests/pcbflags/Makefile (revision 2204) @@ -1,2 +1,4 @@ +all: + test: @./test.sh Index: trunk/tests/strflags/Makefile =================================================================== --- trunk/tests/strflags/Makefile (nonexistent) +++ trunk/tests/strflags/Makefile (revision 2204) @@ -0,0 +1,25 @@ +TRUNK=../.. +IO=$(TRUNK)/src_plugins/io_pcb +CFLAGS = -O3 -I$(TRUNK) -I$(TRUNK)/src -I$(IO) -I$(TRUNK)/src_3rd +GDS= $(TRUNK)/src_3rd/genvector/gds_char.o + +all: tester + +test: tester.diff + @echo "*** all ok, QC PASS ***" + @rm tester.stdout + +tester: tester.o $(GDS) + +tester.o: tester.c + $(CC) -c $(CFLAGS) -o $@ tester.c + +tester.stdout: tester + ./tester > tester.stdout + +tester.diff: tester.stdout + diff -u tester.ref tester.stdout + +clean: + rm tester tester.o 2>/dev/null ; true + Index: trunk/tests/strflags/tester.c =================================================================== --- trunk/tests/strflags/tester.c (nonexistent) +++ trunk/tests/strflags/tester.c (revision 2204) @@ -0,0 +1,161 @@ +/* $Id$ */ +/* + * COPYRIGHT + * + * PCB, interactive printed circuit board design + * Copyright (C) 2005 DJ Delorie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Contact addresses for paper mail and Email: + * DJ Delorie, 334 North Road, Deerfield NH 03037-1110, USA + * dj@delorie.com + * + */ +#include +#include +#include +#include +#include + +#define FLAG_TEST +#include "strflags.c" +#include "flags.c" + +static void dump_flag(FlagType * f) +{ + int l; + printf("F:%08x T:[", f->f); + for (l = 0; l < (MAX_LAYER + 7) / 8; l++) + printf(" %02x", f->t[l]); + printf("]"); +} + + +int mem_any_set(unsigned char *ptr, int bytes) +{ + while (bytes--) + if (*ptr++) + return 1; + return 0; +} + +int main() +{ + time_t now; + int i; + int errors = 0, count = 0; + + time(&now); + srandom((unsigned int) now + getpid()); + + grow_layer_list(0); + for (i = 0; i < 16; i++) { + int j; + char *p; + if (i != 1 && i != 4 && i != 5 && i != 9) + set_layer_list(i, 1); + else + set_layer_list(i, 0); + p = print_layer_list(); + printf("%2d : %20s =", i, p); + parse_layer_list(p + 1, 0); + for (j = 0; j < num_layers; j++) + printf(" %d", layers[j]); + printf("\n"); + } + + while (count < 1000000) { + FlagHolder fh; + char *str; + FlagType new_flags; + int i; + int otype; + + otype = ALL_TYPES; + fh.Flags = empty_flags; + for (i = 0; i < ENTRIES(object_flagbits); i++) { + if (TEST_FLAG(object_flagbits[i].mask, &fh)) + continue; + if ((otype & object_flagbits[i].object_types) == 0) + continue; + if ((random() & 4) == 0) + continue; + + otype &= object_flagbits[i].object_types; + SET_FLAG(object_flagbits[i].mask, &fh); + } + + if (otype & PIN_TYPES) + for (i = 0; i < MAX_LAYER; i++) + if (random() & 4) + ASSIGN_THERM(i, 3, &fh); + + str = flags_to_string(fh.Flags, otype); + new_flags = string_to_flags(str, 0); + + count++; + if (FLAGS_EQUAL(fh.Flags, new_flags)) + continue; + dump_flag(&fh.Flags); + printf(" "); + dump_flag(&new_flags); + printf("\n"); + if (++errors == 5) + goto bad; + } + + while (count < 1000000) { + FlagHolder fh; + char *str; + FlagType new_flags; + int i; + int otype; + + otype = ALL_TYPES; + fh.Flags = empty_flags; + for (i = 0; i < ENTRIES(pcb_flagbits); i++) { + if (TEST_FLAG(pcb_flagbits[i].mask, &fh)) + continue; + if ((random() & 4) == 0) + continue; + + otype &= pcb_flagbits[i].object_types; + SET_FLAG(pcb_flagbits[i].mask, &fh); + } + + str = pcbflags_to_string(fh.Flags); + new_flags = string_to_pcbflags(str, 0); + + count++; + if (FLAGS_EQUAL(fh.Flags, new_flags)) + continue; + + dump_flag(&fh.Flags); + printf(" "); + dump_flag(&new_flags); + printf("\n"); + + if (++errors == 5) + goto bad; + } + printf("%d out of %d failed\n", errors, count); + return errors; + + bad:; + printf("%d out of %d FAILED\n", errors, count); + return errors; +} + Index: trunk/tests/strflags/tester.ref =================================================================== --- trunk/tests/strflags/tester.ref (nonexistent) +++ trunk/tests/strflags/tester.ref (revision 2204) @@ -0,0 +1,17 @@ + 0 : (0) = 1 + 1 : (0) = 1 + 2 : (0,2) = 1 0 1 + 3 : (0,2,3) = 1 0 1 1 + 4 : (0,2,3) = 1 0 1 1 + 5 : (0,2,3) = 1 0 1 1 + 6 : (0,2,3,6) = 1 0 1 1 0 0 1 + 7 : (0,2,3,6,7) = 1 0 1 1 0 0 1 1 + 8 : (0,2,3,6-8) = 1 0 1 1 0 0 1 1 1 + 9 : (0,2,3,6-8) = 1 0 1 1 0 0 1 1 1 +10 : (0,2,3,6-8,10) = 1 0 1 1 0 0 1 1 1 0 1 +11 : (0,2,3,6-8,10,11) = 1 0 1 1 0 0 1 1 1 0 1 1 +12 : (0,2,3,6-8,10-12) = 1 0 1 1 0 0 1 1 1 0 1 1 1 +13 : (0,2,3,6-8,10-13) = 1 0 1 1 0 0 1 1 1 0 1 1 1 1 +14 : (0,2,3,6-8,10-14) = 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 +15 : (0,2,3,6-8,10-15) = 1 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 +0 out of 1000000 failed