False negative tests for std::timed_mutex

Reviewed By: akotulski

Differential Revision: D5154569

fbshipit-source-id: c142261
master
Mehdi Bouaziz 8 years ago committed by Facebook Github Bot
parent c6e2046848
commit c9803a6481

@ -27,6 +27,8 @@ codetoanalyze/cpp/errors/mutex/std_mutex_lock_profiling.cpp, bad_usage1, 3, PREC
codetoanalyze/cpp/errors/mutex/std_mutex_lock_profiling.cpp, bad_usage2, 3, PRECONDITION_NOT_MET, [start of procedure bad_usage2(),Skipped call: function or method not found] codetoanalyze/cpp/errors/mutex/std_mutex_lock_profiling.cpp, bad_usage2, 3, PRECONDITION_NOT_MET, [start of procedure bad_usage2(),Skipped call: function or method not found]
codetoanalyze/cpp/errors/mutex/std_mutex_lock_profiling.cpp, lp_lock<std::mutex>, 7, DOUBLE_LOCK, [start of procedure lp_lock<std::mutex>(),start of procedure detail::try_lock_impl(),Condition is false,return from a call to detail::try_lock_impl,Condition is false,Condition is true,start of procedure detail::lock_impl(),return from a call to detail::lock_impl] codetoanalyze/cpp/errors/mutex/std_mutex_lock_profiling.cpp, lp_lock<std::mutex>, 7, DOUBLE_LOCK, [start of procedure lp_lock<std::mutex>(),start of procedure detail::try_lock_impl(),Condition is false,return from a call to detail::try_lock_impl,Condition is false,Condition is true,start of procedure detail::lock_impl(),return from a call to detail::lock_impl]
codetoanalyze/cpp/errors/mutex/timed_mutex.cpp, alarm1, 2, DOUBLE_LOCK, [start of procedure alarm1()] codetoanalyze/cpp/errors/mutex/timed_mutex.cpp, alarm1, 2, DOUBLE_LOCK, [start of procedure alarm1()]
codetoanalyze/cpp/errors/mutex/timed_mutex.cpp, try_lock_bad, 2, DOUBLE_LOCK, [start of procedure try_lock_bad()]
codetoanalyze/cpp/errors/mutex/timed_mutex.cpp, try_lock_bad, 2, DOUBLE_LOCK, [start of procedure try_lock_bad()]
codetoanalyze/cpp/errors/npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_field_deref, 2, NULL_DEREFERENCE, [start of procedure boxed_ptr::smart_ptr_null_field_deref(),start of procedure SmartPtr,return from a call to boxed_ptr::SmartPtr_SmartPtr,start of procedure get,return from a call to boxed_ptr::SmartPtr_get] codetoanalyze/cpp/errors/npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_field_deref, 2, NULL_DEREFERENCE, [start of procedure boxed_ptr::smart_ptr_null_field_deref(),start of procedure SmartPtr,return from a call to boxed_ptr::SmartPtr_SmartPtr,start of procedure get,return from a call to boxed_ptr::SmartPtr_get]
codetoanalyze/cpp/errors/npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_method_deref, 2, NULL_DEREFERENCE, [start of procedure boxed_ptr::smart_ptr_null_method_deref(),start of procedure SmartPtr,return from a call to boxed_ptr::SmartPtr_SmartPtr,start of procedure get,return from a call to boxed_ptr::SmartPtr_get] codetoanalyze/cpp/errors/npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_method_deref, 2, NULL_DEREFERENCE, [start of procedure boxed_ptr::smart_ptr_null_method_deref(),start of procedure SmartPtr,return from a call to boxed_ptr::SmartPtr_SmartPtr,start of procedure get,return from a call to boxed_ptr::SmartPtr_get]
codetoanalyze/cpp/errors/npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_method_deref2, 2, NULL_DEREFERENCE, [start of procedure boxed_ptr::smart_ptr_null_method_deref2(),start of procedure SmartPtr,return from a call to boxed_ptr::SmartPtr_SmartPtr,start of procedure get,return from a call to boxed_ptr::SmartPtr_get] codetoanalyze/cpp/errors/npe/boxed_ptr.cpp, boxed_ptr::smart_ptr_null_method_deref2, 2, NULL_DEREFERENCE, [start of procedure boxed_ptr::smart_ptr_null_method_deref2(),start of procedure SmartPtr,return from a call to boxed_ptr::SmartPtr_SmartPtr,start of procedure get,return from a call to boxed_ptr::SmartPtr_get]

@ -6,9 +6,26 @@
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#include <chrono>
#include <mutex> #include <mutex>
void alarm1(std::timed_mutex& m) { void alarm1(std::timed_mutex& m) {
m.lock(); m.lock();
m.lock(); m.lock();
} }
void try_lock_bad(std::timed_mutex& m) {
m.try_lock();
m.lock();
}
void try_lock_for_bad_FN(std::timed_mutex& m) {
m.try_lock_for(std::chrono::seconds(123));
m.lock();
}
void try_lock_until_bad_FN(std::timed_mutex& m) {
std::chrono::time_point<std::chrono::steady_clock> timeout;
m.try_lock_until(timeout);
m.lock();
}

Loading…
Cancel
Save