From bf4418b4bb9166a6a27937b53710d2b4d30925af Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 21 Mar 2018 17:51:39 +0100 Subject: kernel: Fix os_SUITE:max_size_command for OTP-19 where string:trim does not exist. --- lib/kernel/test/os_SUITE.erl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl index cfd475becf..d7f0463289 100644 --- a/lib/kernel/test/os_SUITE.erl +++ b/lib/kernel/test/os_SUITE.erl @@ -324,9 +324,17 @@ max_size_command(_Config) -> Res32768 = os:cmd("cat /dev/zero", #{ max_size => 32768 }), 32768 = length(Res32768), - ResHello = string:trim(os:cmd("echo hello", #{ max_size => 20 })), + 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) -> -- cgit v1.2.3