| 945 | } |
| 946 | |
| 947 | static bool tf_only_add_file(const char *path) { |
| 948 | FILE *file = cbm_fopen(path, "r"); |
| 949 | if (!file) { |
| 950 | fprintf(stderr, "cannot read test selection file: %s\n", path); |
| 951 | return false; |
| 952 | } |
| 953 | char line[CBM_SZ_1K]; |
| 954 | bool ok = true; |
| 955 | while (ok && fgets(line, sizeof(line), file)) { |
| 956 | size_t length = strlen(line); |
| 957 | if (length == sizeof(line) - 1 && line[length - 1] != '\n') { |
| 958 | /* The rest of the line would be read back as a token of its own. */ |
| 959 | fprintf(stderr, "test selection file line too long: %s\n", path); |
| 960 | ok = false; |
| 961 | } else { |
| 962 | ok = tf_only_add(line, strcspn(line, "#\n")); |
| 963 | } |
| 964 | } |
| 965 | if (ok && ferror(file)) { |
| 966 | fprintf(stderr, "cannot read test selection file: %s\n", path); |
| 967 | ok = false; |
| 968 | } |
| 969 | (void)fclose(file); |
| 970 | return ok; |
| 971 | } |
| 972 | |
| 973 | static int tf_only_compare(const void *left, const void *right) { |
| 974 | const tf_only_token_t *a = left; |
no test coverage detected