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.

This commit is contained in:
Dale Weiler 2013-01-30 08:04:56 +00:00
parent 9fffb3441c
commit a1fac66587
42 changed files with 95 additions and 112 deletions

View file

@ -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 \

85
test.c
View file

@ -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();

View file

@ -1,7 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
entity() spawn = #3;
float glob[7];
.float above;

View file

@ -1,6 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
void test(float brkat, float contat) {
float i;

View file

@ -1,5 +1,3 @@
void(string) print = #1;
void() main = {
print("hello world");
}

View file

@ -1,6 +1,3 @@
void(string, ...) print = #1;
string(float) ftos = #2;
float(float x, float y, float z) sum = {
return x + y + z;
};

View file

@ -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; }

View file

@ -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)), " ");

18
tests/defs.qh Normal file
View file

@ -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;

View file

@ -27,8 +27,6 @@ enum {
N
};
void (string, ...) print = #1;
string (float) ftos = #2;
void main() {
print(ftos(A), "\n");
print(ftos(B), "\n");

View file

@ -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,");

View file

@ -1,6 +1,3 @@
void(string, string) print = #1;
entity() spawn = #3;
.string a;
.string b;
..string ps;

View file

@ -1,5 +1,3 @@
void(string, string) print = #1;
string() getter = {
return "correct";
};

View file

@ -1,5 +1,3 @@
void(string, ...) print = #1;
// correct execution order:
// label_3
// label_2

View file

@ -1,5 +1,3 @@
void(string, ...) print = #1;
void(float c) main = {
if (c == 1)
print("One\n");

View file

@ -1,6 +1,3 @@
void print(...) = #1;
string vtos(vector) = #5;
// getter to work around future -O
vector get(vector v) {
return v;

View file

@ -1,5 +1,3 @@
void(...) print = %:1;
void() main = ??<
print("??=??'??(??)??!??<??>??-??/??/%>|");
print("#^[]|{}~\\%>\n");

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,8 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
string vtos (vector) = #5;
entity spawn() = #3;
.float mem;
void main() {

View file

@ -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)
{

View file

@ -1,6 +1,3 @@
void(string...) print = #1;
string(float) ftos = #2;
float arr[2];
string gets() { return "S\n"; }

View file

@ -1,5 +1,3 @@
void print(...) = #1;
void main() {
vector va, vb;
string sa, sb;

View file

@ -28,7 +28,6 @@
# define ABC ALPHA(a)##ALPHA(b)##ALPHA(c)
void(string, ...) print = #1;
void() main = {
if (ABC == "abc")
print("ABC\n");

View file

@ -1,5 +1,3 @@
void print(...) = #1;
var float foo = 0;
void funcall() {}

View file

@ -1,5 +1,3 @@
void print(...) = #1;
// method 0
#define METHOD__(...) __VA_ARGS__
#define METHOD_0(F,A) F METHOD__(A)

View file

@ -1,6 +1,3 @@
void print(...) = #1;
string ftos(float) = #2;
float glob1;
float glob2;
float glob3;

View file

@ -1,6 +1,3 @@
void print(...) = #1;
string ftos(float) = #2;
void test(float param, float p2) {
float i;
float c80 = 80;

View file

@ -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"

View file

@ -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; }

View file

@ -1,6 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
void test(string s) {
print(ftos(!s));
if (s) print(" on");

View file

@ -1,4 +1,4 @@
typedef void(string, ...) ptype;
typedef void(...) ptype;
typedef string(float) funcsf;
ptype print = #1;

View file

@ -3,3 +3,4 @@ D: typedefs
T: -execute
C: -std=fteqcc
M: A typedeffed function, 0=0
F: -no-defs

View file

@ -1,7 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
string vtos (vector) = #5;
vector main(float a, vector vin) {
vector v;

View file

@ -1,6 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
void main() {
print("Sum: \{x2211} ");
print("\{8721} ");

View file

@ -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");

View file

@ -1,5 +1,3 @@
void(...) print = #1;
void() main = {
print("hello", " world");
}

View file

@ -1,6 +1,3 @@
void print(string...) = #1;
string vtos(vector) = #5;
void main(vector v) {
print(vtos(v), "\n");
v /= 2;

View file

@ -1,7 +1,3 @@
void print(...) = #1;
string ftos (float) = #2;
string vtos (vector) = #5;
void main() {
vector v;