Esempio n. 1
0
File: runner.c Progetto: lmb/asinine
int
main(int argc, const char **argv) {
	int tests_run          = 0;
	int total_failed_tests = 0;

	(void)argc;
	(void)argv;

	run_test_set(test_asn1_all);
	run_test_set(test_x509_all);

	printf("Ran %u tests\n", tests_run);
	return total_failed_tests;
}
Esempio n. 2
0
int main (int argc, char **argv) {  
  if (argc < 2) {
    printf("Número inválido de argumentos\n");
    printf("Uso: ./lab03 arq_dados.txt\n");
    return 1;
  }
  
  QS_func_t qs_funcs[] = { Quicksort1, Quicksort2, Quicksort3,		\
			   QuicksortH1, QuicksortH2, QuicksortH3 };
  
  // roda cada algoritmo sobre todos os casos de teste contidos no arquivo
  for (uint i = 0; i < sizeof(qs_funcs)/sizeof(qs_funcs[0]); i++) {

    FILE *fp = fopen(argv[1], "r") ;
    if (!fp) {
      fprintf(stderr, "Não foi possível abrir o arquivo de dados \"%s\".\n", argv[1]);
      return 1;
    }    
    int n_test_cases = 0;
    int len_test_case = 0;
  
    if (fscanf(fp, "%d %d", &n_test_cases, &len_test_case) != 2) {
      fprintf(stderr, "Formato invalido.\n");
      return 1;
    }
    
    run_test_set(fp, n_test_cases, len_test_case, qs_funcs[i]);
    fclose(fp);
  }
  
  return 0;
}
Esempio n. 3
0
int main(int argc, char **argv)
{
	int op, ret;
	int failed;

	while ((op = getopt(argc, argv, "f:p:d:D:n:")) != -1) {
		switch (op) {
		case 'd':
			good_address = optarg;
			break;
		case 'D':
			bad_address = optarg;
			break;
		case 'f':
			fabric_hints.name = optarg;
			break;
		case 'n':
			num_good_addr = atoi(optarg);
			break;
		case 'p':
			fabric_hints.prov_name = optarg;
			break;
		default:
			printf("usage: %s\n", argv[0]);
			printf("\t[-d good_address]\n");
			printf("\t[-D bad_address]\n");
			printf("\t[-f fabric_name]\n");
			printf("\t[-n num_good_addr (max=%d]\n", MAX_ADDR - 1);
			printf("\t[-p provider_name]\n");
			exit(1);
		}
	}

	if (good_address == NULL || bad_address == NULL || num_good_addr == 0) {
		printf("Test requires all of -d, -D, and -n\n");
		exit(1);
	}

	if (num_good_addr > MAX_ADDR - 1) {
		printf("num_good_addr = %d is too big, dropped to %d\n", 
				num_good_addr, MAX_ADDR);
		num_good_addr = MAX_ADDR - 1;
	}

	hints.fabric_attr = &fabric_hints;
	hints.mode = ~0;

	ret = fi_getinfo(FI_VERSION(1, 0), NULL, 0, 0, &hints, &fi);
	if (ret != 0) {
		printf("fi_getinfo %s\n", fi_strerror(-ret));
		exit(1);
	}

	ret = fi_fabric(fi->fabric_attr, &fabric, NULL);
	if (ret != 0) {
		printf("fi_fabric %s\n", fi_strerror(-ret));
		exit(1);
	}
	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret != 0) {
		printf("fi_domain %s\n", fi_strerror(-ret));
		exit(1);
	}

	eq_attr.size = 1024;
	eq_attr.wait_obj = FI_WAIT_UNSPEC;
	ret = fi_eq_open(fabric, &eq_attr, &eq, NULL);
	if (ret != 0) {
		printf("fi_eq_open %s\n", fi_strerror(-ret));
		exit(1);
	}

	printf("Testing AVs on fabric %s\n", fi->fabric_attr->name);
	failed = 0;

	av_type = FI_AV_MAP;
	printf("Testing with type = FI_AV_MAP\n");
	failed += run_test_set();

	av_type = FI_AV_TABLE;
	printf("Testing with type = FI_AV_TABLE\n");
	failed += run_test_set();

	if (failed > 0) {
		printf("Summary: %d tests failed\n", failed);
	} else {
		printf("Summary: all tests passed\n");
	}

	ret = fi_close(&eq->fid);
	if (ret != 0) {
		printf("Error %d closing EQ: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}
	ret = fi_close(&domain->fid);
	if (ret != 0) {
		printf("Error %d closing domain: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}
	ret = fi_close(&fabric->fid);
	if (ret != 0) {
		printf("Error %d closing fabric: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}

	exit(failed > 0);
}
Esempio n. 4
0
int main(int argc, char **argv)
{
	int op, ret;
	int failed;

	hints = fi_allocinfo();
	if (!hints)
		return EXIT_FAILURE;

	while ((op = getopt(argc, argv, "f:d:D:n:a:s:")) != -1) {
		switch (op) {
		case 'd':
			good_address = optarg;
			break;
		case 'D':
			bad_address = optarg;
			break;
		case 'a':
			free(hints->fabric_attr->name);
			hints->fabric_attr->name = strdup(optarg);
			break;
		case 'n':
			num_good_addr = atoi(optarg);
			break;
		case 'f':
			free(hints->fabric_attr->prov_name);
			hints->fabric_attr->prov_name = strdup(optarg);
			break;
		case 's':
			src_addr_str = optarg;
			break;
		default:
			printf("usage: %s\n", argv[0]);
			printf("\t[-d good_address]\n");
			printf("\t[-D bad_address]\n");
			printf("\t[-a fabric_name]\n");
			printf("\t[-n num_good_addr (max=%d)]\n", MAX_ADDR - 1);
			printf("\t[-f provider_name]\n");
			printf("\t[-s source_address]\n");
			return EXIT_FAILURE;

		}
	}

	if (good_address == NULL ||  num_good_addr == 0) {
		printf("Test requires -d  and -n\n");
		return EXIT_FAILURE;
	}

	if (num_good_addr > MAX_ADDR - 1) {
		printf("num_good_addr = %d is too big, dropped to %d\n",
				num_good_addr, MAX_ADDR);
		num_good_addr = MAX_ADDR - 1;
	}

	hints->mode = ~0;
	hints->addr_format = FI_SOCKADDR;

	hints->ep_attr->type = FI_EP_RDM;
	ret = fi_getinfo(FT_FIVERSION, src_addr_str, 0, FI_SOURCE, hints, &fi);
	if (ret != 0 && ret != -FI_ENODATA) {
		printf("fi_getinfo %s\n", fi_strerror(-ret));
		goto err;
	}

	if (ret == -FI_ENODATA) {
		hints->ep_attr->type = FI_EP_DGRAM;
		ret = fi_getinfo(FT_FIVERSION, src_addr_str, 0, FI_SOURCE, hints, &fi);
		if (ret != 0) {
			printf("fi_getinfo %s\n", fi_strerror(-ret));
			goto err;
		}
	}

	ret = ft_open_fabric_res();
	if (ret)
		return ret;

	printf("Testing AVs on fabric %s\n", fi->fabric_attr->name);
	failed = 0;

	if (fi->domain_attr->av_type == FI_AV_UNSPEC ||
	    fi->domain_attr->av_type == FI_AV_MAP) {
		av_type = FI_AV_MAP;
		printf("Testing with type = FI_AV_MAP\n");
		failed += run_test_set();
	}

	if (fi->domain_attr->av_type == FI_AV_UNSPEC ||
	    fi->domain_attr->av_type == FI_AV_TABLE) {
		av_type = FI_AV_TABLE;
		printf("Testing with type = FI_AV_TABLE\n");
		failed += run_test_set();
	}

	if (failed > 0) {
		printf("Summary: %d tests failed\n", failed);
	} else {
		printf("Summary: all tests passed\n");
	}

	ft_free_res();
	return (failed > 0);
err:
	ft_free_res();
	return -ret;
}
Esempio n. 5
0
int main(int argc, char **argv)
{
	int op, ret;
	int failed;

	if (getenv("FABTESTS_DEBUG")) {
		fabtests_debug = atoi(getenv("FABTESTS_DEBUG"));
	}

	hints = fi_allocinfo();
	if (!hints)
		exit(1);

	while ((op = getopt(argc, argv, "f:a:")) != -1) {
		switch (op) {
		case 'a':
			hints->fabric_attr->name = strdup(optarg);
			break;
		case 'f':
			hints->fabric_attr->prov_name = strdup(optarg);
			break;
		default:
			printf("usage: %s\n", argv[0]);
			printf("\t[-a fabric_name]\n");
			printf("\t[-f provider_name]\n");
			exit(1);
		}
	}

	hints->mode = ~0;
	hints->ep_attr->type = FI_EP_RDM;

	ret = fi_getinfo(FT_FIVERSION, NULL, 0, 0, hints, &fi);
	if (ret != 0) {
		printf("fi_getinfo %s\n", fi_strerror(-ret));
		exit(-ret);
	}

	DEBUG("using provider \"%s\" and fabric \"%s\"\n",
		fi->fabric_attr->prov_name,
		fi->fabric_attr->name);

	ret = fi_fabric(fi->fabric_attr, &fabric, NULL);
	if (ret != 0) {
		printf("fi_fabric %s\n", fi_strerror(-ret));
		exit(1);
	}
	ret = fi_domain(fabric, fi, &domain, NULL);
	if (ret != 0) {
		printf("fi_domain %s\n", fi_strerror(-ret));
		exit(1);
	}

	eq_attr.size = 1024;
	eq_attr.wait_obj = FI_WAIT_UNSPEC;
	ret = fi_eq_open(fabric, &eq_attr, &eq, NULL);
	if (ret != 0) {
		printf("fi_eq_open %s\n", fi_strerror(-ret));
		exit(1);
	}

	failed =0;

	failed += run_test_set();

	if (failed > 0) {
		printf("Summary: %d tests failed\n", failed);
	} else {
		printf("Summary: all tests passed\n");
	}

	ret = fi_close(&eq->fid);
	if (ret != 0) {
		printf("Error %d closing EQ: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}
	ret = fi_close(&domain->fid);
	if (ret != 0) {
		printf("Error %d closing domain: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}
	ret = fi_close(&fabric->fid);
	if (ret != 0) {
		printf("Error %d closing fabric: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}
	fi_freeinfo(fi);
	if (ret != 0) {
		printf("Error %d freeing info: %s\n", ret, fi_strerror(-ret));
		exit(1);
	}
	fi_freeinfo(hints);

	return (failed > 0);
}
Esempio n. 6
0
void run_curie_tests()
{
   rdfacontext* context =
      rdfa_create_context("http://example.org/");

   rdfa_init_context(context);
   
   rdfa_update_mapping(
      context->uri_mappings, "dc", "http://purl.org/dc/elements/1.1/");
   rdfa_update_mapping(
      context->uri_mappings, "dctv", "http://purl.org/dc/dcmitype/");
   
   printf("------------------------ CURIE tests ---------------------\n");
   
   run_test(context, "IRI", "http://www.example.org/iri",
            rdfa_resolve_curie, "http://www.example.org/iri",
            CURIE_PARSE_HREF_SRC);
   run_test(context, "Safe CURIE", "[dc:title]",
            rdfa_resolve_curie, "http://purl.org/dc/elements/1.1/title",
            CURIE_PARSE_PROPERTY);
   run_test(context, "Unsafe CURIE", "dc:title",
            rdfa_resolve_curie, "http://purl.org/dc/elements/1.1/title",
            CURIE_PARSE_PROPERTY);
   run_test(context, "Non-prefixed CURIE", ":nonprefixed",
            rdfa_resolve_curie, "http://example.org/nonprefixed",
            CURIE_PARSE_PROPERTY);
   run_test(context, "Reference-only CURIE", "foobar",
            rdfa_resolve_curie, NULL, CURIE_PARSE_PROPERTY);
   run_test(context, "Reference-only safe CURIE", "[foobar]",
            rdfa_resolve_curie, NULL, CURIE_PARSE_PROPERTY);
   run_test(context, "Empty safe CURIE", "[]",
            rdfa_resolve_curie, NULL, CURIE_PARSE_PROPERTY);
   run_test(context, "Blank named safe CURIE", "[_:frank]",
            rdfa_resolve_curie, "_:frank", CURIE_PARSE_PROPERTY);

   rdfalist* dctvlist = rdfa_create_list(2);
   rdfa_add_item(
      dctvlist, "http://purl.org/dc/dcmitype/Image", RDFALIST_FLAG_NONE);
   rdfa_add_item(
      dctvlist, "http://purl.org/dc/dcmitype/Sound", RDFALIST_FLAG_NONE);
   run_list_test(
      context, "XHTML multiple @type_of", "[dctv:Image] [dctv:Sound]",
      rdfa_resolve_curie_list, dctvlist, CURIE_PARSE_INSTANCEOF_DATATYPE);
   rdfa_free_list(dctvlist);

   rdfalist* nllist = rdfa_create_list(2);
   rdfa_add_item(
      nllist, XHTML_VOCAB_URI "next", RDFALIST_FLAG_NONE);
   rdfa_add_item(
      nllist, XHTML_VOCAB_URI "license", RDFALIST_FLAG_NONE);
   run_list_test(
      context, "XHTML multiple @rel/@rev", "next license",
      rdfa_resolve_curie_list, nllist, CURIE_PARSE_RELREV);
   rdfa_free_list(nllist);
   
   rdfalist* dtlist = rdfa_create_list(2);
   rdfa_add_item(
      dtlist, XHTML_VOCAB_URI "description", RDFALIST_FLAG_NONE);
   rdfa_add_item(
      dtlist, XHTML_VOCAB_URI "title", RDFALIST_FLAG_NONE);   
   run_list_test(
      context, "XHTML multiple @property", "description title",
      rdfa_resolve_curie_list, dtlist, CURIE_PARSE_PROPERTY);
   rdfa_free_list(dtlist);

   run_test_set(context, "XHTML @rel/@rev reserved",
      my_g_relrev_reserved_words, XHTML_RELREV_RESERVED_WORDS_SIZE,
      rdfa_resolve_relrev_curie, XHTML_VOCAB_URI, CURIE_PARSE_RELREV);

   printf("---------------------- CURIE test results ---------------------\n"
          "%i passed, %i failed\n",
          g_test_passes, g_test_fails);

   rdfa_free_context(context);
}
Esempio n. 7
0
int main(int, char**) {

	bool flawless = true;

	flawless &= run_test_set(prelude_tests, std::cout);
	flawless &= run_test_set(sum_type_tests, std::cout);
	flawless &= run_test_set(either_tests, std::cout);
	flawless &= run_test_set(eithert_tests, std::cout);
	flawless &= run_test_set(maybe_tests, std::cout);
	flawless &= run_test_set(maybet_tests, std::cout);
	flawless &= run_test_set(future_tests, std::cout);
	flawless &= run_test_set(lazy_tests, std::cout);
	flawless &= run_test_set(lazyt_tests, std::cout);
	flawless &= run_test_set(ord_tests, std::cout);
	flawless &= run_test_set(functional_tests, std::cout);
	flawless &= run_test_set(list_tests, std::cout);
	flawless &= run_test_set(vector_tests, std::cout);
	flawless &= run_test_set(fwdlist_tests, std::cout);
	flawless &= run_test_set(tuple_tests, std::cout);
	flawless &= run_test_set(memory_tests, std::cout);
	flawless &= run_test_set(string_tests, std::cout);
	flawless &= run_test_set(set_tests, std::cout);
	flawless &= run_test_set(map_tests, std::cout);
	flawless &= run_test_set(unordered_map_tests, std::cout);
	flawless &= run_test_set(concept_tests, std::cout);

	if(!flawless)
		return -1;

	return 0;
}