dup2(errhandle[1], 2);
execvp(argv[0], &argv[0]);
- exit(EXIT_FAILURE);
+ exit(95);
} else {
/* fork failed */
goto task_popen_error_3;
task_popen_error_1: close(inhandle [0]), close(inhandle [1]);
task_popen_error_0:
- return NULL;
+ return nullptr;
}
static int task_pclose(FILE **handles) {
close(data->pipes[1]); /* stdout */
close(data->pipes[2]); /* stderr */
- waitpid(data->pid, &status, 0);
+ if (data->pid != waitpid(data->pid, &status, 0)) {
+ abort();
+ }
+ if (!WIFEXITED(status))
+ return -1;
+ if (WIFSIGNALED(status))
+ con_out("got signaled!\n");
mem_d(data);
- return status;
+ return status ? 1 : 0;
}
#define TASK_COMPILE 0
static bool task_template_generate(task_template_t *tmpl, char tag, const char *file, size_t line, char *value, size_t *pad) {
size_t desclen = 0;
size_t filelen = 0;
- char **destval = NULL;
+ char **destval = nullptr;
if (!tmpl)
return false;
}
static bool task_template_parse(const char *file, task_template_t *tmpl, FILE *fp, size_t *pad) {
- char *data = NULL;
- char *back = NULL;
+ char *data = nullptr;
+ char *back = nullptr;
size_t size = 0;
size_t line = 1;
/* update line and free old sata */
line++;
mem_d(back);
- back = NULL;
+ back = nullptr;
}
if (back)
mem_d(back);
if (!tmpl)
return;
- tmpl->description = NULL;
- tmpl->proceduretype = NULL;
- tmpl->compileflags = NULL;
- tmpl->executeflags = NULL;
- tmpl->sourcefile = NULL;
- tmpl->tempfilename = NULL;
- tmpl->rulesfile = NULL;
- tmpl->testflags = NULL;
+ tmpl->description = nullptr;
+ tmpl->proceduretype = nullptr;
+ tmpl->compileflags = nullptr;
+ tmpl->executeflags = nullptr;
+ tmpl->sourcefile = nullptr;
+ tmpl->tempfilename = nullptr;
+ tmpl->rulesfile = nullptr;
+ tmpl->testflags = nullptr;
}
static task_template_t *task_template_compile(const char *file, const char *dir, size_t *pad) {
/* a page should be enough */
char fullfile[4096];
size_t filepadd = 0;
- FILE *tempfile = NULL;
- task_template_t *tmpl = NULL;
+ FILE *tempfile = nullptr;
+ task_template_t *tmpl = nullptr;
util_snprintf(fullfile, sizeof(fullfile), "%s/%s", dir, file);
fclose(tempfile);
mem_d(tmpl);
- return NULL;
+ return nullptr;
}
static void task_template_destroy(task_template_t *tmpl) {
mem_d(it);
/*
- * Nullify all the template members otherwise NULL comparision
+ * Nullify all the template members otherwise nullptr comparision
* checks will fail if tmpl pointer is reused.
*/
mem_d(tmpl->tempfilename);
directories.push_back(claim);
} else {
mem_d(claim);
- claim = NULL;
+ claim = nullptr;
}
}
closedir(dir);
if (strcmp(files->d_name + strlen(files->d_name) - 5, ".tmpl") == 0) {
task_template_t *tmpl = task_template_compile(files->d_name, it, pad);
char buf[4096]; /* one page should be enough */
- const char *qcflags = NULL;
+ const char *qcflags = nullptr;
task_t task;
+ memset(&task, 0, sizeof(task));
+
found ++;
if (!tmpl) {
con_err("error compiling task template: %s\n", files->d_name);
* Generate a temportary file name for the output binary
* so we don't trample over an existing one.
*/
- tmpl->tempfilename = NULL;
+ tmpl->tempfilename = nullptr;
util_asprintf(&tmpl->tempfilename, "%s/TMPDAT.%s.dat", it, files->d_name);
/*
* and handle accordingly.
*/
{
- char *data = NULL;
+ char *data = nullptr;
size_t size = 0;
size_t compare = 0;
line.push_back(data);
/* reset */
- data = NULL;
+ data = nullptr;
size = 0;
}
success = false;
mem_d(data);
- data = NULL;
+ data = nullptr;
}
if (process)
static size_t task_schedualize(size_t *pad) {
char space[2][64];
bool execute = false;
- char *data = NULL;
+ char *data = nullptr;
std::vector<char *> match;
size_t size = 0;
size_t i = 0;
util_snprintf(space[1], sizeof(space[1]), "%d", (int)(i));
con_out("test #%u %*s", i, strlen(space[0]) - strlen(space[1]), "");
+ //con_out("[[%*s]]",
+ // (pad[0] + pad[1] - strlen(it.tmpl->description)) + (strlen(it.tmpl->rulesfile) - pad[1]),
+ // it.tmpl->rulesfile);
+ //fflush(stdout);
/*
* Generate a task from thin air if it requires execution in
}
status = task_pclose(it.runhandles);
+ if (status != 0 && status != 1) {
+ con_out("compiler failure (returned: %i): `%s` %*s\n",
+ status,
+ it.tmpl->description,
+ (pad[0] + pad[1] - strlen(it.tmpl->description)) + (strlen(it.tmpl->rulesfile) - pad[1]),
+ it.tmpl->rulesfile
+ );
+ failed++;
+ continue;
+ }
if ((!strcmp(it.tmpl->proceduretype, "-fail") && status == EXIT_SUCCESS)
|| ( strcmp(it.tmpl->proceduretype, "-fail") && status == EXIT_FAILURE)) {
con_out("failure: `%s` %*s %*s\n",
int main(int argc, char **argv) {
bool succeed = false;
- char *defs = NULL;
+ char *defs = nullptr;
con_init();