/* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. * */ int main() { ks3_global_init(); int ret = load_ak_sk(); if (ret != 0) { printf("[ERROR] load ak, sk failed\n"); return ret; } ret = CreateBucket(host, bucket); if (ret != 0) { printf("[ERROR] create bucket failed\n"); return ret; } CU_pSuite pSuite = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1); if (NULL == pSuite) { CU_cleanup_registry(); ks3_global_destroy(); return CU_get_error(); } /* add the tests to the suite */ if (NULL == CU_add_test(pSuite, "test upload part para null\n", TEST_UPLOAD_PART_ALL_NULL) || NULL == CU_add_test(pSuite, "test upload part para return code null\n", TEST_UPLOAD_PART_RETURNCODE_NULL) || NULL == CU_add_test(pSuite, "test upload part para host\n", TEST_UPLOAD_PART_HOST) || NULL == CU_add_test(pSuite, "test upload part para bucket\n", TEST_UPLOAD_PART_BUCKET) || NULL == CU_add_test(pSuite, "test upload part para object\n", TEST_UPLOAD_PART_OBJECT) || NULL == CU_add_test(pSuite, "test upload part para key\n", TEST_UPLOAD_PART_KEY) || NULL == CU_add_test(pSuite, "test upload part para uploadid partnum\n", TEST_UPLOAD_PART_UPLOAD_PARTNUM) || NULL == CU_add_test(pSuite, "test upload part para query\n", TEST_UPLOAD_PART_QUERYPARA) || NULL == CU_add_test(pSuite, "test upload part para header\n", TEST_UPLOAD_PART_HEADERPARA) || NULL == CU_add_test(pSuite, "clean bucket\n", clean)) { CU_cleanup_registry(); ks3_global_destroy(); return CU_get_error(); } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_cleanup_registry(); ret = DeleteBucket(host, bucket); if (ret != 0) { printf("[ERROR] delete bucket failed\n"); } ks3_global_destroy(); return CU_get_error(); }
void* bucketAlloc( struct BucketAlloc *ba ) { void *it; // If running out of memory, allocate new bucket and update the freelist. if ( !ba->freelist || !NextFreeItem( ba ) ) { if ( !CreateBucket( ba ) ) return 0; } // Pop item from in front of the free list. it = ba->freelist; ba->freelist = NextFreeItem( ba ); return it; }
struct BucketAlloc* createBucketAlloc( TESSalloc* alloc, const char* name, unsigned int itemSize, unsigned int bucketSize ) { BucketAlloc* ba = (BucketAlloc*)alloc->memalloc( alloc->userData, sizeof(BucketAlloc) ); ba->alloc = alloc; ba->name = name; ba->itemSize = itemSize; if ( ba->itemSize < sizeof(void*) ) ba->itemSize = sizeof(void*); ba->bucketSize = bucketSize; ba->freelist = 0; ba->buckets = 0; if ( !CreateBucket( ba ) ) { alloc->memfree( alloc->userData, ba ); return 0; } return ba; }
/* The main() function for setting up and running the tests. * Returns a CUE_SUCCESS on successful running, another * CUnit error code on failure. * */ int main() { ks3_global_init(); int ret = load_ak_sk(); if (ret != 0) { printf("[ERROR] load ak, sk failed\n"); return ret; } ret = CreateBucket(host, src_bucket); if (ret != 0) { printf("[ERROR] create src bucket failed\n"); return ret; } ret = CreateBucket(host, dst_bucket); if (ret != 0) { printf("[ERROR] create dst bucket failed\n"); return ret; } CU_pSuite pSuite = NULL; /* initialize the CUnit test registry */ if (CUE_SUCCESS != CU_initialize_registry()) return CU_get_error(); /* add a suite to the registry */ pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1); if (NULL == pSuite) { CU_cleanup_registry(); ks3_global_destroy(); return CU_get_error(); } /* add the tests to the suite */ if (CU_add_test(pSuite, "test copy object with same bucket\n", TEST_COPY_OBJECT_WITH_SAME_BUCKET) == NULL || CU_add_test(pSuite, "test copy object with same bucket and key \n", TEST_COPY_OBJECT_WITH_SAME_BUCKET_AND_SAME_OBJ_KEY) == NULL || CU_add_test(pSuite, "test copy object with same bucket and diff exist key \n", TEST_COPY_OBJECT_WITH_SAME_BUCKET_AND_DIFF_EXIST_OBJ_KEY) == NULL || CU_add_test(pSuite, "test copy object with diff bucket \n", TEST_COPY_OBJECT_WITH_DIFF_BUCKET) == NULL || CU_add_test(pSuite, "test copy object with diff bucket and exist key\n", TEST_COPY_OBJECT_WITH_DIFF_BUCKET_AND_EXIST_KEY) == NULL || CU_add_test(pSuite, "test copy object with src bucket not exist\n", TEST_COPY_OBJECT_WITH_SRC_BUCKET_NOT_EXIST) == NULL || CU_add_test(pSuite, "test copy object with src object not exist\n", TEST_COPY_OBJECT_WITH_SRC_OBJECT_NOT_EXIST) == NULL || CU_add_test(pSuite, "test copy object with dst bucket not exist\n", TEST_COPY_OBJECT_WITH_DST_BUCKET_NOT_EXIST) == NULL || CU_add_test(pSuite, "test copy object with blank dst bucket name\n", TEST_COPY_OBJECT_WITH_BLANK_DST_BUCKET_NAME) == NULL || CU_add_test(pSuite, "test copy object with blank src bucket name\n", TEST_COPY_OBJECT_WITH_BLANK_SRC_BUCKET_NAME) == NULL || CU_add_test(pSuite, "test copy object with blank src object name\n", TEST_COPY_OBJECT_WITH_BLANK_SRC_OBJECT_NAME) == NULL) { CU_cleanup_registry(); ks3_global_destroy(); return CU_get_error(); } /* Run all tests using the CUnit Basic interface */ CU_basic_set_mode(CU_BRM_VERBOSE); CU_basic_run_tests(); CU_cleanup_registry(); ret = DeleteBucket(host, src_bucket); if (ret != 0) { printf("[ERROR] delete src_bucket failed\n"); } ret = DeleteBucket(host, dst_bucket); if (ret != 0) { printf("[ERROR] delete dst_bucket failed\n"); } ks3_global_destroy(); return CU_get_error(); }