int main(int argc, char **argv) { graph *g; struct arguments args; argp_parse (&argp, argc, argv, 0, 0, &args); /* parse command line */ logfile = fopen(args.logfile,"w"); if (logfile==NULL) { perror("could not open log file for writing"); exit(-4); } fprintf(logfile, "file to read: %s\n", args.filename); fprintf(logfile, "number of eigenpairs to be computed: %u\n", args.nev); g = graph_from_file(args.filename); if (g == NULL) { fprintf(stderr, "could not build network from file %s\n", args.filename); exit(-2); } /* check if the graph is connected */ if (!connected_graph(g)) { fprintf(stderr, "The network is not connected: exiting\n"); exit(-5); } /* check nev */ if (args.nev<3 || args.nev>=g->n) { fprintf(stderr, "number of eigenpairs out of range:\n"); fprintf(stderr, "it must be larger than 2 and smaller than the number of nodes\n"); exit(-1); } find_comm(g,args.nev,args.flag); freegraph(g); fclose(logfile); exit(0); }
/** * test__keep_tracking - test using a dummy software event to keep tracking. * * This function implements a test that checks that tracking events continue * when an event is disabled but a dummy software event is not disabled. If the * test passes %0 is returned, otherwise %-1 is returned. */ int test__keep_tracking(void) { struct record_opts opts = { .mmap_pages = UINT_MAX, .user_freq = UINT_MAX, .user_interval = ULLONG_MAX, .freq = 4000, .target = { .uses_mmap = true, }, }; struct thread_map *threads = NULL; struct cpu_map *cpus = NULL; struct perf_evlist *evlist = NULL; struct perf_evsel *evsel = NULL; int found, err = -1; const char *comm; threads = thread_map__new(-1, getpid(), UINT_MAX); CHECK_NOT_NULL__(threads); cpus = cpu_map__new(NULL); CHECK_NOT_NULL__(cpus); evlist = perf_evlist__new(); CHECK_NOT_NULL__(evlist); perf_evlist__set_maps(evlist, cpus, threads); CHECK__(parse_events(evlist, "dummy:u", NULL)); CHECK__(parse_events(evlist, "cycles:u", NULL)); perf_evlist__config(evlist, &opts); evsel = perf_evlist__first(evlist); evsel->attr.comm = 1; evsel->attr.disabled = 1; evsel->attr.enable_on_exec = 0; if (perf_evlist__open(evlist) < 0) { fprintf(stderr, " (not supported)"); err = 0; goto out_err; } CHECK__(perf_evlist__mmap(evlist, UINT_MAX, false)); /* * First, test that a 'comm' event can be found when the event is * enabled. */ perf_evlist__enable(evlist); comm = "Test COMM 1"; CHECK__(prctl(PR_SET_NAME, (unsigned long)comm, 0, 0, 0)); perf_evlist__disable(evlist); found = find_comm(evlist, comm); if (found != 1) { pr_debug("First time, failed to find tracking event.\n"); goto out_err; } /* * Secondly, test that a 'comm' event can be found when the event is * disabled with the dummy event still enabled. */ perf_evlist__enable(evlist); evsel = perf_evlist__last(evlist); CHECK__(perf_evlist__disable_event(evlist, evsel)); comm = "Test COMM 2"; CHECK__(prctl(PR_SET_NAME, (unsigned long)comm, 0, 0, 0)); perf_evlist__disable(evlist); found = find_comm(evlist, comm); if (found != 1) { pr_debug("Seconf time, failed to find tracking event.\n"); goto out_err; } err = 0; out_err: if (evlist) { perf_evlist__disable(evlist); perf_evlist__delete(evlist); } else { cpu_map__put(cpus); thread_map__put(threads); } return err; }