- dir = opendir(curdir);
-
- while ((files = readdir(dir))) {
- memset(buffer, 0, sizeof(buffer));
- if (strstr(files->d_name, "TMP")) {
- snprintf(buffer, sizeof(buffer), "%s/%s", curdir, files->d_name);
- if (remove(buffer))
- con_err("error removing temporary file: %s\n", buffer);
- else
- util_debug("TEST", "removed temporary file: %s\n", buffer);
+ /*
+ * Additional QCFLAGS enviroment variable may be used
+ * to test compile flags for all tests. This needs to be
+ * BEFORE other flags (so that the .tmpl can override them)
+ */
+ qcflags = platform_getenv("QCFLAGS");
+
+ /*
+ * Generate the command required to open a pipe to a process
+ * which will be refered to with a handle in the task for
+ * reading the data from the pipe.
+ */
+ if (strcmp(tmpl->proceduretype, "-pp")) {
+ if (qcflags) {
+ if (tmpl->testflags && !strcmp(tmpl->testflags, "-no-defs")) {
+ util_snprintf(buf, sizeof(buf), "%s %s/%s %s %s -o %s",
+ task_bins[TASK_COMPILE],
+ directories[i],
+ tmpl->sourcefile,
+ qcflags,
+ tmpl->compileflags,
+ tmpl->tempfilename
+ );
+ } else {
+ util_snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s %s -o %s",
+ task_bins[TASK_COMPILE],
+ curdir,
+ defs,
+ directories[i],
+ tmpl->sourcefile,
+ qcflags,
+ tmpl->compileflags,
+ tmpl->tempfilename
+ );
+ }
+ } else {
+ if (tmpl->testflags && !strcmp(tmpl->testflags, "-no-defs")) {
+ util_snprintf(buf, sizeof(buf), "%s %s/%s %s -o %s",
+ task_bins[TASK_COMPILE],
+ directories[i],
+ tmpl->sourcefile,
+ tmpl->compileflags,
+ tmpl->tempfilename
+ );
+ } else {
+ util_snprintf(buf, sizeof(buf), "%s %s/%s %s/%s %s -o %s",
+ task_bins[TASK_COMPILE],
+ curdir,
+ defs,
+ directories[i],
+ tmpl->sourcefile,
+ tmpl->compileflags,
+ tmpl->tempfilename
+ );
+ }
+ }
+ } else {
+ /* Preprocessing (qcflags mean shit all here we don't allow them) */
+ if (tmpl->testflags && !strcmp(tmpl->testflags, "-no-defs")) {
+ util_snprintf(buf, sizeof(buf), "%s -E %s/%s -o %s",
+ task_bins[TASK_COMPILE],
+ directories[i],
+ tmpl->sourcefile,
+ tmpl->tempfilename
+ );
+ } else {
+ util_snprintf(buf, sizeof(buf), "%s -E %s/%s %s/%s -o %s",
+ task_bins[TASK_COMPILE],
+ curdir,
+ defs,
+ directories[i],
+ tmpl->sourcefile,
+ tmpl->tempfilename
+ );
+ }
+ }
+
+ /*
+ * The task template was compiled, now lets create a task from
+ * the template data which has now been propagated.
+ */
+ task.tmpl = tmpl;
+ if (!(task.runhandles = task_popen(buf, "r"))) {
+ con_err("error opening pipe to process for test: %s\n", tmpl->description);
+ success = false;
+ continue;
+ }
+
+ /*
+ * Open up some file desciptors for logging the stdout/stderr
+ * to our own.
+ */
+ util_snprintf(buf, sizeof(buf), "%s.stdout", tmpl->tempfilename);
+ task.stdoutlogfile = util_strdup(buf);
+ if (!(task.stdoutlog = fs_file_open(buf, "w"))) {
+ con_err("error opening %s for stdout\n", buf);
+ continue;
+ }
+
+ util_snprintf(buf, sizeof(buf), "%s.stderr", tmpl->tempfilename);
+ task.stderrlogfile = util_strdup(buf);
+ if (!(task.stderrlog = fs_file_open(buf, "w"))) {
+ con_err("error opening %s for stderr\n", buf);
+ continue;
+ }
+
+ vec_push(task_tasks, task);
+ }