示例#1
0
static TestResult *construct_test_result (RcvMsg *rmsg, int waserror)
{
  TestResult *tr;

  if (rmsg == NULL)
    return NULL;

  tr = tr_create();

  if (rmsg->msg != NULL || waserror) {
    tr->ctx = (cur_fork_status () == CK_FORK) ? rmsg->lastctx : rmsg->failctx;
    tr->msg = rmsg->msg;
    rmsg->msg = NULL;
    tr_set_loc_by_ctx (tr, tr->ctx, rmsg);
  } else if (rmsg->lastctx == CK_CTX_SETUP) {
    tr->ctx = CK_CTX_SETUP;
    tr->msg = NULL;
    tr_set_loc_by_ctx (tr, CK_CTX_SETUP, rmsg);  
  } else {
    tr->ctx = CK_CTX_TEST;
    tr->msg = NULL;
    tr_set_loc_by_ctx (tr, CK_CTX_TEST, rmsg);
  }

  return tr;
}
示例#2
0
文件: check.c 项目: BruceYi/okl4
void _fail_unless (int result, const char *file,
                   int line, const char * msg, ...)
{
  va_list ap;
  char buf[BUFSIZ];

  /* Ensure a sane message was passed in. */
  if (msg == NULL) {
    eprintf ("_fail_unless() called with NULL msg",__FILE__,__LINE__);
    msg = "(null)";
  }

  /* If we passed the test, we need do nothing more. */
  if (result) {
      return;
  }

  /* Unlike normal libcheck, we don't want to mark all the time, as it can
   * waste a lot of memory, so we only mark on failure */
  send_loc_info (get_send_key(), file, line);

  va_start(ap,msg);
  vsnprintf(buf, BUFSIZ, msg, ap);
  va_end(ap);

  /* Display a failure message now, just in case we don't make it
   * until the end of the tests. */
  printf("*** Failure: ");
  puts(buf);

  /* Send failure information to the test controller. */
  send_failure_info(get_send_key(), buf);

#if defined(OKL4_KERNEL_MICRO)
  /* Send failure message to our pager. */
  if (cur_fork_status() == CK_WITHPAGER) {
    L4_MsgTag_t tag = L4_Niltag;

    /* Send a failure message to the test runner. A label of '1' indicates
     * failure. */
    tag = L4_MsgTagAddLabel(tag, 1);
    L4_Set_MsgTag(tag);

    /* Inform the library, and wait for them to kill us. */
    L4_Call(libcheck);
    L4_WaitForever();
  }
#endif
}