[compiler-rt] r302212 - [XRay][compiler-rt] Remove dependency on FileCheck from function id utilities tests
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Thu May 4 18:55:14 PDT 2017
Author: dberris
Date: Thu May 4 20:55:13 2017
New Revision: 302212
URL: http://llvm.org/viewvc/llvm-project?rev=302212&view=rev
Log:
[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.
Modified:
compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc
Modified: compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc?rev=302212&r1=302211&r2=302212&view=diff
==============================================================================
--- compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc (original)
+++ compiler-rt/trunk/test/xray/TestCases/Linux/func-id-utils.cc Thu May 4 20:55:13 2017
@@ -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 <algorithm>
+#include <cassert>
#include <cstdio>
-#include <set>
#include <iterator>
+#include <set>
-[[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<void *> must_be_instrumented;
- must_be_instrumented.insert(reinterpret_cast<void*>(&foo));
- must_be_instrumented.insert(reinterpret_cast<void*>(&bar));
- printf("addresses:\n");
+ assert(__xray_max_function_id() != 0 && "we need xray instrumentation!");
+ std::set<void *> must_be_instrumented = {reinterpret_cast<void *>(&foo),
+ reinterpret_cast<void *>(&bar),
+ reinterpret_cast<void *>(&main)};
std::set<void *> 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<void *>(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<void *> 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;
}
More information about the llvm-commits
mailing list