/** * \test Check if the reference info from the reference.config file have * been loaded into the hash table. */ int SCRConfTest06(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; if (de_ctx == NULL) return 0; FILE *fd = SCRConfGenerateInValidDummyReferenceConfigFD02(); SCRConfLoadReferenceConfigFile(de_ctx, fd); if (de_ctx->reference_conf_ht == NULL) goto end; result = (de_ctx->reference_conf_ht->count == 1); result &= (SCRConfGetReference("one", de_ctx) != NULL); result &= (SCRConfGetReference("two", de_ctx) == NULL); result &= (SCRConfGetReference("three", de_ctx) == NULL); result &= (SCRConfGetReference("four", de_ctx) == NULL); result &= (SCRConfGetReference("five", de_ctx) == NULL); end: if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); return result; }
/** * \test Check if the reference info from the reference.config file have * been loaded into the hash table. */ int SCRConfTest06(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); SCRConfReference *ref = NULL; int result = 1; if (de_ctx == NULL) return 0; SCRConfGenerateInValidDummyReferenceConfigFD02(); SCRConfLoadReferenceConfigFile(de_ctx); SCRConfDeleteDummyReferenceConfigFD(); if (de_ctx->reference_conf_ht == NULL) goto end; result = (de_ctx->reference_conf_ht->count == 1); ref = SCRConfAllocSCRConfReference("one", "one"); result &= (HashTableLookup(de_ctx->reference_conf_ht, ref, 0) != NULL); SCRConfDeAllocSCRConfReference(ref); ref = SCRConfAllocSCRConfReference("two", "two"); result &= (HashTableLookup(de_ctx->reference_conf_ht, ref, 0) == NULL); SCRConfDeAllocSCRConfReference(ref); ref = SCRConfAllocSCRConfReference("three", "three"); result &= (HashTableLookup(de_ctx->reference_conf_ht, ref, 0) == NULL); SCRConfDeAllocSCRConfReference(ref); ref = SCRConfAllocSCRConfReference("four", "four"); result &= (HashTableLookup(de_ctx->reference_conf_ht, ref, 0) == NULL); SCRConfDeAllocSCRConfReference(ref); ref = SCRConfAllocSCRConfReference("five", "five"); result &= (HashTableLookup(de_ctx->reference_conf_ht, ref, 0) == NULL); SCRConfDeAllocSCRConfReference(ref); end: if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); return result; }
/** * \test Check that only valid references are loaded into the hash table from * the reference.config file. */ int SCRConfTest03(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; if (de_ctx == NULL) return result; FILE *fd = SCRConfGenerateInValidDummyReferenceConfigFD02(); SCRConfLoadReferenceConfigFile(de_ctx, fd); if (de_ctx->reference_conf_ht == NULL) goto end; result = (de_ctx->reference_conf_ht->count == 1); end: if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); return result; }