Пример #1
0
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;
}
Пример #2
0
static void srunner_iterate_tcase_tfuns (SRunner *sr, TCase *tc)
{
  List *tfl;
  TF *tfun;
  TestResult *tr = NULL;

  tfl = tc->tflst;
  
  for (list_front(tfl); !list_at_end (tfl); list_advance (tfl)) {
    int i;
    tfun = list_val (tfl);

    for (i = tfun->loop_start; i < tfun->loop_end; i++)
    {
      log_test_start (sr, tc, tfun);
      switch (srunner_fork_status(sr)) {
      case CK_FORK:
#ifdef _POSIX_VERSION
        tr = tcase_run_tfun_fork (sr, tc, tfun, i);
#else /* _POSIX_VERSION */
        eprintf("This version does not support fork", __FILE__, __LINE__);
#endif /* _POSIX_VERSION */
        break;
      case CK_NOFORK:
        tr = tcase_run_tfun_nofork (sr, tc, tfun, i);
        break;
      default:
        eprintf("Bad fork status in SRunner", __FILE__, __LINE__);
      }
      srunner_add_failure (sr, tr);
      log_test_end(sr, tr);
    }
  }
}  
Пример #3
0
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;
}
Пример #4
0
void
init_setup (SRunner *runner, int argc, char **argv)
{
	init_in_tests = (srunner_fork_status (runner) == CK_FORK);
	argc_ = argc;
	argv_ = argv;
}
Пример #5
0
static void srunner_run_init (SRunner *sr, enum print_output print_mode)
{
  set_fork_status(srunner_fork_status(sr));
  setup_messaging();
  srunner_init_logging (sr, print_mode);
  log_srunner_start (sr);
}
Пример #6
0
int main(int argc, char *argv[])
{
    int failed;
    sxc_client_t *sx = server_init(NULL, NULL, NULL, 0, argc, argv);
#ifdef ABS_BUILDDIR
    /* chdir so that tests that use execve() can find
     * the executables */
    if (chdir(ABS_BUILDDIR) == -1) {
        fprintf(stderr,"chdir failed on %s: %s",
                ABS_BUILDDIR, strerror(errno));
        return 2;
    }
#endif

    sr = srunner_create(NULL);
    if (srunner_fork_status(sr))
        skip_dietests = 1;

    srunner_add_suite(sr, test_suite());

    srunner_run_all(sr, CK_NORMAL);

    failed = srunner_ntests_failed(sr);
    srunner_free(sr);
    server_done(&sx);
    return !failed ? EXIT_SUCCESS : EXIT_FAILURE;
}
Пример #7
0
END_TEST

START_TEST(test_env)
{
  putenv((char *) "CK_FORK=no");
  ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_NOFORK,
	      "Fork status does not obey environment variable");
}
Пример #8
0
END_TEST

START_TEST(test_set_fork)
{
  srunner_set_fork_status(fork_dummy_sr, CK_NOFORK);
  ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_NOFORK,
	      "Fork status not changed correctly");
}
Пример #9
0
END_TEST

START_TEST(test_set_fork)
{
  srunner_set_fork_status(fork_dummy_sr, CK_NOFORK);
  fail_unless(srunner_fork_status(fork_dummy_sr) == CK_NOFORK,
	      "Fork status not changed correctly");
}
Пример #10
0
static TestResult *
tcase_run_checked_setup (SRunner * sr, TCase * tc)
{
  TestResult *tr = srunner_run_setup (tc->ch_sflst, srunner_fork_status (sr),
      tc->name, "checked_setup");

  return tr;
}
Пример #11
0
END_TEST

START_TEST(test_env_and_set)
{
  putenv((char *) "CK_FORK=no");
  srunner_set_fork_status(fork_dummy_sr, CK_FORK);  
  ck_assert_msg(srunner_fork_status(fork_dummy_sr) == CK_FORK,
	      "Explicit setting of fork status should override env");
}
Пример #12
0
static int
srunner_run_unchecked_setup (SRunner * sr, TCase * tc)
{
  TestResult *tr = NULL;
  int rval = 1;

  set_fork_status (CK_NOFORK);
  tr = srunner_run_setup (tc->unch_sflst, CK_NOFORK, tc->name,
      "unchecked_setup");
  set_fork_status (srunner_fork_status (sr));

  if (tr != NULL && tr->rtype != CK_PASS) {
    srunner_add_failure (sr, tr);
    rval = 0;
  }

  return rval;
}
Пример #13
0
static void
srunner_iterate_tcase_tfuns (SRunner * sr, TCase * tc)
{
  List *tfl;
  TF *tfun;
  TestResult *tr = NULL;

  tfl = tc->tflst;

  for (check_list_front (tfl); !check_list_at_end (tfl);
      check_list_advance (tfl)) {
    int i;

    tfun = (TF *) check_list_val (tfl);

    for (i = tfun->loop_start; i < tfun->loop_end; i++) {
      log_test_start (sr, tc, tfun);
      switch (srunner_fork_status (sr)) {
        case CK_FORK:
#if defined(HAVE_FORK) && HAVE_FORK==1
          tr = tcase_run_tfun_fork (sr, tc, tfun, i);
#else /* HAVE_FORK */
          eprintf ("This version does not support fork", __FILE__, __LINE__);
#endif /* HAVE_FORK */
          break;
        case CK_NOFORK:
          tr = tcase_run_tfun_nofork (sr, tc, tfun, i);
          break;
        case CK_FORK_GETENV:
        default:
          eprintf ("Bad fork status in SRunner", __FILE__, __LINE__);
      }

      if (NULL != tr) {
        srunner_add_failure (sr, tr);
        log_test_end (sr, tr);
      }
    }
  }
}
Пример #14
0
static void
srunner_run_unchecked_teardown (SRunner * sr, TCase * tc)
{
  srunner_run_teardown (tc->unch_tflst, srunner_fork_status (sr));
}