summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEgor Pugin <egor.pugin@gmail.com>2016-01-11 07:36:11 -0500
committerWill Estes <westes575@gmail.com>2016-05-20 17:31:27 -0400
commit1b7a7165f3f84396c12d0b332b0448d691cf88e5 (patch)
treebf2adcf434507d790aae0e1a800c6059d897e38f /tests
parent98fd512f9a477539a322906cf7a59c7cb75f48a5 (diff)
Exited with error code on some conditions in include tests
Diffstat (limited to 'tests')
-rw-r--r--tests/include_by_buffer.direct.l9
-rw-r--r--tests/include_by_push.direct.l9
-rw-r--r--tests/include_by_reentrant.direct.l9
3 files changed, 24 insertions, 3 deletions
diff --git a/tests/include_by_buffer.direct.l b/tests/include_by_buffer.direct.l
index f3b2d2a..79ff01c 100644
--- a/tests/include_by_buffer.direct.l
+++ b/tests/include_by_buffer.direct.l
@@ -29,6 +29,8 @@ f * are met:
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
+
+int error = 0;
%}
%option 8bit prefix="test"
@@ -56,6 +58,7 @@ int include_stack_ptr = 0;
include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER;
if((yyin=fopen(yytext,"r"))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext);
+ error = 1;
yyterminate();
}
yy_switch_to_buffer( yy_create_buffer( yyin, YY_BUF_SIZE ));
@@ -63,6 +66,7 @@ int include_stack_ptr = 0;
}
.|\n {
fprintf(stderr,"Invalid input \"%s\".\n", yytext);
+ error = 1;
yyterminate();
}
}
@@ -97,6 +101,9 @@ main ( int argc, char** argv )
yyin = fp;
yyout = stdout;
yylex();
- printf("TEST RETURNING OK.\n");
+ if (!error)
+ printf("TEST RETURNING OK.\n");
+ else
+ exit(-1);
return 0;
}
diff --git a/tests/include_by_push.direct.l b/tests/include_by_push.direct.l
index 6b7a5fa..345e02f 100644
--- a/tests/include_by_push.direct.l
+++ b/tests/include_by_push.direct.l
@@ -29,6 +29,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
+
+int error = 0;
%}
%option 8bit prefix="test"
@@ -50,6 +52,7 @@
yytext[yyleng-1]='\0';
if((yyin=fopen(yytext,"r"))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",yytext);
+ error = 1;
yyterminate();
}
yypush_buffer_state( yy_create_buffer( yyin, YY_BUF_SIZE ));
@@ -57,6 +60,7 @@
}
.|\n {
fprintf(stderr,"Invalid input \"%s\".\n", yytext);
+ error = 1;
yyterminate();
}
}
@@ -87,6 +91,9 @@ main ( int argc, char** argv )
yyin = fp;
yyout = stdout;
yylex();
- printf("TEST RETURNING OK.\n");
+ if (!error)
+ printf("TEST RETURNING OK.\n");
+ else
+ exit(-1);
return 0;
}
diff --git a/tests/include_by_reentrant.direct.l b/tests/include_by_reentrant.direct.l
index 9d7967e..2be8b38 100644
--- a/tests/include_by_reentrant.direct.l
+++ b/tests/include_by_reentrant.direct.l
@@ -29,6 +29,8 @@
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
+
+int error = 0;
%}
%option 8bit prefix="test"
@@ -54,6 +56,7 @@
if((fp=fopen(yytext,"r"))==NULL) {
fprintf(stderr,"*** Error: Could not open include file \"%s\".\n",
yytext);
+ error = 1;
yyterminate();
}
yylex_init(&scanner);
@@ -66,6 +69,7 @@
}
.|\n {
fprintf(stderr,"Invalid input \"%s\".\n", yytext);
+ error = 1;
yyterminate();
}
}
@@ -94,6 +98,9 @@ main ( int argc, char **argv )
yyset_out( stdout, scanner);
yylex(scanner);
yylex_destroy(scanner);
- printf("TEST RETURNING OK.\n");
+ if (!error)
+ printf("TEST RETURNING OK.\n");
+ else
+ exit(-1);
return 0;
}