if (fd == NULL) {
filename = SCClassConfGetConfFilename();
if ( (fd = fopen(filename, "r")) == NULL) {
+#ifdef UNITTESTS
+ if (RunmodeIsUnittests())
+ goto error; // silently fail
+#endif
SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename, strerror(errno));
goto error;
}
if ( (new_str = SCStrdup(str)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+ return NULL;
}
temp_str = new_str;
if ( (ct->classtype = SCClassConfStringToLowercase(classtype)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+
+ SCClassConfDeAllocClasstype(ct);
+ return NULL;
}
if (classtype_desc != NULL &&
(ct->classtype_desc = SCStrdup(classtype_desc)) == NULL) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
- exit(EXIT_FAILURE);
+
+ SCClassConfDeAllocClasstype(ct);
+ return NULL;
}
ct->classtype_id = classtype_id;
void SCClassConfLoadClassficationConfigFile(DetectEngineCtx *de_ctx)
{
if (SCClassConfInitContextAndLocalResources(de_ctx) == -1) {
- SCLogInfo("Please check the \"classification-file\" option in your suricata.yaml file");
- exit(EXIT_FAILURE);
+#ifdef UNITTESTS
+ if (RunmodeIsUnittests() && fd == NULL) {
+ return;
+ }
+#endif
+ SCLogError(SC_ERR_OPENING_FILE, "please check the \"classification-file\" "
+ "option in your suricata.yaml file");
+ return;
}
SCClassConfParseFile(de_ctx);
if (fd == NULL) {
filename = SCRConfGetConfFilename();
if ((fd = fopen(filename, "r")) == NULL) {
+#ifdef UNITTESTS
+ if (RunmodeIsUnittests())
+ goto error; // silently fail
+#endif
SCLogError(SC_ERR_FOPEN, "Error opening file: \"%s\": %s", filename,
strerror(errno));
goto error;
int SCRConfLoadReferenceConfigFile(DetectEngineCtx *de_ctx)
{
if (SCRConfInitContextAndLocalResources(de_ctx) == -1) {
- SCLogInfo("Please check the \"reference-config-file\" option in your suricata.yaml file");
- exit(EXIT_FAILURE);
+#ifdef UNITTESTS
+ if (RunmodeIsUnittests() && fd == NULL) {
+ return -1;
+ }
+#endif
+ SCLogError(SC_ERR_OPENING_FILE, "please check the \"reference-config-file\" "
+ "option in your suricata.yaml file");
+ return -1;
}
SCRConfParseFile(de_ctx);
{
SCRConfReference *ref_conf = SCRConfAllocSCRConfReference(rconf_name, NULL);
if (ref_conf == NULL)
- exit(EXIT_FAILURE);
+ return NULL;
SCRConfReference *lookup_ref_conf = HashTableLookup(de_ctx->reference_conf_ht,
ref_conf, 0);