Browse Source

Add forgotten return value test

Yann Weber 7 years ago
parent
commit
3c2cfd848d
2 changed files with 11 additions and 2 deletions
  1. 6
    1
      src/ttail_search_files.c
  2. 5
    1
      tests/ttail_check.h

+ 6
- 1
src/ttail_search_files.c View File

@@ -193,8 +193,13 @@ void _ttail_search_print_files(ttail_t* t, int out)
193 193
 					break;
194 194
 				}
195 195
 				cur_off += r;
196
-				write(out, ttail_file_getline_buf(t),
196
+				r = write(out, ttail_file_getline_buf(t),
197 197
 					strlen(ttail_file_getline_buf(t)));
198
+				if(r == -1)
199
+				{
200
+					perror("unable to write");
201
+					return;
202
+				}
198 203
 			}
199 204
 			else
200 205
 			{

+ 5
- 1
tests/ttail_check.h View File

@@ -140,7 +140,11 @@ Suite * ttail_test_suite(void) \
140 140
 int main(int argc, char **argv) {\
141 141
 	int n_fail;\
142 142
 	SRunner *sr;\
143
-	chdir(dirname(argv[0])); /* move in ./tests dir */ \
143
+	n_fail = chdir(dirname(argv[0])); /* move in ./tests dir */ \
144
+	if(n_fail < 0)\
145
+	{\
146
+		perror("Unable to chdir in tests folder");\
147
+	}\
144 148
 	sr = srunner_create(ttail_test_suite());\
145 149
 	srunner_set_fork_status(sr, CK_FORK);\
146 150
 	srunner_run_all(sr, CK_VERBOSE);\

Loading…
Cancel
Save