CtrlK
BlogDocsLog inGet started
Tessl Logo

testland/libfaketime-c

Wraps libfaketime (github.com/wolfcw/libfaketime), the LD_PRELOAD library that fakes the clock for any binary by intercepting time() / gettimeofday() / clock_gettime(). Covers absolute-date mode (FAKETIME='2026-12-31 23:59:00'), relative offset (FAKETIME='-1d'), advance-rate (FAKETIME='@2026-12-31 23:59:00 x5' for 5x speed), per-process scope via LD_PRELOAD, and FAKETIME_NO_CACHE for high-resolution mocking. Use when you need to fake time, mock the clock, or freeze time for C/C++ or any native binary that needs deterministic wall-clock time.

76

Quality

96%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide

SecuritybySnyk

Medium

Suggest reviewing before use

Overview
Quality
Evals
Security
Files

faketime-modes-and-recipes.mdreferences/

libfaketime modes and recipes

Deeper variants beyond the core absolute-date mode. All flags and syntax per github.com/wolfcw/libfaketime.

Relative offset

Move the clock a fixed delta from real time instead of pinning an absolute instant:

faketime '-1d' your_command         # 1 day in the past
faketime '+1y' your_command         # 1 year in the future
faketime '+2h30m' your_command      # 2h30m ahead

Advance-rate (time speed-up / slow-down)

The -f flag plus an @start xRATE spec starts at a fixed instant and advances faster (or slower) than real time:

faketime -f '@2026-12-31 23:59:00 x10' your_command
# Starts at 23:59:00 on 2026-12-31, advances 10x real-time

Useful for testing schedulers, cron simulations, and long-running clock progress.

High-resolution mode

FAKETIME_NO_CACHE=1 faketime '2026-12-31 23:59:00' your_command

Disables the per-second caching libfaketime does for performance. Tests that read time hundreds of times per second then see consistent behaviour.

Recipes

Spring-forward (non-existent local time)

faketime '2026-03-08 02:30:00 EDT' ./my-program
# Tests behaviour at a non-existent local time (spring-forward) per
# dst-transition-reference

Cron-job time-skip

# Simulate a year in ~10 minutes (1 sec real = 1.46 hrs simulated)
faketime -f '@2026-01-01 00:00:00 x5256' ./cron-runner

Combined with a timezone

TZ='America/New_York' faketime '2026-03-08 02:30:00' ./my-program

SKILL.md

tile.json