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
 					break;
193
 					break;
194
 				}
194
 				}
195
 				cur_off += r;
195
 				cur_off += r;
196
-				write(out, ttail_file_getline_buf(t),
196
+				r = write(out, ttail_file_getline_buf(t),
197
 					strlen(ttail_file_getline_buf(t)));
197
 					strlen(ttail_file_getline_buf(t)));
198
+				if(r == -1)
199
+				{
200
+					perror("unable to write");
201
+					return;
202
+				}
198
 			}
203
 			}
199
 			else
204
 			else
200
 			{
205
 			{

+ 5
- 1
tests/ttail_check.h View File

140
 int main(int argc, char **argv) {\
140
 int main(int argc, char **argv) {\
141
 	int n_fail;\
141
 	int n_fail;\
142
 	SRunner *sr;\
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
 	sr = srunner_create(ttail_test_suite());\
148
 	sr = srunner_create(ttail_test_suite());\
145
 	srunner_set_fork_status(sr, CK_FORK);\
149
 	srunner_set_fork_status(sr, CK_FORK);\
146
 	srunner_run_all(sr, CK_VERBOSE);\
150
 	srunner_run_all(sr, CK_VERBOSE);\

Loading…
Cancel
Save