about summary refs log tree commit diff
path: root/time/bug-mktime4.c
blob: dd1e0c76bfe743f40e376e1196db7230c1c15854 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <time.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>

static int
do_test (void)
{
  struct tm tm = { .tm_year = INT_MIN, .tm_mon = INT_MIN, .tm_mday = INT_MIN,
		    .tm_hour = INT_MIN, .tm_min = INT_MIN, .tm_sec = INT_MIN };
  errno = 0;
  time_t tt = mktime (&tm);
  if (tt != -1)
    {
      printf ("mktime() should have returned -1, returned %ld\n", (long int) tt);
      return 1;
    }
  if (errno != EOVERFLOW)
    {
      printf ("mktime() returned -1, errno should be %d (EOVERFLOW) but is %d (%s)\n", EOVERFLOW, errno, strerror(errno));
      return 1;
    }
  return 0;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"