{"id":21107501,"url":"https://github.com/cjhdev/curl_based_test","last_synced_at":"2026-04-24T18:06:40.373Z","repository":{"id":148216391,"uuid":"148157507","full_name":"cjhdev/curl_based_test","owner":"cjhdev","description":"CURL based test app and library","archived":false,"fork":false,"pushed_at":"2018-09-10T14:49:57.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-31T06:43:39.918Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjhdev.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-09-10T13:12:14.000Z","updated_at":"2018-09-10T14:49:59.000Z","dependencies_parsed_at":"2023-05-19T11:00:23.927Z","dependency_job_id":null,"html_url":"https://github.com/cjhdev/curl_based_test","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cjhdev/curl_based_test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fcurl_based_test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fcurl_based_test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fcurl_based_test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fcurl_based_test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjhdev","download_url":"https://codeload.github.com/cjhdev/curl_based_test/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjhdev%2Fcurl_based_test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32234799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-20T00:40:17.078Z","updated_at":"2026-04-24T18:06:40.331Z","avatar_url":"https://github.com/cjhdev.png","language":"C","readme":"curl_based_test\n===============\n\n[![Build Status](https://travis-ci.org/cjhdev/curl_based_test.svg?branch=master)](https://travis-ci.org/cjhdev/curl_based_test)\n\nThis repository contains a library and application implemented \naccording to the test-and-metrics-test requirements.\n\nI've made the following assumptions:\n\n- Library component shall return IP address and return code for the \n  final GET in a sequence of one or more iterations\n- Application will accept no more than 100 headers\n\n## Building and Running the Application\n\nYou will need the following:\n\n- libcurl with headers in the system include path\n- getopt\n- gcc\n- make\n\nThen from project root:\n\n~~~\ncd app/the_app \u0026\u0026 make\n./app/the_app/bin/the_app\n~~~\n\n### Extra Switches\n\nIn addition to the mandatory switches, I've added:\n\n#### `-V`\n\nPrint version string to stdout.\n\n#### `-h`\n\nPrint usage to stdout.\n\n## Building and Running the Tests\n\n~~~\ncd test \u0026\u0026 make build_and_run\n~~~\n\nOr just look at the most recent [TravisCI](https://travis-ci.org/cjhdev/curl_based_test) run.\n\n## Layout\n\nThe layout is intended to decouple a suite of applications from reusable\nlibrary components. \n\n~~~\n$ tree -I vendor\n.\n├── app\n│   └── the_app\n│       ├── bin\n│       ├── bla\n│       ├── build\n│       ├── makefile\n│       └── the_app.c\n├── include\n│   └── http_test.h\n├── LICENSE\n├── readme.md\n├── src\n│   └── http_test.c\n├── test\n│   ├── bin\n│   ├── build\n│   ├── makefile\n│   ├── mock_curl.c\n│   └── tc_http_test.c\n└── VERSION\n~~~\n\nFolders are as follows:\n\n- `include` contains library headers\n- `src` contains library source\n- `app` contains applications, where each application is sorted\n  into a subfolder\n- `test` contains all test code\n- `vendor` contains third party code suitable to copy in as-is\n\nTop level files are as follows:\n\n- readme.md\n- VERSION (of the library)\n    - Apps may have their own version numbers\n- LICENSE\n    - All public code should have clearly stated T\u0026Cs\n- .travis.yaml\n    - Required for TravisCI\n\n## Code Style\n\n- C99 according to the CFLAGS `-c99 -pedantic`\n- Only static or automatic memory allocation (I'm using VLAs)\n- Local functions are declared static\n\n## Test Strategy\n\nThere are a lot of ways to test this project. Since this is a demo, \nmy requirement is minimum effort.\n\nI chose to write some tests against the `http_test()` interface (the library\ncomponent) using the cmocka framework. The idea is to mock out the \nlibcurl interfaces so that I can control which branches in the function\nare executed.\n\nThe tests are implemented [here](test/tc_http_test.c), the mocks are implemented [here](test/mock_curl.c).\nThe tests can be built and run by the [makefile](test/makefile). For a laugh I get TravisCI to build and \nrun the tests on every change made to the master branch.\n\nMy tests assert the following behaviour:\n\n- `http_test()` shall always cleanup libcurl if it was previously initialised\n- `http_test()` shall return an average of test samples if the return value is true\n- `http_test()` shall return false if number of iterations is zero\n- `http_test()` shall return false if libcurl rejects URL\n- `http_test()` shall return false if libcurl rejects the headers (not sure if this ever happens)\n- `http_test()` shall return false if libcurl header list allocation fails\n\nlibcurl is a nuisance to mock with cmocka since it uses many calls\nto common get/set functions AND those functions accept variadic arguments. \n\nMany calls to the same function means that the standard cmocka mocking\nfeature becomes brittle since if I want to check a parameter or return\na value, that value has to be loaded in the order it will be required.\n\nVariadic arguments are tricky since I can't use the cmocka argument queues. \nI also have to unpack the variadic argument in the mock which \nmakes the mocks more complicated.\n\n## License\n\ncurl_based_test has an MIT license\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjhdev%2Fcurl_based_test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjhdev%2Fcurl_based_test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjhdev%2Fcurl_based_test/lists"}