Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:26
erlang
0384-stdlib-fix-failed-tests-asserting-for-is_u...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0384-stdlib-fix-failed-tests-asserting-for-is_ustar.patch of Package erlang
From 451d2d0612e6cc1c28f4f3e4b0bc2ece128fc55c Mon Sep 17 00:00:00 2001 From: lucioleKi <isabell@erlang.org> Date: Mon, 14 Oct 2024 09:44:36 +0200 Subject: [PATCH] stdlib: fix failed tests asserting for is_ustar When user's id has a length > 7 in octal, tars created in tar_SUITE always have typeflag 'x'. They are not plain USTAR archives. Asserting true for `is_ustar`` in those cases will fail. This fix adds the uid info to config, and skip assertions for `is_ustar` when uid is long. --- lib/stdlib/src/erl_tar.erl | 2 +- lib/stdlib/test/tar_SUITE.erl | 45 +++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 13 deletions(-) diff --git a/lib/stdlib/doc/src/erl_tar.xml b/lib/stdlib/doc/src/erl_tar.xml index 90302906a2..e05d1176f7 100644 --- a/lib/stdlib/doc/src/erl_tar.xml +++ b/lib/stdlib/doc/src/erl_tar.xml @@ -119,7 +119,7 @@ apply them manually.</p> </item> <item> - <p>Like the above, if you must remain USTAR compatible, you must also ensure than paths for + <p>Like the above, if you must remain USTAR compatible, you must also ensure that paths for symbolic/hard links are no more than 100 bytes, otherwise PAX headers will be used.</p> </item> </list> diff --git a/lib/stdlib/test/tar_SUITE.erl b/lib/stdlib/test/tar_SUITE.erl index 294741574c..499a9ee5d2 100644 --- a/lib/stdlib/test/tar_SUITE.erl +++ b/lib/stdlib/test/tar_SUITE.erl @@ -50,7 +50,7 @@ groups() -> []. init_per_suite(Config) -> - Config. + uid_config(Config). end_per_suite(_Config) -> ok. @@ -83,7 +83,7 @@ borderline(Config) when is_list(Config) -> Record = 512, Block = 20 * Record, - lists:foreach(fun(Size) -> borderline_test(Size, TempDir) end, + lists:foreach(fun(Size) -> borderline_test(Size, TempDir, Config) end, [0, 1, 10, 13, 127, 333, Record-1, Record, Record+1, Block-2*Record-1, Block-2*Record, Block-2*Record+1, Block-Record-1, Block-Record, Block-Record+1, @@ -95,13 +95,16 @@ borderline(Config) when is_list(Config) -> verify_ports(Config). -borderline_test(Size, TempDir) -> +borderline_test(Size, TempDir, Config) -> io:format("Testing size ~p", [Size]), - borderline_test(Size, TempDir, true), - borderline_test(Size, TempDir, false), + case long_uid(Config) of + true -> ok; + false -> borderline_test1(Size, TempDir, true) + end, + borderline_test1(Size, TempDir, false), ok. -borderline_test(Size, TempDir, IsUstar) -> +borderline_test1(Size, TempDir, IsUstar) -> Prefix = case IsUstar of true -> "file_"; @@ -341,7 +344,6 @@ create_long_names() -> ok = erl_tar:tt(TarName), %% Extract and verify. - true = is_ustar(TarName), ExtractDir = "extract_dir", ok = file:make_dir(ExtractDir), ok = erl_tar:extract(TarName, [{cwd,ExtractDir}]), @@ -588,7 +590,7 @@ symlinks(Config) when is_list(Config) -> {error, enotsup} -> {skip, "Symbolic links not supported on this platform"}; ok -> - symlinks(Dir, "bad_symlink", PointsTo), + symlinks(Dir, "bad_symlink", PointsTo, Config), long_symlink(Dir), symlink_vulnerability(VulnerableDir) end, @@ -621,7 +623,7 @@ make_symlink(Path, Link) -> file:make_symlink(Path, Link) end. -symlinks(Dir, BadSymlink, PointsTo) -> +symlinks(Dir, BadSymlink, PointsTo, Config) -> Tar = filename:join(Dir, "symlink.tar"), DerefTar = filename:join(Dir, "dereference.tar"), @@ -634,7 +636,6 @@ symlinks(Dir, BadSymlink, PointsTo) -> ok = file:write_file(AFile, ALine), ok = file:make_symlink(AFile, GoodSymlink), ok = erl_tar:create(Tar, [BadSymlink, GoodSymlink, AFile], [verbose]), - true = is_ustar(Tar), %% List contents of tar file. @@ -643,7 +644,12 @@ symlinks(Dir, BadSymlink, PointsTo) -> %% Also create another archive with the dereference flag. ok = erl_tar:create(DerefTar, [AFile, GoodSymlink], [dereference, verbose]), - true = is_ustar(DerefTar), + case long_uid(Config) of + true -> ok; + false -> + true = is_ustar(Tar), + true = is_ustar(DerefTar) + end, %% Extract files to a new directory. @@ -774,7 +780,11 @@ open_add_close(Config) when is_list(Config) -> ok = erl_tar:add(AD, ADir, [verbose]), ok = erl_tar:add(AD, AnotherDir, [verbose]), ok = erl_tar:close(AD), - true = is_ustar(TarOne), + case long_uid(Config) of + true -> ok; + false -> + true = is_ustar(TarOne) + end, ok = erl_tar:t(TarOne), ok = erl_tar:tt(TarOne), @@ -1137,3 +1147,14 @@ verify_ports(Config) -> [_|_]=Rem -> error({leaked_ports,Rem}) end. + +uid_config(Config) -> + DataDir = proplists:get_value(data_dir, Config), + Long = filename:join(DataDir, "long_names.tar"), + {ok, FileInfo} = file:read_file_info(Long), + Uid = FileInfo#file_info.uid, + Octal = integer_to_list(Uid, 8), + [{longuid, length(Octal) > 7}|Config]. + +long_uid(Config) -> + proplists:get_value(longuid, Config). \ No newline at end of file -- 2.43.0
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