aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2016-08-29 18:38:48 +0200
committerRickard Green <[email protected]>2016-08-29 18:38:48 +0200
commit5006f1e0c45d4e9b888b2c0ca48130049d33074c (patch)
tree0dba1e3ed85e04d22755461bcce40704e0d68b49 /erts/emulator/test
parent928d74ffa09bd56652d9390b02fa51ef51d71d51 (diff)
parent0e04e76df2ea71e2e2e116afef04c497d84b1024 (diff)
downloadotp-5006f1e0c45d4e9b888b2c0ca48130049d33074c.tar.gz
otp-5006f1e0c45d4e9b888b2c0ca48130049d33074c.tar.bz2
otp-5006f1e0c45d4e9b888b2c0ca48130049d33074c.zip
Merge branch 'rickard/ds-purge-module/OTP-13808' into maint
* rickard/ds-purge-module/OTP-13808: Perform check_process_code while process is executing dirty Conflicts: erts/doc/src/erl_nif.xml
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/dirty_nif_SUITE.erl75
1 files changed, 73 insertions, 2 deletions
diff --git a/erts/emulator/test/dirty_nif_SUITE.erl b/erts/emulator/test/dirty_nif_SUITE.erl
index 83b098a704..c2d2e58957 100644
--- a/erts/emulator/test/dirty_nif_SUITE.erl
+++ b/erts/emulator/test/dirty_nif_SUITE.erl
@@ -33,7 +33,8 @@
dirty_nif_exception/1, call_dirty_nif_exception/1,
dirty_scheduler_exit/1, dirty_call_while_terminated/1,
dirty_heap_access/1, dirty_process_info/1,
- dirty_process_register/1, dirty_process_trace/1]).
+ dirty_process_register/1, dirty_process_trace/1,
+ code_purge/1]).
-define(nif_stub,nif_stub_error(?LINE)).
@@ -48,7 +49,8 @@ all() ->
dirty_heap_access,
dirty_process_info,
dirty_process_register,
- dirty_process_trace].
+ dirty_process_trace,
+ code_purge].
init_per_suite(Config) ->
try erlang:system_info(dirty_cpu_schedulers) of
@@ -349,6 +351,75 @@ dirty_process_trace(Config) when is_list(Config) ->
ok
end).
+dirty_code_test_code() ->
+ "
+-module(dirty_code_test).
+
+-export([func/1]).
+
+func(Fun) ->
+ Fun(),
+ blipp:blapp().
+
+".
+
+code_purge(Config) when is_list(Config) ->
+ Path = ?config(data_dir, Config),
+ File = filename:join(Path, "dirty_code_test.erl"),
+ ok = file:write_file(File, dirty_code_test_code()),
+ {ok, dirty_code_test, Bin} = compile:file(File, [binary]),
+ {module, dirty_code_test} = erlang:load_module(dirty_code_test, Bin),
+ Start = erlang:monotonic_time(),
+ {Pid1, Mon1} = spawn_monitor(fun () ->
+ dirty_code_test:func(fun () ->
+ %% Sleep for 6 seconds
+ %% in dirty nif...
+ dirty_sleeper()
+ end)
+ end),
+ {module, dirty_code_test} = erlang:load_module(dirty_code_test, Bin),
+ {Pid2, Mon2} = spawn_monitor(fun () ->
+ dirty_code_test:func(fun () ->
+ %% Sleep for 6 seconds
+ %% in dirty nif...
+ dirty_sleeper()
+ end)
+ end),
+ receive
+ {'DOWN', Mon1, process, Pid1, _} ->
+ ct:fail(premature_death)
+ after 100 ->
+ ok
+ end,
+ true = erlang:purge_module(dirty_code_test),
+ receive
+ {'DOWN', Mon1, process, Pid1, Reason} ->
+ killed = Reason
+ end,
+ receive
+ {'DOWN', Mon2, process, Pid2, _} ->
+ ct:fail(premature_death)
+ after 100 ->
+ ok
+ end,
+ true = erlang:delete_module(dirty_code_test),
+ receive
+ {'DOWN', Mon2, process, Pid2, _} ->
+ ct:fail(premature_death)
+ after 100 ->
+ ok
+ end,
+ true = erlang:purge_module(dirty_code_test),
+ receive
+ {'DOWN', Mon2, process, Pid2, Reason} ->
+ killed = Reason
+ end,
+ End = erlang:monotonic_time(),
+ Time = erlang:convert_time_unit(End-Start, native, milli_seconds),
+ io:format("Time=~p~n", [Time]),
+ true = Time =< 1000,
+ ok.
+
%%
%% Internal...
%%