| 59 | } |
| 60 | |
| 61 | static char *agent_fixture(const char *initial, char **dir_out) { |
| 62 | char *dir = th_mktempdir("cbm_agent_clients"); |
| 63 | if (!dir) { |
| 64 | return NULL; |
| 65 | } |
| 66 | size_t length = strlen(dir) + strlen("/config.json") + 1U; |
| 67 | char *path = (char *)malloc(length); |
| 68 | if (!path) { |
| 69 | th_cleanup(dir); |
| 70 | return NULL; |
| 71 | } |
| 72 | snprintf(path, length, "%s/config.json", dir); |
| 73 | if (initial && th_write_file(path, initial) != 0) { |
| 74 | free(path); |
| 75 | th_cleanup(dir); |
| 76 | return NULL; |
| 77 | } |
| 78 | *dir_out = dir; |
| 79 | return path; |
| 80 | } |
| 81 | |
| 82 | static char *agent_read(const char *path) { |
| 83 | FILE *fp = fopen(path, "rb"); |
no test coverage detected