Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
4ca826a6
Commit
4ca826a6
authored
Oct 07, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add regression test for #1299
parent
697dba79
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
113 additions
and
0 deletions
+113
-0
libcaf_core/test/mixin/requester.cpp
libcaf_core/test/mixin/requester.cpp
+113
-0
No files found.
libcaf_core/test/mixin/requester.cpp
View file @
4ca826a6
...
...
@@ -221,4 +221,117 @@ SCENARIO("request.await enforces a processing order") {
}
}
// The GH-1299 worker processes int32 and string messages but alternates between
// processing either type.
using
log_ptr
=
std
::
shared_ptr
<
std
::
string
>
;
behavior
gh1299_worker_bhvr1
(
caf
::
event_based_actor
*
self
,
log_ptr
log
);
behavior
gh1299_worker_bhvr2
(
caf
::
event_based_actor
*
self
,
log_ptr
log
);
behavior
gh1299_worker
(
caf
::
event_based_actor
*
self
,
log_ptr
log
)
{
self
->
set_default_handler
(
skip
);
return
gh1299_worker_bhvr1
(
self
,
log
);
}
behavior
gh1299_worker_bhvr1
(
caf
::
event_based_actor
*
self
,
log_ptr
log
)
{
return
{
[
self
,
log
](
int32_t
x
)
{
*
log
+=
"int: "
;
*
log
+=
std
::
to_string
(
x
);
*
log
+=
'\n'
;
self
->
become
(
gh1299_worker_bhvr2
(
self
,
log
));
},
};
}
behavior
gh1299_worker_bhvr2
(
caf
::
event_based_actor
*
self
,
log_ptr
log
)
{
return
{
[
self
,
log
](
const
std
::
string
&
x
)
{
*
log
+=
"string: "
;
*
log
+=
x
;
*
log
+=
'\n'
;
self
->
become
(
gh1299_worker_bhvr1
(
self
,
log
));
},
};
}
TEST_CASE
(
"GH-1299 regression non-blocking"
)
{
SUBTEST
(
"HIGH (skip) -> NORMAL"
)
{
auto
log
=
std
::
make_shared
<
std
::
string
>
();
auto
worker
=
sys
.
spawn
(
gh1299_worker
,
log
);
scoped_actor
self
{
sys
};
self
->
send
<
message_priority
::
high
>
(
worker
,
"hi there"
);
run
();
self
->
send
(
worker
,
int32_t
{
123
});
run
();
CHECK_EQ
(
*
log
,
"int: 123
\n
string: hi there
\n
"
);
}
SUBTEST
(
"NORMAL (skip) -> HIGH"
)
{
auto
log
=
std
::
make_shared
<
std
::
string
>
();
auto
worker
=
sys
.
spawn
(
gh1299_worker
,
log
);
scoped_actor
self
{
sys
};
self
->
send
(
worker
,
"hi there"
);
run
();
self
->
send
<
message_priority
::
high
>
(
worker
,
int32_t
{
123
});
run
();
CHECK_EQ
(
*
log
,
"int: 123
\n
string: hi there
\n
"
);
}
}
void
gh1299_recv
(
scoped_actor
&
self
,
log_ptr
log
,
int
&
tag
)
{
bool
fin
=
false
;
for
(;;)
{
if
(
tag
==
0
)
{
self
->
receive
(
[
log
,
&
tag
](
int32_t
x
)
{
*
log
+=
"int: "
;
*
log
+=
std
::
to_string
(
x
);
*
log
+=
'\n'
;
tag
=
1
;
},
after
(
timespan
{
0
})
>>
[
&
fin
]
{
fin
=
true
;
});
if
(
fin
)
return
;
}
else
{
self
->
receive
(
[
log
,
&
tag
](
const
std
::
string
&
x
)
{
*
log
+=
"string: "
;
*
log
+=
x
;
*
log
+=
'\n'
;
tag
=
0
;
},
after
(
timespan
{
0
})
>>
[
&
fin
]
{
fin
=
true
;
});
if
(
fin
)
return
;
}
}
}
TEST_CASE
(
"GH-1299 regression blocking"
)
{
SUBTEST
(
"HIGH (skip) -> NORMAL"
)
{
auto
log
=
std
::
make_shared
<
std
::
string
>
();
auto
tag
=
0
;
scoped_actor
sender
{
sys
};
scoped_actor
self
{
sys
};
sender
->
send
<
message_priority
::
high
>
(
self
,
"hi there"
);
gh1299_recv
(
self
,
log
,
tag
);
sender
->
send
(
self
,
int32_t
{
123
});
gh1299_recv
(
self
,
log
,
tag
);
CHECK_EQ
(
*
log
,
"int: 123
\n
string: hi there
\n
"
);
}
SUBTEST
(
"NORMAL (skip) -> HIGH"
)
{
auto
log
=
std
::
make_shared
<
std
::
string
>
();
auto
tag
=
0
;
scoped_actor
sender
{
sys
};
scoped_actor
self
{
sys
};
sender
->
send
(
self
,
"hi there"
);
gh1299_recv
(
self
,
log
,
tag
);
sender
->
send
<
message_priority
::
high
>
(
self
,
int32_t
{
123
});
gh1299_recv
(
self
,
log
,
tag
);
CHECK_EQ
(
*
log
,
"int: 123
\n
string: hi there
\n
"
);
}
}
END_FIXTURE_SCOPE
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment