Пример #1
0
int main(int argc, char** argv) {
    
    LOG_TEST("HELLO");
    LOG_TEST("HELLO" << " !");
    
    return 0;
}
Пример #2
0
static void test_many_additions(void) {
  grpc_chttp2_hptbl tbl;
  int i;
  char *key;
  char *value;

  LOG_TEST("test_many_additions");

  grpc_chttp2_hptbl_init(&tbl);

  for (i = 0; i < 1000000; i++) {
    grpc_mdelem *elem;
    gpr_asprintf(&key, "K:%d", i);
    gpr_asprintf(&value, "VALUE:%d", i);
    elem = grpc_mdelem_from_strings(key, value);
    GPR_ASSERT(grpc_chttp2_hptbl_add(&tbl, elem));
    GRPC_MDELEM_UNREF(elem);
    assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
    gpr_free(key);
    gpr_free(value);
    if (i) {
      gpr_asprintf(&key, "K:%d", i - 1);
      gpr_asprintf(&value, "VALUE:%d", i - 1);
      assert_index(&tbl, 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
      gpr_free(key);
      gpr_free(value);
    }
  }

  grpc_chttp2_hptbl_destroy(&tbl);
}
Пример #3
0
void mediadataclient_object_t::test<6>()
{
    //
    // Test navigate() with a bounce back
    //
    LOG_TEST(6);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(
        _DATA_URLS(VALID_OBJECT_ID,
                   "1.0","true",
                   FAKE_OBJECT_MEDIA_CAP_URL,
                   FAKE_OBJECT_MEDIA_NAVIGATE_CAP_URL_ERROR));
    {
        LLPointer<LLObjectMediaNavigateClient> mdc = new LLObjectMediaNavigateClient(NO_PERIOD,NO_PERIOD);
        const char *TEST_URL = "http://example.com";
        mdc->navigate(o, 0, TEST_URL);
        ensure("post records", gPostRecords->size(), 0);
        ::pump_timers();

        // ensure bounce back
        ensure("bounce back",
               dynamic_cast<LLMediaDataClientObjectTest*>(static_cast<LLMediaDataClientObject*>(o))->getNumBounceBacks(),
               1);

        ensure("post records", gPostRecords->size(), 1);
        ensure("post url", (*gPostRecords)[0]["url"], FAKE_OBJECT_MEDIA_NAVIGATE_CAP_URL_ERROR);
        ensure("post object id", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        ensure("post data", (*gPostRecords)[0]["body"][LLTextureEntry::TEXTURE_INDEX_KEY], 0);
        ensure("post data", (*gPostRecords)[0]["body"][LLMediaEntry::CURRENT_URL_KEY], TEST_URL);
        ensure("queue empty", mdc->isEmpty());
    }
    ensure("REF COUNT", o->getNumRefs(), 1);
}
Пример #4
0
void mediadataclient_object_t::test<8>()
{
    // Test queue handling of objects that are marked dead.
    LOG_TEST(8);

    LLMediaDataClientObject::ptr_t o1 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_1,"4.0","true"));
    LLMediaDataClientObject::ptr_t o2 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_2,"3.0","true"));
    LLMediaDataClientObject::ptr_t o3 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_3,"2.0","true"));
    LLMediaDataClientObject::ptr_t o4 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_4,"1.0","true"));
    {
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);

        // queue up all 4 objects
        mdc->fetchMedia(o1);
        mdc->fetchMedia(o2);
        mdc->fetchMedia(o3);
        mdc->fetchMedia(o4);

        ensure("is in queue 1", mdc->isInQueue(o1));
        ensure("is in queue 2", mdc->isInQueue(o2));
        ensure("is in queue 3", mdc->isInQueue(o3));
        ensure("is in queue 4", mdc->isInQueue(o4));
        ensure("post records", gPostRecords->size(), 0);

        // and mark the second and fourth ones dead.  Call removeFromQueue when marking dead, since this is what LLVOVolume will do.
        dynamic_cast<LLMediaDataClientObjectTest*>(static_cast<LLMediaDataClientObject*>(o2))->markDead();
        mdc->removeFromQueue(o2);
        dynamic_cast<LLMediaDataClientObjectTest*>(static_cast<LLMediaDataClientObject*>(o4))->markDead();
        mdc->removeFromQueue(o4);

        // The removeFromQueue calls should remove the second and fourth ones
        ensure("is in queue 1", mdc->isInQueue(o1));
        ensure("is not in queue 2", !mdc->isInQueue(o2));
        ensure("is in queue 3", mdc->isInQueue(o3));
        ensure("is not in queue 4", !mdc->isInQueue(o4));
        ensure("post records", gPostRecords->size(), 0);

        ::pump_timers();

        // The first tick should process the first item
        ensure("is not in queue 1", !mdc->isInQueue(o1));
        ensure("is not in queue 2", !mdc->isInQueue(o2));
        ensure("is in queue 3", mdc->isInQueue(o3));
        ensure("is not in queue 4", !mdc->isInQueue(o4));
        ensure("post records", gPostRecords->size(), 1);

        ::pump_timers();

        // The second tick should process the third, emptying the queue
        ensure("is not in queue 3", !mdc->isInQueue(o3));
        ensure("post records", gPostRecords->size(), 2);

        ensure("queue empty", mdc->isEmpty());
    }
    ensure("refcount of o1", o1->getNumRefs(), 1);
    ensure("refcount of o2", o2->getNumRefs(), 1);
    ensure("refcount of o3", o3->getNumRefs(), 1);
    ensure("refcount of o4", o4->getNumRefs(), 1);

}
Пример #5
0
void mediadataclient_object_t::test<7>()
{
    // Test LLMediaDataClient::isInQueue()
    LOG_TEST(7);

    LLMediaDataClientObject::ptr_t o1 = new LLMediaDataClientObjectTest(
        _DATA(VALID_OBJECT_ID_1,"3.0","true"));
    LLMediaDataClientObject::ptr_t o2 = new LLMediaDataClientObjectTest(
        _DATA(VALID_OBJECT_ID_2,"1.0","true"));
    int num_refs_start = o1->getNumRefs();
    {
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);

        ensure("not in queue yet 1", ! mdc->isInQueue(o1));
        ensure("not in queue yet 2", ! mdc->isInQueue(o2));

        mdc->fetchMedia(o1);

        ensure("is in queue", mdc->isInQueue(o1));
        ensure("is not in queue", ! mdc->isInQueue(o2));

        ::pump_timers();

        ensure("not in queue anymore", ! mdc->isInQueue(o1));
        ensure("still is not in queue", ! mdc->isInQueue(o2));

        ensure("queue empty", mdc->isEmpty());
    }

    // Make sure everyone's destroyed properly
    ensure("REF COUNT", o1->getNumRefs(), num_refs_start);

}
Пример #6
0
void test_encoding(void) {
    LOG_TEST();
    assert_encodes_as(gpr_time_from_micros(-1), "1n");
    assert_encodes_as(gpr_time_from_seconds(-10), "1n");
    assert_encodes_as(gpr_time_from_nanos(10), "10n");
    assert_encodes_as(gpr_time_from_nanos(999999999), "1S");
    assert_encodes_as(gpr_time_from_micros(1), "1u");
    assert_encodes_as(gpr_time_from_micros(10), "10u");
    assert_encodes_as(gpr_time_from_micros(100), "100u");
    assert_encodes_as(gpr_time_from_micros(890), "890u");
    assert_encodes_as(gpr_time_from_micros(900), "900u");
    assert_encodes_as(gpr_time_from_micros(901), "901u");
    assert_encodes_as(gpr_time_from_millis(1), "1m");
    assert_encodes_as(gpr_time_from_millis(2), "2m");
    assert_encodes_as(gpr_time_from_micros(10001), "10100u");
    assert_encodes_as(gpr_time_from_micros(999999), "1S");
    assert_encodes_as(gpr_time_from_millis(1000), "1S");
    assert_encodes_as(gpr_time_from_millis(2000), "2S");
    assert_encodes_as(gpr_time_from_millis(2500), "2500m");
    assert_encodes_as(gpr_time_from_millis(59900), "59900m");
    assert_encodes_as(gpr_time_from_seconds(50), "50S");
    assert_encodes_as(gpr_time_from_seconds(59), "59S");
    assert_encodes_as(gpr_time_from_seconds(60), "1M");
    assert_encodes_as(gpr_time_from_seconds(80), "80S");
    assert_encodes_as(gpr_time_from_seconds(90), "90S");
    assert_encodes_as(gpr_time_from_minutes(2), "2M");
    assert_encodes_as(gpr_time_from_minutes(20), "20M");
    assert_encodes_as(gpr_time_from_hours(1), "1H");
    assert_encodes_as(gpr_time_from_hours(10), "10H");
    assert_encodes_as(gpr_time_from_seconds(1000000000), "1000000000S");
}
Пример #7
0
void mediadataclient_object_t::test<13>()
{
    //
    // Test supression of redundant navigates.
    //
    LOG_TEST(13);

    LLMediaDataClientObject::ptr_t o1 = new LLMediaDataClientObjectTest(_DATA(VALID_OBJECT_ID_1,"1.0","true"));
    {
        LLPointer<LLObjectMediaNavigateClient> mdc = new LLObjectMediaNavigateClient(NO_PERIOD,NO_PERIOD);
        const char *TEST_URL = "http://foo.example.com";
        const char *TEST_URL_2 = "http://example.com";
        mdc->navigate(o1, 0, TEST_URL);
        mdc->navigate(o1, 1, TEST_URL);
        mdc->navigate(o1, 0, TEST_URL_2);
        mdc->navigate(o1, 1, TEST_URL_2);

        // This should add two requests to the queue, one for face 0 of the object and one for face 1.

        ensure("before pump: 1 is in queue", mdc->isInQueue(o1));

        ::pump_timers();

        ensure("after first pump: 1 is in queue", mdc->isInQueue(o1));

        ::pump_timers();

        ensure("after second pump: 1 is not in queue", !mdc->isInQueue(o1));

        ensure("first post has correct url", (*gPostRecords)[0]["body"][LLMediaEntry::CURRENT_URL_KEY].asString(), std::string(TEST_URL_2));
        ensure("second post has correct url", (*gPostRecords)[1]["body"][LLMediaEntry::CURRENT_URL_KEY].asString(), std::string(TEST_URL_2));

    }
}
Пример #8
0
void test_encoding(void) {
  LOG_TEST("test_encoding");
  assert_encodes_as(gpr_time_from_micros(-1, GPR_TIMESPAN), "1n");
  assert_encodes_as(gpr_time_from_seconds(-10, GPR_TIMESPAN), "1n");
  assert_encodes_as(gpr_time_from_nanos(10, GPR_TIMESPAN), "10n");
  assert_encodes_as(gpr_time_from_nanos(999999999, GPR_TIMESPAN), "1S");
  assert_encodes_as(gpr_time_from_micros(1, GPR_TIMESPAN), "1u");
  assert_encodes_as(gpr_time_from_micros(10, GPR_TIMESPAN), "10u");
  assert_encodes_as(gpr_time_from_micros(100, GPR_TIMESPAN), "100u");
  assert_encodes_as(gpr_time_from_micros(890, GPR_TIMESPAN), "890u");
  assert_encodes_as(gpr_time_from_micros(900, GPR_TIMESPAN), "900u");
  assert_encodes_as(gpr_time_from_micros(901, GPR_TIMESPAN), "901u");
  assert_encodes_as(gpr_time_from_millis(1, GPR_TIMESPAN), "1m");
  assert_encodes_as(gpr_time_from_millis(2, GPR_TIMESPAN), "2m");
  assert_encodes_as(gpr_time_from_micros(10001, GPR_TIMESPAN), "10100u");
  assert_encodes_as(gpr_time_from_micros(999999, GPR_TIMESPAN), "1S");
  assert_encodes_as(gpr_time_from_millis(1000, GPR_TIMESPAN), "1S");
  assert_encodes_as(gpr_time_from_millis(2000, GPR_TIMESPAN), "2S");
  assert_encodes_as(gpr_time_from_millis(2500, GPR_TIMESPAN), "2500m");
  assert_encodes_as(gpr_time_from_millis(59900, GPR_TIMESPAN), "59900m");
  assert_encodes_as(gpr_time_from_seconds(50, GPR_TIMESPAN), "50S");
  assert_encodes_as(gpr_time_from_seconds(59, GPR_TIMESPAN), "59S");
  assert_encodes_as(gpr_time_from_seconds(60, GPR_TIMESPAN), "1M");
  assert_encodes_as(gpr_time_from_seconds(80, GPR_TIMESPAN), "80S");
  assert_encodes_as(gpr_time_from_seconds(90, GPR_TIMESPAN), "90S");
  assert_encodes_as(gpr_time_from_minutes(2, GPR_TIMESPAN), "2M");
  assert_encodes_as(gpr_time_from_minutes(20, GPR_TIMESPAN), "20M");
  assert_encodes_as(gpr_time_from_hours(1, GPR_TIMESPAN), "1H");
  assert_encodes_as(gpr_time_from_hours(10, GPR_TIMESPAN), "10H");
  assert_encodes_as(gpr_time_from_seconds(1000000000, GPR_TIMESPAN),
                    "1000000000S");
}
Пример #9
0
static void test_many_additions(void) {
  grpc_chttp2_hptbl tbl;
  int i;
  char *key;
  char *value;
  grpc_mdctx *mdctx;

  LOG_TEST("test_many_additions");

  mdctx = grpc_mdctx_create();
  grpc_chttp2_hptbl_init(&tbl, mdctx);

  for (i = 0; i < 1000000; i++) {
    gpr_asprintf(&key, "K:%d", i);
    gpr_asprintf(&value, "VALUE:%d", i);
    grpc_chttp2_hptbl_add(&tbl, grpc_mdelem_from_strings(mdctx, key, value));
    assert_index(&tbl, 1 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
    gpr_free(key);
    gpr_free(value);
    if (i) {
      gpr_asprintf(&key, "K:%d", i - 1);
      gpr_asprintf(&value, "VALUE:%d", i - 1);
      assert_index(&tbl, 2 + GRPC_CHTTP2_LAST_STATIC_ENTRY, key, value);
      gpr_free(key);
      gpr_free(value);
    }
  }

  grpc_chttp2_hptbl_destroy(&tbl);
  grpc_mdctx_unref(mdctx);
}
Пример #10
0
static void test_cq_end_read(void) {
  grpc_event *ev;
  grpc_completion_queue *cc;
  int on_finish_called = 0;
  void *tag = create_test_tag();

  LOG_TEST();

  cc = grpc_completion_queue_create();

  grpc_cq_begin_op(cc, NULL, GRPC_READ);
  grpc_cq_end_read(cc, tag, NULL, increment_int_on_finish, &on_finish_called,
                   NULL);

  ev = grpc_completion_queue_next(cc, gpr_inf_past);
  GPR_ASSERT(ev != NULL);
  GPR_ASSERT(ev->type == GRPC_READ);
  GPR_ASSERT(ev->tag == tag);
  GPR_ASSERT(ev->data.read == NULL);
  GPR_ASSERT(on_finish_called == 0);
  grpc_event_finish(ev);
  GPR_ASSERT(on_finish_called == 1);

  shutdown_and_destroy(cc);
}
Пример #11
0
void object::test<2>() {
    set_test_name("Run");
    putchar('\n');

    elf::time64_t st = elf::time_ms();

    for (int i = 0; i < TIMER_NUMBER; ++i) {
        elf::timer_add(rand() % TIMER_MAX_LIFE, "timer.onTimeout");
    }

    while (elf::timer_size()) {
        elf::time64_t time = elf::time_ms();

        elf::timer_run();

        // Clamp the framerate so that we do not hog all the CPU.
        const int MIN_FRAME_TIME = 1000 / FPS;
        elf::time64_t last_frame = time;
        int dt = (int)elf::time_diff(last_frame, time);

        last_frame = time;
        if (dt < MIN_FRAME_TIME) {
            int ms = MIN_FRAME_TIME - dt;
            if (ms >= 0)
                usleep(ms);
        }
    }

    elf::time64_t delta = elf::time_diff(elf::time_ms(), st);

    LOG_TEST("Run %d timers: %lld.%03lld s",
            TIMER_NUMBER,
            delta / 1000, delta % 1000);
    elf::timer_stat();
}
Пример #12
0
void mediadataclient_object_t::test<1>()
{
    //
    // Test fetchMedia()
    //
    LOG_TEST(1);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(DATA);
    int num_refs_start = o->getNumRefs();
    {
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);
        mdc->fetchMedia(o);

        // Make sure no posts happened yet...
        ensure("post records", gPostRecords->size(), 0);

        ::pump_timers();

        ensure("post records", gPostRecords->size(), 1);
        ensure("post url", (*gPostRecords)[0]["url"], FAKE_OBJECT_MEDIA_CAP_URL);
        ensure("post GET", (*gPostRecords)[0]["body"]["verb"], "GET");
        ensure("post object id", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        ensure("queue empty", mdc->isEmpty());
    }

    // Make sure everyone's destroyed properly
    ensure("REF COUNT", o->getNumRefs(), num_refs_start);
}
Пример #13
0
static void test_readall(void) {
  char* lotsa_as[512];
  char* lotsa_bs[1024];
  gpr_slice slices[2];
  grpc_byte_buffer *buffer;
  grpc_byte_buffer_reader reader;
  gpr_slice slice_out;

  LOG_TEST("test_readall");

  memset(lotsa_as, 'a', 512);
  memset(lotsa_bs, 'b', 1024);
  /* use slices large enough to overflow inlining */
  slices[0] = gpr_slice_malloc(512);
  memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512);
  slices[1] = gpr_slice_malloc(1024);
  memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024);

  buffer = grpc_raw_byte_buffer_create(slices, 2);
  gpr_slice_unref(slices[0]);
  gpr_slice_unref(slices[1]);

  grpc_byte_buffer_reader_init(&reader, buffer);
  slice_out = grpc_byte_buffer_reader_readall(&reader);

  GPR_ASSERT(GPR_SLICE_LENGTH(slice_out) == 512 + 1024);
  GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0);
  GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) ==
             0);
  gpr_slice_unref(slice_out);
  grpc_byte_buffer_destroy(buffer);
}
Пример #14
0
static void test_create_many_persistant_metadata(void) {
  grpc_mdctx *ctx;
  char buffer[GPR_LTOA_MIN_BUFSIZE];
  long i;
  grpc_mdelem **created = gpr_malloc(sizeof(grpc_mdelem *) * MANY);
  grpc_mdelem *md;

  LOG_TEST("test_create_many_persistant_metadata");

  ctx = grpc_mdctx_create();
  /* add phase */
  for (i = 0; i < MANY; i++) {
    gpr_ltoa(i, buffer);
    created[i] = grpc_mdelem_from_strings(ctx, "a", buffer);
  }
  /* verify phase */
  for (i = 0; i < MANY; i++) {
    gpr_ltoa(i, buffer);
    md = grpc_mdelem_from_strings(ctx, "a", buffer);
    GPR_ASSERT(md == created[i]);
    GRPC_MDELEM_UNREF(md);
  }
  /* cleanup phase */
  for (i = 0; i < MANY; i++) {
    GRPC_MDELEM_UNREF(created[i]);
  }
  grpc_mdctx_unref(ctx);

  gpr_free(created);
}
Пример #15
0
void mediadataclient_object_t::test<2>()
{
    //
    // Test updateMedia()
    //
    LOG_TEST(2);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(DATA);
    {
        // queue time w/ no delay ensures that ::pump_timers() will hit the tick()
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD);
        mdc->updateMedia(o);
        ensure("post records", gPostRecords->size(), 0);
        ::pump_timers();

        ensure("post records", gPostRecords->size(), 1);
        ensure("post url", (*gPostRecords)[0]["url"], FAKE_OBJECT_MEDIA_CAP_URL);
        ensure("post UPDATE", (*gPostRecords)[0]["body"]["verb"], "UPDATE");
        ensure("post object id", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        ensure_llsd("post data llsd", (*gPostRecords)[0]["body"][LLTextureEntry::OBJECT_MEDIA_DATA_KEY],
                    "<llsd>" MEDIA_DATA "</llsd>");
        ensure("queue empty", mdc->isEmpty());
    }

    ensure("REF COUNT", o->getNumRefs(), 1);
}
Пример #16
0
static void test_no_op_with_start(void) {
    grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
    grpc_tcp_server *s = grpc_tcp_server_create(NULL);
    LOG_TEST("test_no_op_with_start");
    grpc_tcp_server_start(&exec_ctx, s, NULL, 0, on_connect, NULL);
    grpc_tcp_server_unref(&exec_ctx, s);
    grpc_exec_ctx_finish(&exec_ctx);
}
Пример #17
0
static void test_no_op(void) {
  grpc_mdctx *ctx;

  LOG_TEST("test_no_op");

  ctx = grpc_mdctx_create();
  grpc_mdctx_unref(ctx);
}
Пример #18
0
/* test creation & destruction */
static void test_no_op(void) {
  grpc_chttp2_stream_map map;

  LOG_TEST("test_no_op");

  grpc_chttp2_stream_map_init(&map, 8);
  grpc_chttp2_stream_map_destroy(&map);
}
Пример #19
0
static void test_no_op_with_start(void) {
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_udp_server *s = grpc_udp_server_create();
  LOG_TEST("test_no_op_with_start");
  grpc_udp_server_start(&exec_ctx, s, NULL, 0, NULL);
  grpc_udp_server_destroy(&exec_ctx, s, NULL);
  grpc_exec_ctx_finish(&exec_ctx);
}
Пример #20
0
static void test_merge(void) {
  gpr_histogram *h1, *h2;
  double last;
  double i;
  double cur;

  LOG_TEST("test_merge");

  h1 = gpr_histogram_create(0.05, 1e9);
  gpr_histogram_add(h1, 2.5);
  gpr_histogram_add(h1, 2.5);
  gpr_histogram_add(h1, 8);
  gpr_histogram_add(h1, 4);

  h2 = gpr_histogram_create(0.01, 1e9);
  GPR_ASSERT(gpr_histogram_merge(h1, h2) == 0);
  gpr_histogram_destroy(h2);

  h2 = gpr_histogram_create(0.05, 1e10);
  GPR_ASSERT(gpr_histogram_merge(h1, h2) == 0);
  gpr_histogram_destroy(h2);

  h2 = gpr_histogram_create(0.05, 1e9);
  GPR_ASSERT(gpr_histogram_merge(h1, h2) == 1);
  GPR_ASSERT(gpr_histogram_count(h1) == 4);
  GPR_ASSERT(gpr_histogram_minimum(h1) == 2.5);
  GPR_ASSERT(gpr_histogram_maximum(h1) == 8);
  GPR_ASSERT(gpr_histogram_sum(h1) == 17);
  GPR_ASSERT(gpr_histogram_sum_of_squares(h1) == 92.5);
  GPR_ASSERT(gpr_histogram_mean(h1) == 4.25);
  GPR_ASSERT(gpr_histogram_variance(h1) == 5.0625);
  GPR_ASSERT(gpr_histogram_stddev(h1) == 2.25);
  gpr_histogram_destroy(h2);

  h2 = gpr_histogram_create(0.05, 1e9);
  gpr_histogram_add(h2, 7.0);
  gpr_histogram_add(h2, 17.0);
  gpr_histogram_add(h2, 1.0);
  GPR_ASSERT(gpr_histogram_merge(h1, h2) == 1);
  GPR_ASSERT(gpr_histogram_count(h1) == 7);
  GPR_ASSERT(gpr_histogram_minimum(h1) == 1.0);
  GPR_ASSERT(gpr_histogram_maximum(h1) == 17.0);
  GPR_ASSERT(gpr_histogram_sum(h1) == 42.0);
  GPR_ASSERT(gpr_histogram_sum_of_squares(h1) == 431.5);
  GPR_ASSERT(gpr_histogram_mean(h1) == 6.0);

  /* test monotonicity */
  last = 0.0;
  for (i = 0; i < 100.0; i += 0.01) {
    cur = gpr_histogram_percentile(h1, i);
    GPR_ASSERT(cur >= last);
    last = cur;
  }

  gpr_histogram_destroy(h1);
  gpr_histogram_destroy(h2);
}
Пример #21
0
static void test_shutdown_then_next_with_timeout(void) {
  grpc_completion_queue *cc;
  LOG_TEST("test_shutdown_then_next_with_timeout");

  cc = grpc_completion_queue_create();
  grpc_completion_queue_shutdown(cc);
  GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_future).type == GRPC_QUEUE_SHUTDOWN);
  grpc_completion_queue_destroy(cc);
}
Пример #22
0
static void test_wait_empty(void) {
  grpc_completion_queue *cc;

  LOG_TEST();

  cc = grpc_completion_queue_create();
  GPR_ASSERT(grpc_completion_queue_next(cc, gpr_now()) == NULL);
  shutdown_and_destroy(cc);
}
Пример #23
0
static void test_spin_creating_the_same_thing(void) {
  LOG_TEST("test_spin_creating_the_same_thing");

  grpc_init();
  GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", "b"));
  GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", "b"));
  GRPC_MDELEM_UNREF(grpc_mdelem_from_strings("a", "b"));
  grpc_shutdown();
}
Пример #24
0
/* test lookup on an empty map */
static void test_empty_find(void) {
  grpc_chttp2_stream_map map;

  LOG_TEST("test_empty_find");

  grpc_chttp2_stream_map_init(&map, 8);
  GPR_ASSERT(NULL == grpc_chttp2_stream_map_find(&map, 39128));
  grpc_chttp2_stream_map_destroy(&map);
}
Пример #25
0
static void test_shutdown_then_next_polling(void) {
  grpc_completion_queue *cc;
  LOG_TEST("test_shutdown_then_next_polling");

  cc = grpc_completion_queue_create();
  grpc_completion_queue_shutdown(cc);
  GPR_ASSERT(grpc_completion_queue_next(cc, gpr_inf_past).type == GRPC_QUEUE_SHUTDOWN);
  grpc_completion_queue_destroy(cc);
}
Пример #26
0
void test_decoding(void) {
    LOG_TEST();
    decode_suite('n', gpr_time_from_nanos);
    decode_suite('u', gpr_time_from_micros);
    decode_suite('m', gpr_time_from_millis);
    decode_suite('S', gpr_time_from_seconds);
    decode_suite('M', gpr_time_from_minutes);
    decode_suite('H', gpr_time_from_hours);
    assert_decodes_as("1000000000000000000000u", gpr_inf_future);
}
Пример #27
0
static void test_wait_empty(void) {
  grpc_completion_queue *cc;

  LOG_TEST("test_wait_empty");

  cc = grpc_completion_queue_create();
  GPR_ASSERT(grpc_completion_queue_next(cc, gpr_now()).type ==
             GRPC_QUEUE_TIMEOUT);
  shutdown_and_destroy(cc);
}
Пример #28
0
static void test_wait_empty(void) {
  grpc_completion_queue *cc;
  grpc_event event;

  LOG_TEST("test_wait_empty");

  cc = grpc_completion_queue_create(NULL);
  event = grpc_completion_queue_next(cc, gpr_now(GPR_CLOCK_REALTIME), NULL);
  GPR_ASSERT(event.type == GRPC_QUEUE_TIMEOUT);
  shutdown_and_destroy(cc);
}
Пример #29
0
static void test_no_op_with_port(void) {
  struct sockaddr_in addr;
  grpc_tcp_server *s = grpc_tcp_server_create();
  LOG_TEST();

  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  GPR_ASSERT(
      grpc_tcp_server_add_port(s, (struct sockaddr *)&addr, sizeof(addr)));

  grpc_tcp_server_destroy(s);
}
Пример #30
0
void mediadataclient_object_t::test<5>()
{
    //
    // Test fetchMedia() getting a 503 error
    //
    LOG_TEST(5);

    LLMediaDataClientObject::ptr_t o = new LLMediaDataClientObjectTest(
        _DATA_URLS(VALID_OBJECT_ID,
                   "1.0","true",
                   FAKE_OBJECT_MEDIA_CAP_URL_503,
                   FAKE_OBJECT_MEDIA_NAVIGATE_CAP_URL));
    int num_refs_start = o->getNumRefs();
    {
        const int NUM_RETRIES = 5;
        LLPointer<LLObjectMediaDataClient> mdc = new LLObjectMediaDataClient(NO_PERIOD,NO_PERIOD,NUM_RETRIES);

        // This should generate a retry
        mdc->fetchMedia(o);

        // Make sure no posts happened yet...
        ensure("post records before", gPostRecords->size(), 0);

        // Once, causes retry
        // Second, fires retry timer
        // Third, fires queue timer again
        for (int i=0; i<NUM_RETRIES; ++i)
        {
            ::pump_timers();  // Should pump (fire) the queue timer, causing a retry timer to be scheduled
            // XXX This ensure is not guaranteed, because scheduling a timer might actually get it pumped in the same loop
            //ensure("post records " + STR(i), gPostRecords->size(), i+1);
            ::pump_timers();  // Should pump (fire) the retry timer, scheduling the queue timer
        }

        // Do some extra pumps to make sure no other timer work occurs.
        ::pump_timers();
        ::pump_timers();
        ::pump_timers();

        // Make sure there were 2 posts
        ensure("post records after", gPostRecords->size(), NUM_RETRIES);
        for (int i=0; i<NUM_RETRIES; ++i)
        {
            ensure("[" + STR(i) + "] post url", (*gPostRecords)[i]["url"], FAKE_OBJECT_MEDIA_CAP_URL_503);
            ensure("[" + STR(i) + "] post GET", (*gPostRecords)[i]["body"]["verb"], "GET");
            ensure("[" + STR(i) + "] post object id", (*gPostRecords)[i]["body"][LLTextureEntry::OBJECT_ID_KEY].asUUID(), LLUUID(VALID_OBJECT_ID));
        }
        ensure("queue empty", mdc->isEmpty());
    }

    // Make sure everyone's destroyed properly
    ensure("REF COUNT", o->getNumRefs(), num_refs_start);
}