Ejemplo n.º 1
0
// Driver program
int main(void)
{

    char *line = NULL;
    size_t size;
    int i, j;
    int nb_test_cases, N, M, Ci;
    char army[2];
    int city1, city2;

    struct Graph* graph;

    if (getline(&line, &size, stdin) == -1) DEBUG_PRINTF("No line\n");
    else {
            sscanf(line,"%d", &nb_test_cases);
            DEBUG_PRINTF("There are %d test cases\n", nb_test_cases);
    }

    for(i=0;i<nb_test_cases;i++){

            if (getline(&line, &size, stdin) == -1) DEBUG_PRINTF("No line\n");
            else {
                    sscanf(line,"%d %d", &N, &M);
            }

            graph = createGraph(N);

            DEBUG_PRINTF("\nTest case %d : Byteland has %d cities and %d roads\n", i+1, N, M);

            for(j=0;j<N;j++){
                    if (getline(&line, &size, stdin) == -1) DEBUG_PRINTF("No line\n");
                    else {
                            sscanf(line,"%c %d", army, &Ci);
                            //DEBUG_PRINTF("%s %d\n", army, Ci);
                            setNodeProperty(graph, j, Ci, army[0]);
                    }
            }

            for(j=0;j<M;j++){
                    if (getline(&line, &size, stdin) == -1) printf("No line\n");
                    else {
                            sscanf(line,"%d %d", &city1, &city2);
                            //DEBUG_PRINTF("%d %d\n", city1, city2);
                            addEdge(graph, city1-1, city2-1);
                    }
            }

            DEBUG_PRINTGRAPH(graph);
            executeTestCase(graph);

    }

    return 0;
}
Ejemplo n.º 2
0
int HarnessTestExecutor :: execute (InfoForExecutor &ir)
{
	time_t rawtime;
	time ( &rawtime );
	std::string nowStr(ctime (&rawtime));
	nowStr = nowStr.substr(0,nowStr.size()-1); // remove newline

	if (strcasecmp (ir.logDestination.c_str (), LOGDESTINATION_CONSOLE) != 0)
	{
		cout << "[" << ir.test_sequence_number << "][" << nowStr << "]: "
		     << "[start] " << ir.testID << std::endl;
	}

	copyToLocal (ir);

	if (validateParameters () == FAILURE)
		return FAILURE;

	createLogger ();
	//print_executor_environment ();

	if (prepareShellscript () == FAILURE)
	{
		LOG4CXX_INFO (_logger, "EXECUTOR returning FAILURE to the caller.");
		return FAILURE;
	}

	if (executeTestCase () == FAILURE)
	{
		LOG4CXX_INFO (_logger, "EXECUTOR returning FAILURE to the caller.");
		return FAILURE;
	}

	LOG4CXX_INFO (_logger, "EXECUTOR returning SUCCESS to the caller.");
	return SUCCESS;
}