Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions test/checkers/trace_checker.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,20 +172,16 @@ static void
_check_wildcard(coldtrace_entry_type type,
struct next_expected_entry_iterator *iter, uint64_t tid, int i)
{
struct expected_entry *next = (iter->e) + 1;
// see the next if required
if (next->set && next->atleast > 0 && type == next->type) {
// skip wildcard
struct expected_entry *wild = (iter->e);
// if current matches the wildcard
if (type == wild->type) {
next_entry_and_reset(iter);
_check_next(type, iter, tid, i);
return;
}

/// just match it
log_info("thread=%lu entry=%d wildcard match=%s", tid, i,
coldtrace_entry_type_str((iter->e)->type));
ensure((iter->e)->atleast == (iter->e)->atmost);
ensure((iter->e)->atleast == 1);
next_entry_and_reset(iter);
coldtrace_entry_type_str(wild->type));
}

static void
Expand All @@ -211,8 +207,8 @@ coldtrace_writer_close(void *page, const size_t size, uint64_t tid)
static caslock_t loop_lock = CASLOCK_INIT();

log_info("checking thread=%lu", tid);
struct entry_it it = iter_init(page, size);
struct expected_entry *next = _expected[tid];
struct entry_it it = iter_init(page, size);
struct expected_entry *next = _expected[tid];
struct next_expected_entry_iterator expected_it = {0};

if (next != NULL)
Expand Down
66 changes: 66 additions & 0 deletions test/trace_cxa_guard.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include <sys/time.h>
#include <thread>
#include <trace_checker.h>
#include <unistd.h>

#define NUM_THREADS 2

struct expected_entry expected_1[] = {
EXPECT_SUFFIX(COLDTRACE_THREAD_CREATE),
EXPECT_SUFFIX(COLDTRACE_THREAD_CREATE),
EXPECT_SUFFIX(COLDTRACE_THREAD_JOIN),
EXPECT_SUFFIX(COLDTRACE_THREAD_JOIN),
EXPECT_SUFFIX(COLDTRACE_THREAD_EXIT),
EXPECT_END,
};

struct expected_entry expected_2[] = {
EXPECT_ENTRY(COLDTRACE_THREAD_START),
EXPECT_ENTRY(COLDTRACE_ATOMIC_READ),
EXPECT_SOME(COLDTRACE_READ, 0, 1),
EXPECT_ENTRY(COLDTRACE_CXA_GUARD_ACQUIRE),
EXPECT_SUFFIX(COLDTRACE_CXA_GUARD_RELEASE),
EXPECT_ENTRY(COLDTRACE_READ),
EXPECT_ENTRY(COLDTRACE_FREE),
EXPECT_ENTRY(COLDTRACE_THREAD_EXIT),
EXPECT_END,
};

struct expected_entry expected_3[] = {
EXPECT_ENTRY(COLDTRACE_THREAD_START),
EXPECT_ENTRY(COLDTRACE_ATOMIC_READ),
EXPECT_SOME(COLDTRACE_CXA_GUARD_ACQUIRE, 0, 1),
EXPECT_SUFFIX(COLDTRACE_THREAD_EXIT),
EXPECT_END,
};

uint64_t
check()
{
static const uint64_t some_int = getpid();
return some_int;
}

void *
fun()
{
check();
return nullptr;
}

int
main()
{
register_expected_trace(1, expected_1);
register_expected_trace(2, expected_2);
register_expected_trace(3, expected_3);
std::thread threads[NUM_THREADS];
for (int i = 0; i < NUM_THREADS; i++) {
threads[i] = std::thread([&]() { fun(); });
}

for (int i = 0; i < NUM_THREADS; i++) {
threads[i].join();
}
return 0;
}
2 changes: 1 addition & 1 deletion test/trace_write_var.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct expected_entry expected[] = {
EXPECT_SOME(COLDTRACE_FREE, 0, 1),
EXPECT_SUFFIX(COLDTRACE_WRITE),
EXPECT_SOME(COLDTRACE_READ, 0, 1),
EXPECT_ENTRY(COLDTRACE_THREAD_EXIT),
EXPECT_SUFFIX(COLDTRACE_THREAD_EXIT),

EXPECT_END,
};
Expand Down