| 1158 | } |
| 1159 | |
| 1160 | static bool tf_coverage_channel_end(int index, bool require_flags) { |
| 1161 | int fd = tf_coverage_channel.fd[index]; |
| 1162 | struct stat current; |
| 1163 | if (fd < 0) { |
| 1164 | return false; |
| 1165 | } |
| 1166 | int status; |
| 1167 | do { |
| 1168 | status = fstat(fd, ¤t); |
| 1169 | } while (status < 0 && errno == EINTR); |
| 1170 | if (status != 0 || !S_ISFIFO(current.st_mode) || |
| 1171 | current.st_dev != tf_coverage_channel.identity[index].st_dev || |
| 1172 | current.st_ino != tf_coverage_channel.identity[index].st_ino) { |
| 1173 | return false; |
| 1174 | } |
| 1175 | int flags = tf_coverage_channel_flags(fd, F_GETFL); |
| 1176 | if (flags < 0 || (flags & O_ACCMODE) != (index == 0 ? O_RDONLY : O_WRONLY)) { |
| 1177 | return false; |
| 1178 | } |
| 1179 | if (!require_flags) { |
| 1180 | return true; |
| 1181 | } |
| 1182 | int descriptor_flags = tf_coverage_channel_flags(fd, F_GETFD); |
| 1183 | return (flags & O_NONBLOCK) != 0 && descriptor_flags >= 0 && |
| 1184 | (descriptor_flags & FD_CLOEXEC) != 0; |
| 1185 | } |
| 1186 | |
| 1187 | static bool tf_coverage_channel_intact(void) { |
| 1188 | return tf_coverage_channel.fd[0] >= 0 && tf_coverage_channel.fd[1] >= 0 && |
no test coverage detected