static const Type* rewrite_type(World& world, const Type* type) { Array<const Type*> new_ops(type->num_ops()); for (size_t i = 0; i < type->num_ops(); ++i) { if (is_graph_type(type->op(i))) new_ops[i] = graph_type(world); else if (is_task_type(type->op(i))) new_ops[i] = task_type(world); else new_ops[i] = rewrite_type(world, type->op(i)); } return type->rebuild(world, new_ops); }
void CCompoundDatabaseTaskBase::Add_Child_Task( IDatabaseTask *task ) { FATAL_ASSERT( ID != EDatabaseTaskIDType::INVALID ); task->Set_ID( ID ); Loki::TypeInfo task_type( typeid( *task ) ); DBTaskListType *task_list = nullptr; auto iter = Children.find( task_type ); if ( iter == Children.end() ) { task_list = new DBTaskListType; Children[ task_type ] = task_list; } else { task_list = iter->second; } FATAL_ASSERT( task_list != nullptr ); task_list->push_back( task ); }
static size_t task_schedualize(size_t *pad) { char space[2][64]; bool execute = false; char *data = NULL; char **match = NULL; size_t size = 0; size_t i = 0; size_t j = 0; size_t failed = 0; util_snprintf(space[0], sizeof(space[0]), "%d", (int)vec_size(task_tasks)); for (; i < vec_size(task_tasks); i++) { memset(space[1], 0, sizeof(space[1])); util_snprintf(space[1], sizeof(space[1]), "%d", (int)(i + 1)); con_out("test #%u %*s", i + 1, strlen(space[0]) - strlen(space[1]), ""); /* * Generate a task from thin air if it requires execution in * the QCVM. */ /* diagnostic is not executed, but compare tested instead, like preproessor */ execute = !! (!strcmp(task_tasks[i].tmpl->proceduretype, "-execute")) || (!strcmp(task_tasks[i].tmpl->proceduretype, "-pp")) || (!strcmp(task_tasks[i].tmpl->proceduretype, "-diagnostic")); /* * We assume it compiled before we actually compiled :). On error * we change the value */ task_tasks[i].compiled = true; /* * Read data from stdout first and pipe that stuff into a log file * then we do the same for stderr. */ while (fs_file_getline(&data, &size, task_tasks[i].runhandles[1]) != FS_FILE_EOF) { fs_file_puts(task_tasks[i].stdoutlog, data); if (strstr(data, "failed to open file")) { task_tasks[i].compiled = false; execute = false; } } while (fs_file_getline(&data, &size, task_tasks[i].runhandles[2]) != FS_FILE_EOF) { /* * If a string contains an error we just dissalow execution * of it in the vm. * * TODO: make this more percise, e.g if we print a warning * that refers to a variable named error, or something like * that .. then this will blowup :P */ if (strstr(data, "error") && strcmp(task_tasks[i].tmpl->proceduretype, "-diagnostic")) { execute = false; task_tasks[i].compiled = false; } fs_file_puts (task_tasks[i].stderrlog, data); fs_file_flush(task_tasks[i].stderrlog); /* fast flush for read */ } if (!task_tasks[i].compiled && strcmp(task_tasks[i].tmpl->proceduretype, "-fail")) { con_out("failure: `%s` %*s %*s\n", task_tasks[i].tmpl->description, (pad[0] + pad[1] - strlen(task_tasks[i].tmpl->description)) + (strlen(task_tasks[i].tmpl->rulesfile) - pad[1]), task_tasks[i].tmpl->rulesfile, (pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen("(failed to compile)") - pad[2]), "(failed to compile)" ); failed++; continue; } if (task_pclose(task_tasks[i].runhandles) != EXIT_SUCCESS && strcmp(task_tasks[i].tmpl->proceduretype, "-fail")) { con_out("failure: `%s` %*s %*s\n", task_tasks[i].tmpl->description, (pad[0] + pad[1] - strlen(task_tasks[i].tmpl->description)) + (strlen(task_tasks[i].tmpl->rulesfile) - pad[1]), task_tasks[i].tmpl->rulesfile, (pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen("(compiler didn't return exit success)") - pad[2]), "(compiler didn't return exit success)" ); failed++; continue; } if (!execute) { con_out("succeeded: `%s` %*s %*s\n", task_tasks[i].tmpl->description, (pad[0] + pad[1] - strlen(task_tasks[i].tmpl->description)) + (strlen(task_tasks[i].tmpl->rulesfile) - pad[1]), task_tasks[i].tmpl->rulesfile, (pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen(task_type(task_tasks[i].tmpl)) - pad[2]), task_type(task_tasks[i].tmpl) ); continue; } /* * If we made it here that concludes the task is to be executed * in the virtual machine (or the preprocessor output needs to * be matched). */ if (!task_trymatch(i, &match)) { size_t d = 0; con_out("failure: `%s` %*s %*s\n", task_tasks[i].tmpl->description, (pad[0] + pad[1] - strlen(task_tasks[i].tmpl->description)) + (strlen(task_tasks[i].tmpl->rulesfile) - pad[1]), task_tasks[i].tmpl->rulesfile, (pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen( (strcmp(task_tasks[i].tmpl->proceduretype, "-pp")) ? "(invalid results from execution)" : (strcmp(task_tasks[i].tmpl->proceduretype, "-diagnostic")) ? "(invalid results from preprocessing)" : "(invalid results from compiler diagnsotics)" ) - pad[2]), (strcmp(task_tasks[i].tmpl->proceduretype, "-pp")) ? "(invalid results from execution)" : (strcmp(task_tasks[i].tmpl->proceduretype, "-diagnostic")) ? "(invalid results from preprocessing)" : "(invalid results from compiler diagnsotics)" ); /* * Print nicely formatted expected match lists to console error * handler for the all the given matches in the template file and * what was actually returned from executing. */ con_out(" Expected From %u Matches: (got %u Matches)\n", vec_size(task_tasks[i].tmpl->comparematch), vec_size(match) ); for (; d < vec_size(task_tasks[i].tmpl->comparematch); d++) { char *select = task_tasks[i].tmpl->comparematch[d]; size_t length = 60 - strlen(select); con_out(" Expected: \"%s\"", select); while (length --) con_out(" "); con_out("| Got: \"%s\"\n", (d >= vec_size(match)) ? "<<nothing else to compare>>" : match[d]); } /* * Print the non-expected out (since we are simply not expecting it) * This will help track down bugs in template files that fail to match * something. */ if (vec_size(match) > vec_size(task_tasks[i].tmpl->comparematch)) { for (d = 0; d < vec_size(match) - vec_size(task_tasks[i].tmpl->comparematch); d++) { con_out(" Expected: Nothing | Got: \"%s\"\n", match[d + vec_size(task_tasks[i].tmpl->comparematch)] ); } } for (j = 0; j < vec_size(match); j++) mem_d(match[j]); vec_free(match); failed++; continue; } for (j = 0; j < vec_size(match); j++) mem_d(match[j]); vec_free(match); con_out("succeeded: `%s` %*s %*s\n", task_tasks[i].tmpl->description, (pad[0] + pad[1] - strlen(task_tasks[i].tmpl->description)) + (strlen(task_tasks[i].tmpl->rulesfile) - pad[1]), task_tasks[i].tmpl->rulesfile, (pad[1] + pad[2] - strlen(task_tasks[i].tmpl->rulesfile)) + (strlen(task_type(task_tasks[i].tmpl))- pad[2]), task_type(task_tasks[i].tmpl) ); } mem_d(data); return failed; }