{"id":20646283,"url":"https://github.com/boon-code/libtimefreeze","last_synced_at":"2026-04-18T08:03:27.220Z","repository":{"id":55460784,"uuid":"519869493","full_name":"boon-code/libtimefreeze","owner":"boon-code","description":"Small LD_PRELOAD shared library that allows to freeze the wall clock to a specific time. The wall clock can be controlled through an environment variable ˋTIMEFREEZEˋ by the running process. This shall simplify writing unit tests that depend on time.","archived":false,"fork":false,"pushed_at":"2022-08-23T07:06:47.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T16:36:15.537Z","etag":null,"topics":["ld-preload","ldpreload","testing","time"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"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/boon-code.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}},"created_at":"2022-07-31T19:31:20.000Z","updated_at":"2023-10-06T09:47:24.000Z","dependencies_parsed_at":"2022-08-15T00:50:22.275Z","dependency_job_id":null,"html_url":"https://github.com/boon-code/libtimefreeze","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/boon-code/libtimefreeze","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boon-code%2Flibtimefreeze","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boon-code%2Flibtimefreeze/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boon-code%2Flibtimefreeze/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boon-code%2Flibtimefreeze/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/boon-code","download_url":"https://codeload.github.com/boon-code/libtimefreeze/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/boon-code%2Flibtimefreeze/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31961350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T00:39:45.007Z","status":"online","status_checked_at":"2026-04-18T02:00:07.018Z","response_time":103,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ld-preload","ldpreload","testing","time"],"created_at":"2024-11-16T16:25:09.646Z","updated_at":"2026-04-18T08:03:27.192Z","avatar_url":"https://github.com/boon-code.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"libtimefreeze\n=============\n\n[![pipeline](https://gitlab.com/zahnputzmonster/libtimefreeze/badges/main/pipeline.svg)](https://gitlab.com/zahnputzmonster/libtimefreeze/-/commits/main)\n\n[![codecov](https://codecov.io/gl/zahnputzmonster/libtimefreeze/branch/main/graph/badge.svg?token=719ZBL64D6)](https://codecov.io/gl/zahnputzmonster/libtimefreeze)\n\n*Obsolete*: Use `libfaketime` instead (please read below)\n\nThis is a small shared library that can be preloaded to allow to set / freeze\nthe real time clock while f.e. executing test cases that depend on the wall\nclock.\nA good example of this use-case is testing certificate handling and time\ndependend signatures. During the test case, the environment variable\n`TIMEFREEZE` may be adjusted as needed or disabled. Certificates can be\nstatically created and the same certificate can be used for failing and passing\ntests by only changing `TIMEFREEZE` accordingly.\n\nI recommend using `libfaketime` as it is a much more complete, widely support\nand prooven in use solution to fake the current time:\n- https://github.com/wolfcw/libfaketime.git\n\nThis library is heavily inspired by the awsome `libfaketime`.\n\nOriginally, it seemed that this use case is not possible with `libfaketime`.\nBy setting the environment variable `FAKETIME_NO_CACHE` to `1`, the use case can\nbe accomplished in a similar way.\n\n\n# Usage\n\nThe shared library has to be preloaded using `LD_PRELOAD`. The following\nenvironment variables can be used to manipulate the behavior:\n- `TIMEFREEZE`: Can be used to specify a UTC timestamp in the format\n  `%Y-%m-%d %T` (`2022-08-03 09:21:07`). If set, this time will be provided\n  (frozen). By deleting the environment variable or setting it to an empty\n  string, the mechanism can be disabled again and the actual wall clock can be\n  retrieved again.\n- `TIMEFREEZE_DEBUG`: set to `1` to enable debug messages to `stderr`. Has to\n  be configured before initialization. The library is initialized on the first\n  invocation of one of the replaced time related functions.\n\nUse the environment variable `LD_PRELOAD` to preload this library when\nexecuting the application (in this case `date`):\n\n        LD_PRELOAD=./.build/libtimefreeze.so.0 TIMEFREEZE=\"2022-01-01 10:01:02\" date\n\nWith debug logs enabled:\n\n        LD_PRELOAD=./.build/libtimefreeze.so.0 TIMEFREEZE_DEBUG=1 TIMEFREEZE=\"2022-01-01 10:01:02\" date\n\nHowever, the main use case for this library is to run test cases with some\ntesting framework (like GoogleTest). Assuming you compile your tests into an\nexecutable called `tests`, you would typically run your tests like this:\n\n        LD_PRELOAD=\u003cpath\u003e/libtimefreeze.so.0 ./tests [gtest options]\n\nThis way, your test cases are not affected at first, as `TIMEFREEZE` is not\nyet set. The `TIMEFREEZE` variable will only be set in the test cases that\nrequire a faked time to succeed.\nA GoogleTest example can be found here: [test\\_time.cpp](examples/gtest_example/src/test_time.cpp)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboon-code%2Flibtimefreeze","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fboon-code%2Flibtimefreeze","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fboon-code%2Flibtimefreeze/lists"}