/** * \test Check if the reference info from the invalid reference.config file * have not been loaded into the hash table, and cross verify to check * that the hash table contains no reference data. */ int SCRConfTest05(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 1; if (de_ctx == NULL) return 0; FILE *fd = SCRConfGenerateInValidDummyReferenceConfigFD03(); SCRConfLoadReferenceConfigFile(de_ctx, fd); if (de_ctx->reference_conf_ht == NULL) goto end; result = (de_ctx->reference_conf_ht->count == 0); 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 invalid reference.config file * have not been loaded into the hash table, and cross verify to check * that the hash table contains no reference data. */ int SCRConfTest05(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); SCRConfReference *ref = NULL; int result = 1; if (de_ctx == NULL) return 0; SCRConfGenerateInValidDummyReferenceConfigFD03(); SCRConfLoadReferenceConfigFile(de_ctx); SCRConfDeleteDummyReferenceConfigFD(); if (de_ctx->reference_conf_ht == NULL) goto end; result = (de_ctx->reference_conf_ht->count == 0); 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 invalid references present in the reference.config file * aren't loaded. */ int SCRConfTest02(void) { DetectEngineCtx *de_ctx = DetectEngineCtxInit(); int result = 0; if (de_ctx == NULL) return result; FILE *fd = SCRConfGenerateInValidDummyReferenceConfigFD03(); SCRConfLoadReferenceConfigFile(de_ctx, fd); if (de_ctx->reference_conf_ht == NULL) goto end; result = (de_ctx->reference_conf_ht->count == 0); end: if (de_ctx != NULL) DetectEngineCtxFree(de_ctx); return result; }