aboutsummaryrefslogtreecommitdiff
path: root/lib/asan/lit_tests/Linux/time_null_regtest.cc
blob: 975bca3d105ac415b19d5a1715bc3e904552bd1a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// RUN: %clangxx_asan -m64 -O0 %s -fsanitize-address-zero-base-shadow -pie -o %t && %t 2>&1 | %symbolize | FileCheck %s

// Zero-base shadow only works on x86_64 and i386.
// REQUIRES: x86_64-supported-target

// A regression test for time(NULL), which caused ASan to crash in the
// zero-based shadow mode on Linux.
// FIXME: this test does not work on Darwin, because the code pages of the
// executable interleave with the zero-based shadow.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
  time_t t = time(NULL);
  fprintf(stderr, "Time: %s\n", ctime(&t));  // NOLINT
  // CHECK: {{Time: .* .* .*}}
  return 0;
}