int main() { int size = SIZE; int *first, *result; monitor *m; first = make_square_matrix(size); result = make_square_matrix(size); initialize_matrix(first, size); NOTIFY(print_matrix(first, size, size)); m = monitor_init(SELF); monitor_start(m); multiply_matrix_symm_transp(first, result, size); monitor_end(m); monitor_print_stats(m, VERBOSE); NOTIFY(print_matrix(result, size, size)); NOTIFY(verify_matrix(first, result, size)); monitor_free(m); return 0; }
static void monitors_apply_config (Plugin *p) { ENTER; MonitorsPlugin *mp; mp = (MonitorsPlugin *) p->priv; int i; int current_n_monitors = 0; start: for (i = 0; i < N_MONITORS; i++) { if (mp->displayed_monitors[i]) current_n_monitors++; if (mp->displayed_monitors[i] && !mp->monitors[i]) { /* We've just activated monitor<i> */ mp->monitors[i] = monitors_add_monitor(p, mp, update_functions[i], tooltip_update[i], colors[i]); /* * It is probably best for users if their monitors are always * displayed in the same order : the CPU monitor always on the left, * the RAM monitor always on the right of the CPU monitor (if the * CPU monitor is displayed), etc. That's why we do not just use * gtk_box_pack_start/gtk_box_pack_end, and use * gtk_box_reorder_child. */ gtk_box_reorder_child(GTK_BOX(p->pwid), mp->monitors[i]->da,current_n_monitors-1); } else if (!mp->displayed_monitors[i] && mp->monitors[i]) { /* We've just removed monitor<i> */ gtk_container_remove(GTK_CONTAINER(p->pwid), mp->monitors[i]->da); monitor_free(mp->monitors[i]); mp->monitors[i] = NULL; } if (mp->monitors[i] && strncmp(mp->monitors[i]->color, colors[i], COLOR_SIZE) != 0) { /* We've changed the color */ monitor_set_foreground_color(p, mp->monitors[i], colors[i]); } } /* Workaround meant to prevent users to display no monitor at all. * FIXME : write something clean. When there is only one monitor displayed, * its toggle button should not be clickable in the prefs. */ if (current_n_monitors == 0) { mp->displayed_monitors[0] = 1; goto start; } RET(); }
int main(int argc, char *argv[]) { int n = ARRAY_SIZE; int *array; HANDLE(!(array = malloc(n * sizeof(int)))); monitor *m; make_array(&array, n, ARRAY_ALGO, RANGE); NOTIFY(print_array(&array, n, OUT_LINE_SIZE)); m = monitor_init(SELF); monitor_start(m); csort(array, n); monitor_end(m); NOTIFY(print_array(&array, n, OUT_LINE_SIZE)); assert(verify(&array, n)); free(array); monitor_print_stats(m, VERBOSE); monitor_free(m); return 0; }
void test_monitor(monitor_target who, bool all_verbosities, bool threaded) { monitor *m = monitor_init(who); monitor_start(m); if(threaded){ busy_threads(); } else { busy_loop(); } monitor_end(m); if(all_verbosities){ monitor_print_stats(m, SILENT); SMALL_SEP(); monitor_print_stats(m, QUIET); SMALL_SEP(); } monitor_print_stats(m, VERBOSE); monitor_free(m); }
void destroy(void) { struct monitor *mon; for (mon = mons; mon; mon = mon->next) { while (mon->cstack) remove_client(mon->cstack, false); } while (mons) mons = monitor_free(mons); bars_free(); cursors_free(); rules_free(); x11_destroy(); }
static void monitors_destructor(Plugin *p) { ENTER; int i; MonitorsPlugin *mp; mp = (MonitorsPlugin *) p->priv; /* Removing timer */ g_source_remove(mp->timer); /* Freeing all monitors */ for (i = 0; i < N_MONITORS; i++) { if (mp->monitors[i]) monitor_free(mp->monitors[i]); } g_free(mp->action); g_free(mp); RET(); }
int run_tests(struct test_options *options) { bool use_stdout = false; struct monitor *monitor = monitor_alloc(options->command_name, options->is_debug, options->is_verbose, use_stdout); if (!monitor) { perror(options->command_name); return -1; } int failure_count = 0; int test_count = 0; DIR *dir = opendir(options->functional_tests_dir); if (!dir) { monitor_system_error(monitor); monitor_free(monitor); return -1; } struct dirent *entry; while ((entry = readdir(dir))) { if (!is_test_dir_name(entry)) continue; ++test_count; char *working_dir = path_alloc_absolute(options->functional_tests_dir, entry->d_name); if (!working_dir) { monitor_system_error(monitor); ++failure_count; continue; } int result = chdir(working_dir); if (-1 == result) { monitor_system_error(monitor); ++failure_count; free(working_dir); continue; } struct path *executable_path = path_alloc("fillin", options->command_dir); char const *argv[] = { executable_path->absolute, "-dv", "input.txt", "input.json", NULL, }; struct path *expected_stdout_path = path_alloc("expected_stdout.txt", working_dir); if (!expected_stdout_path) { monitor_system_error(monitor); ++failure_count; free(working_dir); continue; } struct path *expected_stderr_path = path_alloc("expected_stderr.txt", working_dir); free(working_dir); if (!expected_stderr_path) { monitor_system_error(monitor); ++failure_count; path_free(expected_stdout_path); continue; } int expected_status = 0; struct functional_test *test = functional_test_alloc(entry->d_name, monitor, executable_path, argv, expected_status, expected_stdout_path, expected_stderr_path); path_free(executable_path); path_free(expected_stdout_path); path_free(expected_stderr_path); if (!test) { monitor_system_error(monitor); ++failure_count; continue; } result = functional_test_fork(test); if (-1 == result) { monitor_system_error(monitor); ++failure_count; functional_test_free(test); continue; } result = functional_test_wait(test); if (-1 == result) { monitor_system_error(monitor); ++failure_count; functional_test_free(test); continue; } if (functional_test_state_passed != test->state) ++failure_count; functional_test_free(test); } int result = closedir(dir); if (-1 == result) { monitor_system_error(monitor); monitor_free(monitor); return -1; } monitor_free(monitor); return failure_count ? -1 : 0; }
static gboolean monitors_apply_config (gpointer user_data) { ENTER; GtkWidget *p = user_data; MonitorsPlugin *mp; mp = lxpanel_plugin_get_data(p); int i; int current_n_monitors = 0; start: for (i = 0; i < N_MONITORS; i++) { if (mp->displayed_monitors[i]) current_n_monitors++; if (mp->displayed_monitors[i] && !mp->monitors[i]) { /* We've just activated monitor<i> */ mp->monitors[i] = monitors_add_monitor(p, mp, update_functions[i], tooltip_update[i], colors[i]); /* * It is probably best for users if their monitors are always * displayed in the same order : the CPU monitor always on the left, * the RAM monitor always on the right of the CPU monitor (if the * CPU monitor is displayed), etc. That's why we do not just use * gtk_box_pack_start/gtk_box_pack_end, and use * gtk_box_reorder_child. */ gtk_box_reorder_child(GTK_BOX(p), mp->monitors[i]->da,current_n_monitors-1); } else if (!mp->displayed_monitors[i] && mp->monitors[i]) { /* We've just removed monitor<i> */ gtk_widget_destroy(mp->monitors[i]->da); monitor_free(mp->monitors[i]); mp->monitors[i] = NULL; } if (mp->monitors[i] && strncmp(mp->monitors[i]->color, colors[i], COLOR_SIZE) != 0) { /* We've changed the color */ monitor_set_foreground_color(mp, mp->monitors[i], colors[i]); } } /* Workaround meant to prevent users to display no monitor at all. * FIXME : write something clean. When there is only one monitor displayed, * its toggle button should not be clickable in the prefs. */ if (current_n_monitors == 0) { mp->displayed_monitors[0] = 1; goto start; } config_group_set_int(mp->settings, "DisplayCPU", mp->displayed_monitors[CPU_POSITION]); config_group_set_int(mp->settings, "DisplayRAM", mp->displayed_monitors[MEM_POSITION]); config_group_set_string(mp->settings, "Action", mp->action); config_group_set_string(mp->settings, "CPUColor", mp->monitors[CPU_POSITION] ? colors[CPU_POSITION] : NULL); config_group_set_string(mp->settings, "RAMColor", mp->monitors[MEM_POSITION] ? colors[MEM_POSITION] : NULL); RET(FALSE); }