Exemple #1
0
/* For verbose runs, print a short packet dump of all live packets. */
static void verbose_packet_dump(struct state *state, const char *type,
				struct packet *live_packet, s64 time_usecs)
{
	if (state->config->verbose) {
		char *dump = NULL, *dump_error = NULL;

		packet_to_string(live_packet, DUMP_SHORT,
				 &dump, &dump_error);

		printf("%s packet: %9.6f %s%s%s\n",
		       type, usecs_to_secs(time_usecs), dump,
		       dump_error ? "\n" : "",
		       dump_error ? dump_error : "");

		free(dump);
		free(dump_error);
	}
}
Exemple #2
0
/* Add a dump of the given packet to the given error message.
 * Frees *error and replaces it with a version that has the original
 * *error followed by the given type and a hex dump of the given
 * packet.
 */
static void add_packet_dump(char **error, const char *type,
			    struct packet *packet, s64 time_usecs,
			    enum dump_format_t format)
{
	if (packet->ip_bytes != 0) {
		char *old_error = *error;
		char *dump = NULL, *dump_error = NULL;

		packet_to_string(packet, format,
				 &dump, &dump_error);
		asprintf(error, "%s\n%s packet: %9.6f %s%s%s",
			 old_error, type, usecs_to_secs(time_usecs), dump,
			 dump_error ? "\n" : "",
			 dump_error ? dump_error : "");

		free(dump);
		free(dump_error);
		free(old_error);
	}
}
Exemple #3
0
/*
 * Verify that something happened at the expected time.
 * WARNING: verify_time() should not be looking at state->event
 * because in some cases (checking the finish time for blocking system
 * calls) we call verify_time() at a time when state->event
 * points at an event other than the one whose time we're currently
 * checking.
 */
int verify_time(struct state *state, enum event_time_t time_type,
                s64 script_usecs, s64 script_usecs_end,
                s64 live_usecs, const char *description, char **error)
{
	s64 expected_usecs = script_usecs - state->script_start_time_usecs;
	s64 expected_usecs_end = script_usecs_end -
	                         state->script_start_time_usecs;
	s64 actual_usecs = live_usecs - state->live_start_time_usecs;
	int tolerance_usecs = state->config->tolerance_usecs;

	DEBUGP("expected: %.3f actual: %.3f  (secs)\n",
	       usecs_to_secs(script_usecs), usecs_to_secs(actual_usecs));

	if (time_type == ANY_TIME)
		return STATUS_OK;

	if (time_type == ABSOLUTE_RANGE_TIME ||
	        time_type == RELATIVE_RANGE_TIME)
	{
		DEBUGP("expected_usecs_end %.3f\n",
		       usecs_to_secs(script_usecs_end));
		if (actual_usecs < (expected_usecs - tolerance_usecs) ||
		        actual_usecs > (expected_usecs_end + tolerance_usecs))
		{
			if (time_type == ABSOLUTE_RANGE_TIME)
			{
#ifdef ECOS
				int len = strlen("timing error: expected ") + strlen(description) + strlen(" in time range ~ sec ") + 32 + strlen("but happened at  sec");
				*error = malloc(len);
				snprintf(*error, len, "timing error: expected "
				         "%s in time range %.6f~%.6f sec "
				         "but happened at %.6f sec",
				         description,
				         usecs_to_secs(script_usecs),
				         usecs_to_secs(script_usecs_end),
				         usecs_to_secs(actual_usecs));
#else
				asprintf(error,
				         "timing error: expected "
				         "%s in time range %.6f~%.6f sec "
				         "but happened at %.6f sec",
				         description,
				         usecs_to_secs(script_usecs),
				         usecs_to_secs(script_usecs_end),
				         usecs_to_secs(actual_usecs));
#endif
			}
			else if (time_type == RELATIVE_RANGE_TIME)
			{
				s64 offset_usecs = state->event->offset_usecs;
#ifdef ECOS
				int len = strlen("timing error: expected ") + strlen(description) + strlen(" in relative time range +~+ ") + 32 + strlen("sec but happened at  sec");
				*error = malloc(len);
				snprintf(*error, len, "timing error: expected "
				         "%s in relative time range +%.6f~+%.6f "
				         "sec but happened at %+.6f sec",
				         description,
				         usecs_to_secs(script_usecs -
				                       offset_usecs),
				         usecs_to_secs(script_usecs_end -
				                       offset_usecs),
				         usecs_to_secs(actual_usecs -
				                       offset_usecs));
#else
				asprintf(error,
				         "timing error: expected "
				         "%s in relative time range +%.6f~+%.6f "
				         "sec but happened at %+.6f sec",
				         description,
				         usecs_to_secs(script_usecs -
				                       offset_usecs),
				         usecs_to_secs(script_usecs_end -
				                       offset_usecs),
				         usecs_to_secs(actual_usecs -
				                       offset_usecs));
#endif
			}
			return STATUS_ERR;
		}
		else
		{
			return STATUS_OK;
		}
	}

	if ((actual_usecs < (expected_usecs - tolerance_usecs)) ||
	        (actual_usecs > (expected_usecs + tolerance_usecs)))
	{
#ifdef ECOS
		int len = strlen("timing error: expected ") + strlen(description) + strlen(" at  sec but happened at  sec") + 24;
		*error = malloc(len);
		snprintf(*error, len, 		         "timing error: "
		         "expected %s at %.6f sec but happened at %.6f sec",
		         description,
		         usecs_to_secs(script_usecs),
		         usecs_to_secs(actual_usecs));
#else
		asprintf(error,
		         "timing error: "
		         "expected %s at %.6f sec but happened at %.6f sec",
		         description,
		         usecs_to_secs(script_usecs),
		         usecs_to_secs(actual_usecs));
#endif
		return STATUS_ERR;
	}
	else
	{
		return STATUS_OK;
	}
}
Exemple #4
0
struct rmDsummary *parse_summary(FILE *stream, char *filename)
{
	static FILE *last_stream = NULL;
	static int   summ_id     = 1;

	if(last_stream != stream)
	{
		last_stream = stream;
		summ_id     = 1;
	}
	else
	{
		summ_id++;
	}

	struct rmsummary  *so = rmsummary_parse_next(stream);

	if(!so)
		return NULL;

	struct rmDsummary *s  = malloc(sizeof(struct rmDsummary));

	s->command    = so->command;

	s->file       = xxstrdup(filename);

	if(so->category)
	{
		s->category   = so->category;
	}
	else if(so->command)
	{
		s->category   = parse_executable_name(so->command);
	}
	else
	{
		s->category   = xxstrdup(DEFAULT_CATEGORY);
		s->command    = xxstrdup(DEFAULT_CATEGORY);
	}

	s->start     = usecs_to_secs(so->start);
	s->end       = usecs_to_secs(so->end);
	s->wall_time = usecs_to_secs(so->wall_time);
	s->cpu_time  = usecs_to_secs(so->cpu_time);

	s->cores = so->cores;
	s->total_processes = so->total_processes;
	s->max_concurrent_processes = so->max_concurrent_processes;

	s->virtual_memory = so->virtual_memory;
	s->resident_memory = so->resident_memory;
	s->swap_memory = so->swap_memory;

	s->bytes_read    = bytes_to_Mbytes(so->bytes_read);
	s->bytes_written = bytes_to_Mbytes(so->bytes_written);

	s->workdir_num_files = so->workdir_num_files;
	s->workdir_footprint = so->workdir_footprint;

	s->task_id = so->task_id;
	if(s->task_id < 0)
	{
		s->task_id = get_rule_number(filename);
	}

	struct field *f;
	for(f = &fields[WALL_TIME]; f->name != NULL; f++)
	{
		if(value_of_field(s, f) < 0)
		{
			assign_to_field(s, f, 0);
		}
	}

	free(so); //we do not free so->command on purpouse.

	return s;
}