예제 #1
0
END_TEST

START_TEST(test_ppack_multictx)
{
  FILE * result_file;
  char * result_file_name = NULL;
  CtxMsg cmsg;
  LocMsg lmsg;
  RcvMsg *rmsg;
  
  cmsg.ctx = CK_CTX_SETUP;
  lmsg.line = 5;
  lmsg.file = (char *) "abc123.c";
  result_file = open_tmp_file(&result_file_name);
  free(result_file_name);
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (result_file, CK_MSG_LOC, (CheckMsg *) &lmsg);
  cmsg.ctx = CK_CTX_TEST;
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (result_file, CK_MSG_LOC, (CheckMsg *) &lmsg);
  cmsg.ctx = CK_CTX_TEARDOWN;
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  rewind(result_file);
  rmsg = punpack (result_file);

  ck_assert_msg (rmsg != NULL && rmsg->test_line == 5,
	       "Test loc not being preserved on CTX change");

  ck_assert_msg (rmsg->fixture_line == -1,
	       "Fixture not reset on CTX change");

  free (rmsg);
  fclose(result_file);
}
예제 #2
0
TestResult *
receive_test_result (int waserror)
{
  FILE *fp;
  RcvMsg *rmsg;
  TestResult *result;

  fp = get_pipe ();
  if (fp == NULL) {
    eprintf ("Error in call to get_pipe", __FILE__, __LINE__ - 2);
  }

  rewind (fp);
  rmsg = punpack (fp);

  if (rmsg == NULL) {
    eprintf ("Error in call to punpack", __FILE__, __LINE__ - 4);
  }

  teardown_pipe ();
  setup_pipe ();

  result = construct_test_result (rmsg, waserror);
  rcvmsg_free (rmsg);
  return result;
}
예제 #3
0
END_TEST

START_TEST(test_ppack_nofail)
{
  FILE * result_file;
  char * result_file_name = NULL;
  CtxMsg cmsg;
  LocMsg lmsg;
  RcvMsg *rmsg;

  lmsg.file = (char *) "abc123.c";
  lmsg.line = 10;
  cmsg.ctx = CK_CTX_SETUP;
  result_file = open_tmp_file(&result_file_name);
  free(result_file_name);
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (result_file, CK_MSG_LOC, (CheckMsg *) &lmsg);
  rewind (result_file);
  rmsg = punpack (result_file);

  ck_assert_msg (rmsg != NULL && rmsg->msg == NULL,
	       "Failure result should be NULL with no failure message");
  
  free (rmsg);
  fclose(result_file);
}
예제 #4
0
END_TEST

START_TEST(test_ppack_noctx)
{
  FILE * result_file;
  char * result_file_name = NULL;
  LocMsg lmsg;
  FailMsg fmsg;
  RcvMsg *rmsg;
  
  lmsg.file = (char *) "abc123.c";
  lmsg.line = 10;
  fmsg.msg = (char *) "oops";
  result_file = open_tmp_file(&result_file_name);
  free(result_file_name);
  ppack (result_file, CK_MSG_LOC, (CheckMsg *) &lmsg);
  ppack (result_file, CK_MSG_FAIL, (CheckMsg *) &fmsg);

  rewind(result_file);
  rmsg = punpack (result_file);

  ck_assert_msg (rmsg == NULL,
	       "Result should be NULL with no CTX");

  if (rmsg != NULL)
    free (rmsg);
  fclose(result_file);
}
예제 #5
0
END_TEST

START_TEST(test_ppack_onlyctx)
{
  FILE * result_file;
  char * result_file_name = NULL;
  CtxMsg cmsg;
  RcvMsg *rmsg;
  
  cmsg.ctx = CK_CTX_SETUP;
  result_file = open_tmp_file(&result_file_name);
  free(result_file_name);
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  rewind(result_file);
  rmsg = punpack (result_file);

  ck_assert_msg (rmsg != NULL && rmsg->msg == NULL,
	       "Result message should be NULL with only CTX");
  ck_assert_msg (rmsg->fixture_line == -1,
	       "Result loc line should be -1 with only CTX");
  ck_assert_msg (rmsg->test_line == -1,
	       "Result loc line should be -1 with only CTX");

  if (rmsg != NULL)
    free (rmsg);
  fclose(result_file);
}
예제 #6
0
END_TEST

START_TEST(test_ppack_multictx)
{
  int filedes[2];
  CtxMsg cmsg;
  LocMsg lmsg;
  RcvMsg *rmsg;

  cmsg.ctx = CK_CTX_SETUP;
  lmsg.line = 5;
  lmsg.file = (char *) "abc123.c";
  pipe (filedes);
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (filedes[1], CK_MSG_LOC, (CheckMsg *) &lmsg);
  cmsg.ctx = CK_CTX_TEST;
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (filedes[1], CK_MSG_LOC, (CheckMsg *) &lmsg);
  cmsg.ctx = CK_CTX_TEARDOWN;
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  close (filedes[1]);
  rmsg = punpack (filedes[0]);

  fail_unless (rmsg->test_line == 5,
	       "Test loc not being preserved on CTX change");

  fail_unless (rmsg->fixture_line == -1,
	       "Fixture not reset on CTX change");
  if (rmsg != NULL)
    free (rmsg);
}
예제 #7
0
END_TEST

#define BIG_MSG_LEN 1037

START_TEST(test_ppack_big)
{
  FILE * result_file;
  char * result_file_name = NULL;
  CtxMsg cmsg;
  LocMsg lmsg;
  FailMsg fmsg;
  RcvMsg *rmsg;

  cmsg.ctx = CK_CTX_TEST;
  lmsg.file = (char *)emalloc (BIG_MSG_LEN);
  memset (lmsg.file,'a',BIG_MSG_LEN - 1);
  lmsg.file[BIG_MSG_LEN - 1] = '\0';
  lmsg.line = 10;
  fmsg.msg = (char *)emalloc (BIG_MSG_LEN);
  memset (fmsg.msg, 'a', BIG_MSG_LEN - 1);
  fmsg.msg[BIG_MSG_LEN - 1] = '\0';
  result_file = open_tmp_file(&result_file_name);
  free(result_file_name);
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (result_file, CK_MSG_LOC, (CheckMsg *) &lmsg);
  ppack (result_file, CK_MSG_FAIL, (CheckMsg *) &fmsg);
  rewind (result_file);
  rmsg = punpack (result_file);

  ck_assert_msg (rmsg != NULL,
	       "Return value from ppack should always be malloc'ed");
  ck_assert_msg (rmsg->lastctx == CK_CTX_TEST,
	       "CTX not set correctly in ppack");
  ck_assert_msg (rmsg->test_line == 10,
	       "Test line not received correctly");
  ck_assert_msg (strcmp (rmsg->test_file, lmsg.file) == 0,
	       "Test file not received correctly");
  ck_assert_msg (strcmp (rmsg->msg, fmsg.msg) == 0,
	       "Failure message not received correctly");
  
  free (rmsg);
  free (lmsg.file);
  free (fmsg.msg);
  fclose(result_file);
}
예제 #8
0
END_TEST

/* the ppack probably means 'pipe' pack */
#if defined(HAVE_FORK) && HAVE_FORK==1
START_TEST(test_ppack)
{
  FILE * result_file;
  char * result_file_name = NULL;
  CtxMsg cmsg;
  LocMsg lmsg;
  FailMsg fmsg;
  RcvMsg *rmsg;
  
  cmsg.ctx = CK_CTX_TEST;
  lmsg.file = (char *) "abc123.c";
  lmsg.line = 10;
  fmsg.msg = (char *) "oops";
  result_file = open_tmp_file(&result_file_name);
  free(result_file_name);
  ppack (result_file, CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (result_file, CK_MSG_LOC, (CheckMsg *) &lmsg);
  ppack (result_file, CK_MSG_FAIL, (CheckMsg *) &fmsg);

  rewind(result_file);
  rmsg = punpack (result_file);

  ck_assert_msg (rmsg != NULL,
	       "Return value from ppack should always be malloc'ed");
  ck_assert_msg (rmsg->lastctx == CK_CTX_TEST,
	       "CTX not set correctly in ppack");
  ck_assert_msg (rmsg->fixture_line == -1,
	       "Default fixture loc not correct");
  ck_assert_msg (rmsg->fixture_file == NULL,
	       "Default fixture loc not correct");
  ck_assert_msg (rmsg->test_line == 10,
	       "Test line not received correctly");
  ck_assert_msg (strcmp(rmsg->test_file,"abc123.c") == 0,
	       "Test file not received correctly");
  ck_assert_msg (strcmp(rmsg->msg, "oops") == 0,
	       "Failure message not received correctly");

  free(rmsg);
  fclose(result_file);
}
예제 #9
0
END_TEST


#define BIG_MSG_LEN 1037

START_TEST(test_ppack_big)
{
  int filedes[2];
  CtxMsg cmsg;
  LocMsg lmsg;
  FailMsg fmsg;
  RcvMsg *rmsg;

  cmsg.ctx = CK_CTX_TEST;
  lmsg.file = emalloc (BIG_MSG_LEN);
  memset (lmsg.file,'a',BIG_MSG_LEN - 1);
  lmsg.file[BIG_MSG_LEN - 1] = '\0';
  lmsg.line = 10;
  fmsg.msg = emalloc (BIG_MSG_LEN);
  memset (fmsg.msg, 'a', BIG_MSG_LEN - 1);
  fmsg.msg[BIG_MSG_LEN - 1] = '\0';
  pipe (filedes);
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (filedes[1], CK_MSG_LOC, (CheckMsg *) &lmsg);
  ppack (filedes[1], CK_MSG_FAIL, (CheckMsg *) &fmsg);
  close (filedes[1]);
  rmsg = punpack (filedes[0]);

  fail_unless (rmsg != NULL,
	       "Return value from ppack should always be malloc'ed");
  fail_unless (rmsg->lastctx == CK_CTX_TEST,
	       "CTX not set correctly in ppack");
  fail_unless (rmsg->test_line == 10,
	       "Test line not received correctly");
  fail_unless (strcmp (rmsg->test_file, lmsg.file) == 0,
	       "Test file not received correctly");
  fail_unless (strcmp (rmsg->msg, fmsg.msg) == 0,
	       "Failure message not received correctly");
  
  free (rmsg);
  free (lmsg.file);
  free (fmsg.msg);
}
예제 #10
0
END_TEST

START_TEST(test_ppack)
{
  int filedes[2];
  CtxMsg cmsg;
  LocMsg lmsg;
  FailMsg fmsg;
  RcvMsg *rmsg;

  cmsg.ctx = CK_CTX_TEST;
  lmsg.file = (char *) "abc123.c";
  lmsg.line = 10;
  fmsg.msg = (char *) "oops";
  pipe (filedes);
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (filedes[1], CK_MSG_LOC, (CheckMsg *) &lmsg);
  ppack (filedes[1], CK_MSG_FAIL, (CheckMsg *) &fmsg);
  close (filedes[1]);
  rmsg = punpack (filedes[0]);

  fail_unless (rmsg != NULL,
	       "Return value from ppack should always be malloc'ed");
  fail_unless (rmsg->lastctx == CK_CTX_TEST,
	       "CTX not set correctly in ppack");
  fail_unless (rmsg->fixture_line == -1,
	       "Default fixture loc not correct");
  fail_unless (rmsg->fixture_file == NULL,
	       "Default fixture loc not correct");
  fail_unless (rmsg->test_line == 10,
	       "Test line not received correctly");
  fail_unless (strcmp(rmsg->test_file,"abc123.c") == 0,
	       "Test file not received correctly");
  fail_unless (strcmp(rmsg->msg, "oops") == 0,
	       "Failure message not received correctly");

  free(rmsg);
}
예제 #11
0
END_TEST

START_TEST(test_ppack_nofail)
{
  int filedes[2];
  CtxMsg cmsg;
  LocMsg lmsg;
  RcvMsg *rmsg;

  lmsg.file = (char *) "abc123.c";
  lmsg.line = 10;
  cmsg.ctx = CK_CTX_SETUP;
  pipe (filedes);
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  ppack (filedes[1], CK_MSG_LOC, (CheckMsg *) &lmsg);
  close (filedes[1]);
  rmsg = punpack (filedes[0]);

  fail_unless (rmsg->msg == NULL,
	       "Failure result should be NULL with no failure message");
  if (rmsg != NULL)
    free (rmsg);
}
예제 #12
0
END_TEST

START_TEST(test_ppack_onlyctx)
{
  int filedes[2];
  CtxMsg cmsg;
  RcvMsg *rmsg;

  cmsg.ctx = CK_CTX_SETUP;
  pipe (filedes);
  ppack (filedes[1], CK_MSG_CTX, (CheckMsg *) &cmsg);
  close (filedes[1]);
  rmsg = punpack (filedes[0]);

  fail_unless (rmsg->msg == NULL,
	       "Result message should be NULL with only CTX");
  fail_unless (rmsg->fixture_line == -1,
	       "Result loc line should be -1 with only CTX");
  fail_unless (rmsg->test_line == -1,
	       "Result loc line should be -1 with only CTX");

  if (rmsg != NULL)
    free (rmsg);
}
예제 #13
0
END_TEST

START_TEST(test_ppack_noctx)
{
  int filedes[2];
  LocMsg lmsg;
  FailMsg fmsg;
  RcvMsg *rmsg;

  lmsg.file = (char *) "abc123.c";
  lmsg.line = 10;
  fmsg.msg = (char *) "oops";
  pipe (filedes);
  ppack (filedes[1], CK_MSG_LOC, (CheckMsg *) &lmsg);
  ppack (filedes[1], CK_MSG_FAIL, (CheckMsg *) &fmsg);
  close (filedes[1]);
  rmsg = punpack (filedes[0]);

  fail_unless (rmsg == NULL,
	       "Result should be NULL with no CTX");

  if (rmsg != NULL)
    free (rmsg);
}