Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:23
erlang
1142-erts-Save-otp_src-directory-if-z_SUITE-cor...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 1142-erts-Save-otp_src-directory-if-z_SUITE-core_files-fa.patch of Package erlang
From 776562e13e47c8fd165b5f7f0179d7a5a57f97c9 Mon Sep 17 00:00:00 2001 From: Sverker Eriksson <sverker@erlang.org> Date: Thu, 15 Dec 2022 16:50:10 +0100 Subject: [PATCH 1/2] erts: Save otp_src directory if z_SUITE:core_files fails Decrease risk of losing otp source and beam executable for interesting core dumps. --- erts/test/z_SUITE.erl | 58 ++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 4 deletions(-) diff --git a/erts/test/z_SUITE.erl b/erts/test/z_SUITE.erl index 18a42f7c28..5a4f228aa4 100644 --- a/erts/test/z_SUITE.erl +++ b/erts/test/z_SUITE.erl @@ -26,7 +26,8 @@ -include_lib("kernel/include/file.hrl"). --record(core_search_conf, {search_dir, +-record(core_search_conf, {db_top_dir, + search_dir, extra_search_dir, cerl, file, @@ -113,7 +114,8 @@ core_search_conf(RunByTS, DBTop, XDir) -> _ -> XDir end end, - #core_search_conf{search_dir = SearchDir, + #core_search_conf{db_top_dir = DBTop, + search_dir = SearchDir, extra_search_dir = XSearchDir, cerl = find_cerl(DBTop), file = os:find_executable("file"), @@ -326,11 +328,59 @@ core_file_search(#core_search_conf{search_dir = Base, case {RunByTS, ICores, FCores} of {true, [], []} -> ok; {true, _, []} -> {comment, Res}; - {true, _, _} -> ct:fail(Res); - _ -> Res + {true, _, _} -> + docker_export_otp_src(Conf), + ct:fail(Res); + _ -> + Res end end. +docker_export_otp_src(#core_search_conf{db_top_dir = DbTop}) -> + %% If this is a docker run, export the otp_src directory + %% to not get lost when the docker image is purged. + try + case {is_dir(DbTop), is_dir("/daily_build/otp_src/erts")} of + {true, true} -> + %% Stolen from get_otp_src script. + %% Basically it's a recursive copy of otp_src dir + %% with preserved permissions, etc. + run("cd /daily_build && " + "tar -cf - otp_src | (cd "++DbTop++" && tar -xpf -)"), + OtpSrc = DbTop ++ "/otp_src", + run("cd " ++ OtpSrc ++ "/erts && " + "ERL_TOP=" ++ OtpSrc ++ " make local_setup"), + io:format("otp_src directory exported from docker image"); + _ -> + ok + end + catch + C:E:S -> + io:format("Failed to export otp_src directory:" + "Exception: ~p\nReason: ~p\nStack: ~p\n", + [C, E, S]) + end. + +run(Cmd) -> + Options = [binary, exit_status,stderr_to_stdout,{line,4096}], + Port = open_port({spawn,"sh -c \"" ++ Cmd ++ "\""}, Options), + run_loop(Cmd, Port, []). + +run_loop(Cmd, Port, Output) -> + receive + {Port, {exit_status,0}} -> + lists:reverse(Output); + {Port, {exit_status,Status}} -> + io:format("Failed command (~p): ~p\nOutput: ~p\n", [Status, Cmd, Output]), + error(bailout); + {Port, {data,{eol,Bin}}} -> + run_loop(Cmd, Port, [Bin|Output]); + Msg -> + io:format("Unexpected message: ~p\nCommand was: ~p\n", [Msg, Cmd]), + error(bailout) + end. + + win32_search(RunByTS, DBTop) -> case os:getenv("WSLENV") of false when RunByTS -> -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor