-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6372f09
commit 1230f1e
Showing
220 changed files
with
111,075 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
examples/benchmarks/concuerror_suites/basic_tests/ac_tab_insert.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-module(ac_tab_insert). | ||
|
||
-compile(export_all). | ||
|
||
scenarios() -> | ||
[ test | ||
]. | ||
|
||
%% This test exercises code for restoring the state of public tables | ||
%% not owned by any process under Concuerror. This code might become | ||
%% useful again if e.g. support for application:start is added back. | ||
|
||
test() -> | ||
[] = ets:lookup(ac_tab, fake), | ||
true = ets:insert(ac_tab, {fake, value}), | ||
[{fake, value}] = ets:lookup(ac_tab, fake), | ||
true = ets:delete(ac_tab, fake), | ||
[] = ets:lookup(ac_tab, fake), | ||
true = ets:insert(ac_tab, {fake, value}), | ||
[{fake, value}] = ets:lookup(ac_tab, fake), | ||
P = self(), | ||
spawn(fun() -> P ! ok end), | ||
receive | ||
ok -> ok | ||
after | ||
0 -> ok | ||
end. |
23 changes: 23 additions & 0 deletions
23
examples/benchmarks/concuerror_suites/basic_tests/after_test_2.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
-module(after_test_2). | ||
|
||
-export([after_test_2/0]). | ||
-export([scenarios/0]). | ||
|
||
scenarios() -> [{?MODULE, inf, dpor}]. | ||
|
||
after_test_2() -> | ||
Parent = self(), | ||
spawn(fun() -> Parent ! one end), | ||
receive | ||
two -> throw(two) | ||
after | ||
0 -> ok | ||
end, | ||
receive | ||
one -> ok | ||
after | ||
0 -> ok | ||
end, | ||
receive | ||
deadlock -> ok | ||
end. |
32 changes: 32 additions & 0 deletions
32
examples/benchmarks/concuerror_suites/basic_tests/after_test_3.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-module(after_test_3). | ||
|
||
-export([after_test_3/0]). | ||
-export([scenarios/0]). | ||
|
||
-concuerror_options_forced([{instant_delivery, false}]). | ||
|
||
scenarios() -> [{?MODULE, inf, dpor}]. | ||
|
||
after_test_3() -> | ||
Parent = self(), | ||
Child = | ||
spawn(fun() -> | ||
receive | ||
Get1 -> | ||
receive | ||
Get2 -> | ||
throw({Get1, Get2}) | ||
end | ||
end | ||
end), | ||
spawn(fun() -> | ||
Child ! a, | ||
Parent ! f | ||
end), | ||
Msg = | ||
receive | ||
f -> b | ||
after | ||
0 -> c | ||
end, | ||
Child ! Msg. |
27 changes: 27 additions & 0 deletions
27
examples/benchmarks/concuerror_suites/basic_tests/after_vs_trap_exit.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
-module(after_vs_trap_exit). | ||
|
||
-export([after_vs_trap_exit/0]). | ||
-export([scenarios/0]). | ||
|
||
scenarios() -> [{?MODULE, inf, dpor}]. | ||
|
||
after_vs_trap_exit() -> | ||
P1 = self(), | ||
_ = spawn_link( | ||
fun() -> | ||
process_flag(trap_exit, true), | ||
P1 ! ok, | ||
receive after infinity -> block end | ||
end), | ||
receive ok -> ok end, | ||
P3 = | ||
spawn( | ||
fun() -> | ||
process_flag(trap_exit, true), | ||
receive | ||
Msg -> throw(Msg) | ||
after | ||
0 -> ok | ||
end | ||
end), | ||
catch link(P3). |
19 changes: 19 additions & 0 deletions
19
examples/benchmarks/concuerror_suites/basic_tests/allow_first_crash.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(allow_first_crash). | ||
|
||
-export([scenarios/0]). | ||
-export([test/0]). | ||
|
||
-concuerror_options_forced([{keep_going, false}]). | ||
|
||
scenarios() -> | ||
[{test, inf, dpor}]. | ||
|
||
test() -> | ||
P = self(), | ||
spawn(fun() -> P ! ok end), | ||
receive | ||
ok -> ok | ||
after | ||
0 -> ok | ||
end, | ||
exit(error). |
33 changes: 33 additions & 0 deletions
33
examples/benchmarks/concuerror_suites/basic_tests/bad_dictionary.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
-module(bad_dictionary). | ||
|
||
-compile(export_all). | ||
|
||
scenarios() -> | ||
[ bad_put | ||
, bad_get | ||
, bad_erase | ||
]. | ||
|
||
bad_put() -> | ||
BadFun = | ||
fun() -> | ||
erlang:put(key, value), | ||
erlang:put(key, value, extra_arg_bad) | ||
end, | ||
spawn_monitor(BadFun). | ||
|
||
bad_get() -> | ||
BadFun = | ||
fun() -> | ||
erlang:get(key), | ||
erlang:get(key, extra_arg_bad) | ||
end, | ||
spawn_monitor(BadFun). | ||
|
||
bad_erase() -> | ||
BadFun = | ||
fun() -> | ||
erlang:erase(key), | ||
erlang:erase(key, value) | ||
end, | ||
spawn_monitor(BadFun). |
10 changes: 10 additions & 0 deletions
10
examples/benchmarks/concuerror_suites/basic_tests/bad_whereis.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
-module(bad_whereis). | ||
|
||
-export([scenarios/0]). | ||
-export([test/0]). | ||
|
||
scenarios() -> | ||
[{test, inf, dpor}]. | ||
|
||
test() -> | ||
whereis(1). |
19 changes: 19 additions & 0 deletions
19
examples/benchmarks/concuerror_suites/basic_tests/code_when_undef.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(code_when_undef). | ||
|
||
-compile(export_all). | ||
|
||
scenarios() -> | ||
[ test | ||
]. | ||
|
||
test() -> | ||
catch ets:non_existing_function(), | ||
code:module_info(), | ||
P = self(), | ||
spawn(fun() -> P ! ok end), | ||
receive | ||
ok -> ok | ||
after | ||
0 -> ok | ||
end, | ||
exit(error). |
17 changes: 17 additions & 0 deletions
17
examples/benchmarks/concuerror_suites/basic_tests/concuerror_crash.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-module(concuerror_crash). | ||
|
||
-export([scenarios/0]). | ||
-export([test/0]). | ||
|
||
scenarios() -> | ||
[{test, inf, dpor, crash}]. | ||
|
||
test() -> | ||
P = self(), | ||
spawn(fun() -> P ! ok end), | ||
receive | ||
ok -> | ||
list_to_pid("<0.42.42>") ! ok | ||
after | ||
0 -> ok | ||
end. |
19 changes: 19 additions & 0 deletions
19
examples/benchmarks/concuerror_suites/basic_tests/fun_fail.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(fun_fail). | ||
|
||
-export([scenarios/0]). | ||
-export([test1/0,test2/0,test3/0]). | ||
|
||
scenarios() -> | ||
[{T, inf, dpor} || T <- [test1,test2,test3]]. | ||
|
||
test1() -> | ||
A = ban, | ||
A(foo). | ||
|
||
test2() -> | ||
A = fun() -> ok end, | ||
A(foo). | ||
|
||
test3() -> | ||
A = 1, | ||
A:foo(blip). |
19 changes: 19 additions & 0 deletions
19
examples/benchmarks/concuerror_suites/basic_tests/group_leader.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-module(group_leader). | ||
|
||
-export([scenarios/0]). | ||
-export([test/0, test1/0]). | ||
|
||
scenarios() -> | ||
[{T, inf, dpor} || T <- [test,test1]]. | ||
|
||
test() -> | ||
C = spawn(fun() -> receive _ -> ok end end), | ||
group_leader(C, self()), | ||
C ! ok. | ||
|
||
test1() -> | ||
{C, _} = spawn_monitor(fun() -> ok end), | ||
receive | ||
_MonitorDown -> ok | ||
end, | ||
group_leader(C, self()). |
34 changes: 34 additions & 0 deletions
34
examples/benchmarks/concuerror_suites/basic_tests/group_leader2.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-module(group_leader2). | ||
|
||
-export([scenarios/0]). | ||
-export([test/0]). | ||
|
||
scenarios() -> | ||
[{test, inf, dpor}]. | ||
|
||
test() -> | ||
UserPid = whereis(user), | ||
UserPid = group_leader(), | ||
group_leader(self(), self()), | ||
true = self() =:= group_leader(), | ||
Fun = | ||
fun() -> | ||
case flip_coin() of | ||
true -> io:format("Block"); | ||
false -> ok | ||
end | ||
end, | ||
Fun(), | ||
spawn(Fun), | ||
group_leader(UserPid, self()), | ||
UserPid = group_leader(), | ||
io:format("All fine"). | ||
|
||
flip_coin() -> | ||
P = self(), | ||
spawn(fun() -> P ! ok end), | ||
receive | ||
ok -> true | ||
after | ||
0 -> receive ok -> false end | ||
end. |
16 changes: 16 additions & 0 deletions
16
examples/benchmarks/concuerror_suites/basic_tests/hopeless_after.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
-module(hopeless_after). | ||
|
||
-export([hopeless_after/0]). | ||
-export([scenarios/0]). | ||
|
||
scenarios() -> [{?MODULE, inf, dpor}]. | ||
|
||
hopeless_after() -> | ||
P = self(), | ||
spawn(fun() -> P ! hopeless end), | ||
receive | ||
hope -> saved | ||
after | ||
100 -> | ||
throw(no_hope) | ||
end. |
14 changes: 14 additions & 0 deletions
14
examples/benchmarks/concuerror_suites/basic_tests/i_hate_myself.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
-module(i_hate_myself). | ||
|
||
-export([i_hate_myself/0]). | ||
-export([scenarios/0]). | ||
|
||
scenarios() -> [{?MODULE, inf, dpor}]. | ||
|
||
i_hate_myself() -> | ||
Name = list_to_atom(lists:flatten(io_lib:format("~p",[make_ref()]))), | ||
spawn(fun() -> Name ! message end), | ||
register(Name, self()), | ||
receive | ||
message -> ok | ||
end. |
49 changes: 49 additions & 0 deletions
49
examples/benchmarks/concuerror_suites/basic_tests/immediate_delivery.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
-module(immediate_delivery). | ||
|
||
-export([test1/0, test2/0, test3/0]). | ||
-export([scenarios/0]). | ||
|
||
-concuerror_options_forced([{instant_delivery, true}]). | ||
|
||
scenarios() -> | ||
[{T, inf, dpor} || | ||
{T,0} <- ?MODULE:module_info(exports), | ||
T =/= scenarios, | ||
T =/= concuerror_options, | ||
T =/= module_info | ||
]. | ||
|
||
test1() -> | ||
P = self(), | ||
C1 = spawn(fun() -> | ||
receive | ||
p -> | ||
receive | ||
c -> ok | ||
end; | ||
c -> error(fault) | ||
end | ||
end), | ||
C1 ! p, | ||
spawn(fun() -> C1 ! c end). | ||
|
||
test2() -> | ||
P = self(), | ||
C1 = spawn(fun() -> | ||
receive | ||
p -> | ||
receive | ||
c -> ok | ||
end; | ||
c -> error(fault) | ||
end | ||
end), | ||
spawn(fun() -> C1 ! c end), | ||
C1 ! p. | ||
|
||
test3() -> | ||
Fun = fun() -> io:format("Foo") end, | ||
Fun(), | ||
spawn(Fun), | ||
Fun(), | ||
spawn(Fun). |
18 changes: 18 additions & 0 deletions
18
examples/benchmarks/concuerror_suites/basic_tests/init_race_condition.erl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
%% A late reply from init could be registered as unblocking the respective child | ||
%% but not be previously instrumented. This bug appears on bigger machines. | ||
|
||
-module(init_race_condition). | ||
|
||
-export([scenarios/0]). | ||
-export([test/0]). | ||
|
||
scenarios() -> [{test, inf, dpor}]. | ||
|
||
get_arguments() -> | ||
init ! {self(), get_arguments}, | ||
receive | ||
{init, Rep} -> Rep | ||
end. | ||
|
||
test() -> | ||
[ spawn(fun() -> get_arguments() end) || _ <- lists:seq(1, 2) ]. |
Oops, something went wrong.