/** * * Init_nlm_hash: Init the hashtable for NLM Owner cache. * * Perform all the required initialization for hashtable State Id cache * * @param param [IN] parameter used to init the duplicate request cache * * @return 0 if successful, -1 otherwise * */ int Init_nlm_hash(void) { if((ht_nsm_client = HashTable_Init(&nfs_param.nsm_client_hash_param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init NSM Client cache"); return -1; } if((ht_nlm_client = HashTable_Init(&nfs_param.nlm_client_hash_param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init NLM Client cache"); return -1; } if((ht_nlm_owner = HashTable_Init(&nfs_param.nlm_owner_hash_param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init NLM Owner cache"); return -1; } return 0; } /* Init_nlm_hash */
/** * * nfs_Init_dupreq: Init the hashtable and LRU for duplicate request cache * * Perform all the required initialization for hashtable and LRU for duplicate request cache * * @param param [IN] parameter used to init the duplicate request cache * * @return 0 if successful, -1 otherwise * */ int nfs_Init_dupreq(nfs_rpc_dupreq_parameter_t param) { if((ht_dupreq_udp = HashTable_Init(param.hash_param)) == NULL) { LogCrit(COMPONENT_DUPREQ, "Cannot init the duplicate request hash table"); return -1; } if((ht_dupreq_tcp = HashTable_Init(param.hash_param)) == NULL) { LogCrit(COMPONENT_DUPREQ, "Cannot init the duplicate request hash table"); return -1; } return DUPREQ_SUCCESS; } /* nfs_Init_dupreq */
/** * * nfs41_Init_session_id: Init the hashtable for Session Id cache. * * Perform all the required initialization for hashtable Session Id cache * * @param param [IN] parameter used to init the session id cache * * @return 0 if successful, -1 otherwise * */ int nfs41_Init_session_id(nfs_session_id_parameter_t param) { if((ht_session_id = HashTable_Init(param.hash_param)) == NULL) { LogCrit(COMPONENT_SESSIONS, "NFS SESSION_ID: Cannot init Session Id cache"); return -1; } return 0; } /* nfs_Init_sesion_id */
/** * * Init_nlm_hash: Init the hashtable for NLM Owner cache. * * Perform all the required initialization for hashtable State Id cache * * @param param [IN] parameter used to init the duplicate request cache * * @return 0 if successful, -1 otherwise * */ int Init_nlm_hash(hash_parameter_t client_param, hash_parameter_t owner_param) { if((ht_nlm_client = HashTable_Init(client_param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init NLM Client cache"); return -1; } if((ht_nlm_owner = HashTable_Init(owner_param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init NLM Owner cache"); return -1; } return 0; } /* Init_nlm_hash */
/** * * Init_9p_hash: Init the hashtable for 9P Owner cache. * * Perform all the required initialization for hashtable State Id cache * * @param param [IN] parameter used to init the duplicate request cache * * @return 0 if successful, -1 otherwise * */ int Init_9p_hash(void) { if((ht_9p_owner = HashTable_Init(&nfs_param._9p_owner_hash_param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init 9P Owner cache"); return -1; } return 0; } /* Init_9p_hash */
/** * @brief Init the hashtable for NFSv4 owner cache * * @param[in] param Parameter to init the owner table * * @retval 0 if successful. * @retval -1 if we failed. */ int Init_nfs4_owner(hash_parameter_t *param) { if((ht_nfs4_owner = HashTable_Init(param)) == NULL) { LogCrit(COMPONENT_STATE, "Cannot init NFS Open Owner cache"); return -1; } return 0; } /* nfs4_Init_nfs4_owner */
/** * * nfs_Init_ip_stats: Init the hashtable for IP stats cache. * * Perform all the required initialization for hashtable IP stats cache * * @param param [IN] parameter used to init the duplicate request cache * * @return 0 if successful, -1 otherwise * */ hash_table_t *nfs_Init_ip_stats(nfs_ip_stats_parameter_t param) { hash_table_t *ht_ip_stats; if((ht_ip_stats = HashTable_Init(param.hash_param)) == NULL) { LogCrit(COMPONENT_INIT, "NFS IP_STATS: Cannot init IP stats cache"); return NULL; } return ht_ip_stats; } /* nfs_Init_ip_stats */
/* Initialize namespace and create root with the given inode number */ int NamespaceInit(ino_t root_inode, dev_t root_dev, unsigned int *p_root_gen) { hash_buffer_t buffkey; hash_buffer_t buffval; fsnode_t *root; /* Initialize pools. */ STUFF_PREALLOC(peer_pool, POOL_CHUNK_SIZE, lookup_peer_t, p_next); STUFF_PREALLOC(node_pool, POOL_CHUNK_SIZE, fsnode_t, p_next); /* initialize namespace lock */ if(rw_lock_init(&ns_lock)) return ENOMEM; /* init the lookup hash table */ lookup_hash = HashTable_Init(lookup_hash_config); nodes_hash = HashTable_Init(nodes_hash_config); if(!lookup_hash || !nodes_hash) return ENOMEM; /* allocate the root entry */ root = h_insert_new_node(root_inode, root_dev, *p_root_gen, TRUE); if(!root) return ENOMEM; LogFullDebug(COMPONENT_FSAL, "namespace: Root=%lX.%ld (gen:%u)", root_dev, root_inode, root->inode.generation); *p_root_gen = root->inode.generation; /* never remove it */ root->n_lookup = 1; return 0; }
/** * * nfs_Init_ip_name: Init the hashtable for IP/name cache. * * Perform all the required initialization for hashtable IP/name cache * * @param param [IN] parameter used to init the ip name cache * * @return 0 if successful, -1 otherwise * */ int nfs_Init_ip_name(nfs_ip_name_parameter_t param) { if((ht_ip_name = HashTable_Init(¶m.hash_param)) == NULL) { LogCrit(COMPONENT_INIT, "NFS IP_NAME: Cannot init IP/name cache"); return -1; } /* Set the expiration time */ expiration_time = param.expiration_time; return IP_NAME_SUCCESS; } /* nfs_Init_ip_name */
/** * * cache_inode_init: Init the ressource necessary for the cache inode management. * * Init the ressource necessary for the cache inode management. * * @param param [IN] the parameter for this cache. * @param pstatus [OUT] pointer to buffer used to store the status for the operation. * * @return NULL if operation failed, other value is a pointer to the hash table used for the cache. * */ hash_table_t *cache_inode_init(cache_inode_parameter_t param, cache_inode_status_t * pstatus) { hash_table_t *ht = NULL; ht = HashTable_Init(param.hparam); if(ht != NULL) *pstatus = CACHE_INODE_SUCCESS; else *pstatus = CACHE_INODE_INVALID_ARGUMENT; LogInfo(COMPONENT_CACHE_INODE, "Hash Table initiated"); return ht; } /* cache_inode_init */
int StringChunk_Init(StringChunk *dl, int InitialCount /* For no-wildcard domain */) { if( StringList_Init(&(dl -> List), NULL, 0) != 0 ) { return -1; } if( HashTable_Init(&(dl -> List_Pos), sizeof(EntryForString), InitialCount, NULL) != 0 ) { StringList_Free(&(dl -> List)); return -2; } if( StringList_Init(&(dl -> List_W), NULL, 0) != 0 ) { StringList_Free(&(dl -> List)); HashTable_Free(&(dl -> List_Pos)); return -3; } if( Array_Init(&(dl -> List_W_Pos), sizeof(EntryForString), 0, FALSE, NULL) != 0 ) { StringList_Free(&(dl -> List)); HashTable_Free(&(dl -> List_Pos)); StringList_Free(&(dl -> List_W)); return -4; } if( ExtendableBuffer_Init(&(dl -> AdditionalDataChunk), 0, -1) != 0 ) { StringList_Free(&(dl -> List)); HashTable_Free(&(dl -> List_Pos)); StringList_Free(&(dl -> List_W)); Array_Free(&(dl -> List_W_Pos)); return -5; } return 0; }
int nfs4_acls_init() { LogDebug(COMPONENT_NFS_V4_ACL, "Initialize NFSv4 ACLs"); LogDebug(COMPONENT_NFS_V4_ACL, "sizeof(fsal_ace_t)=%lu, sizeof(fsal_acl_t)=%lu", sizeof(fsal_ace_t), sizeof(fsal_acl_t)); /* Initialize memory pool of ACLs. */ MakePool(&fsal_acl_pool, nb_pool_prealloc, fsal_acl_t, NULL, NULL); /* Initialize memory pool of ACL keys. */ MakePool(&fsal_acl_key_pool, nb_pool_prealloc, fsal_acl_key_t, NULL, NULL); /* Create hash table. */ fsal_acl_hash = HashTable_Init(fsal_acl_hash_config); if(!fsal_acl_hash) { LogCrit(COMPONENT_NFS_V4_ACL, "ERROR creating hash table for NFSv4 ACLs"); return NFS_V4_ACL_INTERNAL_ERROR; } nfs4_acls_test(); return NFS_V4_ACL_SUCCESS; }
int main(int argc, char *argv[]) { SetDefaultLogging("TEST"); SetNamePgm("test_cmchash"); hash_table_t *ht = NULL; hash_parameter_t hparam; hash_buffer_t buffval; hash_buffer_t buffkey; hash_buffer_t buffval2; hash_buffer_t buffkey2; hash_stat_t statistiques; int i; int val; int rc; int res; struct Temps debut, fin; char tmpstr[10]; char tmpstr2[10]; char tmpstr3[10]; char strtab[MAXTEST][10]; int critere_recherche = 0; int random_val = 0; hparam.index_size = PRIME; hparam.alphabet_length = 10; hparam.nb_node_prealloc = NB_PREALLOC; hparam.hash_func_key = simple_hash_func; hparam.hash_func_rbt = rbt_hash_func; hparam.compare_key = compare_string_buffer; hparam.key_to_str = display_buff; hparam.val_to_str = display_buff; BuddyInit(NULL); /* Init de la table */ if((ht = HashTable_Init(hparam)) == NULL) { LogTest("Test FAILED: Bad init"); exit(1); } MesureTemps(&debut, NULL); LogTest("Created the table"); for(i = 0; i < MAXTEST; i++) { sprintf(strtab[i], "%d", i); buffkey.len = strlen(strtab[i]); buffkey.pdata = strtab[i]; buffval.len = strlen(strtab[i]); buffval.pdata = strtab[i]; rc = HashTable_Set(ht, &buffkey, &buffval); LogFullDebug(COMPONENT_HASHTABLE,"Added %s , %d , return = %d", strtab[i], i, rc); } MesureTemps(&fin, &debut); LogTest("Time to insert %d entries: %s", MAXTEST, ConvertiTempsChaine(fin, NULL)); LogFullDebug(COMPONENT_HASHTABLE, "-----------------------------------------"); HashTable_Log(COMPONENT_HASHTABLE,ht); LogTest("========================================="); /* Premier test simple: verif de la coherence des valeurs lues */ critere_recherche = CRITERE; sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; MesureTemps(&debut, NULL); rc = HashTable_Get(ht, &buffkey, &buffval); MesureTemps(&fin, &debut); LogTest("Recovery of %d th key ->%d", critere_recherche, rc); LogTest("Time to recover = %s", ConvertiTempsChaine(fin, NULL)); if(rc != HASHTABLE_SUCCESS) { LogTest("Test FAILED: The key is not found"); exit(1); } sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; MesureTemps(&debut, NULL); rc = HashTable_Get(ht, &buffkey, &buffval); MesureTemps(&fin, &debut); LogTest("Recovery of %d th key (test 2) -> %s", critere_recherche, rc); LogTest("Time to recover = %s", ConvertiTempsChaine(fin, NULL)); if(rc != HASHTABLE_SUCCESS) { LogTest("Test FAILED: The key is not found (test 2)"); exit(1); } LogTest("----> retrieved value = len %d ; val = %s", buffval.len, buffval.pdata); val = atoi(buffval.pdata); if(val != critere_recherche) { LogTest("Test FAILED: the reading is incorrect"); exit(1); } LogTest("Now, I try to retrieve %d entries (taken at random, almost)", MAXGET); MesureTemps(&debut, NULL); for(i = 0; i < MAXGET; i++) { random_val = random() % MAXTEST; sprintf(tmpstr, "%d", random_val); buffkey2.len = strlen(tmpstr); buffkey2.pdata = tmpstr; rc = HashTable_Get(ht, &buffkey2, &buffval2); LogFullDebug(COMPONENT_HASHTABLE,"\tPlaying key = %s --> %s", buffkey2.pdata, buffval2.pdata); if(rc != HASHTABLE_SUCCESS) { LogTest("Error reading %d = %d", i, rc); LogTest("Test FAILED: the reading is incorrect"); exit(1); } } MesureTemps(&fin, &debut); LogTest("Time to read %d elements = %s", MAXGET, ConvertiTempsChaine(fin, NULL)); LogTest("-----------------------------------------"); sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Del(ht, &buffkey, NULL, NULL); LogTest("Deleting the key %d --> %d", critere_recherche, rc); if(rc != HASHTABLE_SUCCESS) { LogTest("Test FAILED: delete incorrect"); exit(1); } LogTest("========================================="); sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Del(ht, &buffkey, NULL, NULL); LogTest("Deleting the key %d (2nd try) --> %d", critere_recherche, rc); if(rc != HASHTABLE_ERROR_NO_SUCH_KEY) { printf("Test FAILED: delete incorrect"); exit(1); } LogTest("========================================="); sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Get(ht, &buffkey, &buffval); LogTest ("Recovery of the %d key (erased) (must return HASH_ERROR_NO_SUCH_KEY) = %d --> %d", critere_recherche, HASHTABLE_ERROR_NO_SUCH_KEY, rc); if(rc != HASHTABLE_ERROR_NO_SUCH_KEY) { LogTest("Test FAILED: the reading is incorrect"); exit(1); } LogTest("-----------------------------------------"); LogTest ("Destruction of %d items, taken at random (well if you want ... I use srandom)", MAXDESTROY); srandom(getpid()); random_val = random() % MAXTEST; MesureTemps(&debut, NULL); for(i = 0; i < MAXDESTROY; i++) { /* it used to be that the random values were chosen with repeated calls to random(), but if the same key comes up twice, that causes a fail. This way we start with a random value and just linearly delete from it */ random_val = (random_val + 1) % MAXTEST; sprintf(tmpstr, "%d", random_val); LogTest("\t Delete %d", random_val); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Del(ht, &buffkey, NULL, NULL); if(rc != HASHTABLE_SUCCESS) { LogTest("Error on delete %d = %d", i, rc); LogTest("Test FAILED: delete incorrect"); exit(1); } } MesureTemps(&fin, &debut); LogTest("Time to delete %d elements = %s", MAXDESTROY, ConvertiTempsChaine(fin, NULL)); LogTest("-----------------------------------------"); LogTest("Now, I try to retrieve %d entries (if necessary destroyed)", MAXGET); MesureTemps(&debut, NULL); for(i = 0; i < MAXGET; i++) { random_val = random() % MAXTEST; sprintf(tmpstr, "%d", random_val); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Get(ht, &buffkey, &buffval); } MesureTemps(&fin, &debut); LogTest("Tie to read %d elements = %s", MAXGET, ConvertiTempsChaine(fin, NULL)); LogTest("-----------------------------------------"); LogTest("Writing a duplicate key "); sprintf(tmpstr, "%d", CRITERE_2); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Test_And_Set(ht, &buffkey, &buffval, HASHTABLE_SET_HOW_SET_NO_OVERWRITE); LogTest("The value should be HASHTABLE_ERROR_KEY_ALREADY_EXISTS = %d --> %d", HASHTABLE_ERROR_KEY_ALREADY_EXISTS, rc); if(rc != HASHTABLE_ERROR_KEY_ALREADY_EXISTS) { LogTest("Test FAILED: duplicate key"); exit(1); } LogTest("-----------------------------------------"); HashTable_Log(COMPONENT_HASHTABLE,ht); LogFullDebug(COMPONENT_HASHTABLE,"-----------------------------------------"); LogTest("Displaying table statistics "); HashTable_GetStats(ht, &statistiques); LogTest(" Number of entries = %d", statistiques.dynamic.nb_entries); LogTest(" Successful operations : Set = %d, Get = %d, Del = %d, Test = %d", statistiques.dynamic.ok.nb_set, statistiques.dynamic.ok.nb_get, statistiques.dynamic.ok.nb_del, statistiques.dynamic.ok.nb_test); LogTest(" Failed operations : Set = %d, Get = %d, Del = %d, Test = %d", statistiques.dynamic.err.nb_set, statistiques.dynamic.err.nb_get, statistiques.dynamic.err.nb_del, statistiques.dynamic.err.nb_test); LogTest(" Operations 'NotFound': Set = %d, Get = %d, Del = %d, Test = %d", statistiques.dynamic.notfound.nb_set, statistiques.dynamic.notfound.nb_get, statistiques.dynamic.notfound.nb_del, statistiques.dynamic.notfound.nb_test); LogTest (" Calculated statistics: min_rbt_node = %d, max_rbt_node = %d, average_rbt_node = %d", statistiques.computed.min_rbt_num_node, statistiques.computed.max_rbt_num_node, statistiques.computed.average_rbt_num_node); /* Test sur la pertinence des valeurs de statistiques */ if(statistiques.dynamic.ok.nb_set != MAXTEST) { LogTest("Test FAILED: Incorrect statistics: ok.nb_set "); exit(1); } if(statistiques.dynamic.ok.nb_get + statistiques.dynamic.notfound.nb_get != 2 * MAXGET + 3) { LogTest("Test FAILED: Incorrect statistics: *.nb_get "); exit(1); } if(statistiques.dynamic.ok.nb_del != MAXDESTROY + 1 || statistiques.dynamic.notfound.nb_del != 1) { LogTest("Test ECHOUE : statistiques incorrectes: *.nb_del "); exit(1); } if(statistiques.dynamic.err.nb_test != 1) { LogTest("Test ECHOUE : statistiques incorrectes: err.nb_test "); exit(1); } /* Tous les tests sont ok */ BuddyDumpMem(stdout); LogTest("\n-----------------------------------------"); LogTest("Test succeeded: all tests pass successfully"); exit(0); }
int main(int argc, char *argv[]) { SetDefaultLogging("TEST"); SetNamePgm("test_libcmc_bugdelete"); LogTest("Initialized test program"); hash_table_t *ht = NULL; hash_parameter_t hparam; hash_buffer_t buffval; hash_buffer_t buffkey; hash_buffer_t buffval2; hash_buffer_t buffkey2; hash_stat_t statistiques; int i; int rc; struct Temps debut, fin; char tmpstr[10]; char strtab[MAXTEST][10]; int critere_recherche = 0; int random_val = 0; hparam.index_size = PRIME; hparam.alphabet_length = 10; hparam.nb_node_prealloc = NB_PREALLOC; hparam.hash_func_key = simple_hash_func; hparam.hash_func_rbt = rbt_hash_func; hparam.hash_func_both = NULL ; /* BUGAZOMEU */ hparam.compare_key = compare_string_buffer; hparam.key_to_str = display_buff; hparam.val_to_str = display_buff; BuddyInit(NULL); /* Init de la table */ if((ht = HashTable_Init(hparam)) == NULL) { LogTest("Test FAILED: Bad init"); exit(1); } MesureTemps(&debut, NULL); LogTest("Created hash table"); for(i = 0; i < MAXTEST; i++) { sprintf(strtab[i], "%d", i); buffkey.len = strlen(strtab[i]); buffkey.pdata = strtab[i]; buffval.len = strlen(strtab[i]); buffval.pdata = strtab[i]; rc = HashTable_Set(ht, &buffkey, &buffval); LogFullDebug(COMPONENT_HASHTABLE, "Added %s , %d , return code = %d", strtab[i], i, rc); } MesureTemps(&fin, &debut); LogTest("Time to insert %d entries: %s", MAXTEST, ConvertiTempsChaine(fin, NULL)); LogFullDebug(COMPONENT_HASHTABLE, "-----------------------------------------"); HashTable_Log(COMPONENT_HASHTABLE, ht); LogFullDebug(COMPONENT_HASHTABLE, "========================================="); /* Premier test simple: verif de la coherence des valeurs lues */ critere_recherche = CRITERE; sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; MesureTemps(&debut, NULL); rc = HashTable_Get(ht, &buffkey, &buffval); MesureTemps(&fin, &debut); LogTest("Now, I try to retrieve %d entries (taken at random, almost)", MAXGET); MesureTemps(&debut, NULL); for(i = 0; i < MAXGET; i++) { random_val = random() % MAXTEST; sprintf(tmpstr, "%d", random_val); buffkey2.len = strlen(tmpstr); buffkey2.pdata = tmpstr; rc = HashTable_Get(ht, &buffkey2, &buffval2); LogTest("\tPlaying key = %s --> %s", buffkey2.pdata, buffval2.pdata); if(rc != HASHTABLE_SUCCESS) { LogTest("Error reading %d = %d", i, rc); LogTest("Test FAILED: the reading is incorrect"); exit(1); } } MesureTemps(&fin, &debut); LogTest("Time to read elements %d = %s", MAXGET, ConvertiTempsChaine(fin, NULL)); LogTest("-----------------------------------------"); sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; sprintf(tmpstr, "%d", critere_recherche); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; srandom(getpid()); MesureTemps(&debut, NULL); for(i = 0; i < MAXDESTROY; i++) { random_val = bugdelete_key_array[i]; sprintf(tmpstr, "%d", random_val); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; LogFullDebug(COMPONENT_HASHTABLE, "\t Erase %u -> %lu | %lu", random_val, simple_hash_func(&hparam, &buffkey), rbt_hash_func(&hparam, &buffkey)); rc = HashTable_Del(ht, &buffkey, NULL, NULL); if(rc != HASHTABLE_SUCCESS) { LogTest("Erreur lors de la destruction de %d = %d", random_val, rc); LogTest("Test FAILED: delete incorrect"); exit(1); } } MesureTemps(&fin, &debut); LogTest("Time to delete %d elements = %s", MAXDESTROY, ConvertiTempsChaine(fin, NULL)); LogTest("-----------------------------------------"); LogTest("Now, I try to retrieve %d entries (possibly destroyed)", MAXGET); MesureTemps(&debut, NULL); for(i = 0; i < MAXGET; i++) { random_val = random() % MAXTEST; sprintf(tmpstr, "%d", random_val); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Get(ht, &buffkey, &buffval); } MesureTemps(&fin, &debut); LogTest("Time to read %d elements = %s", MAXGET, ConvertiTempsChaine(fin, NULL)); LogTest("-----------------------------------------"); LogTest("Writing a duplicated key"); sprintf(tmpstr, "%d", CRITERE_2); buffkey.len = strlen(tmpstr); buffkey.pdata = tmpstr; rc = HashTable_Test_And_Set(ht, &buffkey, &buffval, HASHTABLE_SET_HOW_SET_NO_OVERWRITE); LogTest("The value must be HASHTABLE_ERROR_KEY_ALREADY_EXISTS = %d --> %d", HASHTABLE_ERROR_KEY_ALREADY_EXISTS, rc); if(rc != HASHTABLE_ERROR_KEY_ALREADY_EXISTS) { LogTest("Test ECHOUE : Clef redondante"); exit(1); } LogTest("-----------------------------------------"); HashTable_Log(COMPONENT_HASHTABLE,ht); LogFullDebug(COMPONENT_HASHTABLE,"-----------------------------------------"); LogTest("Displaying table statistics"); HashTable_GetStats(ht, &statistiques); LogTest(" Number of Entrees = %d", statistiques.dynamic.nb_entries); LogTest(" Successful operations : Set = %d, Get = %d, Del = %d, Test = %d", statistiques.dynamic.ok.nb_set, statistiques.dynamic.ok.nb_get, statistiques.dynamic.ok.nb_del, statistiques.dynamic.ok.nb_test); LogTest(" Failed operations : Set = %d, Get = %d, Del = %d, Test = %d", statistiques.dynamic.err.nb_set, statistiques.dynamic.err.nb_get, statistiques.dynamic.err.nb_del, statistiques.dynamic.err.nb_test); LogTest(" Operations 'NotFound': Set = %d, Get = %d, Del = %d, Test = %d", statistiques.dynamic.notfound.nb_set, statistiques.dynamic.notfound.nb_get, statistiques.dynamic.notfound.nb_del, statistiques.dynamic.notfound.nb_test); LogTest(" Statistics computed: min_rbt_node = %d, max_rbt_node = %d, average_rbt_node = %d", statistiques.computed.min_rbt_num_node, statistiques.computed.max_rbt_num_node, statistiques.computed.average_rbt_num_node); /* Test sur la pertinence des valeurs de statistiques */ if(statistiques.dynamic.ok.nb_set != MAXTEST) { LogTest("Test FAILED: Incorrect statistics: ok.nb_set "); exit(1); } if(statistiques.dynamic.ok.nb_get + statistiques.dynamic.notfound.nb_get != 2 * MAXGET + 1) { LogTest("Test FAILED: Incorrect statistics: *.nb_get. Expected %d, got %d", 2 * MAXGET + 1, statistiques.dynamic.ok.nb_get + statistiques.dynamic.notfound.nb_get); exit(1); } if(statistiques.dynamic.ok.nb_del != MAXDESTROY) { LogTest("Test FAILED: Incorrect statistics: *.nb_del. Expected %d, got %d", MAXDESTROY, statistiques.dynamic.ok.nb_del); exit(1); } if(statistiques.dynamic.notfound.nb_del != 0) { LogTest("Test FAILED: Incorrect statistics: *.nb_del. Expected %d, got %d", 0, statistiques.dynamic.notfound.nb_del); exit(1); } if(statistiques.dynamic.err.nb_test != 1) { LogTest("Test FAILED: Incorrect statistics: err.nb_test "); exit(1); } /* Tous les tests sont ok */ BuddyDumpMem(stdout); LogTest("\n-----------------------------------------"); LogTest("Test succeeded: all tests pass successfully"); exit(0); }