Skip to content

Commit

Permalink
PR feedback. Add parameter comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihasgupta committed Sep 20, 2023
1 parent cae897a commit dc3c3c7
Showing 1 changed file with 26 additions and 22 deletions.
48 changes: 26 additions & 22 deletions clients/drcachesim/tests/invariant_checker_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@ check_sane_control_flow()
// Kernel-mediated.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 1),
gen_instr(TID, /*pc=*/1, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 2),
gen_instr(TID, 101),
gen_instr(TID, /*pc=*/101, /*size=*/1),
};
if (!run_checker(memrefs, false))
return false;
Expand All @@ -360,7 +360,7 @@ check_sane_control_flow()
// marker.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 1),
gen_instr(TID, /*pc=*/1, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 3),
};
if (!run_checker(
Expand All @@ -373,13 +373,15 @@ check_sane_control_flow()
return false;
}
}
// Correct test: Transition from instr to kernel_xfer event marker. goes to the next
// Correct test: Transition from instr to kernel_xfer event marker, goes to the next
// instruction.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 1), gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 2),
gen_instr(TID, 101), gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 102),
gen_instr(TID, 2),
gen_instr(TID, /*pc=*/1, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 2),
gen_instr(TID, /*pc=*/101, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 102),
gen_instr(TID, /*pc=*/2, /*size=*/1),
};
if (!run_checker(memrefs, false)) {
return false;
Expand All @@ -398,9 +400,11 @@ check_sane_control_flow()
// Correct test: Pre-signal instr continues after signal.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 2), gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 2),
gen_instr(TID, 101), gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 102),
gen_instr(TID, 2),
gen_instr(TID, /*pc=*/2, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 2),
gen_instr(TID, /*pc=*/101, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 102),
gen_instr(TID, /*pc=*/2, /*size=*/1),
};
if (!run_checker(memrefs, false)) {
return false;
Expand All @@ -410,12 +414,12 @@ check_sane_control_flow()
// of type TRACE_TYPE_INSTR_SYSENTER.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 5),
gen_instr_type(TRACE_TYPE_INSTR_SYSENTER, TID, 6),
gen_instr(TID, /*pc=*/5, /*size=*/1),
gen_instr_type(TRACE_TYPE_INSTR_SYSENTER, TID, /*pc=*/6, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_TIMESTAMP, 2),
gen_marker(TID, TRACE_MARKER_TYPE_CPU_ID, 3),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 2),
gen_instr(TID, 101),
gen_instr(TID, /*pc=*/101, /*size=*/1),
};
if (!run_checker(memrefs, false)) {
return false;
Expand All @@ -424,7 +428,7 @@ check_sane_control_flow()
// Correct test: RSEQ abort in last signal context.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 1),
gen_instr(TID, /*pc=*/1, /*size=*/1),
// The RSEQ_ABORT marker is always follwed by a KERNEL_EVENT marker.
gen_marker(TID, TRACE_MARKER_TYPE_RSEQ_ABORT, 40),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 40),
Expand All @@ -439,7 +443,7 @@ check_sane_control_flow()
// have an encoding with it.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 1),
gen_instr(TID, /*pc=*/1, /*size=*/1),
gen_branch(TID, 2),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 50),
};
Expand All @@ -450,17 +454,17 @@ check_sane_control_flow()
// Correct test: back-to-back signals without any intervening instruction.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 101),
gen_instr(TID, /*pc=*/101, /*size=*/1),
// First signal.
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 102),
gen_instr(TID, 201),
gen_instr(TID, /*pc=*/201, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 202),
// Second signal.
// The Marker value for this signal needs to be 102.
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 102),
gen_instr(TID, 201),
gen_instr(TID, /*pc=*/201, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 202),
gen_instr(TID, 102),
gen_instr(TID, /*pc=*/102, /*size=*/1),
};
if (!run_checker(memrefs, false)) {
return false;
Expand All @@ -469,16 +473,16 @@ check_sane_control_flow()
// Incorrect test: back-to-back signals without any intervening instruction.
{
std::vector<memref_t> memrefs = {
gen_instr(TID, 101),
gen_instr(TID, /*pc=*/101, /*size=*/1),
// First signal.
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 102),
gen_instr(TID, 201),
gen_instr(TID, /*pc=*/201, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 202),
// Second signal.
// There will be a PC discontinuity here since the marker value is 500, and
// the previous PC is 101.
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_EVENT, 500),
gen_instr(TID, 201),
gen_instr(TID, /*pc=*/201, /*size=*/1),
gen_marker(TID, TRACE_MARKER_TYPE_KERNEL_XFER, 202),
};
if (!run_checker(
Expand Down

0 comments on commit dc3c3c7

Please sign in to comment.