Exemplo n.º 1
0
static void testcase10(void)
{
  /* try to shut down when an emergency call is ongoing */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // set up an emergency call
  DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE msg =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE);
  msg.ongoing = true;
  send_message(state, &msg);

  // request shutdown
  DSM_MSGTYPE_SHUTDOWN_REQ msg2 = TEST_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ);
  send_message(state, &msg2);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // stop the emergency call
  msg.ongoing = false;
  send_message(state, &msg);
  expect_shutdown(state);

  unload_module_under_test(state);
}
Exemplo n.º 2
0
static void expect_shutdown_or_reboot(module_t*    module,
                                      dsme_state_t state,
                                      int          runlevel)
{
  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == state);
  free(ind);

  DSM_MSGTYPE_SAVE_DATA_IND* ind2;
  assert((ind2 = queued(DSM_MSGTYPE_SAVE_DATA_IND)));
  free(ind2);

  assert(message_queue_is_empty());
  assert(timer_exists());

  trigger_timer();

  DSM_MSGTYPE_SHUTDOWN* msg3;
  assert((msg3 = queued(DSM_MSGTYPE_SHUTDOWN)));
  assert(msg3->runlevel == runlevel);
  free(msg3);

  assert(!timer_exists());
  assert(message_queue_is_empty());
}
Exemplo n.º 3
0
static void testcase2b(void)
{
  /*
   * continue after booting to actdead
   * 2. unplug a known to be plugged in charger
   * 3. wait for the shutdown to happen
   */
  module_t* state = load_state_module("ACT_DEAD", DSME_STATE_ACTDEAD);
  assert(!timer_exists());

  // unplug charger
  connect_charger(state);
  assert(!timer_exists());
  assert(message_queue_is_empty());
  disconnect_charger(state);
  assert(timer_exists());
  assert(message_queue_is_empty());

  // plug charger
  connect_charger(state);
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);
  assert(message_queue_is_empty());
  assert(timer_exists());

  // wait for the shutdown
  trigger_timer();
  expect_shutdown(state);

  unload_module_under_test(state);
}
Exemplo n.º 4
0
static void testcase17(void)
{
  /*
   * 1. overheat
   * 2. cool down before shutdown; we still have to shutdown
   */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // overheat
  DSM_MSGTYPE_SET_THERMAL_STATE msg =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_THERMAL_STATE);
  msg.overheated = true;
  send_message(state, &msg);

  assert(message_queue_is_empty());
  assert(timer_exists());

  // cool down
  DSM_MSGTYPE_SET_THERMAL_STATE msg2 =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_THERMAL_STATE);
  msg2.overheated = false;
  send_message(state, &msg2);

  assert(message_queue_is_empty());
  assert(timer_exists());

  trigger_timer();
  expect_shutdown(state);
  unload_module_under_test(state);
}
Exemplo n.º 5
0
/* 300sec > DSME SNOOZE TIMEOUT */
static void test_init_alarm_in5min(void)
{
  load_alarmtracker(time(0)+300);

  /* INTERNAL MSGs */
  DSM_MSGTYPE_SET_ALARM_STATE *msg;
  assert(message_queue_is_empty());

  /* DBUS IF */
  assert(dbusmsgq_async->len == 0);
  assert(dbusmsgq_blocking->len == 0);

  /* DSMESOCK */
  assert((msg = queued_dsmesock(DSM_MSGTYPE_SET_ALARM_STATE)));
  assert(msg->alarm_set);
  free(msg);
  assert(g_slist_length(dsmesock_broadcasts)==0);

  assert(timer_exists());
  sumtime(first_timer_seconds());
  trigger_timer();

  assert(!message_queue_is_empty());
  assert((msg = queued(DSM_MSGTYPE_SET_ALARM_STATE)));
  assert(msg->alarm_set);
  free(msg);
  assert(dbusmsgq_async->len == 0);
  assert(dbusmsgq_blocking->len == 0);
  assert(g_slist_length(dsmesock_broadcasts)==0);

  assert(!timer_exists());

  unload_alarmtracker();
}
Exemplo n.º 6
0
static void request_shutdown_expecting_actdead(module_t* state)
{
  DSM_MSGTYPE_SHUTDOWN_REQ msg = TEST_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ);
  send_message(state, &msg);

  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_ACTDEAD);
  free(ind);

  DSM_MSGTYPE_SAVE_DATA_IND* ind2;
  assert((ind2 = queued(DSM_MSGTYPE_SAVE_DATA_IND)));
  free(ind2);

  assert(message_queue_is_empty());
  assert(timer_exists());

  trigger_timer();

  DSM_MSGTYPE_CHANGE_RUNLEVEL* msg2;
  assert((msg2 = queued(DSM_MSGTYPE_CHANGE_RUNLEVEL)));
  assert(msg2->runlevel == 5);
  free(msg2);

  assert(!timer_exists());
  assert(message_queue_is_empty());
}
Exemplo n.º 7
0
static void testcase7(void)
{
  /* start in actdead */
  module_t* state = load_state_module("ACT_DEAD", DSME_STATE_ACTDEAD);
  assert(!timer_exists());

  assert(message_queue_is_empty());
  assert(!timer_exists());

  unload_module_under_test(state);
}
Exemplo n.º 8
0
/* Set alarm with com.nokia.time dbus interface */
static void test_init_set_alarm_in5min(void)
{
  load_alarmtracker(0);

  DBusMessage* alarm_setup_msg = dbus_message_new_signal("/com/nokia/time", "com.nokia.time", "next_bootup_event");

  time_t new_alarm_time = time(0)+300;
  dbus_message_append_args(alarm_setup_msg,
                           DBUS_TYPE_INT32, &new_alarm_time);

  dsme_dbus_stub_send_signal(alarm_setup_msg);
  free(alarm_setup_msg);

  assert(!message_queue_is_empty());
  assert(queued(DSM_MSGTYPE_WAIT));
  assert(message_queue_is_empty());

  DSM_MSGTYPE_WAKEUP wakeupmsg =
      TEST_MSG_INIT(DSM_MSGTYPE_WAKEUP);
  send_message(alarmtracker_module, &wakeupmsg);


  /* INTERNAL MSGs */
  DSM_MSGTYPE_SET_ALARM_STATE *msg;
  assert(message_queue_is_empty());

  /* DBUS IF */
  assert(dbusmsgq_async->len == 0);
  assert(dbusmsgq_blocking->len == 0);

  /* DSMESOCK */
  assert((msg = queued_dsmesock(DSM_MSGTYPE_SET_ALARM_STATE)));
  assert(msg->alarm_set);
  free(msg);
  assert(g_slist_length(dsmesock_broadcasts)==0);

  assert(timer_exists());
  sumtime(first_timer_seconds());
  trigger_timer();

  assert(!message_queue_is_empty());
  assert((msg = queued(DSM_MSGTYPE_SET_ALARM_STATE)));
  assert(msg->alarm_set);
  free(msg);
  assert(dbusmsgq_async->len == 0);
  assert(dbusmsgq_blocking->len == 0);
  assert(g_slist_length(dsmesock_broadcasts)==0);

  assert(!timer_exists());

  unload_alarmtracker();
}
Exemplo n.º 9
0
static void testcase14(void)
{
  /*
   * 1. request shutdown when charger is known to be plugged in
   * 2. start emergency call before timer runs out
   * 3. stop emergency call
   */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // plug in charger
  connect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // request shutdown
  DSM_MSGTYPE_SHUTDOWN_REQ msg = TEST_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ);
  send_message(state, &msg);

  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_ACTDEAD);
  free(ind);

  DSM_MSGTYPE_SAVE_DATA_IND* ind2;
  assert((ind2 = queued(DSM_MSGTYPE_SAVE_DATA_IND)));
  free(ind2);

  assert(message_queue_is_empty());
  assert(timer_exists());

  // start emergency call
  DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE msg2 =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE);
  msg2.ongoing = true;
  send_message(state, &msg2);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // stop emergency call
  DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE msg3 =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_EMERGENCY_CALL_STATE);
  msg3.ongoing = false;
  send_message(state, &msg3);

  // TODO: should we go to actdead instead?
  assert(message_queue_is_empty());
  assert(!timer_exists());

  unload_module_under_test(state);
}
Exemplo n.º 10
0
static void testcase5(void)
{
  /*
   * 1. request shutdown when charger is known to be unplugged
   * 2. plug in charger before timer runs out
   * => expect shutdown
   */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // request shutdown
  DSM_MSGTYPE_SHUTDOWN_REQ msg = TEST_MSG_INIT(DSM_MSGTYPE_SHUTDOWN_REQ);
  send_message(state, &msg);

  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_SHUTDOWN);
  free(ind);

  DSM_MSGTYPE_SAVE_DATA_IND* ind2;
  assert((ind2 = queued(DSM_MSGTYPE_SAVE_DATA_IND)));
  free(ind2);

  assert(message_queue_is_empty());
  assert(timer_exists());

  // plug in charger
  connect_charger(state);
  assert(message_queue_is_empty());

  // expect shutdown
  trigger_timer();
  DSM_MSGTYPE_HWWD_KICK* ind3;
  assert((ind3 = queued(DSM_MSGTYPE_HWWD_KICK)));
  free(ind3);
  DSM_MSGTYPE_SHUTDOWN* msg2;
  assert((msg2 = queued(DSM_MSGTYPE_SHUTDOWN)));
  assert(msg2->runlevel == 0);
  free(msg2);
  assert(!timer_exists());
  assert(message_queue_is_empty());

  unload_module_under_test(state);
}
Exemplo n.º 11
0
static void testcase20(void)
{
  /* weird $BOOTSTATE cases */
  gchar* module_name = g_strconcat(dsme_module_path, "state.so", NULL);

  // do not specify $BOOTSTATE
  module_t* state = load_module_under_test(module_name);
  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert(ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND));
  assert(ind->state == DSME_STATE_USER);
  free(ind);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);

  // specify a bad $BOOTSTATE
  state = load_state_module("DIIBADAABA", DSME_STATE_USER);

  DSM_MSGTYPE_ENTER_MALF* msg;
  assert(msg = queued(DSM_MSGTYPE_ENTER_MALF));
  free(msg);
  assert(!timer_exists());
  assert(message_queue_is_empty());
  unload_module_under_test(state);

  // specify SHUTDOWN
  setenv("BOOTSTATE", "SHUTDOWN", true);
  state = load_module_under_test(module_name);
  unsetenv("BOOTSTATE");
  expect_shutdown(state);
  unload_module_under_test(state);

  // specify SHUTDOWN
  setenv("BOOTSTATE", "SHUTDOWN", true);
  state = load_module_under_test(module_name);
  unsetenv("BOOTSTATE");
  expect_shutdown(state);
  unload_module_under_test(state);

  // specify BOOT
  setenv("BOOTSTATE", "BOOT", true);
  state = load_module_under_test(module_name);
  unsetenv("BOOTSTATE");
  expect_reboot(state);
  unload_module_under_test(state);

  g_free(module_name);
}
Exemplo n.º 12
0
static void testcase6(void)
{
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // plug and unplug charger
  connect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  disconnect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  unload_module_under_test(state);
}
Exemplo n.º 13
0
int	update_system_timer (const char *entry)
{
	int	i;
	int	all = 0;

	if (entry == NULL)
		all = 1;

	for (i = 0; system_timers[i].name; i++)
	{
	    if (all == 1 || !strcmp(system_timers[i].name, entry))
	    {
		/* This needs to be set before calling 'system_timer' */
		get_time(&now);

		if (get_int_var(*system_timers[i].toggle_variable) &&
		    get_int_var(*system_timers[i].interval_variable))
			system_timer(&system_timers[i]);
		else
		{
		    if (timer_exists(system_timers[i].name))
			remove_timer(system_timers[i].name);
		}

		if (all == 0)
			return 0;
	    }
	}

	if (all == 1)
		return 0;

	return -1;
}
Exemplo n.º 14
0
static void testcase21(void)
{
  /* non-rd_mode cases and cal problems */

  // non-rd_mode
  rd_mode = "";
  setenv("BOOTSTATE", "DIIBADAABA", true);
  module_t* state = load_module_under_test("../modules/libstate.so");
  unsetenv("BOOTSTATE");
  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_MALF);
  free(ind);
  assert(message_queue_is_empty());
  assert(timer_exists());
  trigger_timer();
  DSM_MSGTYPE_HWWD_KICK* ind3;
  assert((ind3 = queued(DSM_MSGTYPE_HWWD_KICK)));
  free(ind3);
  DSM_MSGTYPE_SHUTDOWN* msg;
  assert((msg = queued(DSM_MSGTYPE_SHUTDOWN)));
  assert(msg->runlevel == 8);
  free(msg);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);

  // cal problem
  rd_mode = 0;
  setenv("BOOTSTATE", "DIIBADAABA", true);
  state = load_module_under_test("../modules/libstate.so");
  unsetenv("BOOTSTATE");
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_MALF);
  free(ind);
  assert(message_queue_is_empty());
  assert(timer_exists());
  trigger_timer();
  assert((ind3 = queued(DSM_MSGTYPE_HWWD_KICK)));
  free(ind3);
  assert((msg = queued(DSM_MSGTYPE_SHUTDOWN)));
  assert(msg->runlevel == 8);
  free(msg);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);
}
Exemplo n.º 15
0
static void testcase18(void)
{
  /*
   * 1. start in actdead
   * 2. request startup
   */
  module_t* state = load_state_module("ACT_DEAD", DSME_STATE_ACTDEAD);
  assert(!timer_exists());
  assert(message_queue_is_empty());

  // query state
  DSM_MSGTYPE_STATE_QUERY msg = TEST_MSG_INIT(DSM_MSGTYPE_STATE_QUERY);
  send_message(state, &msg);
  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_ACTDEAD);
  free(ind);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // request startup
  DSM_MSGTYPE_POWERUP_REQ msg2 = TEST_MSG_INIT(DSM_MSGTYPE_POWERUP_REQ);
  send_message(state, &msg2);

  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_USER);
  free(ind);

  assert(timer_exists());
  trigger_timer();

  DSM_MSGTYPE_CHANGE_RUNLEVEL* req;
  assert((req = queued(DSM_MSGTYPE_CHANGE_RUNLEVEL)));
  assert(req->runlevel == 2);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // query state
  send_message(state, &msg);
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_USER);
  free(ind);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);
}
Exemplo n.º 16
0
static void testcase22(void)
{
  /* TEST/LOCAL mode */

  // boot to TEST state
  module_t* state = load_state_module("TEST", DSME_STATE_TEST);
  assert(!timer_exists());
  unload_module_under_test(state);
}
Exemplo n.º 17
0
static void testcase2(void)
{
  /*
   * 1. request shutdown when charger is known to be plugged in
   */
  // boot to user state
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // request shutdown when charger connected
  connect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  request_shutdown_expecting_actdead(state);

  unload_module_under_test(state);
}
Exemplo n.º 18
0
static void testcase11(void)
{
  /* reboot */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // request reboot
  DSM_MSGTYPE_REBOOT_REQ msg = TEST_MSG_INIT(DSM_MSGTYPE_REBOOT_REQ);
  send_message(state, &msg);
  expect_reboot(state);

  unload_module_under_test(state);
}
Exemplo n.º 19
0
static void testcase21(void)
{
  /* non-rd_mode cases and cal problems */

  gchar* module_name = g_strconcat(dsme_module_path, "state.so", NULL);

  // non-rd_mode
  rd_mode = "";
  unsetenv("DSME_RD_FLAGS_ENV");
  setenv("BOOTSTATE", "DIIBADAABA", true);
  module_t* state = load_module_under_test(module_name);
  unsetenv("BOOTSTATE");
  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert(ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND));
  assert(ind->state == DSME_STATE_USER);
  free(ind);
  assert(!message_queue_is_empty());
  DSM_MSGTYPE_ENTER_MALF* malfmsg;
  assert((malfmsg = queued(DSM_MSGTYPE_ENTER_MALF)));
  //TODO: Should the reason / component be checked?
  free(malfmsg);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);

  // cal problem
  rd_mode = 0;
  setenv("BOOTSTATE", "DIIBADAABA", true);
  state = load_module_under_test(module_name);
  unsetenv("BOOTSTATE");
  assert(ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND));
  assert(ind->state == DSME_STATE_USER);
  free(ind);
  assert(!message_queue_is_empty());
  assert(malfmsg = queued(DSM_MSGTYPE_ENTER_MALF));
  //TODO: Should the reason / component be checked?
  free(malfmsg);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);

  g_free(module_name);
}
Exemplo n.º 20
0
static void testcase16(void)
{
  /* thermal shutdown due to overheating */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  DSM_MSGTYPE_SET_THERMAL_STATE msg =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_THERMAL_STATE);
  msg.overheated = true;
  send_message(state, &msg);

  assert(message_queue_is_empty());
  assert(timer_exists());

  trigger_timer();
  expect_shutdown(state);

  unload_module_under_test(state);
}
Exemplo n.º 21
0
static void testcase12(void)
{
  /* shutdown on empty battery */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);

  // indicate an empty battery
  DSM_MSGTYPE_SET_BATTERY_STATE msg =
      TEST_MSG_INIT(DSM_MSGTYPE_SET_BATTERY_STATE);
  msg.empty = true;
  send_message(state, &msg);

  assert(timer_exists());
  trigger_timer();

  DSM_MSGTYPE_BATTERY_EMPTY_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_BATTERY_EMPTY_IND)));
  free(ind);

  DSM_MSGTYPE_STATE_CHANGE_IND* ind2;
  assert((ind2 = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind2->state == DSME_STATE_SHUTDOWN);
  free(ind2);

  DSM_MSGTYPE_SAVE_DATA_IND* ind3;
  assert((ind3 = queued(DSM_MSGTYPE_SAVE_DATA_IND)));
  free(ind3);

  // expect shutdown
  trigger_timer();
  DSM_MSGTYPE_SHUTDOWN* msg2;
  assert((msg2 = queued(DSM_MSGTYPE_SHUTDOWN)));
  assert(msg2->runlevel == 0);
  free(msg2);
  assert(!timer_exists());
  assert(message_queue_is_empty());

  unload_module_under_test(state);
}
Exemplo n.º 22
0
static void testcase1(void)
{
  /* request shutdown right after starting in user state */

  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  request_shutdown_expecting_reboot(state);

  unload_module_under_test(state);
}
Exemplo n.º 23
0
static void testcase20(void)
{
  /* weird $BOOTSTATE cases */

  // do not specify $BOOTSTATE
  module_t* state = load_module_under_test("../modules/libstate.so");
  DSM_MSGTYPE_STATE_CHANGE_IND* ind;
  assert((ind = queued(DSM_MSGTYPE_STATE_CHANGE_IND)));
  assert(ind->state == DSME_STATE_MALF);
  free(ind);
  assert(message_queue_is_empty());
  assert(!timer_exists());
  unload_module_under_test(state);

  // specify a bad $BOOTSTATE
  state = load_state_module("DIIBADAABA", DSME_STATE_MALF);
  assert(!timer_exists());
  assert(message_queue_is_empty());
  unload_module_under_test(state);

  // specify SHUTDOWN
  setenv("BOOTSTATE", "SHUTDOWN", true);
  state = load_module_under_test("../modules/libstate.so");
  unsetenv("BOOTSTATE");
  expect_shutdown(state);
  unload_module_under_test(state);

  // specify SHUTDOWN
  setenv("BOOTSTATE", "SHUTDOWN", true);
  state = load_module_under_test("../modules/libstate.so");
  unsetenv("BOOTSTATE");
  expect_shutdown(state);
  unload_module_under_test(state);

  // specify BOOT
  setenv("BOOTSTATE", "BOOT", true);
  state = load_module_under_test("../modules/libstate.so");
  unsetenv("BOOTSTATE");
  expect_reboot(state);
  unload_module_under_test(state);
}
Exemplo n.º 24
0
static void test_init_noalarm(void)
{
  load_alarmtracker(0);

  assert(message_queue_is_empty());
  assert(!timer_exists());

  assert(dbusmsgq_async->len == 0);
  assert(dbusmsgq_blocking->len == 0);

  unload_alarmtracker();
}
Exemplo n.º 25
0
static void testcase1(void)
{
  /* request shutdown right after starting in user state */
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  request_shutdown_expecting_actdead(state);

  unload_module_under_test(state);

  assert(g_slist_length(dbus_signal_bindings) == 0);
}
Exemplo n.º 26
0
static void testcase8(void)
{
  /* start in actdead and unplug the charger */
  module_t* state = load_state_module("ACT_DEAD", DSME_STATE_ACTDEAD);
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);
  expect_shutdown(state);

  unload_module_under_test(state);
}
Exemplo n.º 27
0
static void testcase9(void)
{
  /* start in actdead and plug and uplug the charger */
  module_t* state = load_state_module("ACT_DEAD", DSME_STATE_ACTDEAD);
  assert(!timer_exists());

  // plug charger
  connect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  // unplug charger
  disconnect_charger(state);
  assert(message_queue_is_empty());
  assert(timer_exists());

  // wait for the shutdown
  trigger_timer();
  expect_shutdown(state);

  unload_module_under_test(state);
}
Exemplo n.º 28
0
static void testcase3(void)
{
  /*
   * 1. request shutdown when charger is known to be plugged in
   * 2. unplug charger
   * 3. plug the charger back in
   * 4. unplug charger
   * 5. wait for the shutdown to happen
   */
  // boot to user state
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  // request shutdown when charger connected
  connect_charger(state);
  assert(message_queue_is_empty());
  assert(!timer_exists());

  request_shutdown_expecting_reboot(state);

  unload_module_under_test(state);
}
Exemplo n.º 29
0
void    set_cpu_saver_after (const void *stuff)
{
	int value = *(const int *)stuff;

        if (value == 0)
	{
		/* Remove the watchdog timer only if it is running. */
		if (timer_exists(cpu_saver_timeref))
			remove_timer(cpu_saver_timeref);
	}
	else
                cpu_saver_timer(NULL);
}
Exemplo n.º 30
0
static void testcase4(void)
{
  /* request shutdown when charger is known to be unplugged */

  // boot to user state
  module_t* state = load_state_module("USER", DSME_STATE_USER);
  assert(!timer_exists());

  disconnect_charger(state);

  request_shutdown_expecting_shutdown(state);

  unload_module_under_test(state);
}