]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Added definition file for test-suite, used by default by the test system. To overrid...
authorDale Weiler <killfieldengine@gmail.com>
Wed, 30 Jan 2013 08:04:56 +0000 (08:04 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Wed, 30 Jan 2013 08:04:56 +0000 (08:04 +0000)
42 files changed:
Makefile
test.c
tests/arrays.qc
tests/break.qc
tests/builtin.qc
tests/calls.qc
tests/correct-logic.qc
tests/correct-vs-short.qc
tests/defs.qh [new file with mode: 0644]
tests/enum.qc
tests/equality.qc
tests/fieldparams.qc
tests/functions-as-params.qc
tests/goto.qc
tests/ifs.qc
tests/mul_vf.qc
tests/ngraphs.qc
tests/noreturn.qc
tests/noreturn1.tmpl
tests/noreturn2.tmpl
tests/noreturn3.tmpl
tests/noreturn4.tmpl
tests/operators.qc
tests/param8.qc
tests/parens.qc
tests/perl-logic.qc
tests/pmacros.qc
tests/pointlife.qc
tests/pp_va_args.qc
tests/short-logic.qc
tests/switch.qc
tests/ternary.qc
tests/truth-flags-2.qc
tests/truth.qc
tests/typedefs.qc
tests/typedefs.tmpl
tests/uninit.qc
tests/utf8.qc
tests/varargs.qc
tests/variadic.qc
tests/vec_ops.qc
tests/vector-init.qc

index 25828d1546fedae0299792f83cb3c47087e28f04..e31c0987124ba0596fd39040d18a920c312cabfe 100644 (file)
--- 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 be823246c5b80d3d659575e1ae90e5cf58ba694c..5e99df404063de4b7d638cd3e6217107414f5f36 100644 (file)
--- 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();
 
 
index a3a84c17e9ba8d27c0a6629fbdb8f60b1e4cf955..2c8f9fe533921ca98ce2bb8d2155414f49709aa6 100644 (file)
@@ -1,7 +1,3 @@
-void     print(...)   = #1;
-string   ftos (float) = #2;
-entity() spawn = #3;
-
 float  glob[7];
 
 .float above;
index 1a0fed1a98997a6fb29b42d3de5e5aa8186dd737..46f1805bda18c81d595017cb80ba873be62e3b69 100644 (file)
@@ -1,6 +1,3 @@
-void   print(...)   = #1;
-string ftos (float) = #2;
-
 void test(float brkat, float contat) {
     float i;
 
index 6e586443c4bf818555ac8dacc2fc56d5446a2496..06a1846e50a55c44193d1781f955dc70165fea45 100644 (file)
@@ -1,5 +1,3 @@
-void(string) print = #1;
-
 void() main = {
     print("hello world");
 }
index e230dc46adfaffe7fede589f9393c169deae7a38..7b09f11e0737abcc288403d8e530f3e909f63243 100644 (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;
 };
index cb9a38d0219067f15f18dc386b32136c813de24b..a8684247ed6cfb315938e6cf3220f8d358194815 100644 (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; }
index 81f9b7aa35d6e131a49936166a3b871baac55b22..e7cd2dcc73528cf7b5811bd32799f26279b57edd 100644 (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)), " ");
diff --git a/tests/defs.qh b/tests/defs.qh
new file mode 100644 (file)
index 0000000..830692c
--- /dev/null
@@ -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;
index 521863357694f66e77f3edcdb06576b1353b786b..da08ceee128aa2a0da962a5f9c1f852ed89b51a5 100644 (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");
index bc134b0d1b6c93295f85137c8d05bfcd9a572db1..95eccb824f292caa90976e8198cba7c3566e2d22 100644 (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,");
index 8e5cb031772457a30fd9f698ae6740b002b592b2..eed2ed614c0234013d477addd59caa79f1afa6e8 100644 (file)
@@ -1,6 +1,3 @@
-void(string, string) print = #1;
-entity() spawn = #3;
-
 .string a;
 .string b;
 ..string ps;
index 7790e64ed0044e4bc6e740206400e1d67ca3f94e..22136b7ab3d6c1d3e37b926c782d55604088309a 100644 (file)
@@ -1,5 +1,3 @@
-void(string, string) print = #1;
-
 string() getter = {
     return "correct";
 };
index 7c9f297739f4cd127ba507fdb702d7142aac440e..9e6f30bb2abeedbb491773a77f114a6290e345d1 100644 (file)
@@ -1,5 +1,3 @@
-void(string, ...) print = #1;
-
 // correct execution order:
 // label_3
 // label_2
index d3089ce4d24aa51705dc4bc3e9e14a2253f4a1d1..7a7f13cf91ef81683818444211ba4eb1f46c90f8 100644 (file)
@@ -1,5 +1,3 @@
-void(string, ...) print = #1;
-
 void(float c) main = {
     if (c == 1)
         print("One\n");
index 3e60e2385214c197eb667e97cc7750c54353c019..0e8df52cd0e6c12f659962ac72d15c833562dbe0 100644 (file)
@@ -1,6 +1,3 @@
-void print(...) = #1;
-string vtos(vector) = #5;
-
 // getter to work around future -O
 vector get(vector v) {
     return v;
index 330d625e4803ec295b279ee2b77927ec64d5c50b..6e1a9570f9c239ab99bd851ff4bc2a3c64498ea0 100644 (file)
@@ -1,5 +1,3 @@
-void(...) print = %:1;
-
 void() main = ??<
        print("??=??'??(??)??!??<??>??-??/??/%>|");
        print("#^[]|{}~\\%>\n");
index e56cc8810059c346211642e1653a6f98332cb389..ae614e77b5f27177728cf088d303baefb20e702c 100644 (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
index 0f6aad138a292c0c283a489a09367a10b38d3546..f662da4911e569b33f515bb05b5389effbf1ec1f 100644 (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
index 8d7ad09c55f572f8c7a1808e80ad227fbfbfbfda..d328c4f65b79df5c808d414bfb3fcf2d6d162461 100644 (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
index 56c28b51754d34d0803d6b29b304acf1f2b1fc61..653bd8afd4e01ffb42671c3e3e6781a49fb36b6f 100644 (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
index 18dc275789a3e5b6b05823d48899a88ac14dc7e3..4d87c9417226466c0f5da0aa23caf89545d308b6 100644 (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
index 1ca6f67caa0e5cf56ecf2516b82f487af3ba750d..46bd6bbeb81c2268edb8de30f86f74e18fad9b32 100644 (file)
@@ -1,8 +1,3 @@
-void   print(...)    = #1;
-string ftos (float)  = #2;
-string vtos (vector) = #5;
-entity spawn()       = #3;
-
 .float mem;
 
 void main() {
index 68e96f721982097d4ca8344749605def2a6192ea..bdb868a21db0f3932639a461021b5c89966161d1 100644 (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)
 {
index 1ae09a036a27f1dabeec8b67fa62823b68f95ad6..c4a369aa9e7ab358389c75a9096965c6d2701690 100644 (file)
@@ -1,6 +1,3 @@
-void(string...)   print  = #1;
-string(float)     ftos   = #2;
-
 float arr[2];
 
 string gets() { return "S\n"; }
index 5b56c45e293fca00e9fb6960470181b85602ec5d..5c7f16b64abd498f2c2f926a299ecd21a6f78fd8 100644 (file)
@@ -1,5 +1,3 @@
-void print(...) = #1;
-
 void main() {
     vector va, vb;
     string sa, sb;
index 1ecee8c3a673094771981f6a3f1a3fd95ebd9007..1ec0780ae24443cac920cddd0d190618e93bd1d9 100644 (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");
index b37e62abfd5b95560e141637c0a2e77b7a7ddff1..13bbde71eab0b53623504b8a4ab6d1a4fb42ab56 100644 (file)
@@ -1,5 +1,3 @@
-void print(...) = #1;
-
 var float foo = 0;
 
 void funcall() {}
index 89a98c864b1a17166b48b41f8c4cc9684c788c06..a42e1927938e2c1e499d81f64444ff9da92aea01 100644 (file)
@@ -1,5 +1,3 @@
-void print(...) = #1;
-
 // method 0
 #define METHOD__(...) __VA_ARGS__
 #define METHOD_0(F,A) F METHOD__(A)
index a62ed79b170ea0c1b0c8487eecd55b18f31c9509..9dd0550d5b7f0959617d735658b4b311515fcd83 100644 (file)
@@ -1,6 +1,3 @@
-void   print(...) = #1;
-string ftos(float) = #2;
-
 float glob1;
 float glob2;
 float glob3;
index 1758c8af759ae002de99da948b970c1f44db8bd5..2e9cf8edd5f7db3e24769e1db90ca16ff1f2f39c 100644 (file)
@@ -1,6 +1,3 @@
-void print(...) = #1;
-string ftos(float) = #2;
-
 void test(float param, float p2) {
     float i;
     float c80 = 80;
index 242a2404d54f3668a0f707f16cf7f71895250dc0..bdac5264191d8ed88442ee98cd278df77d35fb41 100644 (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"
index 0c10708029cc004a004066ae1539ff9f1ddebf1f..7ac93a58379c3c1f8697319b80bef5e4180b5a0e 100644 (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; }
index e08bde84cfd0cebbfb32e3b91e34850603a13264..9df6217bbe3569ab155e4c9e0c86ba7c2ecc03cd 100644 (file)
@@ -1,6 +1,3 @@
-void   print(...)   = #1;
-string ftos (float) = #2;
-
 void test(string s) {
     print(ftos(!s));
     if (s)   print(" on");
index 79143fd80bfe54f1767860503cf18c160cb090c8..e9bc13b1b48efbabee4a2de9c3f0a8c3f60079a7 100644 (file)
@@ -1,4 +1,4 @@
-typedef void(string, ...) ptype;
+typedef void(...)     ptype;
 typedef string(float) funcsf;
 
 ptype print = #1;
index 8c22ca4f304c8629fd23dd9e6addbafdfe6e3d01..2eb2253f797f724f45f2d04e063fed2ef316eea1 100644 (file)
@@ -3,3 +3,4 @@ D: typedefs
 T: -execute
 C: -std=fteqcc
 M: A typedeffed function, 0=0
+F: -no-defs
index 3d75f07173c137aae898460149f64c26296ee16e..d71721c32f22844eb000cd5a30103c5027602247 100644 (file)
@@ -1,7 +1,3 @@
-void   print(...)    = #1;
-string ftos (float)  = #2;
-string vtos (vector) = #5;
-
 vector main(float a, vector vin) {
     vector v;
 
index 4ca03483bd1a461857fdce235a9f23ae274df42c..f5a9255f057105135caf8bd38da59c55287d2241 100644 (file)
@@ -1,6 +1,3 @@
-void   print(...)   = #1;
-string ftos (float) = #2;
-
 void main() {
     print("Sum: \{x2211} ");
     print("\{8721} ");
index 89cb5b8d6bf5c35781965177441ae6dca756d326..4b0d80686e079be78b63f3c0a2f95e0768062a83 100644 (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");
index 27d938fc92f650b8562ebaab527ad0608cc59c83..26f301b1df83289a8756c73fdc0d0194a0960c4b 100644 (file)
@@ -1,5 +1,3 @@
-void(...) print = #1;
-
 void() main = {
     print("hello", " world");
 }
index a5c80c9ac8b1c0c7ff55c8abd2f416cac7ce5adf..ac84ffcc7768b1cd9b794ea96b9fce55cf6c0ec2 100644 (file)
@@ -1,6 +1,3 @@
-void print(string...) = #1;
-string vtos(vector)   = #5;
-
 void main(vector v) {
     print(vtos(v), "\n");
     v /= 2;
index 880bc3945120cbfe3e7df985ea0e87af0e4e5f39..41df059bc4ceb8047f1157fcabc500cd42698ce3 100644 (file)
@@ -1,7 +1,3 @@
-void   print(...)    = #1;
-string ftos (float)  = #2;
-string vtos (vector) = #5;
-
 void main() {
     vector v;