Ejemplo n.º 1
0
static int partition_consume (void *args) {
        part_consume_info_t *info = (part_consume_info_t *)args;
        rd_kafka_queue_t *rkqu = info->rkqu;
        int partition = info->partition;
        int64_t ts_start = test_clock();
        int max_time = (test_session_timeout_ms + 3000) * 1000;
        int running = 1;

        free(args); /* Free the parameter struct dynamically allocated for us */

        while (ts_start + max_time > test_clock() && running &&
               is_consuming()) {
                rd_kafka_message_t *rkmsg;

                rkmsg = rd_kafka_consume_queue(rkqu, 500);

                if (!rkmsg)
                        continue;
                else if (rkmsg->err == RD_KAFKA_RESP_ERR__PARTITION_EOF)
                        running = 0;
                else if (rkmsg->err) {
                        mtx_lock(&lock);
                        TEST_FAIL("Message error "
                                  "(at offset %" PRId64 " after "
                                  "%d/%d messages and %dms): %s",
                                  rkmsg->offset, consumed_msg_cnt, exp_msg_cnt,
                                  (int)(test_clock() - ts_start) / 1000,
                                  rd_kafka_message_errstr(rkmsg));
                        mtx_unlock(&lock);
                } else {
                        if (rkmsg->partition != partition) {
                                mtx_lock(&lock);
                                TEST_FAIL("Message consumed has partition %d "
                                          "but we expected partition %d.",
                                          rkmsg->partition, partition);
                                mtx_unlock(&lock);
                        }
                }
                rd_kafka_message_destroy(rkmsg);

                mtx_lock(&lock);
                if (running && ++consumed_msg_cnt >= exp_msg_cnt) {
                        TEST_SAY("All messages consumed\n");
                        running = 0;
                }
                mtx_unlock(&lock);
        }

        rd_kafka_queue_destroy(rkqu);

        return thrd_success;
}
Ejemplo n.º 2
0
static int stats_cb (rd_kafka_t *rk, char *json, size_t json_len,
                     void *opaque) {
    struct state *state = opaque;
    const int64_t now = test_clock();
    /* Fake the first elapsed time since we dont really know how
     * long rd_kafka_new() takes and at what time the timer is started. */
    const int64_t elapsed = state->ts_last ?
                            now - state->ts_last : state->interval;
    const int64_t overshoot = elapsed - state->interval;
    const int wiggleroom = (state->interval * 0.2);

    TEST_SAY("Call #%d: after %"PRId64"ms, %.0f%% outside "
             "interval %"PRId64" +-%d\n",
             state->calls, elapsed / 1000,
             ((double)overshoot / state->interval) * 100.0,
             (int64_t)state->interval / 1000, wiggleroom / 1000);

    if (overshoot < -wiggleroom || overshoot > wiggleroom) {
        TEST_WARN("^ outside range\n");
        state->fails++;
    }

    state->ts_last = now;
    state->calls++;

    return 0;
}
Ejemplo n.º 3
0
int sc_main(int argc, char* argv[]) {
	sc_signal<bool> input_1, input_2, output;
	sc_clock test_clock("TestClock", 10, SC_NS, 0.5);
	sc_trace_file *trace_file;
	
	stimulus stimulus_1("Stimulus");
	stimulus_1.input_1(input_1);
	stimulus_1.input_2(input_2);
	stimulus_1.clock(test_clock);
	
	monitor monitor_1("Monitor");
	monitor_1.input_1(input_1);
	monitor_1.input_2(input_2);
	monitor_1.output(output);
	monitor_1.clock(test_clock);

	xor_ xor_1("Xor");
	xor_1.input_1(input_1);
	xor_1.input_2(input_2);
	xor_1.output(output);

	trace_file = sc_create_vcd_trace_file("wave");


	sc_trace(trace_file, test_clock, "Clock");
	sc_trace(trace_file, input_1, "Input_1");
	sc_trace(trace_file, input_2, "Input_2");
	sc_trace(trace_file, output, "Output");

	sc_start();

	sc_close_vcd_trace_file(trace_file);

	return 0;
}
Ejemplo n.º 4
0
void 
el_test_time(void* arg) 
{
  fprintf(stdout, "enter into function >> `%s`\n", __func__);

  test_clock();
}
Ejemplo n.º 5
0
/*various time functions tests for better tests coverage*/
void test_issue_128(){
    int ret;
    struct timezone tz;
    struct timezone *tz_p=NULL; //pass null pointer instead NULL, to avoid warnings
    struct timeval *tv_p=NULL;
    TEST_OPERATION_RESULT( gettimeofday(tv_p, &tz), &ret, ret!=0&&errno==EFAULT);
    TEST_OPERATION_RESULT( gettimeofday(tv_p, tz_p), &ret, ret!=0&&errno==EFAULT);
    test_clock();
}
Ejemplo n.º 6
0
static void consume_all (rd_kafka_t **rk_c, int rk_cnt, int exp_msg_cnt,
			 int max_time/*ms*/) {
	int64_t ts_start = test_clock();
	int i;

	max_time *= 1000;
	while (ts_start + max_time > test_clock()) {
		for (i = 0 ; i < rk_cnt ; i++) {
			rd_kafka_message_t *rkmsg;

			if (!rk_c[i])
				continue;

			rkmsg = rd_kafka_consumer_poll(rk_c[i], 500);

			if (!rkmsg)
				continue;
			else if (rkmsg->err)
				TEST_SAY("Message error "
                                         "(at offset %"PRId64" after "
                                         "%d/%d messages and %dms): %s\n",
                                         rkmsg->offset,
                                         consumed_msg_cnt, exp_msg_cnt,
                                         (int)(test_clock() - ts_start)/1000,
					 rd_kafka_message_errstr(rkmsg));
			else
				consumed_msg_cnt++;

			rd_kafka_message_destroy(rkmsg);

			if (consumed_msg_cnt >= exp_msg_cnt) {
				static int once = 0;
				if (!once++)
					TEST_SAY("All messages consumed\n");
				return;
			}
		}
	}
}
Ejemplo n.º 7
0
static int ctrl_thrd_main (void *arg) {


        mtx_lock(&ctrl.lock);
        while (!ctrl.term) {
                int64_t now;

                cnd_timedwait_ms(&ctrl.cnd, &ctrl.lock, 10);

                if (ctrl.cmd.ts_at) {
                        ctrl.next.ts_at = ctrl.cmd.ts_at;
                        ctrl.next.delay = ctrl.cmd.delay;
                        ctrl.cmd.ts_at = 0;
                        ctrl.cmd.ack = 1;
                        printf(_C_CYA "## %s: sockem: "
                               "receieved command to set delay "
                               "to %d in %dms\n" _C_CLR,
                               __FILE__,
                               ctrl.next.delay,
                               (int)(ctrl.next.ts_at - test_clock()) / 1000);

                }

                now = test_clock();
                if (ctrl.next.ts_at && now > ctrl.next.ts_at) {
                        assert(ctrl.skm);
                        printf(_C_CYA "## %s: "
                               "sockem: setting socket delay to %d\n" _C_CLR,
                               __FILE__, ctrl.next.delay);
                        sockem_set(ctrl.skm, "delay", ctrl.next.delay, NULL);
                        ctrl.next.ts_at = 0;
                        cnd_signal(&ctrl.cnd); /* signal back to caller */
                }
        }
        mtx_unlock(&ctrl.lock);

        return 0;
}
Ejemplo n.º 8
0
static void do_consume (struct _consumer *cons, int timeout_s) {
        rd_kafka_message_t *rkm;

        rkm = rd_kafka_consumer_poll(cons->rk, 100+(timeout_s*1000));
        if (!rkm)
                return;

        TEST_ASSERT(!rkm->err,
                    "%s consumer error: %s (last poll was %dms ago)",
                    rd_kafka_name(cons->rk),
                    rd_kafka_message_errstr(rkm),
                    (int)((test_clock() - cons->last)/1000));

        rd_kafka_message_destroy(rkm);

        cons->cnt++;
        cons->last = test_clock();

        if (timeout_s > 0) {
                TEST_SAY("%s: simulate processing by sleeping for %ds\n",
                         rd_kafka_name(cons->rk), timeout_s);
                rd_sleep(timeout_s);
        }
}
Ejemplo n.º 9
0
/**
 * @brief Set socket delay to kick in after \p after ms
 */
static void set_delay (int after, int delay) {
        TEST_SAY("Set delay to %dms (after %dms)\n", delay, after);

        mtx_lock(&ctrl.lock);
        ctrl.cmd.ts_at = test_clock() + (after*1000);
        ctrl.cmd.delay = delay;
        ctrl.cmd.ack = 0;
        cnd_broadcast(&ctrl.cnd);

        /* Wait for ack from sockem thread */
        while (!ctrl.cmd.ack) {
                TEST_SAY("Waiting for sockem control ack\n");
                cnd_timedwait_ms(&ctrl.cnd, &ctrl.lock, 1000);
        }
        mtx_unlock(&ctrl.lock);
}
Ejemplo n.º 10
0
static void test_init (void) {
	int seed;
#ifndef _MSC_VER
	char *tmp;
#endif

	if (test_seed)
		return;

#ifndef _MSC_VER
	if ((tmp = getenv("TEST_LEVEL")))
		test_level = atoi(tmp);
	if ((tmp = getenv("TEST_SEED")))
		seed = atoi(tmp);
	else
#endif
		seed = test_clock() & 0xffffffff;

	srand(seed);
	test_seed = seed;
}
Ejemplo n.º 11
0
int main(int argc, char **argv) {
	int r = 0;
        const char *tests_to_run = NULL; /* all */
        int i;
	test_timing_t t_all;

#ifndef _MSC_VER
        tests_to_run = getenv("TESTS");
#endif

        for (i = 1 ; i < argc ; i++) {
			if (!strcmp(argv[i], "-p"))
				tests_run_in_parallel = 1;
			else if (i == 1)
				tests_to_run = argv[i];
                else {
                        printf("Unknown option: %s\n"
                               "\n"
							   "Usage: %s [options] [<test-match-substr>]\n"
                               "Options:\n"
                               "  -p     Run tests in parallel\n"
                               "\n",
                               argv[0], argv[i]);
                        exit(1);
                }
        }

	test_curr = "<MAIN>";
	test_start = test_clock();

	TEST_SAY("Tests to run: %s\n", tests_to_run ? tests_to_run : "all");

#define RUN_TEST(NAME) do { \
	extern int main_ ## NAME (int, char **); \
        if (!tests_to_run || strstr(# NAME, tests_to_run)) {     \
                r |= run_test(# NAME, main_ ## NAME, argc, argv);	\
        } else { \
                TEST_SAY("================= Skipping test %s "	\
			 "================\n", # NAME );	\
        } \
	} while (0)

	TIMING_START(&t_all, "ALL-TESTS");
	RUN_TEST(0001_multiobj);
	RUN_TEST(0002_unkpart);
	RUN_TEST(0003_msgmaxsize);
	RUN_TEST(0004_conf);
	RUN_TEST(0005_order);
	RUN_TEST(0006_symbols);
	RUN_TEST(0007_autotopic);
	RUN_TEST(0008_reqacks);
	RUN_TEST(0011_produce_batch);
	RUN_TEST(0012_produce_consume);
        RUN_TEST(0013_null_msgs);
        RUN_TEST(0014_reconsume_191);
	RUN_TEST(0015_offsets_seek);
	RUN_TEST(0017_compression);
	RUN_TEST(0018_cgrp_term);

        if (tests_run_in_parallel) {
                while (tests_running_cnt > 0)
                        rd_sleep(1);
        }

	TIMING_STOP(&t_all);

        /* Wait for everything to be cleaned up since broker destroys are
	 * handled in its own thread. */
	test_wait_exit(tests_run_in_parallel ? 10 : 5);

	/* If we havent failed at this point then
	 * there were no threads leaked */

	TEST_SAY("\n============== ALL TESTS PASSED ==============\n");
	return r;
}
Ejemplo n.º 12
0
int main(int argc, char **argv) {
        const char *tests_to_run = NULL; /* all */
        int test_flags = 0;
        int i, r;
	test_timing_t t_all;

	mtx_init(&test_mtx, mtx_plain);

        test_init();

#ifndef _MSC_VER
        tests_to_run = getenv("TESTS");
#endif

        for (i = 1 ; i < argc ; i++) {
                if (!strncmp(argv[i], "-p", 2) && strlen(argv[i]) > 2)
                        test_concurrent_max = strtod(argv[i]+2, NULL);
                else if (!strcmp(argv[i], "-l"))
                        test_flags |= TEST_F_LOCAL;
                else if (!strcmp(argv[i], "-a"))
                        test_assert_on_fail = 1;
                else if (*argv[i] != '-')
                        tests_to_run = argv[i];
                else {
                        printf("Unknown option: %s\n"
                               "\n"
                               "Usage: %s [options] [<test-match-substr>]\n"
                               "Options:\n"
                               "  -p<N>  Run N tests in parallel\n"
                               "  -l     Only run local tests (no broker needed)\n"
                               "  -a     Assert on failures\n"
                               "\n",
                               argv[0], argv[i]);
                        exit(1);
                }
        }

        test_curr = &tests[0];
        test_curr->state = TEST_PASSED;
        test_curr->start = test_clock();

	TEST_SAY("Tests to run: %s\n", tests_to_run ? tests_to_run : "all");
        TEST_SAY("Test filter: %s\n",
                 (test_flags & TEST_F_LOCAL) ?
                 "local tests only" : "no filter");
        TEST_SAY("Action on test failure: %s\n",
                 test_assert_on_fail ? "assert crash" : "continue other tests");

        test_timeout_set(20);

        TIMING_START(&t_all, "ALL-TESTS");

        run_tests(tests_to_run, test_flags, argc, argv);

        TEST_LOCK();
        while (tests_running_cnt > 0) {
                struct test *test;

                TEST_SAY("%d test(s) running:", tests_running_cnt);
                for (test = tests ; test->name ; test++)
                        if (test->state == TEST_RUNNING)
                                TEST_SAY0(" %s", test->name);
                TEST_SAY0("\n");
                TEST_UNLOCK();

                rd_sleep(1);
                TEST_LOCK();
        }

	TIMING_STOP(&t_all);

        test_curr = &tests[0];
        test_curr->duration = test_clock() - test_curr->start;

        TEST_UNLOCK();

        /* Wait for everything to be cleaned up since broker destroys are
	 * handled in its own thread. */
	test_wait_exit(10);

        r = test_summary(1/*lock*/) ? 1 : 0;

	/* If we havent failed at this point then
	 * there were no threads leaked */
        if (r == 0)
                TEST_SAY("\n============== ALL TESTS PASSED ==============\n");

	return r;
}
Ejemplo n.º 13
0
/**
 * @brief Print summary for all tests.
 *
 * @returns the number of failed tests.
 */
static int test_summary (int do_lock) {
        struct test *test;
        FILE *report_fp;
        char report_path[128];
        time_t t;
        struct tm *tm;
        char datestr[64];
        int64_t total_duration;
        int tests_run = 0;
        int tests_failed = 0;
        int tests_passed = 0;

        t = time(NULL);
        tm = localtime(&t);

        strftime(datestr, sizeof(datestr), "%Y%m%d%H%M%S", tm);
        rd_snprintf(report_path, sizeof(report_path), "test_report_%s.json",
                    datestr);

        report_fp = fopen(report_path, "w+");
        if (!report_fp)
                TEST_WARN("Failed to create report file %s: %s\n",
                          report_path, strerror(errno));
        else
                fprintf(report_fp,
                        "{ \"date\": \"%s\", \"tests\": [", datestr);

        printf("TEST SUMMARY\n"
               "#==================================================================#\n");
        if (do_lock)
                TEST_LOCK();
        for (test = tests ; test->name ; test++) {
                const char *color;
                int64_t duration;

                if (!(duration = test->duration) && test->start > 0)
                        duration = test_clock() - test->start;

                if (test == tests) /* <MAIN> test accounts for total runtime */
                        total_duration = duration;

                switch (test->state)
                {
                case TEST_PASSED:
                        color = _C_GRN;
                        tests_passed++;
                        tests_run++;
                        break;
                case TEST_FAILED:
                        color = _C_RED;
                        tests_failed++;
                        tests_run++;
                        break;
                case TEST_RUNNING:
                        color = _C_MAG;
                        tests_run++;
                        break;
                case TEST_NOT_STARTED:
                        color = _C_YEL;
                        break;
                default:
                        color = _C_CYA;
                        break;
                }

                printf("|%s %-40s | %10s | %7.3fs %s|\n",
                       color,
                       test->name, test_states[test->state],
                       (double)duration/1000000.0, _C_CLR);

                if (report_fp)
                        fprintf(report_fp,
                                "%s{"
                                "\"name\": \"%s\", "
                                "\"state\": \"%s\", "
                                "\"duration\": %.3f"
                                "}",
                                test == tests ? "": ", ",
                                test->name, test_states[test->state],
                                (double)duration/1000000.0);
        }
        if (do_lock)
                TEST_UNLOCK();

        printf("#==================================================================#\n");

        if (report_fp) {
                fprintf(report_fp,
                        "], "
                        "\"tests_run\": %d, "
                        "\"tests_passed\": %d, "
                        "\"tests_failed\": %d, "
                        "\"duration\": %.3f"
                        "}\n",
                        tests_run, tests_passed, tests_failed,
                        (double)total_duration/1000000.0);

                fclose(report_fp);
                TEST_SAY("# Test report written to %s\n", report_path);
        }

        return tests_failed;
}
Ejemplo n.º 14
0
int main_0089_max_poll_interval (int argc, char **argv) {
        const char *topic = test_mk_topic_name("0089_max_poll_interval", 1);
        uint64_t testid;
        const int msgcnt = 10;
        rd_kafka_t *c[2];
        rd_kafka_conf_t *conf;
        int64_t ts_next[2] = { 0, 0 };
        int64_t ts_exp_msg[2] = { 0, 0 };
        int cmsgcnt = 0;
        int i;
        int bad = -1;

        testid = test_id_generate();

        test_create_topic(topic, 1, 1);

        test_produce_msgs_easy(topic, testid, -1, msgcnt);

        test_conf_init(&conf, NULL, 60);

        test_conf_set(conf, "session.timeout.ms", "6000");
        test_conf_set(conf, "max.poll.interval.ms", "10000" /*10s*/);
        test_conf_set(conf, "auto.offset.reset", "earliest");

        c[0] = test_create_consumer(topic, NULL, rd_kafka_conf_dup(conf), NULL);
        c[1] = test_create_consumer(topic, NULL, conf, NULL);

        test_consumer_subscribe(c[0], topic);
        test_consumer_subscribe(c[1], topic);

        while (1) {
                for (i = 0 ; i < 2 ; i++) {
                        int64_t now;
                        rd_kafka_message_t *rkm;

                        /* Consumer is "processing" */
                        if (ts_next[i] > test_clock())
                                continue;

                        rkm = rd_kafka_consumer_poll(c[i], 100);
                        if (!rkm)
                                continue;

                        if (rkm->err) {
                                TEST_WARN("Consumer %d error: %s: "
                                          "ignoring\n", i,
                                          rd_kafka_message_errstr(rkm));
                                continue;
                        }

                        now = test_clock();

                        cmsgcnt++;

                        TEST_SAY("Consumer %d received message (#%d) "
                                 "at offset %"PRId64"\n",
                                 i, cmsgcnt, rkm->offset);

                        if (ts_exp_msg[i]) {
                                /* This consumer is expecting a message
                                 * after a certain time, namely after the
                                 * rebalance following max.poll.. being
                                 * exceeded in the other consumer */
                                TEST_ASSERT(now > ts_exp_msg[i],
                                            "Consumer %d: did not expect "
                                            "message for at least %dms",
                                            i,
                                            (int)((ts_exp_msg[i] - now)/1000));
                                TEST_ASSERT(now < ts_exp_msg[i] + 10000*1000,
                                            "Consumer %d: expected message "
                                            "within 10s, not after %dms",
                                            i,
                                            (int)((now - ts_exp_msg[i])/1000));
                                TEST_SAY("Consumer %d: received message "
                                         "at offset %"PRId64
                                         " after rebalance\n",
                                         i, rkm->offset);

                                rd_kafka_message_destroy(rkm);
                                goto done;

                        } else if (cmsgcnt == 1) {
                                /* Process this message for 20s */
                                ts_next[i] = now + (20000 * 1000);

                                /* Exp message on other consumer after
                                 * max.poll.interval.ms */
                                ts_exp_msg[i^1] = now + (10000 * 1000);

                                /* This is the bad consumer */
                                bad = i;

                                TEST_SAY("Consumer %d processing message at "
                                         "offset %"PRId64"\n",
                                         i, rkm->offset);
                                rd_kafka_message_destroy(rkm);
                        } else {
                                rd_kafka_message_destroy(rkm);

                                TEST_FAIL("Consumer %d did not expect "
                                          "a message", i);
                        }
                }
        }

 done:

        TEST_ASSERT(bad != -1, "Bad consumer not set");

        /* Wait for error ERR__MAX_POLL_EXCEEDED on the bad consumer. */
        while (1) {
                rd_kafka_message_t *rkm;

                rkm = rd_kafka_consumer_poll(c[bad], 1000);
                TEST_ASSERT(rkm, "Expected consumer result within 1s");

                TEST_ASSERT(rkm->err, "Did not expect message on bad consumer");

                TEST_SAY("Consumer error: %s: %s\n",
                         rd_kafka_err2name(rkm->err),
                         rd_kafka_message_errstr(rkm));

                if (rkm->err == RD_KAFKA_RESP_ERR__MAX_POLL_EXCEEDED) {
                        rd_kafka_message_destroy(rkm);
                        break;
                }

                rd_kafka_message_destroy(rkm);
        }


        for (i = 0 ; i < 2 ; i++)
                rd_kafka_destroy_flags(c[i],
                                       RD_KAFKA_DESTROY_F_NO_CONSUMER_CLOSE);
        return 0;
}
Ejemplo n.º 15
0
void sim_input_test (char lign[220], int *status, int *ptr)
{
	int j;
	
	switch (*status)
	{
		case CLOCK:
			if ( sscanf (lign, "%d", &horloge) )
			{
				if ( test_clock (horloge) )
				{
					sim_save_time (horloge);
					*status=OASIS_SIZE_PARAMETER;
					break;
				}
				
				else 
				{
					*status=EXIT;
					break;
				}
			}
			
			else 
			{
				error_missing_time();
				*status = EXIT;
				break;
			}
		
		case OASIS_SIZE_PARAMETER:
			if ( (sscanf(lign, "%d", &oasis)) )
			{
				if ( (test_oasis_size_parameter (oasis) ) )
				{
					oasis = 2*(oasis) + 1;
					sim_save_oasis(oasis);
					cell_create_tab(oasis);
					*status=OASIS;
					i=0;
					break;
				}
				
				else 
				{
					*status=EXIT;
					break;
				}
				
			}
			
			else 
			{
				error_missing_map_size();
				*status=EXIT;
				break;
			}
			
		case OASIS:
			for (j=0; j<oasis;j++)
			{
				if ( (sscanf (lign, "%c", &c_cell) ) )
				{
					if ( (test_oasis_cell(c_cell, i, j)) )
					{
						cell_add(oasis-1+DESERT_SIZE-i, j+DESERT_SIZE, c_cell);
						c_cell=0;
						lign++;
					}
					
					else
					{
						*status=EXIT;
						break;
					}	
				}
			}
			
			i++;
			
			if (i==oasis) 
			{
				*status = PREY_NUMBER;
				i=0;
				break;
			}
			
			break;
			
		case PREY_NUMBER:
			if( (sscanf(lign, "%d", &prey_nb)) && (test_number (prey_nb, PREY_NUMBER, oasis) ) )
			{
				sim_save_prey_nb(prey_nb);
				*status=PREY_COORDINATES;
				break;
			}
			 
			else 
			{
				error_missing_prey_number();
				*status=EXIT;
				break;
			}
			
		case PREY_COORDINATES:
			if ( (sscanf (lign, " %d %d %d %f ", &prey_x, &prey_y, &prey_bool, &prey_energy)) )
			{				
				if(test_coordinates (i, prey_nb, oasis, PREY_COORDINATES, prey_x, prey_y, prey_energy))
				{
					prey_add(prey_x, prey_y, prey_bool, prey_energy);
				
					if (i==prey_nb-1)
					{
						i=0;
						*status=PREDATOR_NUMBER;
						break;
					}
					
					if (i<prey_nb-1)
					{
						i++;
						break;
					}
				}
				
				else 
				{
					*status=EXIT;
					break;
				}
			}
			
			else 
			{
				*status = EXIT;
				break; 
			}
			
		
		case PREDATOR_NUMBER:
			if( (sscanf(lign, "%d", &pred_nb)) && (test_number (pred_nb, PREDATOR_NUMBER, oasis) ) )
			{
				sim_save_pred_nb(pred_nb);
				*status=PREDATOR_COORDINATES;
				break;
			}
			 
			else 
			{
				error_missing_predator_number();
				*status=EXIT;
				break;
			}
			
		case PREDATOR_COORDINATES:	
			if ( (sscanf (lign, " %d %d %f ", &pred_x, &pred_y, &pred_energy)) )
			{		
				pred_add(pred_x, pred_y, pred_energy);
				
				(*ptr)++;

				if(test_coordinates (i, pred_nb, oasis, PREDATOR_COORDINATES, pred_x, pred_y, pred_energy))
				{
					if (i==pred_nb-1)
					{
						input_is_valid();
						*status=CORRECT;
						break;
					}
					
					if (i<pred_nb-1)
					{
						i++;	
					}
				}
				
				else 
				{
					*status=EXIT;
					break;
				}
			}
			
			else 
			{
				*status = EXIT;
				break; 
			}
			
		case EXIT:
			break;
	}
	
}
void
selftest(void)
{
	// for handling "errout"

	if (setjmp(jbuf))
		return;

#if SELFTEST

	test_low_level();

	test_multiply();
	test_scan();
	test_power();
	test_factor_number();
	test_test();
	test_tensor();

	test_bake();

	test(__FILE__, s, sizeof (s) / sizeof (char *)); // "s" is in selftest.h

	test_abs();
	test_adj();
	test_arg();
	test_besselj();
	test_bessely();
	test_ceiling();
	test_choose();
	test_circexp();
	test_clock();
	test_cofactor();
	test_condense();
	test_contract();
	test_defint();
	test_denominator();
	test_derivative();
	test_dirac();
	test_erf();
	test_erfc();
	test_expand();
	test_expcos();
	test_expsin();
	test_factorpoly();
	test_float();
	test_floor();
	test_gamma();
	test_gcd();
	test_imag();
	test_inner();
	test_lcm();
	test_log();
	test_mag();
	test_mod();
	test_nroots();
	test_numerator();
	test_outer();
	test_polar();
	test_quotient();
	test_rationalize();
	test_real();
	test_rect();
	test_sgn();
	test_taylor();
	test_transpose();
	test_zero();

	test_hermite();
	test_laguerre();
	test_legendre();
	test_binomial();
	test_divisors();
	test_coeff();
	test_sin();
	test_cos();
	test_tan();
	test_sinh();
	test_cosh();
	test_tanh();
	test_arcsin();
	test_arcsinh();
	test_arccos();
	test_arccosh();
	test_arctan();
	test_arctanh();
	test_index();
	test_isprime();
	test_integral();
	test_simplify();
	test_roots();
	test_eigen();

#endif

	mini_test();

	logout("OK, all tests passed.\n");
}