Exemplo n.º 1
0
static void
restart_simulation (MainData *data)
{
	guint i;

	/* Have we finished? */
	if (data->num_test_runs_remaining == 0) {
		g_message (_("Stopping simulation due to performing the desired number of test runs."));

		stop_simulation (data);
		return;
	}

	g_message (_("Restarting simulation."));

	/* Stop the test program and reset all our simulation objects. */
	dsim_program_wrapper_kill (DSIM_PROGRAM_WRAPPER (data->test_program), FALSE);

	for (i = 0; i < data->simulated_objects->len; i++) {
		DfsmObject *simulated_object = g_ptr_array_index (data->simulated_objects, i);
		dfsm_object_reset (simulated_object);
	}

	dfsm_object_factory_set_unfuzzed_transition_limit (unfuzzed_transition_limit);

	/* Re-spawn the program under test. */
	spawn_test_program (data);
}
Exemplo n.º 2
0
void start_simulation(void) 
{ int kernel_st ;
  int tmp ;

  {
  {
  kernel_st = 0;
  init_threads();
  }
  {
  while (1) {
    while_3_continue: /* CIL Label */ ;
    {
    kernel_st = 1;
    eval();
    tmp = stop_simulation();
    }
    if (tmp) {
      goto while_3_break;
    } else {

    }
  }
  while_3_break: /* CIL Label */ ;
  }

  return;
}
}
Exemplo n.º 3
0
void start_simulation(void) 
{ int kernel_st ;
  int tmp ;
  int tmp___0 ;

  {
  {
  kernel_st = 0;
  update_channels();
  init_threads();
  fire_delta_events();
  activate_threads();
  reset_delta_events();
  }
  {
  while (1) {
    while_6_continue: /* CIL Label */ ;
    {
    kernel_st = 1;
    eval();
    }
    {
    kernel_st = 2;
    update_channels();
    }
    {
    kernel_st = 3;
    fire_delta_events();
    activate_threads();
    reset_delta_events();
    }
    {
    tmp = exists_runnable_thread();
    }
    if (tmp == 0) {
      {
      kernel_st = 4;
      fire_time_events();
      activate_threads();
      reset_time_events();
      }
    } else {

    }
    {
    tmp___0 = stop_simulation();
    }
    if (tmp___0) {
      goto while_6_break;
    } else {

    }
  }
  while_6_break: /* CIL Label */ ;
  }

  return;
}
}
Exemplo n.º 4
0
static gboolean
simulation_timeout_cb (MainData *data)
{
	g_message (_("Stopping simulation due to simulation timeout being reached."));
	stop_simulation (data);

	return FALSE;
}
Exemplo n.º 5
0
void main1() {
  int i;

  start_metric();
  pr("Starting Hello World", 0, PR_CPU_ID | PR_STRING | PR_NEWL);
  for(i=0;i<5;i++) {
      pr("", i, PR_CPU_ID | PR_DEC | PR_NEWL);
  }

  stop_metric();
  stop_simulation();
}
Exemplo n.º 6
0
static void
connection_closed_cb (GDBusConnection *connection, gboolean remote_peer_vanished, GError *error, MainData *data)
{
	g_debug ("D-Bus connection closed (remote peer vanished: %s, error: %s).", (remote_peer_vanished == TRUE) ? "yes" : "no",
	         (error != NULL) ? error->message : "no");

	/* Shut down if this wasn't the result of us calling close() on the connection. */
	if (remote_peer_vanished == TRUE || error != NULL) {
		g_clear_object (&data->connection);

		stop_simulation (data);
	}
}
Exemplo n.º 7
0
static void
test_program_died_cb (DsimProgramWrapper *wrapper, gint status, MainData *data)
{
	if (WIFEXITED (status) || (WIFSIGNALED (status) && (WTERMSIG (status) == SIGTERM || WTERMSIG (status) == SIGINT))) {
		/* Exited normally: proceed to the next test run. However, if bendy-bus was signalled beforehand, ignore the test program exiting
		 * and continue to close ourselves. */
		if (data->exit_signal == EXIT_SIGNAL_INVALID) {
			/* We have to do this in an idle callback so that we don't try to re-spawn the test program while it's still closing. */
			g_idle_add ((GSourceFunc) restart_simulation_idle_cb, data);
		}
	} else {
		/* Crashed: stop the entire simulation. */
		g_message (_("Stopping simulation due to test program crashing (status: %i)."), status);

		stop_simulation (data);
	}
}
void start_simulation(void) 
{ int kernel_st ;
  int tmp ;

  {
  {
  kernel_st = 0;
  update_channels();
  init_threads();
  fire_delta_events();
  activate_threads();
  reset_delta_events();
  }
  {
  while (1) {
    while_1_continue: /* CIL Label */ ;
    {
    kernel_st = 1;
    eval();
    }
    {
    kernel_st = 2;
    update_channels();
    }
    {
    kernel_st = 3;
    fire_delta_events();
    activate_threads();
    reset_delta_events();
    tmp = stop_simulation();
    }
    if (tmp) {
      goto while_1_break;
    } else {

    }
  }
  while_1_break: /* CIL Label */ ;
  }

  return;
}
}
Exemplo n.º 9
0
static void
signal_handler (int signum, MainData *data)
{
	g_debug ("signal_handler(%i) called.", signum);

	/* We need to propagate the signal when we exit, in order that the calling process knows we exited due to a signal.
	 * However, if we kill() now, we won't finish cleaning up properly (because we need to re-enter the main loop for a little
	 * while to be able to do that). */
	data->exit_status = STATUS_SUCCESS;
	data->exit_signal = signum;

	/* Have we created/spawned the test program yet? If not, we don't have much cleaning up to do. */
	if (data->test_program != NULL) {
		g_message (_("Stopping simulation due to receiving termination signal."));
		stop_simulation (data);
	} else {
		g_main_loop_quit (data->main_loop);
	}
}
Exemplo n.º 10
0
static void
spawn_test_program (MainData *data)
{
	GError *error = NULL;

	dsim_program_wrapper_spawn (DSIM_PROGRAM_WRAPPER (data->test_program), &error);

	if (data->num_test_runs_remaining > 0) {
		data->num_test_runs_remaining--;
	}

	if (error != NULL) {
		g_printerr (_("Error spawning test program instance: %s"), error->message);
		g_printerr ("\n");

		g_error_free (error);

		data->exit_status = STATUS_TEST_PROGRAM_SPAWN_ERROR;
		stop_simulation (data);

		return;
	}
}
Exemplo n.º 11
0
static void
dbus_daemon_died_cb (DsimProgramWrapper *wrapper, gint status, MainData *data)
{
	/* This should never happen. We assume the dbus-daemon is rock solid. */
	if (WIFEXITED (status) || (WIFSIGNALED (status) && (WTERMSIG (status) == SIGTERM || WTERMSIG (status) == SIGINT))) {
		/* Ignore the daemon disappearing if bendy-bus was signalled beforehand. */
		if (data->exit_signal == EXIT_SIGNAL_INVALID) {
			g_message (_("Stopping simulation due to dbus-daemon exiting (status: %i)."), status);
		}
	} else {
		g_message (_("Stopping simulation due to dbus-daemon crashing (status: %i)."), status);
	}

	if (data->exit_signal != EXIT_SIGNAL_INVALID) {
		return;
	}

	/* Have we created/spawned the test program yet? If not, we don't have much cleaning up to do. */
	if (data->test_program != NULL) {
		stop_simulation (data);
	} else {
		g_main_loop_quit (data->main_loop);
	}
}