summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-05-23 16:54:14 +0200
committerLoïc Hoguin <[email protected]>2018-05-23 16:54:14 +0200
commit6cf0748b5ac7bd32f8d338224b843e419b1ea7c0 (patch)
tree30db4de4b50d437242b7c0115dac017dc886c3e3
parent0ef2e3a314a679ccf9f7bab9dd6f934b63f53d0f (diff)
downloadct_helper-6cf0748b5ac7bd32f8d338224b843e419b1ea7c0.tar.gz
ct_helper-6cf0748b5ac7bd32f8d338224b843e419b1ea7c0.tar.bz2
ct_helper-6cf0748b5ac7bd32f8d338224b843e419b1ea7c0.zip
On native releases, make name() return the current pid
Because current_stacktrace is not always accurate and I have not figured out how to make it accurate yet.
-rw-r--r--src/ct_helper.erl12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/ct_helper.erl b/src/ct_helper.erl
index 22a6be6..e1b4ab3 100644
--- a/src/ct_helper.erl
+++ b/src/ct_helper.erl
@@ -159,9 +159,19 @@ make_certs_in_ets() ->
ok.
%% @doc Return the name of the calling function.
+%%
+%% With a native VM we always return the current pid because
+%% the stacktrace is not as well maintained and may not return
+%% the correct function name, especially when there is a mix
+%% of normal and native code.
name() ->
- element(2, hd(tl(element(2, process_info(self(), current_stacktrace))))).
+ case code:is_module_native(kernel) of
+ true ->
+ self();
+ false ->
+ element(2, hd(tl(element(2, process_info(self(), current_stacktrace)))))
+ end.
%% @doc Start and stop applications and their dependencies.