| Line |
Branch |
Exec |
Source |
| 1 |
|
|
#include <curl/curl.h> |
| 2 |
|
|
#include "api/api.h" |
| 3 |
|
|
#include "api/internal.h" |
| 4 |
|
|
|
| 5 |
|
2 |
extern int heartbeat() { |
| 6 |
1/1
✓ Branch 1 taken 2 times.
|
2 |
CURL* curl = api_curl_handle_new(); |
| 7 |
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
2 |
if (!curl) |
| 8 |
|
2 |
return -1; |
| 9 |
|
|
|
| 10 |
|
|
char url[1024]; |
| 11 |
2/3
✓ Branch 1 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2 times.
|
2 |
if (api_build_url(url, sizeof(url), "/") != 0) { |
| 12 |
|
✗ |
curl_easy_cleanup(curl); |
| 13 |
|
✗ |
return -1; |
| 14 |
|
|
} |
| 15 |
|
|
|
| 16 |
1/1
✓ Branch 1 taken 2 times.
|
2 |
curl_easy_setopt(curl, CURLOPT_URL, url); |
| 17 |
1/1
✓ Branch 1 taken 2 times.
|
2 |
curl_easy_setopt(curl, CURLOPT_NOBODY, 5L); // short timeout for heartbeat |
| 18 |
|
|
|
| 19 |
1/1
✓ Branch 1 taken 2 times.
|
2 |
CURLcode result = curl_easy_perform(curl); |
| 20 |
1/1
✓ Branch 1 taken 2 times.
|
2 |
api_result_e check = api_check_response(curl, result); |
| 21 |
|
|
|
| 22 |
1/1
✓ Branch 1 taken 2 times.
|
2 |
curl_easy_cleanup(curl); |
| 23 |
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
|
2 |
return (check == API_OK) ? 0 : -1; |
| 24 |
|
|
} |
| 25 |
|
|
|