test_helpers.c 600 B

1234567891011121314151617181920212223242526
  1. /* Copyright (c) 2014, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file test_helpers.c
  5. * \brief Some helper functions to avoid code duplication in unit tests.
  6. */
  7. #include "orconfig.h"
  8. #include "or.h"
  9. #include "test_helpers.h"
  10. /* Return a statically allocated string representing yesterday's date
  11. * in ISO format. We use it so that state file items are not found to
  12. * be outdated. */
  13. const char *
  14. get_yesterday_date_str(void)
  15. {
  16. static char buf[ISO_TIME_LEN+1];
  17. time_t yesterday = time(NULL) - 24*60*60;
  18. format_iso_time(buf, yesterday);
  19. return buf;
  20. }