From: Dale Weiler Date: Wed, 30 Jan 2013 08:04:56 +0000 (+0000) Subject: Added definition file for test-suite, used by default by the test system. To overrid... X-Git-Tag: before-library~181 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a1fac665873519b137764119e6d57e3bf9b324f5;p=xonotic%2Fgmqcc.git Added definition file for test-suite, used by default by the test system. To override the defs globally, use -defs=file from the command line for the test-suite. To override the defs per-file, use F: -no-defs flag in the test template file. --- diff --git a/Makefile b/Makefile index 25828d1..e31c098 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ endif #turn on tons of warnings if clang is present # but also turn off the STUPID ONES ifeq ($(CC), clang) - CFLAGS += \ + CFLAGS += \ -Weverything \ -Wno-padded \ -Wno-format-nonliteral \ diff --git a/test.c b/test.c index be82324..5e99df4 100644 --- a/test.c +++ b/test.c @@ -311,6 +311,9 @@ int task_pclose(FILE **handles) { * Used to set the compilation flags for the given task, this * must be provided, this tag is NOT optional. * + * F: Used to set some test suite flags, currently the only option + * is -no-defs (to including of defs.qh) + * * E: * Used to set the execution flags for the given task. This tag * must be provided if T == -execute, otherwise it's erroneous @@ -350,6 +353,7 @@ typedef struct { char *tempfilename; char **comparematch; char *rulesfile; + char *testflags; } task_template_t; /* @@ -369,6 +373,7 @@ bool task_template_generate(task_template_t *template, char tag, const char *fil case 'C': destval = &template->compileflags; break; case 'E': destval = &template->executeflags; break; case 'I': destval = &template->sourcefile; break; + case 'F': destval = &template->testflags; break; default: con_printmsg(LVL_ERROR, __FILE__, __LINE__, "internal error", "invalid tag `%c:` during code generation\n", @@ -475,6 +480,7 @@ bool task_template_parse(const char *file, task_template_t *template, FILE *fp, case 'C': case 'E': case 'I': + case 'F': if (data[1] != ':') { con_printmsg(LVL_ERROR, file, line, "template parse error", "expected `:` after `%c`", @@ -561,6 +567,7 @@ void task_template_nullify(task_template_t *template) { template->sourcefile = NULL; template->tempfilename = NULL; template->rulesfile = NULL; + template->testflags = NULL; } task_template_t *task_template_compile(const char *file, const char *dir, size_t *pad) { @@ -682,6 +689,7 @@ void task_template_destroy(task_template_t **template) { if ((*template)->executeflags) mem_d((*template)->executeflags); if ((*template)->sourcefile) mem_d((*template)->sourcefile); if ((*template)->rulesfile) mem_d((*template)->rulesfile); + if ((*template)->testflags) mem_d((*template)->testflags); /* * Delete all allocated string for task template then destroy the @@ -722,7 +730,7 @@ task_t *task_tasks = NULL; * Read a directory and searches for all template files in it * which is later used to run all tests. */ -bool task_propagate(const char *curdir, size_t *pad) { +bool task_propagate(const char *curdir, size_t *pad, const char *defs) { bool success = true; DIR *dir; struct dirent *files; @@ -782,22 +790,47 @@ bool task_propagate(const char *curdir, size_t *pad) { */ memset (buf,0,sizeof(buf)); if (qcflags) { - snprintf(buf, sizeof(buf), "%s %s/%s %s %s -o %s", - task_bins[TASK_COMPILE], - curdir, - template->sourcefile, - qcflags, - template->compileflags, - template->tempfilename - ); + if (template->testflags && !strcmp(template->testflags, "-no-defs")) { + snprintf(buf, sizeof(buf), "%s %s/%s %s %s -o %s", + task_bins[TASK_COMPILE], + curdir, + template->sourcefile, + qcflags, + template->compileflags, + template->tempfilename + ); + } else { + snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s %s -o %s", + task_bins[TASK_COMPILE], + curdir, + defs, + curdir, + template->sourcefile, + qcflags, + template->compileflags, + template->tempfilename + ); + } } else { - snprintf(buf, sizeof(buf), "%s %s/%s %s -o %s", - task_bins[TASK_COMPILE], - curdir, - template->sourcefile, - template->compileflags, - template->tempfilename - ); + if (template->testflags && !strcmp(template->testflags, "-no-defs")) { + snprintf(buf, sizeof(buf), "%s %s/%s %s -o %s", + task_bins[TASK_COMPILE], + curdir, + template->sourcefile, + template->compileflags, + template->tempfilename + ); + } else { + snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s -o %s", + task_bins[TASK_COMPILE], + curdir, + defs, + curdir, + template->sourcefile, + template->compileflags, + template->tempfilename + ); + } } /* @@ -1165,13 +1198,24 @@ void task_schedualize(size_t *pad) { * * It expects con_init() was called before hand. */ -GMQCC_WARN bool test_perform(const char *curdir) { +GMQCC_WARN bool test_perform(const char *curdir, const char *defs) { + static const char *default_defs = "defs.qh"; + size_t pad[] = { 0, 0 }; + /* + * If the default definition file isn't set to anything. We will + * use the default_defs here, which is "defs.qc" + */ + if (!defs) { + defs = default_defs; + } + + task_precleanup(curdir); - if (!task_propagate(curdir, pad)) { + if (!task_propagate(curdir, pad, defs)) { con_err("error: failed to propagate tasks\n"); task_destroy(); return false; @@ -1223,6 +1267,7 @@ int main(int argc, char **argv) { bool succeed = false; char *redirout = (char*)stdout; char *redirerr = (char*)stderr; + char *defs = NULL; con_init(); @@ -1239,6 +1284,8 @@ int main(int argc, char **argv) { continue; if (parsecmd("redirerr", &argc, &argv, &redirerr, 1, false)) continue; + if (parsecmd("defs", &argc, &argv, &defs, 1, false)) + continue; con_change(redirout, redirerr); @@ -1260,7 +1307,7 @@ int main(int argc, char **argv) { } } con_change(redirout, redirerr); - succeed = test_perform("tests"); + succeed = test_perform("tests", defs); util_meminfo(); diff --git a/tests/arrays.qc b/tests/arrays.qc index a3a84c1..2c8f9fe 100644 --- a/tests/arrays.qc +++ b/tests/arrays.qc @@ -1,7 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; -entity() spawn = #3; - float glob[7]; .float above; diff --git a/tests/break.qc b/tests/break.qc index 1a0fed1..46f1805 100644 --- a/tests/break.qc +++ b/tests/break.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - void test(float brkat, float contat) { float i; diff --git a/tests/builtin.qc b/tests/builtin.qc index 6e58644..06a1846 100644 --- a/tests/builtin.qc +++ b/tests/builtin.qc @@ -1,5 +1,3 @@ -void(string) print = #1; - void() main = { print("hello world"); } diff --git a/tests/calls.qc b/tests/calls.qc index e230dc4..7b09f11 100644 --- a/tests/calls.qc +++ b/tests/calls.qc @@ -1,6 +1,3 @@ -void(string, ...) print = #1; -string(float) ftos = #2; - float(float x, float y, float z) sum = { return x + y + z; }; diff --git a/tests/correct-logic.qc b/tests/correct-logic.qc index cb9a38d..a868424 100644 --- a/tests/correct-logic.qc +++ b/tests/correct-logic.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - float test_s_not (vector s) { return !s; } float test_s_and (vector s, vector t) { return s && t; } float test_s_or (vector s, vector t) { return s || t; } diff --git a/tests/correct-vs-short.qc b/tests/correct-vs-short.qc index 81f9b7a..e7cd2dc 100644 --- a/tests/correct-vs-short.qc +++ b/tests/correct-vs-short.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - void test(vector a, vector b) { print(ftos((a && b) + (a && b)), " "); print(ftos((a || b) + (a || b)), " "); diff --git a/tests/defs.qh b/tests/defs.qh new file mode 100644 index 0000000..830692c --- /dev/null +++ b/tests/defs.qh @@ -0,0 +1,18 @@ +// builtins for the standalone qcvm included with gmqcc +// in exec.c These should be updated to reflect the new +// builtins. I no event shall you even consider adding +// these individually per test. + +void (string, ...) print = #1; +string (float) ftos = #2; +entity () spawn = #3; +void (entity) kill = #4; +string (vector) vtos = #5; +void (string) error = #6; +float (vector) vlen = #7; +string (entity) etos = #8; +float (string) stof = #9; +string (...) strcat = #10; +float (string, string) strcmp = #11; +vector (vector) normalize = #12; +float (float) sqrt = #13; diff --git a/tests/enum.qc b/tests/enum.qc index 5218633..da08cee 100644 --- a/tests/enum.qc +++ b/tests/enum.qc @@ -27,8 +27,6 @@ enum { N }; -void (string, ...) print = #1; -string (float) ftos = #2; void main() { print(ftos(A), "\n"); print(ftos(B), "\n"); diff --git a/tests/equality.qc b/tests/equality.qc index bc134b0..95eccb8 100644 --- a/tests/equality.qc +++ b/tests/equality.qc @@ -1,6 +1,3 @@ -void(string, ...) print = #1; -string(float) ftos = #2; - void(float a, float b) main = { if (a == b) print("eq,"); if (a != b) print("ne,"); diff --git a/tests/fieldparams.qc b/tests/fieldparams.qc index 8e5cb03..eed2ed6 100644 --- a/tests/fieldparams.qc +++ b/tests/fieldparams.qc @@ -1,6 +1,3 @@ -void(string, string) print = #1; -entity() spawn = #3; - .string a; .string b; ..string ps; diff --git a/tests/functions-as-params.qc b/tests/functions-as-params.qc index 7790e64..22136b7 100644 --- a/tests/functions-as-params.qc +++ b/tests/functions-as-params.qc @@ -1,5 +1,3 @@ -void(string, string) print = #1; - string() getter = { return "correct"; }; diff --git a/tests/goto.qc b/tests/goto.qc index 7c9f297..9e6f30b 100644 --- a/tests/goto.qc +++ b/tests/goto.qc @@ -1,5 +1,3 @@ -void(string, ...) print = #1; - // correct execution order: // label_3 // label_2 diff --git a/tests/ifs.qc b/tests/ifs.qc index d3089ce..7a7f13c 100644 --- a/tests/ifs.qc +++ b/tests/ifs.qc @@ -1,5 +1,3 @@ -void(string, ...) print = #1; - void(float c) main = { if (c == 1) print("One\n"); diff --git a/tests/mul_vf.qc b/tests/mul_vf.qc index 3e60e23..0e8df52 100644 --- a/tests/mul_vf.qc +++ b/tests/mul_vf.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string vtos(vector) = #5; - // getter to work around future -O vector get(vector v) { return v; diff --git a/tests/ngraphs.qc b/tests/ngraphs.qc index 330d625..6e1a957 100644 --- a/tests/ngraphs.qc +++ b/tests/ngraphs.qc @@ -1,5 +1,3 @@ -void(...) print = %:1; - void() main = ??< print("??=??'??(??)??!????-??/??/%>|"); print("#^[]|{}~\\%>\n"); diff --git a/tests/noreturn.qc b/tests/noreturn.qc index e56cc88..ae614e7 100644 --- a/tests/noreturn.qc +++ b/tests/noreturn.qc @@ -2,8 +2,10 @@ #define NORETURN [[noreturn]] #endif -void print(...) = #1; -string ftos(float) = #2; +void (...) print = #1; +string (float) ftos = #2; + + NORETURN void error(...) = #6; #if TEST == 1 diff --git a/tests/noreturn1.tmpl b/tests/noreturn1.tmpl index 0f6aad1..f662da4 100644 --- a/tests/noreturn1.tmpl +++ b/tests/noreturn1.tmpl @@ -2,3 +2,4 @@ I: noreturn.qc D: noreturn keyword - should work T: -compile C: -std=fteqcc -Wall -Werror -DTEST=1 -DNORETURN=[[noreturn]] +F: -no-defs diff --git a/tests/noreturn2.tmpl b/tests/noreturn2.tmpl index 8d7ad09..d328c4f 100644 --- a/tests/noreturn2.tmpl +++ b/tests/noreturn2.tmpl @@ -2,3 +2,4 @@ I: noreturn.qc D: noreturn keyword - should fail T: -compile C: -std=fteqcc -Wall -Werror -DTEST=2 -DNORETURN=[[noreturn]] +F: -no-defs diff --git a/tests/noreturn3.tmpl b/tests/noreturn3.tmpl index 56c28b5..653bd8a 100644 --- a/tests/noreturn3.tmpl +++ b/tests/noreturn3.tmpl @@ -2,3 +2,4 @@ I: noreturn.qc D: noreturn keyword - should work T: -fail C: -std=fteqcc -Wall -Werror -DTEST=1 -DNORETURN +F: -no-defs diff --git a/tests/noreturn4.tmpl b/tests/noreturn4.tmpl index 18dc275..4d87c94 100644 --- a/tests/noreturn4.tmpl +++ b/tests/noreturn4.tmpl @@ -2,3 +2,4 @@ I: noreturn.qc D: noreturn keyword - should fail T: -fail C: -std=fteqcc -Wall -Werror -DTEST=2 -DNORETURN +F: -no-defs diff --git a/tests/operators.qc b/tests/operators.qc index 1ca6f67..46bd6bb 100644 --- a/tests/operators.qc +++ b/tests/operators.qc @@ -1,8 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; -string vtos (vector) = #5; -entity spawn() = #3; - .float mem; void main() { diff --git a/tests/param8.qc b/tests/param8.qc index 68e96f7..bdb868a 100644 --- a/tests/param8.qc +++ b/tests/param8.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos(float) = #2; - void p10(float a, float b, float c, float d, float e, float f, float g, float h, float e1, float e2) { diff --git a/tests/parens.qc b/tests/parens.qc index 1ae09a0..c4a369a 100644 --- a/tests/parens.qc +++ b/tests/parens.qc @@ -1,6 +1,3 @@ -void(string...) print = #1; -string(float) ftos = #2; - float arr[2]; string gets() { return "S\n"; } diff --git a/tests/perl-logic.qc b/tests/perl-logic.qc index 5b56c45..5c7f16b 100644 --- a/tests/perl-logic.qc +++ b/tests/perl-logic.qc @@ -1,5 +1,3 @@ -void print(...) = #1; - void main() { vector va, vb; string sa, sb; diff --git a/tests/pmacros.qc b/tests/pmacros.qc index 1ecee8c..1ec0780 100644 --- a/tests/pmacros.qc +++ b/tests/pmacros.qc @@ -28,7 +28,6 @@ # define ABC ALPHA(a)##ALPHA(b)##ALPHA(c) - void(string, ...) print = #1; void() main = { if (ABC == "abc") print("ABC\n"); diff --git a/tests/pointlife.qc b/tests/pointlife.qc index b37e62a..13bbde7 100644 --- a/tests/pointlife.qc +++ b/tests/pointlife.qc @@ -1,5 +1,3 @@ -void print(...) = #1; - var float foo = 0; void funcall() {} diff --git a/tests/pp_va_args.qc b/tests/pp_va_args.qc index 89a98c8..a42e192 100644 --- a/tests/pp_va_args.qc +++ b/tests/pp_va_args.qc @@ -1,5 +1,3 @@ -void print(...) = #1; - // method 0 #define METHOD__(...) __VA_ARGS__ #define METHOD_0(F,A) F METHOD__(A) diff --git a/tests/short-logic.qc b/tests/short-logic.qc index a62ed79..9dd0550 100644 --- a/tests/short-logic.qc +++ b/tests/short-logic.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos(float) = #2; - float glob1; float glob2; float glob3; diff --git a/tests/switch.qc b/tests/switch.qc index 1758c8a..2e9cf8e 100644 --- a/tests/switch.qc +++ b/tests/switch.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos(float) = #2; - void test(float param, float p2) { float i; float c80 = 80; diff --git a/tests/ternary.qc b/tests/ternary.qc index 242a240..bdac526 100644 --- a/tests/ternary.qc +++ b/tests/ternary.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - void test(float cond, float v1, float v2, float a) { print(ftos(cond ? v1 : v2), " "); print( (cond ? v1 : v2) ? ( (a == 1) ? "a=1" diff --git a/tests/truth-flags-2.qc b/tests/truth-flags-2.qc index 0c10708..7ac93a5 100644 --- a/tests/truth-flags-2.qc +++ b/tests/truth-flags-2.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - float test_s_not (string s) { return !s; } float test_s_and (string s, string t) { return s && t; } float test_s_or (string s, string t) { return s || t; } diff --git a/tests/truth.qc b/tests/truth.qc index e08bde8..9df6217 100644 --- a/tests/truth.qc +++ b/tests/truth.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - void test(string s) { print(ftos(!s)); if (s) print(" on"); diff --git a/tests/typedefs.qc b/tests/typedefs.qc index 79143fd..e9bc13b 100644 --- a/tests/typedefs.qc +++ b/tests/typedefs.qc @@ -1,4 +1,4 @@ -typedef void(string, ...) ptype; +typedef void(...) ptype; typedef string(float) funcsf; ptype print = #1; diff --git a/tests/typedefs.tmpl b/tests/typedefs.tmpl index 8c22ca4..2eb2253 100644 --- a/tests/typedefs.tmpl +++ b/tests/typedefs.tmpl @@ -3,3 +3,4 @@ D: typedefs T: -execute C: -std=fteqcc M: A typedeffed function, 0=0 +F: -no-defs diff --git a/tests/uninit.qc b/tests/uninit.qc index 3d75f07..d71721c 100644 --- a/tests/uninit.qc +++ b/tests/uninit.qc @@ -1,7 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; -string vtos (vector) = #5; - vector main(float a, vector vin) { vector v; diff --git a/tests/utf8.qc b/tests/utf8.qc index 4ca0348..f5a9255 100644 --- a/tests/utf8.qc +++ b/tests/utf8.qc @@ -1,6 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; - void main() { print("Sum: \{x2211} "); print("\{8721} "); diff --git a/tests/varargs.qc b/tests/varargs.qc index 89cb5b8..4b0d806 100644 --- a/tests/varargs.qc +++ b/tests/varargs.qc @@ -1,6 +1,3 @@ -void(string...) print = #1; -string(float) ftos = #2; - void nbva(float a, string...count) { print("You gave me ", ftos(count), " additional parameters\n"); print("First: ", ...(0, string), "\n"); diff --git a/tests/variadic.qc b/tests/variadic.qc index 27d938f..26f301b 100644 --- a/tests/variadic.qc +++ b/tests/variadic.qc @@ -1,5 +1,3 @@ -void(...) print = #1; - void() main = { print("hello", " world"); } diff --git a/tests/vec_ops.qc b/tests/vec_ops.qc index a5c80c9..ac84ffc 100644 --- a/tests/vec_ops.qc +++ b/tests/vec_ops.qc @@ -1,6 +1,3 @@ -void print(string...) = #1; -string vtos(vector) = #5; - void main(vector v) { print(vtos(v), "\n"); v /= 2; diff --git a/tests/vector-init.qc b/tests/vector-init.qc index 880bc39..41df059 100644 --- a/tests/vector-init.qc +++ b/tests/vector-init.qc @@ -1,7 +1,3 @@ -void print(...) = #1; -string ftos (float) = #2; -string vtos (vector) = #5; - void main() { vector v;