static void serialize_large_test( void ) { int i; bson b; for ( i=0; i<PER_TRIAL; i++ ) { make_large( &b, i ); bson_destroy( &b ); } }
static void single_insert_large_test( void ) { int i; bson b; for ( i=0; i<PER_TRIAL; i++ ) { make_large( &b, i ); mongo_insert( conn, DB ".single.large", &b, NULL ); bson_destroy( &b ); } }
static void index_insert_large_test( void ) { int i; bson b; ASSERT( mongo_create_simple_index( conn, DB ".index.large", "x", 0, NULL ) == MONGO_OK ); for ( i=0; i<PER_TRIAL; i++ ) { make_large( &b, i ); mongo_insert( conn, DB ".index.large", &b, NULL ); bson_destroy( &b ); } }
static void batch_insert_large_test( void ) { int i, j; bson b[BATCH_SIZE]; const bson *bp[BATCH_SIZE]; for ( j=0; j < BATCH_SIZE; j++ ) bp[j] = &b[j]; for ( i=0; i < ( PER_TRIAL / BATCH_SIZE ); i++ ) { for ( j=0; j < BATCH_SIZE; j++ ) make_large( &b[j], i ); mongo_insert_batch( conn, DB ".batch.large", bp, BATCH_SIZE, NULL, 0 ); for ( j=0; j < BATCH_SIZE; j++ ) bson_destroy( &b[j] ); } }
void init_resources(coap_context_t *ctx) { coap_resource_t *r; coap_payload_t *test_payload; test_payload = coap_new_payload(200); if (!test_payload) coap_log(LOG_CRIT, "cannot allocate resource /test"); else { test_payload->length = 13; memcpy(test_payload->data, "put data here", test_payload->length); /* test_payload->media_type is 0 anyway */ r = coap_resource_init((unsigned char *)"test", 4, 0); coap_register_handler(r, COAP_REQUEST_GET, hnd_get_resource); coap_register_handler(r, COAP_REQUEST_POST, hnd_post_test); coap_register_handler(r, COAP_REQUEST_PUT, hnd_put_test); coap_register_handler(r, COAP_REQUEST_DELETE, hnd_delete_test); coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0); coap_add_attr(r, (unsigned char *)"rt", 2, (unsigned char *)"test", 4, 0); coap_add_attr(r, (unsigned char *)"if", 2, (unsigned char *)"core#b", 6, 0); #if 0 coap_add_attr(r, (unsigned char *)"obs", 3, NULL, 0, 0); #endif coap_add_resource(ctx, r); coap_add_payload(r->key, test_payload, NULL); } /* TD_COAP_BLOCK_01 * TD_COAP_BLOCK_02 */ test_payload = make_large("etsi_iot_01_largedata.txt"); if (!test_payload) coap_log(LOG_CRIT, "cannot allocate resource /large\n"); else { r = coap_resource_init((unsigned char *)"large", 5, 0); coap_register_handler(r, COAP_REQUEST_GET, hnd_get_resource); coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"41", 2, 0); coap_add_attr(r, (unsigned char *)"rt", 2, (unsigned char *)"large", 5, 0); coap_add_resource(ctx, r); test_payload->flags |= REQUIRE_ETAG; coap_add_payload(r->key, test_payload, NULL); } /* For TD_COAP_CORE_12 */ test_payload = coap_new_payload(20); if (!test_payload) coap_log(LOG_CRIT, "cannot allocate resource /seg1/seg2/seg3\n"); else { test_payload->length = 10; memcpy(test_payload->data, "segsegseg!", test_payload->length); /* test_payload->media_type is 0 anyway */ r = coap_resource_init((unsigned char *)"seg1/seg2/seg3", 14, 0); coap_register_handler(r, COAP_REQUEST_GET, hnd_get_resource); coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0); coap_add_resource(ctx, r); coap_add_payload(r->key, test_payload, NULL); } /* For TD_COAP_CORE_13 */ r = coap_resource_init((unsigned char *)"query", 5, 0); coap_register_handler(r, COAP_REQUEST_GET, hnd_get_query); coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0); coap_add_resource(ctx, r); /* For TD_COAP_CORE_16 */ r = coap_resource_init((unsigned char *)"separate", 8, 0); coap_register_handler(r, COAP_REQUEST_GET, hnd_get_separate); coap_add_attr(r, (unsigned char *)"ct", 2, (unsigned char *)"0", 1, 0); coap_add_attr(r, (unsigned char *)"rt", 2, (unsigned char *)"separate", 8, 0); coap_add_resource(ctx, r); }