From: Dean Michael Berris Date: Fri, 5 May 2017 01:55:13 +0000 (+0000) Subject: [XRay][compiler-rt] Remove dependency on FileCheck from function id utilities tests X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6016158215ba9197e6dcd40ac4ef7386597a8540;p=platform%2Fupstream%2Fllvm.git [XRay][compiler-rt] Remove dependency on FileCheck from function id utilities tests Follow-up on D32846 to simplify testing and not rely on FileCheck to test boundary conditions, and instead do all the testing in code instead. llvm-svn: 302212 --- diff --git a/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc b/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc index 834e7b4..1183d01 100644 --- a/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc +++ b/compiler-rt/test/xray/TestCases/Linux/func-id-utils.cc @@ -2,45 +2,41 @@ // maximum function id for the current binary. // // RUN: %clangxx_xray -std=c++11 %s -o %t -// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false" %run %t | FileCheck %s +// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false" %run %t #include "xray/xray_interface.h" #include +#include #include -#include #include +#include -[[clang::xray_always_instrument]] void bar(){ - // do nothing! -} +[[clang::xray_always_instrument]] void bar(){} - [[clang::xray_always_instrument]] void foo() { +[[clang::xray_always_instrument]] void foo() { bar(); } [[clang::xray_always_instrument]] int main(int argc, char *argv[]) { - printf("max function id: %zu\n", __xray_max_function_id()); - // CHECK: max function id: [[MAX:.*]] - - std::set must_be_instrumented; - must_be_instrumented.insert(reinterpret_cast(&foo)); - must_be_instrumented.insert(reinterpret_cast(&bar)); - printf("addresses:\n"); + assert(__xray_max_function_id() != 0 && "we need xray instrumentation!"); + std::set must_be_instrumented = {reinterpret_cast(&foo), + reinterpret_cast(&bar), + reinterpret_cast(&main)}; std::set all_instrumented; for (auto i = __xray_max_function_id(); i != 0; --i) { auto addr = __xray_function_address(i); - printf("#%lu -> @%04lx\n", i, addr); all_instrumented.insert(reinterpret_cast(addr)); } + assert(all_instrumented.size() == __xray_max_function_id() && + "each function id must be assigned to a unique function"); - // CHECK-LABEL: addresses: - // CHECK: #[[MAX]] -> @[[ADDR:.*]] - // CHECK-NOT: #0 -> @{{.*}} std::set common; - std::set_intersection(all_instrumented.begin(), all_instrumented.end(), must_be_instrumented.begin(), must_be_instrumented.end(), std::inserter(common, common.begin())); + assert( + common == must_be_instrumented && + "we should see all explicitly instrumented functions with function ids"); return common == must_be_instrumented ? 0 : 1; }