aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/os_SUITE.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2018-03-21 18:16:46 +0100
committerErlang/OTP <[email protected]>2018-03-21 18:16:46 +0100
commit5af1c7339be4ad3ec6336e32207cfa70535a5440 (patch)
treef10cd9d49bd78d914d4e5317fb8ab35b22fc0c11 /lib/kernel/test/os_SUITE.erl
parent33521da61673b890bcd05eda02f38fea1fe58a30 (diff)
parentbf4418b4bb9166a6a27937b53710d2b4d30925af (diff)
downloadotp-5af1c7339be4ad3ec6336e32207cfa70535a5440.tar.gz
otp-5af1c7339be4ad3ec6336e32207cfa70535a5440.tar.bz2
otp-5af1c7339be4ad3ec6336e32207cfa70535a5440.zip
Merge branch 'sverker/maint-19/os-cmd-2/OTP-14823' into maint-19
* sverker/maint-19/os-cmd-2/OTP-14823: kernel: Fix os_SUITE:max_size_command for OTP-19 kernel: Fix handling of os:cmd option max_size in win kernel: Add os:cmd/2 with max_size option
Diffstat (limited to 'lib/kernel/test/os_SUITE.erl')
-rw-r--r--lib/kernel/test/os_SUITE.erl26
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl
index e76d6ec482..d7f0463289 100644
--- a/lib/kernel/test/os_SUITE.erl
+++ b/lib/kernel/test/os_SUITE.erl
@@ -25,7 +25,8 @@
-export([space_in_cwd/1, quoting/1, cmd_unicode/1, space_in_name/1, bad_command/1,
find_executable/1, unix_comment_in_command/1, deep_list_command/1,
large_output_command/1, background_command/0, background_command/1,
- message_leak/1, close_stdin/0, close_stdin/1, perf_counter_api/1]).
+ message_leak/1, close_stdin/0, close_stdin/1, max_size_command/1,
+ perf_counter_api/1]).
-include_lib("common_test/include/ct.hrl").
@@ -37,7 +38,7 @@ all() ->
[space_in_cwd, quoting, cmd_unicode, space_in_name, bad_command,
find_executable, unix_comment_in_command, deep_list_command,
large_output_command, background_command, message_leak,
- close_stdin, perf_counter_api].
+ close_stdin, max_size_command, perf_counter_api].
groups() ->
[].
@@ -312,6 +313,27 @@ close_stdin(Config) ->
"-1" = os:cmd(Fds).
+max_size_command(_Config) ->
+
+ Res20 = os:cmd("cat /dev/zero", #{ max_size => 20 }),
+ 20 = length(Res20),
+
+ Res0 = os:cmd("cat /dev/zero", #{ max_size => 0 }),
+ 0 = length(Res0),
+
+ Res32768 = os:cmd("cat /dev/zero", #{ max_size => 32768 }),
+ 32768 = length(Res32768),
+
+ ResHello = string_trim(os:cmd("echo hello", #{ max_size => 20 })),
+ 5 = length(ResHello).
+
+string_trim(S) ->
+ lists:reverse(string_trim_left(lists:reverse(string_trim_left(S)))).
+
+string_trim_left([C | T]) when C =:= $\s; C =:= $\n; C =:= $\t; C =:= $\r ->
+ string_trim_left(T);
+string_trim_left(S) ->
+ S.
%% Test that the os:perf_counter api works as expected
perf_counter_api(_Config) ->