File 2211-code_SUITE-Enhance-test-of-archive-files.patch of Package erlang

From 620676577bb80a41a991b52254b445589330a3da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 29 Apr 2016 06:04:42 +0200
Subject: [PATCH 1/9] code_SUITE: Enhance test of archive files

When using a code archive for an application, it should be possible
to store some directories for the application outside of the archive
file (for example, shared libraries that will not work inside an
archive). Make sure that we test that a directory outside of the
archive file really works.
---
 lib/kernel/test/code_SUITE.erl | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index 7f9718a..383eab9 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -1023,6 +1023,12 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) ->
     {ok, _} = zip:create(Archive, [Base],
 			       [{compress, []}, {cwd, PrivDir}]),
 
+    %% Create a directory and a file outside of the archive.
+    OtherFile = filename:join([RootDir,VsnBase,"other","other.txt"]),
+    OtherContents = ?MODULE:module_info(md5),
+    filelib:ensure_dir(OtherFile),
+    ok = file:write_file(OtherFile, OtherContents),
+
     %% Set up ERL_LIBS and start a slave node.
     {ok, Node} =
 	?t:start_node(code_archive, slave,
@@ -1037,13 +1043,25 @@ do_code_archive(Config, Root, StripVsn) when is_list(Config) ->
     %% Start the app
     ok = rpc:call(Node, application, start, [App]),
 
+    %% Get the lib dir for the app.
+    AppLibDir = rpc:call(Node, code, lib_dir, [App]),
+    io:format("AppLibDir: ~p\n", [AppLibDir]),
+    AppLibDir = filename:join(RootDir, VsnBase),
+
     %% Access the app priv dir
     AppPrivDir = rpc:call(Node, code, priv_dir, [App]),
     AppPrivFile = filename:join([AppPrivDir, "code_archive.txt"]),
     io:format("AppPrivFile: ~p\n", [AppPrivFile]),
-    {ok, _Bin, _Path} =
+    {ok, _Bin, _} =
 	rpc:call(Node, erl_prim_loader, get_file, [AppPrivFile]),
 
+    %% Read back the other text file.
+    OtherDirPath = rpc:call(Node, code, lib_dir, [App,other]),
+    OtherFilePath = filename:join(OtherDirPath, "other.txt"),
+    io:format("OtherFilePath: ~p\n", [OtherFilePath]),
+    {ok, OtherContents, _} =
+	rpc:call(Node, erl_prim_loader, get_file, [OtherFilePath]),
+
     %% Use the app
     Tab = code_archive_tab,
     Key = foo,
-- 
2.1.4

openSUSE Build Service is sponsored by