示例#1
0
END_TEST


START_TEST(test_send_test_error)
{
  TestResult *tr;
  setup_messaging();
  send_ctx_info(CK_CTX_SETUP);
  send_loc_info("abc123.c", 10);
  send_ctx_info(CK_CTX_TEST);
  send_loc_info("abc124.c", 22);
  send_loc_info("abc125.c", 25);
  tr = receive_test_result(1);
  teardown_messaging();

  ck_assert_msg (tr != NULL,
	       "No test result received");
  ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST,
	       "Bad CTX received");
  ck_assert_msg (strcmp(tr_lfile(tr), "abc125.c") == 0,
	       "Bad loc file received");
  ck_assert_msg (tr_lno(tr) == 25,
	       "Bad loc line received");
  if (tr != NULL)
    tr_free(tr);
}
示例#2
0
文件: run.c 项目: maleadt/genetic
static TestResult * tcase_run_checked_setup (SRunner *sr, TCase *tc)
{
  TestResult *tr = NULL;
  List *l;
  Fixture *f;
  enum fork_status fstat = srunner_fork_status(sr);
  
  l = tc->ch_sflst;
  if (fstat == CK_FORK) {
    send_ctx_info(CK_CTX_SETUP);
  }
  
  for (list_front(l); !list_at_end(l); list_advance(l)) {
    if (fstat == CK_NOFORK) {
      send_ctx_info(CK_CTX_SETUP);
    }
    f = list_val(l);
    f->fun();

    /* Stop the setup and return the failure if nofork mode. */
    if (fstat == CK_NOFORK) {
      tr = receive_result_info_nofork (tc->name, "checked_setup", 0);
      if (tr->rtype != CK_PASS) {
        break;
      }

      free(tr->file);
      free(tr->msg);
      free(tr);
      tr = NULL;
    }
  }

  return tr;
}
示例#3
0
END_TEST

START_TEST(test_send_big)
{
  TestResult *tr;
  int i;
  
  setup_messaging();
  send_ctx_info(CK_CTX_SETUP);
  send_loc_info("abc123.c", 10);
  for (i = 0; i < 10000; i++) {
    send_ctx_info(CK_CTX_TEST);
    send_loc_info("abc124.c", i);
  }

  tr = receive_test_result(0);
  teardown_messaging();

  ck_assert_msg (tr != NULL,
	       "No test result received");
  ck_assert_msg (tr_ctx(tr) == CK_CTX_TEST,
	       "Bad CTX received");
  ck_assert_msg (strcmp(tr_lfile(tr), "abc124.c") == 0,
	       "Bad loc file received");
  ck_assert_msg (tr_lno(tr) == i -1,
	       "Bad loc line received");
  if (tr != NULL)
    tr_free(tr);
}
示例#4
0
文件: run.c 项目: maleadt/genetic
static int srunner_run_unchecked_setup (SRunner *sr, TCase *tc)
{
  TestResult *tr;
  List *l;
  Fixture *f;
  int rval = 1;

  set_fork_status(CK_NOFORK);

  l = tc->unch_sflst;

  for (list_front(l); !list_at_end(l); list_advance(l)) {
    send_ctx_info(CK_CTX_SETUP);
    f = list_val(l);
    f->fun();

    tr = receive_result_info_nofork (tc->name, "unchecked_setup", 0);

    if (tr->rtype != CK_PASS) {
      srunner_add_failure(sr, tr);
      rval = 0;
      break;
    }
    free(tr->file);
    free(tr->msg);
    free(tr);
  } 

  set_fork_status(srunner_fork_status(sr));
  return rval;
}
示例#5
0
文件: run.c 项目: maleadt/genetic
static void srunner_run_teardown (List *l)
{
  Fixture *f;
  
  for (list_front(l); !list_at_end(l); list_advance(l)) {
    f = list_val(l);
    send_ctx_info(CK_CTX_TEARDOWN);
    f->fun ();
  }
}
static TestResult *
srunner_run_setup (List * fixture_list, enum fork_status fork_usage,
    const char *test_name, const char *setup_name)
{
  TestResult *tr = NULL;
  Fixture *setup_fixture;

  if (fork_usage == CK_FORK) {
    send_ctx_info (CK_CTX_SETUP);
  }

  for (check_list_front (fixture_list); !check_list_at_end (fixture_list);
      check_list_advance (fixture_list)) {
    setup_fixture = (Fixture *) check_list_val (fixture_list);

    if (fork_usage == CK_NOFORK) {
      send_ctx_info (CK_CTX_SETUP);

      if (0 == setjmp (error_jmp_buffer)) {
        setup_fixture->fun ();
      }

      /* Stop the setup and return the failure in nofork mode. */
      tr = receive_result_info_nofork (test_name, setup_name, 0, -1);
      if (tr->rtype != CK_PASS) {
        break;
      }

      free (tr->file);
      free (tr->msg);
      free (tr);
      tr = NULL;
    } else {
      setup_fixture->fun ();
    }
  }

  return tr;
}
static void
srunner_run_teardown (List * fixture_list, enum fork_status fork_usage)
{
  Fixture *fixture;

  for (check_list_front (fixture_list); !check_list_at_end (fixture_list);
      check_list_advance (fixture_list)) {
    fixture = (Fixture *) check_list_val (fixture_list);
    send_ctx_info (CK_CTX_TEARDOWN);

    if (fork_usage == CK_NOFORK) {
      if (0 == setjmp (error_jmp_buffer)) {
        fixture->fun ();
      } else {
        /* Abort the remaining teardowns */
        break;
      }
    } else {
      fixture->fun ();
    }
  }
}
示例#8
0
文件: check.c 项目: BruceYi/okl4
void tcase_fn_start (const char *fname, const char *file, int line)
{
    printf("%s\n", fname);
  send_ctx_info (get_send_key(),CK_CTX_TEST);
  send_loc_info (get_send_key(),file, line);
}