Index: lib/Fuzzer/CMakeLists.txt
===================================================================
--- lib/Fuzzer/CMakeLists.txt
+++ lib/Fuzzer/CMakeLists.txt
@@ -7,3 +7,5 @@
   FuzzerMutate.cpp
   FuzzerUtil.cpp
   )
+
+add_subdirectory(test)
Index: lib/Fuzzer/FuzzerLoop.cpp
===================================================================
--- lib/Fuzzer/FuzzerLoop.cpp
+++ lib/Fuzzer/FuzzerLoop.cpp
@@ -41,12 +41,12 @@
       duration_cast<seconds>(system_clock::now() - UnitStartTime).count();
   std::cerr << "ALARM: working on the last Unit for " << Seconds << " seconds"
             << std::endl;
-  if (Seconds > 60) {
+  if (Seconds >= 3) {
     Print(CurrentUnit, "\n");
     PrintASCII(CurrentUnit, "\n");
     WriteToCrash(CurrentUnit, "timeout-");
   }
-  abort();
+  exit(1);
 }
 
 void Fuzzer::ShuffleAndMinimize() {
Index: lib/Fuzzer/test/CMakeLists.txt
===================================================================
--- /dev/null
+++ lib/Fuzzer/test/CMakeLists.txt
@@ -0,0 +1,37 @@
+set(Tests
+  ExactTest
+  InfiniteTest
+  NullDerefTest
+  SimpleTest
+  TimeoutTest
+  )
+
+set(TestBinaries)
+
+foreach(Test ${Tests})
+  add_executable(LLVMFuzzer-${Test}
+    EXCLUDE_FROM_ALL
+    ${Test}.cpp
+    )
+  target_link_libraries(LLVMFuzzer-${Test}
+    LLVMFuzzer
+    )
+  set(TestBinaries ${TestBinaries} LLVMFuzzer-${Test})
+endforeach()
+
+set_target_properties(${TestBinaries}
+  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+  )
+
+set(EXCLUDE_FROM_ALL TRUE)
+add_lit_testsuite(check-fuzzer "Running Fuzzer tests"
+    ${CMAKE_CURRENT_BINARY_DIR}
+    DEPENDS ${TestBinaries}
+    )
+set(EXCLUDE_FROM_ALL FALSE)
+
+configure_lit_site_cfg(
+  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+  )
+
Index: lib/Fuzzer/test/fuzzer.test
===================================================================
--- /dev/null
+++ lib/Fuzzer/test/fuzzer.test
@@ -0,0 +1,14 @@
+
+RUN: ./LLVMFuzzer-SimpleTest 2>&1 | FileCheck %s --check-prefix=SimpleTest
+SimpleTest: Found the target, exiting
+
+RUN: not ./LLVMFuzzer-InfiniteTest -timeout=2 2>&1 | FileCheck %s --check-prefix=InfiniteTest
+InfiniteTest: ALARM: working on the last Unit for
+InfiniteTest-NOT: CRASHED; file written to timeout
+
+RUN: not ./LLVMFuzzer-TimeoutTest -timeout=5 2>&1 | FileCheck %s --check-prefix=TimeoutTest
+TimeoutTest: ALARM: working on the last Unit for
+TimeoutTest: CRASHED; file written to timeout
+
+RUN: not ./LLVMFuzzer-NullDerefTest 2>&1 | FileCheck %s --check-prefix=NullDerefTest
+NullDerefTest: CRASHED; file written to crash-
Index: lib/Fuzzer/test/lit.cfg
===================================================================
--- /dev/null
+++ lib/Fuzzer/test/lit.cfg
@@ -0,0 +1,8 @@
+# import lit.util
+import lit.formats
+
+config.name = "LLVMFuzzer"
+config.test_format = lit.formats.ShTest(True)
+config.suffixes = ['.test']
+config.test_source_root = os.path.dirname(__file__)
+
Index: lib/Fuzzer/test/lit.site.cfg.in
===================================================================
--- /dev/null
+++ lib/Fuzzer/test/lit.site.cfg.in
@@ -0,0 +1,2 @@
+config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
+lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg")