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