diff options
Diffstat (limited to 'lib/stdlib/test/io_proto_SUITE.erl')
-rw-r--r-- | lib/stdlib/test/io_proto_SUITE.erl | 1338 |
1 files changed, 669 insertions, 669 deletions
diff --git a/lib/stdlib/test/io_proto_SUITE.erl b/lib/stdlib/test/io_proto_SUITE.erl index c16d301279..6c0e4241a9 100644 --- a/lib/stdlib/test/io_proto_SUITE.erl +++ b/lib/stdlib/test/io_proto_SUITE.erl @@ -57,7 +57,7 @@ -define(format(S, A), io:format(S, A)). -define(dbg(Data),io:format(standard_error, "DBG: ~p\r\n",[Data])). -define(RM_RF(Dir),begin io:format(standard_error, "Not Removed: ~p\r\n",[Dir]), - ok end). + ok end). -else. -define(format(S, A), ok). -define(dbg(Data),noop). @@ -105,171 +105,171 @@ end_per_group(_GroupName, Config) -> q = [], nxt = eof, mode = list - }). + }). uprompt(_L) -> [1050,1072,1082,1074,1086,32,1077,32,85,110,105,99,111,100,101,32,63]. %% Test that an Unicode prompt does not crash the shell. unicode_prompt(Config) when is_list(Config) -> - ?line PA = filename:dirname(code:which(?MODULE)), + PA = filename:dirname(code:which(?MODULE)), case proplists:get_value(default_shell,Config) of old -> ok; new -> - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline, "2"}, - {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."}, - {getline, "default"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline, "\"hej\\n\""}, - {putline, "io:setopts([{binary,true}])."}, - {getline, "ok"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline, "<<\"hej\\n\">>"} - ],[],[],"-pa \""++ PA++"\"") + rtnode([{putline,""}, + {putline, "2."}, + {getline, "2"}, + {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."}, + {getline, "default"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "\"hej\\n\""}, + {putline, "io:setopts([{binary,true}])."}, + {getline, "ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "<<\"hej\\n\">>"} + ],[],[],"-pa \""++ PA++"\"") end, %% And one with oldshell - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline_re, ".*2$"}, - {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."}, - {getline_re, ".*default"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline_re, ".*\"hej\\\\n\""}, - {putline, "io:setopts([{binary,true}])."}, - {getline_re, ".*ok"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline_re, ".*<<\"hej\\\\n\">>"} - ],[],[],"-oldshell -pa \""++PA++"\""), + rtnode([{putline,""}, + {putline, "2."}, + {getline_re, ".*2$"}, + {putline, "shell:prompt_func({io_proto_SUITE,uprompt})."}, + {getline_re, ".*default"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*\"hej\\\\n\""}, + {putline, "io:setopts([{binary,true}])."}, + {getline_re, ".*ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*<<\"hej\\\\n\">>"} + ],[],[],"-oldshell -pa \""++PA++"\""), ok. - + %% Check io:setopts and io:getopts functions. setopts_getopts(Config) when is_list(Config) -> - ?line FileName = filename:join([?config(priv_dir,Config), - "io_proto_SUITE_setopts_getopts.dat"]), - ?line {ok,WFile} = file:open(FileName,[write]), - ?line Server = start_io_server_proxy(), - ?line [{binary, false}] = io:getopts(Server), - ?line [getopts] = proxy_getall(Server), - ?line [{binary,false},{encoding,latin1}] = lists:sort(io:getopts(WFile)), - ?line proxy_setnext(Server,"Hej"), - ?line "Hej" = io:get_line(Server,''), - ?line proxy_setnext(Server,"Hej"++[532]), - ?line [$H,$e,$j,532] = io:get_line(Server,''), - ?line ok = io:setopts(Server,[{binary,true}]), - ?line proxy_setnext(Server,"Hej"), - ?line <<"Hej">> = io:get_line(Server,''), - ?line proxy_setnext(Server,"Hej"++[532]), - ?line <<72,101,106,200,148>> = io:get_line(Server,''), - ?line [$H,$e,$j,532] = lists:flatten(io_lib:format("~ts",[<<72,101,106,200,148>>])), - ?line file:write(WFile,<<"HejA">>), - ?line file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,unicode)), - ?line file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf16,big})), - ?line file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf16,little})), - ?line file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf32,big})), - ?line file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf32,little})), - ?line file:close(WFile), - ?line {ok,RFile} = file:open(FileName,[read]), - ?line [{binary,false},{encoding,latin1}] = lists:sort(io:getopts(RFile)), - ?line [$H,$e,$j,$A] = io:get_chars(RFile,'',4), - ?line io:setopts(RFile,[{encoding,unicode}]), - ?line [$H,$e,$j,532] = io:get_chars(RFile,'',4), - ?line [{binary,false},{encoding,unicode}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf16,big}}]), - ?line [$H,$e,$j,532] = io:get_chars(RFile,'',4), - ?line [{binary,false},{encoding,{utf16,big}}] = + FileName = filename:join([?config(priv_dir,Config), + "io_proto_SUITE_setopts_getopts.dat"]), + {ok,WFile} = file:open(FileName,[write]), + Server = start_io_server_proxy(), + [{binary, false}] = io:getopts(Server), + [getopts] = proxy_getall(Server), + [{binary,false},{encoding,latin1}] = lists:sort(io:getopts(WFile)), + proxy_setnext(Server,"Hej"), + "Hej" = io:get_line(Server,''), + proxy_setnext(Server,"Hej"++[532]), + [$H,$e,$j,532] = io:get_line(Server,''), + ok = io:setopts(Server,[{binary,true}]), + proxy_setnext(Server,"Hej"), + <<"Hej">> = io:get_line(Server,''), + proxy_setnext(Server,"Hej"++[532]), + <<72,101,106,200,148>> = io:get_line(Server,''), + [$H,$e,$j,532] = lists:flatten(io_lib:format("~ts",[<<72,101,106,200,148>>])), + file:write(WFile,<<"HejA">>), + file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,unicode)), + file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf16,big})), + file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf16,little})), + file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf32,big})), + file:write(WFile,unicode:characters_to_binary("Hej"++[532],unicode,{utf32,little})), + file:close(WFile), + {ok,RFile} = file:open(FileName,[read]), + [{binary,false},{encoding,latin1}] = lists:sort(io:getopts(RFile)), + [$H,$e,$j,$A] = io:get_chars(RFile,'',4), + io:setopts(RFile,[{encoding,unicode}]), + [$H,$e,$j,532] = io:get_chars(RFile,'',4), + [{binary,false},{encoding,unicode}] = lists:sort(io:getopts(RFile)), + io:setopts(RFile,[{encoding,{utf16,big}}]), + [$H,$e,$j,532] = io:get_chars(RFile,'',4), + [{binary,false},{encoding,{utf16,big}}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf16,little}}]), - ?line [$H,$e,$j,532] = io:get_chars(RFile,'',4), - ?line [{binary,false},{encoding,{utf16,little}}] = + io:setopts(RFile,[{encoding,{utf16,little}}]), + [$H,$e,$j,532] = io:get_chars(RFile,'',4), + [{binary,false},{encoding,{utf16,little}}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf32,big}}]), - ?line [$H,$e,$j,532] = io:get_chars(RFile,'',4), - ?line [{binary,false},{encoding,{utf32,big}}] = + io:setopts(RFile,[{encoding,{utf32,big}}]), + [$H,$e,$j,532] = io:get_chars(RFile,'',4), + [{binary,false},{encoding,{utf32,big}}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf32,little}}]), - ?line [$H,$e,$j,532] = io:get_chars(RFile,'',4), - ?line [{binary,false},{encoding,{utf32,little}}] = + io:setopts(RFile,[{encoding,{utf32,little}}]), + [$H,$e,$j,532] = io:get_chars(RFile,'',4), + [{binary,false},{encoding,{utf32,little}}] = lists:sort(io:getopts(RFile)), - ?line eof = io:get_line(RFile,''), - ?line file:position(RFile,0), - ?line io:setopts(RFile,[{binary,true},{encoding,latin1}]), - ?line <<$H,$e,$j,$A>> = io:get_chars(RFile,'',4), - ?line [{binary,true},{encoding,latin1}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,unicode}]), - ?line <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), - ?line [{binary,true},{encoding,unicode}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf16,big}}]), - ?line <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), - ?line [{binary,true},{encoding,{utf16,big}}] = + eof = io:get_line(RFile,''), + file:position(RFile,0), + io:setopts(RFile,[{binary,true},{encoding,latin1}]), + <<$H,$e,$j,$A>> = io:get_chars(RFile,'',4), + [{binary,true},{encoding,latin1}] = lists:sort(io:getopts(RFile)), + io:setopts(RFile,[{encoding,unicode}]), + <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), + [{binary,true},{encoding,unicode}] = lists:sort(io:getopts(RFile)), + io:setopts(RFile,[{encoding,{utf16,big}}]), + <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), + [{binary,true},{encoding,{utf16,big}}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf16,little}}]), - ?line <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), - ?line [{binary,true},{encoding,{utf16,little}}] = + io:setopts(RFile,[{encoding,{utf16,little}}]), + <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), + [{binary,true},{encoding,{utf16,little}}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf32,big}}]), - ?line <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), - ?line [{binary,true},{encoding,{utf32,big}}] = + io:setopts(RFile,[{encoding,{utf32,big}}]), + <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), + [{binary,true},{encoding,{utf32,big}}] = lists:sort(io:getopts(RFile)), - ?line io:setopts(RFile,[{encoding,{utf32,little}}]), - ?line <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), - ?line [{binary,true},{encoding,{utf32,little}}] = + io:setopts(RFile,[{encoding,{utf32,little}}]), + <<$H,$e,$j,532/utf8>> = io:get_chars(RFile,'',4), + [{binary,true},{encoding,{utf32,little}}] = lists:sort(io:getopts(RFile)), - ?line eof = io:get_line(RFile,''), - ?line file:close(RFile), + eof = io:get_line(RFile,''), + file:close(RFile), case proplists:get_value(default_shell,Config) of old -> ok; new -> %% So, lets test another node with new interactive shell - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline, "2"}, - {putline, "lists:keyfind(binary,1,io:getopts())."}, - {getline, "{binary,false}"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline, "\"hej\\n\""}, - {putline, "io:setopts([{binary,true}])."}, - {getline, "ok"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline, "<<\"hej\\n\">>"} - ],[]) + rtnode([{putline,""}, + {putline, "2."}, + {getline, "2"}, + {putline, "lists:keyfind(binary,1,io:getopts())."}, + {getline, "{binary,false}"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "\"hej\\n\""}, + {putline, "io:setopts([{binary,true}])."}, + {getline, "ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "<<\"hej\\n\">>"} + ],[]) end, %% And one with oldshell - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline_re, ".*2$"}, - {putline, "lists:keyfind(binary,1,io:getopts())."}, - {getline_re, ".*{binary,false}"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline_re, ".*\"hej\\\\n\""}, - {putline, "io:setopts([{binary,true}])."}, - {getline_re, ".*ok"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline_re, ".*<<\"hej\\\\n\">>"} - ],[],[],"-oldshell"), + rtnode([{putline,""}, + {putline, "2."}, + {getline_re, ".*2$"}, + {putline, "lists:keyfind(binary,1,io:getopts())."}, + {getline_re, ".*{binary,false}"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*\"hej\\\\n\""}, + {putline, "io:setopts([{binary,true}])."}, + {getline_re, ".*ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*<<\"hej\\\\n\">>"} + ],[],[],"-oldshell"), ok. get_lc_ctype() -> - case {os:type(),os:version()} of - {{unix,sunos},{5,N,_}} when N =< 8 -> - "iso_8859_1"; - _ -> - "ISO-8859-1" - end. - + case {os:type(),os:version()} of + {{unix,sunos},{5,N,_}} when N =< 8 -> + "iso_8859_1"; + _ -> + "ISO-8859-1" + end. + %% Test various unicode options. unicode_options(Config) when is_list(Config) -> DataDir = ?config(data_dir,Config), @@ -312,7 +312,6 @@ unicode_options(Config) when is_list(Config) -> [read,binary]), {ok,Bin} = file:read(F,4), {Type,Bytes} = unicode:bom_to_encoding(Bin), - file:position(F,Bytes), io:setopts(F,[{encoding,Type}]), R = unicode:characters_to_list( @@ -330,26 +329,26 @@ unicode_options(Config) when is_list(Config) -> R end, ReadBomlessFileList = fun({Type,File},DataLen,Dir) -> - {ok,F} = file:open(filename:join([Dir,File]), - [read, - {encoding,Type}]), - R = io:get_chars(F,'',DataLen), - file:close(F), - R - end, + {ok,F} = file:open(filename:join([Dir,File]), + [read, + {encoding,Type}]), + R = io:get_chars(F,'',DataLen), + file:close(F), + R + end, ReadBomlessFileListLine = fun({Type,File},Dir) -> - {ok,F} = file:open(filename:join([Dir,File]), - [read, - {encoding,Type}]), - R = io:get_line(F,''), - file:close(F), - R - end, - ?line [TestData = ReadBomFile(F,DataDir) || F <- InternalBomFiles ], - ?line [ExternalTestData = ReadBomFile(F,DataDir) || F <- ExternalBomFiles ], - ?line [TestData = ReadBomlessFile(F,length(TestData),DataDir) || F <- AllNoBom ], - ?line [TestData = ReadBomlessFileList(F,length(TestData),DataDir) || F <- AllNoBom ], - ?line [TestData = ReadBomlessFileListLine(F,DataDir) || F <- AllNoBom ], + {ok,F} = file:open(filename:join([Dir,File]), + [read, + {encoding,Type}]), + R = io:get_line(F,''), + file:close(F), + R + end, + [TestData = ReadBomFile(F,DataDir) || F <- InternalBomFiles ], + [ExternalTestData = ReadBomFile(F,DataDir) || F <- ExternalBomFiles ], + [TestData = ReadBomlessFile(F,length(TestData),DataDir) || F <- AllNoBom ], + [TestData = ReadBomlessFileList(F,length(TestData),DataDir) || F <- AllNoBom ], + [TestData = ReadBomlessFileListLine(F,DataDir) || F <- AllNoBom ], BomDir = filename:join([PrivDir,"BOMDATA"]), BomlessDir = filename:join([PrivDir,"BOMLESSDATA"]), @@ -365,8 +364,8 @@ unicode_options(Config) when is_list(Config) -> file:close(F), ok end, - ?line [ ok = WriteBomFile(F,BomDir) || F <- AllNoBom ], - ?line [TestData = ReadBomFile(F,BomDir) || {_,F} <- AllNoBom ], + [ ok = WriteBomFile(F,BomDir) || F <- AllNoBom ], + [TestData = ReadBomFile(F,BomDir) || {_,F} <- AllNoBom ], WriteBomlessFile = fun({Enc,File},TData,Dir) -> {ok,F} = file:open( filename:join([Dir,File]), @@ -375,11 +374,11 @@ unicode_options(Config) when is_list(Config) -> file:close(F), ok end, - ?line [ ok = WriteBomlessFile(F,TestData,BomlessDir) || F <- AllNoBom ], - ?line [TestData = ReadBomlessFile(F,length(TestData),BomlessDir) || F <- AllNoBom ], - ?line [TestData = ReadBomlessFileList(F,length(TestData),BomlessDir) || F <- AllNoBom ], - ?line [TestData = ReadBomlessFileListLine(F,BomlessDir) || F <- AllNoBom ], - + [ ok = WriteBomlessFile(F,TestData,BomlessDir) || F <- AllNoBom ], + [TestData = ReadBomlessFile(F,length(TestData),BomlessDir) || F <- AllNoBom ], + [TestData = ReadBomlessFileList(F,length(TestData),BomlessDir) || F <- AllNoBom ], + [TestData = ReadBomlessFileListLine(F,BomlessDir) || F <- AllNoBom ], + CannotReadFile = fun({Enc,File},Dir) -> %%io:format(standard_error,"~s\r\n",[filename:join([Dir,File])]), {ok,F} = file:open( @@ -398,14 +397,14 @@ unicode_options(Config) when is_list(Config) -> {error,terminated} = io:get_chars(F,'',10), ok end, - ?line [ ok = CannotReadFile(F,DataDir) || F <- AllNoBom ], - ?line [ ok = CannotReadFile(F,BomlessDir) || F <- AllNoBom ], - ?line [ ok = CannotReadFile(F,BomDir) || F <- AllNoBom ], + [ ok = CannotReadFile(F,DataDir) || F <- AllNoBom ], + [ ok = CannotReadFile(F,BomlessDir) || F <- AllNoBom ], + [ ok = CannotReadFile(F,BomDir) || F <- AllNoBom ], - ?line [ ok = WriteBomlessFile(F,TestData2,BomlessDir) || F <- AllNoBom ], - ?line [TestData2 = ReadBomlessFile(F,length(TestData2),BomlessDir) || F <- AllNoBom ], - ?line [TestData2 = ReadBomlessFileList(F,length(TestData2),BomlessDir) || F <- AllNoBom ], - ?line [TestData2 = ReadBomlessFileListLine(F,BomlessDir) || F <- AllNoBom ], + [ ok = WriteBomlessFile(F,TestData2,BomlessDir) || F <- AllNoBom ], + [TestData2 = ReadBomlessFile(F,length(TestData2),BomlessDir) || F <- AllNoBom ], + [TestData2 = ReadBomlessFileList(F,length(TestData2),BomlessDir) || F <- AllNoBom ], + [TestData2 = ReadBomlessFileListLine(F,BomlessDir) || F <- AllNoBom ], FailDir = filename:join([PrivDir,"FAIL"]), @@ -415,52 +414,52 @@ unicode_options(Config) when is_list(Config) -> {ok,F} = file:open( filename:join([Dir,File]), [write,binary]), - ?line {'EXIT', {no_translation,_}} = + {'EXIT', {no_translation,_}} = (catch io:put_chars(F,TestData)), - ?line {'EXIT', {terminated,_}} = (catch io:put_chars(F,TestData)), + {'EXIT', {terminated,_}} = (catch io:put_chars(F,TestData)), ok end, - ?line [ ok = CannotWriteFile(F,FailDir) || F <- AllNoBom ], + [ ok = CannotWriteFile(F,FailDir) || F <- AllNoBom ], case proplists:get_value(default_shell,Config) of old -> ok; new -> %% OK, time for the group_leaders... - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline, "2"}, - {putline, "lists:keyfind(encoding,1,io:getopts())."}, - {getline, "{encoding,latin1}"}, - {putline, "io:format(\"~ts~n\",[[1024]])."}, - {getline, "\\x{400}"}, - {putline, "io:setopts([unicode])."}, - {getline, "ok"}, - {putline, "io:format(\"~ts~n\",[[1024]])."}, - {getline, - binary_to_list(unicode:characters_to_binary( - [1024],unicode,utf8))} - ],[],"LC_CTYPE=\""++get_lc_ctype()++"\"; " - "export LC_CTYPE; ") + rtnode([{putline,""}, + {putline, "2."}, + {getline, "2"}, + {putline, "lists:keyfind(encoding,1,io:getopts())."}, + {getline, "{encoding,latin1}"}, + {putline, "io:format(\"~ts~n\",[[1024]])."}, + {getline, "\\x{400}"}, + {putline, "io:setopts([unicode])."}, + {getline, "ok"}, + {putline, "io:format(\"~ts~n\",[[1024]])."}, + {getline, + binary_to_list(unicode:characters_to_binary( + [1024],unicode,utf8))} + ],[],"LC_CTYPE=\""++get_lc_ctype()++"\"; " + "export LC_CTYPE; ") end, - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline_re, ".*2$"}, - {putline, "lists:keyfind(encoding,1,io:getopts())."}, - {getline_re, ".*{encoding,latin1}"}, - {putline, "io:format(\"~ts~n\",[[1024]])."}, - {getline_re, ".*\\\\x{400\\}"}, - {putline, "io:setopts([{encoding,unicode}])."}, - {getline_re, ".*ok"}, - {putline, "io:format(\"~ts~n\",[[1024]])."}, - {getline_re, - ".*"++binary_to_list(unicode:characters_to_binary( - [1024],unicode,utf8))} - ],[],"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; ", - " -oldshell "), + rtnode([{putline,""}, + {putline, "2."}, + {getline_re, ".*2$"}, + {putline, "lists:keyfind(encoding,1,io:getopts())."}, + {getline_re, ".*{encoding,latin1}"}, + {putline, "io:format(\"~ts~n\",[[1024]])."}, + {getline_re, ".*\\\\x{400\\}"}, + {putline, "io:setopts([{encoding,unicode}])."}, + {getline_re, ".*ok"}, + {putline, "io:format(\"~ts~n\",[[1024]])."}, + {getline_re, + ".*"++binary_to_list(unicode:characters_to_binary( + [1024],unicode,utf8))} + ],[],"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; ", + " -oldshell "), ok. - + %% Tests various unicode options on random generated files. unicode_options_gen(Config) when is_list(Config) -> random:seed(1240, 900586, 553728), @@ -605,7 +604,7 @@ do_read_whole_file(Fname, Options, Fun) -> Res = do_read_whole_file_1(Fun, F), ok = file:close(F), unicode:characters_to_list(Res, unicode). - + do_read_whole_file_1(Fun, F) -> case Fun(F) of eof -> @@ -630,7 +629,7 @@ do_write_read_file(Fname, Options, Encoding, Writer) -> {ok,Bin} = file:read_file(Fname), ok = file:delete(Fname), Bin. - + enc2str(Atom) when is_atom(Atom) -> atom_to_list(Atom); enc2str({A1,A2}) when is_atom(A1), is_atom(A2) -> @@ -642,12 +641,12 @@ random_unicode(0) -> random_unicode(N) -> %% Favour large unicode and make linebreaks X = case random:uniform(20) of - A when A =< 1 -> $\n; - A0 when A0 =< 3 -> random:uniform(16#10FFFF); - A1 when A1 =< 6 -> random:uniform(16#10FFFF - 16#7F) + 16#7F; - A2 when A2 =< 12 -> random:uniform(16#10FFFF - 16#7FF) + 16#7FF; - _ -> random:uniform(16#10FFFF - 16#FFFF) + 16#FFFF - end, + A when A =< 1 -> $\n; + A0 when A0 =< 3 -> random:uniform(16#10FFFF); + A1 when A1 =< 6 -> random:uniform(16#10FFFF - 16#7F) + 16#7F; + A2 when A2 =< 12 -> random:uniform(16#10FFFF - 16#7FF) + 16#7FF; + _ -> random:uniform(16#10FFFF - 16#FFFF) + 16#FFFF + end, case X of Inv1 when Inv1 >= 16#D800, Inv1 =< 16#DFFF; Inv1 =:= 16#FFFE; @@ -656,7 +655,7 @@ random_unicode(N) -> _ -> [X | random_unicode(N-1)] end. - + %% Test variants with binary option. binary_options(Config) when is_list(Config) -> @@ -672,73 +671,74 @@ binary_options(Config) when is_list(Config) -> First10List = binary_to_list(First10), Second10List = binary_to_list(Second10), TestFile = filename:join([DataDir, "testdata_utf8.dat"]), - ?line {ok, F} = file:open(TestFile,[read]), - ?line {ok, First10List} = file:read(F,10), - ?line io:setopts(F,[binary]), - ?line {ok, Second10} = file:read(F,10), - ?line file:close(F), - ?line {ok, F2} = file:open(TestFile,[read,binary]), - ?line {ok, First10} = file:read(F2,10), - ?line io:setopts(F2,[list]), - ?line {ok, Second10List} = file:read(F2,10), - ?line file:position(F2,0), - ?line First10List = io:get_chars(F2,'',10), - ?line io:setopts(F2,[binary]), - ?line Second10 = unicode:characters_to_binary(io:get_chars(F2,'',10),unicode,latin1), - ?line file:close(F2), - ?line LineBreakFileName = filename:join([PrivDir, "testdata.dat"]), - ?line LineBreakTestData = <<TestData/binary,$\n>>, - ?line LineBreakTestDataList = binary_to_list(LineBreakTestData), - ?line file:write_file(LineBreakFileName,[LineBreakTestData,LineBreakTestData,LineBreakTestData,TestData]), - ?line {ok, F3} = file:open(LineBreakFileName,[read]), - ?line LineBreakTestDataList = io:get_line(F3,''), - ?line io:setopts(F3,[binary]), - ?line LineBreakTestData = unicode:characters_to_binary(io:get_line(F3,''),unicode,latin1), - ?line io:setopts(F3,[list]), - ?line LineBreakTestDataList = io:get_line(F3,''), - ?line io:setopts(F3,[binary]), - ?line TestData = unicode:characters_to_binary(io:get_line(F3,''),unicode,latin1), - ?line eof = io:get_line(F3,''), - ?line file:close(F3), + {ok, F} = file:open(TestFile,[read]), + {ok, First10List} = file:read(F,10), + io:setopts(F,[binary]), + {ok, Second10} = file:read(F,10), + file:close(F), + {ok, F2} = file:open(TestFile,[read,binary]), + {ok, First10} = file:read(F2,10), + io:setopts(F2,[list]), + {ok, Second10List} = file:read(F2,10), + file:position(F2,0), + First10List = io:get_chars(F2,'',10), + io:setopts(F2,[binary]), + Second10 = unicode:characters_to_binary(io:get_chars(F2,'',10),unicode,latin1), + file:close(F2), + LineBreakFileName = filename:join([PrivDir, "testdata.dat"]), + LineBreakTestData = <<TestData/binary,$\n>>, + LineBreakTestDataList = binary_to_list(LineBreakTestData), + file:write_file(LineBreakFileName,[LineBreakTestData,LineBreakTestData,LineBreakTestData,TestData]), + {ok, F3} = file:open(LineBreakFileName,[read]), + LineBreakTestDataList = io:get_line(F3,''), + io:setopts(F3,[binary]), + LineBreakTestData = unicode:characters_to_binary(io:get_line(F3,''),unicode,latin1), + io:setopts(F3,[list]), + LineBreakTestDataList = io:get_line(F3,''), + io:setopts(F3,[binary]), + TestData = unicode:characters_to_binary(io:get_line(F3,''),unicode,latin1), + eof = io:get_line(F3,''), + file:close(F3), + %% OK, time for the group_leaders... case proplists:get_value(default_shell,Config) of old -> ok; new -> - ?line rtnode([{putline, "2."}, - {getline, "2"}, - {putline, "lists:keyfind(binary,1,io:getopts())."}, - {getline, "{binary,false}"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline, "\"hej\\n\""}, - {putline, "io:setopts([{binary,true},unicode])."}, - {getline, "ok"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline, "<<\"hej\\n\">>"}, - {putline, "io:get_line('')."}, - {putline, binary_to_list(<<"\345\344\366"/utf8>>)}, - {getline, "<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\n\"/utf8>>"} - ],[]) + rtnode([{putline, "2."}, + {getline, "2"}, + {putline, "lists:keyfind(binary,1,io:getopts())."}, + {getline, "{binary,false}"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "\"hej\\n\""}, + {putline, "io:setopts([{binary,true},unicode])."}, + {getline, "ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline, "<<\"hej\\n\">>"}, + {putline, "io:get_line('')."}, + {putline, binary_to_list(<<"\345\344\366"/utf8>>)}, + {getline, "<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\n\"/utf8>>"} + ],[]) end, - %% And one with oldshell - ?line rtnode([{putline, "2."}, - {getline_re, ".*2$"}, - {putline, "lists:keyfind(binary,1,io:getopts())."}, - {getline_re, ".*{binary,false}"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline_re, ".*\"hej\\\\n\""}, - {putline, "io:setopts([{binary,true},unicode])."}, - {getline_re, ".*ok"}, - {putline, "io:get_line('')."}, - {putline, "hej"}, - {getline_re, ".*<<\"hej\\\\n\">>"}, - {putline, "io:get_line('')."}, - {putline, binary_to_list(<<"\345\344\366"/utf8>>)}, - {getline_re, ".*<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\\\n\"/utf8>>"} - ],[],[],"-oldshell"), + %% And one with oldshell + rtnode([{putline, "2."}, + {getline_re, ".*2$"}, + {putline, "lists:keyfind(binary,1,io:getopts())."}, + {getline_re, ".*{binary,false}"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*\"hej\\\\n\""}, + {putline, "io:setopts([{binary,true},unicode])."}, + {getline_re, ".*ok"}, + {putline, "io:get_line('')."}, + {putline, "hej"}, + {getline_re, ".*<<\"hej\\\\n\">>"}, + {putline, "io:get_line('')."}, + {putline, binary_to_list(<<"\345\344\366"/utf8>>)}, + {getline_re, ".*<<\""++binary_to_list(<<"\345\344\366"/utf8>>)++"\\\\n\"/utf8>>"} + ],[],[],"-oldshell"), ok. %% Test io protocol compatibility with R12 nodes. @@ -751,132 +751,132 @@ bc_with_r12(Config) when is_list(Config) -> bc_with_r12_1(Config) -> PA = filename:dirname(code:which(?MODULE)), Name1 = io_proto_r12_1, - ?line N1 = list_to_atom(atom_to_list(Name1) ++ "@" ++ hostname()), + N1 = list_to_atom(atom_to_list(Name1) ++ "@" ++ hostname()), test_server:start_node(Name1, peer, [{args, "-pz \""++PA++"\""}, {erl,[{release,"r12b"}]}]), DataDir = ?config(data_dir,Config), FileName1 = filename:join([DataDir,"testdata_latin1.dat"]), TestDataLine1 = [229,228,246], TestDataLine2 = [197,196,214], - ?line SPid1 = rpc:call(N1,erlang,spawn,[?MODULE,hold_the_line,[self(),FileName1,[read]]]), - ?line {ok,F1} = receive - {SPid1,Res1} -> - Res1 - after 5000 -> - exit(timeout) - end, - ?line TestDataLine1 = chomp(io:get_line(F1,'')), - ?line SPid1 ! die, + SPid1 = rpc:call(N1,erlang,spawn,[?MODULE,hold_the_line,[self(),FileName1,[read]]]), + {ok,F1} = receive + {SPid1,Res1} -> + Res1 + after 5000 -> + exit(timeout) + end, + TestDataLine1 = chomp(io:get_line(F1,'')), + SPid1 ! die, receive after 1000 -> ok end, - ?line SPid2 = rpc:call(N1,erlang,spawn,[?MODULE,hold_the_line,[self(),FileName1,[read,binary]]]), - ?line {ok,F2} = receive - {SPid2,Res2} -> - Res2 - after 5000 -> - exit(timeout) - end, + SPid2 = rpc:call(N1,erlang,spawn,[?MODULE,hold_the_line,[self(),FileName1,[read,binary]]]), + {ok,F2} = receive + {SPid2,Res2} -> + Res2 + after 5000 -> + exit(timeout) + end, TestDataLine1BinUtf = unicode:characters_to_binary(TestDataLine1), TestDataLine1BinLatin = list_to_binary(TestDataLine1), TestDataLine2BinUtf = unicode:characters_to_binary(TestDataLine2), TestDataLine2BinLatin = list_to_binary(TestDataLine2), - ?line TestDataLine1BinUtf = chomp(io:get_line(F2,'')), - ?line TestDataLine2BinUtf = chomp(io:get_line(F2,'')), + TestDataLine1BinUtf = chomp(io:get_line(F2,'')), + TestDataLine2BinUtf = chomp(io:get_line(F2,'')), %%io:format(standard_error,"Exec:~s\r\n",[rpc:call(N1,os,find_executable,["erl"])]), %%io:format(standard_error,"Io:~s\r\n",[rpc:call(N1,code,which,[io])]), %%io:format(standard_error,"File_io_server:~s\r\n",[rpc:call(N1,code,which,[file_io_server])]), - ?line file:position(F2,0), - ?line TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[F2,''])), - ?line TestDataLine2BinUtf = chomp(io:get_line(F2,'')), - ?line file:position(F2,0), - ?line TestDataLine1BinUtf = chomp(io:get_line(F2,'')), - ?line TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F2,''])), - ?line eof = chomp(rpc:call(N1,io,get_line,[F2,''])), - ?line file:position(F2,0), - ?line TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[F2,'',3]), + file:position(F2,0), + TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[F2,''])), + TestDataLine2BinUtf = chomp(io:get_line(F2,'')), + file:position(F2,0), + TestDataLine1BinUtf = chomp(io:get_line(F2,'')), + TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F2,''])), + eof = chomp(rpc:call(N1,io,get_line,[F2,''])), + file:position(F2,0), + TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[F2,'',3]), io:get_chars(F2,'',1), - ?line TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F2,''])), - ?line file:position(F2,0), - ?line {ok,[TestDataLine1]} = io:fread(F2,'',"~s"), - ?line {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F2,'',"~s"]), - - ?line DataLen1 = length(TestDataLine1), - ?line DataLen2 = length(TestDataLine2), - - ?line file:position(F2,0), - ?line {ok,TestDataLine1BinLatin} = file:read(F2,DataLen1), - ?line {ok,_} = file:read(F2,1), - ?line {ok,TestDataLine2BinLatin} = rpc:call(N1,file,read,[F2,DataLen2]), - ?line {ok,_} = file:read(F2,1), - ?line eof = rpc:call(N1,file,read,[F2,1]), + TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F2,''])), + file:position(F2,0), + {ok,[TestDataLine1]} = io:fread(F2,'',"~s"), + {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F2,'',"~s"]), + + DataLen1 = length(TestDataLine1), + DataLen2 = length(TestDataLine2), + + file:position(F2,0), + {ok,TestDataLine1BinLatin} = file:read(F2,DataLen1), + {ok,_} = file:read(F2,1), + {ok,TestDataLine2BinLatin} = rpc:call(N1,file,read,[F2,DataLen2]), + {ok,_} = file:read(F2,1), + eof = rpc:call(N1,file,read,[F2,1]), %% As r12 has a bug when setting options with setopts, we need %% to reopen the file... - ?line SPid2 ! die, + SPid2 ! die, receive after 1000 -> ok end, - ?line SPid3 = rpc:call(N1,erlang,spawn,[?MODULE,hold_the_line,[self(),FileName1,[read]]]), - ?line {ok,F3} = receive - {SPid3,Res3} -> - Res3 - after 5000 -> - exit(timeout) - end, - - ?line file:position(F3,0), - ?line {ok,[TestDataLine1]} = io:fread(F3,'',"~s"), - ?line {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F3,'',"~s"]), - - - ?line file:position(F3,0), - ?line {ok,TestDataLine1} = file:read(F3,DataLen1), - ?line {ok,_} = file:read(F3,1), - ?line {ok,TestDataLine2} = rpc:call(N1,file,read,[F3,DataLen2]), - ?line {ok,_} = file:read(F3,1), - ?line eof = rpc:call(N1,file,read,[F3,1]), - + SPid3 = rpc:call(N1,erlang,spawn,[?MODULE,hold_the_line,[self(),FileName1,[read]]]), + {ok,F3} = receive + {SPid3,Res3} -> + Res3 + after 5000 -> + exit(timeout) + end, + + file:position(F3,0), + {ok,[TestDataLine1]} = io:fread(F3,'',"~s"), + {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F3,'',"~s"]), + + + file:position(F3,0), + {ok,TestDataLine1} = file:read(F3,DataLen1), + {ok,_} = file:read(F3,1), + {ok,TestDataLine2} = rpc:call(N1,file,read,[F3,DataLen2]), + {ok,_} = file:read(F3,1), + eof = rpc:call(N1,file,read,[F3,1]), + %% So, lets do it all again, but the other way around {ok,F4} = file:open(FileName1,[read]), - ?line TestDataLine1 = chomp(io:get_line(F4,'')), - ?line file:position(F4,0), - ?line io:setopts(F4,[binary]), - ?line TestDataLine1BinUtf = chomp(io:get_line(F4,'')), - ?line TestDataLine2BinUtf = chomp(io:get_line(F4,'')), - ?line file:position(F4,0), - ?line TestDataLine1BinUtf = chomp(io:get_line(F4,'')), - ?line TestDataLine2BinUtf = chomp(io:get_line(F4,'')), - ?line file:position(F4,0), - ?line TestDataLine1BinUtf = chomp(io:get_line(F4,'')), - ?line TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F4,''])), - ?line file:position(F4,0), - ?line TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[F4,''])), - ?line TestDataLine2BinUtf = chomp(io:get_line(F4,'')), - ?line eof = chomp(rpc:call(N1,io,get_line,[F4,''])), - ?line file:position(F4,0), - ?line TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[F4,'',3]), + TestDataLine1 = chomp(io:get_line(F4,'')), + file:position(F4,0), + io:setopts(F4,[binary]), + TestDataLine1BinUtf = chomp(io:get_line(F4,'')), + TestDataLine2BinUtf = chomp(io:get_line(F4,'')), + file:position(F4,0), + TestDataLine1BinUtf = chomp(io:get_line(F4,'')), + TestDataLine2BinUtf = chomp(io:get_line(F4,'')), + file:position(F4,0), + TestDataLine1BinUtf = chomp(io:get_line(F4,'')), + TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F4,''])), + file:position(F4,0), + TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[F4,''])), + TestDataLine2BinUtf = chomp(io:get_line(F4,'')), + eof = chomp(rpc:call(N1,io,get_line,[F4,''])), + file:position(F4,0), + TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[F4,'',3]), io:get_chars(F4,'',1), - ?line TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F4,''])), - ?line file:position(F4,0), - ?line {ok,[TestDataLine1]} = io:fread(F4,'',"~s"), - ?line {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F4,'',"~s"]), - ?line file:position(F4,0), - ?line {ok,TestDataLine1BinLatin} = file:read(F4,DataLen1), - ?line {ok,_} = file:read(F4,1), - ?line {ok,TestDataLine2BinLatin} = rpc:call(N1,file,read,[F4,DataLen2]), - ?line {ok,_} = file:read(F4,1), - ?line eof = rpc:call(N1,file,read,[F4,1]), - ?line io:setopts(F4,[list]), - - ?line file:position(F4,0), - ?line {ok,[TestDataLine1]} = io:fread(F4,'',"~s"), - ?line {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F4,'',"~s"]), - - - ?line file:position(F4,0), - ?line {ok,TestDataLine1} = file:read(F4,DataLen1), - ?line {ok,_} = file:read(F4,1), - ?line {ok,TestDataLine2} = rpc:call(N1,file,read,[F4,DataLen2]), - ?line {ok,_} = file:read(F4,1), - ?line eof = rpc:call(N1,file,read,[F4,1]), - + TestDataLine2BinLatin = chomp(rpc:call(N1,io,get_line,[F4,''])), + file:position(F4,0), + {ok,[TestDataLine1]} = io:fread(F4,'',"~s"), + {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F4,'',"~s"]), + file:position(F4,0), + {ok,TestDataLine1BinLatin} = file:read(F4,DataLen1), + {ok,_} = file:read(F4,1), + {ok,TestDataLine2BinLatin} = rpc:call(N1,file,read,[F4,DataLen2]), + {ok,_} = file:read(F4,1), + eof = rpc:call(N1,file,read,[F4,1]), + io:setopts(F4,[list]), + + file:position(F4,0), + {ok,[TestDataLine1]} = io:fread(F4,'',"~s"), + {ok,[TestDataLine2]} = rpc:call(N1,io,fread,[F4,'',"~s"]), + + + file:position(F4,0), + {ok,TestDataLine1} = file:read(F4,DataLen1), + {ok,_} = file:read(F4,1), + {ok,TestDataLine2} = rpc:call(N1,file,read,[F4,DataLen2]), + {ok,_} = file:read(F4,1), + eof = rpc:call(N1,file,read,[F4,1]), + file:close(F4), test_server:stop_node(N1), ok. @@ -887,7 +887,7 @@ hold_the_line(Parent,Filename,Options) -> die -> ok end. - + %% Test io protocol compatibility with R12 nodes (terminals). bc_with_r12_gl(Config) when is_list(Config) -> @@ -920,7 +920,7 @@ bc_with_r12_ogl(Config) when is_list(Config) -> bc_with_r12_gl_1(_Config,Machine) -> PA = filename:dirname(code:which(?MODULE)), Name1 = io_proto_r12_gl_1, - ?line N1 = list_to_atom(atom_to_list(Name1) ++ "@" ++ hostname()), + N1 = list_to_atom(atom_to_list(Name1) ++ "@" ++ hostname()), test_server:start_node(Name1, peer, [{args, "-pz \""++PA++"\""}, {erl,[{release,"r12b"}]}]), TestDataLine1 = [229,228,246], @@ -932,141 +932,141 @@ bc_with_r12_gl_1(_Config,Machine) -> register(io_proto_suite,self()), AM1 = spawn(?MODULE,Machine, [MyNodeList, "io_proto_suite", N2List]), - - ?line GL = receive X when is_pid(X) -> X end, + + GL = receive X when is_pid(X) -> X end, %% get_line - ?line "Hej\n" = rpc:call(N1,io,get_line,[GL,"Prompt\n"]), - ?line io:setopts(GL,[binary]), - ?line io:format(GL,"Okej~n",[]), - ?line <<"Hej\n">> = rpc:call(N1,io,get_line,[GL,"Prompt\n"]), - ?line io:setopts(GL,[{encoding,latin1}]), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[GL,"Prompt\n"])), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), - ?line io:setopts(GL,[{encoding,unicode}]), - - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[GL,"Prompt\n"])), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), - ?line io:setopts(GL,[list]), - ?line io:format(GL,"Okej~n",[]), - + "Hej\n" = rpc:call(N1,io,get_line,[GL,"Prompt\n"]), + io:setopts(GL,[binary]), + io:format(GL,"Okej~n",[]), + <<"Hej\n">> = rpc:call(N1,io,get_line,[GL,"Prompt\n"]), + io:setopts(GL,[{encoding,latin1}]), + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[GL,"Prompt\n"])), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), + io:setopts(GL,[{encoding,unicode}]), + + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = chomp(rpc:call(N1,io,get_line,[GL,"Prompt\n"])), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), + io:setopts(GL,[list]), + io:format(GL,"Okej~n",[]), + %%get_chars - ?line "Hej" = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), - ?line io:setopts(GL,[binary]), - ?line io:format(GL,"Okej~n",[]), - ?line <<"Hej">> = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), - ?line io:setopts(GL,[{encoding,latin1}]), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), - ?line io:setopts(GL,[{encoding,unicode}]), - - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), - ?line io:setopts(GL,[list]), - ?line io:format(GL,"Okej~n",[]), + "Hej" = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), + io:setopts(GL,[binary]), + io:format(GL,"Okej~n",[]), + <<"Hej">> = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), + io:setopts(GL,[{encoding,latin1}]), + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), + io:setopts(GL,[{encoding,unicode}]), + + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = rpc:call(N1,io,get_chars,[GL,"Prompt\n",3]), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), + io:setopts(GL,[list]), + io:format(GL,"Okej~n",[]), %%fread - ?line {ok,["Hej"]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), - ?line io:setopts(GL,[binary]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,["Hej"]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), - ?line io:setopts(GL,[{encoding,latin1}]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), - ?line io:setopts(GL,[{encoding,unicode}]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), - ?line io:setopts(GL,[list]), - ?line io:format(GL,"Okej~n",[]), - - - ?line receive - {AM1,done} -> - ok - after 5000 -> - exit(timeout) - end, + {ok,["Hej"]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), + io:setopts(GL,[binary]), + io:format(GL,"Okej~n",[]), + {ok,["Hej"]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), + io:setopts(GL,[{encoding,latin1}]), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), + io:setopts(GL,[{encoding,unicode}]), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = rpc:call(N1,io,fread,[GL,"Prompt\n","~s"]), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), + io:setopts(GL,[list]), + io:format(GL,"Okej~n",[]), + + + receive + {AM1,done} -> + ok + after 5000 -> + exit(timeout) + end, test_server:stop_node(N1), ok. - + answering_machine1(OthNode,OthReg,Me) -> TestDataLine1 = [229,228,246], TestDataUtf = binary_to_list(unicode:characters_to_binary(TestDataLine1)), - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline, "2"}, - {putline, "{"++OthReg++","++OthNode++"} ! group_leader()."}, - {getline, "<"}, - %% get_line - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - %% get_chars - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - %% fread - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"} - - ],Me,"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "), + rtnode([{putline,""}, + {putline, "2."}, + {getline, "2"}, + {putline, "{"++OthReg++","++OthNode++"} ! group_leader()."}, + {getline, "<"}, + %% get_line + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + %% get_chars + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + %% fread + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"} + + ],Me,"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "), O = list_to_atom(OthReg), O ! {self(),done}, ok. @@ -1074,74 +1074,74 @@ answering_machine1(OthNode,OthReg,Me) -> answering_machine2(OthNode,OthReg,Me) -> TestDataLine1 = [229,228,246], TestDataUtf = binary_to_list(unicode:characters_to_binary(TestDataLine1)), - ?line rtnode([{putline,""}, - {putline, "2."}, - {getline, "2"}, - {putline, "{"++OthReg++","++OthNode++"} ! group_leader()."}, - {getline_re, ".*<[0-9].*"}, - %% get_line - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - %% get_chars - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - %% fread - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, "Hej"}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataLine1}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"}, - {getline_re, ".*Prompt"}, - {putline, TestDataUtf}, - {getline_re, ".*Okej"} - - ],Me,"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "," -oldshell "), + rtnode([{putline,""}, + {putline, "2."}, + {getline, "2"}, + {putline, "{"++OthReg++","++OthNode++"} ! group_leader()."}, + {getline_re, ".*<[0-9].*"}, + %% get_line + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + %% get_chars + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + %% fread + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, "Hej"}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataLine1}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"}, + {getline_re, ".*Prompt"}, + {putline, TestDataUtf}, + {getline_re, ".*Okej"} + + ],Me,"LC_CTYPE=\""++get_lc_ctype()++"\"; export LC_CTYPE; "," -oldshell "), O = list_to_atom(OthReg), O ! {self(),done}, ok. - + %% Test various modes when reading from the group leade from another machine. read_modes_ogl(Config) when is_list(Config) -> @@ -1173,72 +1173,72 @@ read_modes_gl_1(_Config,Machine) -> register(io_proto_suite,self()), AM1 = spawn(?MODULE,Machine, [MyNodeList, "io_proto_suite", N2List]), - - ?line GL = receive X when is_pid(X) -> X end, + + GL = receive X when is_pid(X) -> X end, ?dbg({group_leader,X}), %% get_line - ?line receive after 500 -> ok end, % Dont clash with the new shell... - ?line "Hej\n" = io:get_line(GL,"Prompt\n"), - ?line io:setopts(GL,[binary]), - ?line io:format(GL,"Okej~n",[]), - ?line <<"Hej\n">> = io:get_line(GL,"Prompt\n"), - ?line io:setopts(GL,[{encoding,latin1}]), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = chomp(io:request(GL,{get_line,latin1,"Prompt\n"})), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), - ?line io:setopts(GL,[{encoding,unicode}]), - - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = chomp(io:request(GL,{get_line,latin1,"Prompt\n"})), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), - ?line io:setopts(GL,[list]), - ?line io:format(GL,"Okej~n",[]), - + receive after 500 -> ok end, % Dont clash with the new shell... + "Hej\n" = io:get_line(GL,"Prompt\n"), + io:setopts(GL,[binary]), + io:format(GL,"Okej~n",[]), + <<"Hej\n">> = io:get_line(GL,"Prompt\n"), + io:setopts(GL,[{encoding,latin1}]), + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = chomp(io:request(GL,{get_line,latin1,"Prompt\n"})), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), + io:setopts(GL,[{encoding,unicode}]), + + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = chomp(io:request(GL,{get_line,latin1,"Prompt\n"})), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = chomp(io:get_line(GL,"Prompt\n")), + io:setopts(GL,[list]), + io:format(GL,"Okej~n",[]), + %%get_chars - ?line "Hej" = io:get_chars(GL,"Prompt\n",3), - ?line io:setopts(GL,[binary]), - ?line io:format(GL,"Okej~n",[]), - ?line <<"Hej">> = io:get_chars(GL,"Prompt\n",3), - ?line io:setopts(GL,[{encoding,latin1}]), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = io:request(GL,{get_chars,latin1,"Prompt\n",3}), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), - ?line io:setopts(GL,[{encoding,unicode}]), - - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinLatin = io:request(GL,{get_chars,latin1,"Prompt\n",3}), - ?line io:format(GL,"Okej~n",[]), - ?line TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), - ?line io:setopts(GL,[list]), - ?line io:format(GL,"Okej~n",[]), + "Hej" = io:get_chars(GL,"Prompt\n",3), + io:setopts(GL,[binary]), + io:format(GL,"Okej~n",[]), + <<"Hej">> = io:get_chars(GL,"Prompt\n",3), + io:setopts(GL,[{encoding,latin1}]), + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = io:request(GL,{get_chars,latin1,"Prompt\n",3}), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), + io:setopts(GL,[{encoding,unicode}]), + + io:format(GL,"Okej~n",[]), + TestDataLine1BinLatin = io:request(GL,{get_chars,latin1,"Prompt\n",3}), + io:format(GL,"Okej~n",[]), + TestDataLine1BinUtf = io:get_chars(GL,"Prompt\n",3), + io:setopts(GL,[list]), + io:format(GL,"Okej~n",[]), %%fread - ?line {ok,["Hej"]} = io:fread(GL,"Prompt\n","~s"), - ?line io:setopts(GL,[binary]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,["Hej"]} = io:fread(GL,"Prompt\n","~s"), - ?line io:setopts(GL,[{encoding,latin1}]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), - ?line io:setopts(GL,[{encoding,unicode}]), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), - ?line io:format(GL,"Okej~n",[]), - ?line {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), - ?line io:setopts(GL,[list]), - ?line io:format(GL,"Okej~n",[]), - - - ?line receive - {AM1,done} -> - ok - after 5000 -> - exit(timeout) - end, + {ok,["Hej"]} = io:fread(GL,"Prompt\n","~s"), + io:setopts(GL,[binary]), + io:format(GL,"Okej~n",[]), + {ok,["Hej"]} = io:fread(GL,"Prompt\n","~s"), + io:setopts(GL,[{encoding,latin1}]), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), + io:setopts(GL,[{encoding,unicode}]), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), + io:format(GL,"Okej~n",[]), + {ok,[TestDataLine1]} = io:fread(GL,"Prompt\n","~s"), + io:setopts(GL,[list]), + io:format(GL,"Okej~n",[]), + + + receive + {AM1,done} -> + ok + after 5000 -> + exit(timeout) + end, ok. @@ -1252,10 +1252,10 @@ broken_unicode(Config) when is_list(Config) -> lists:duplicate(10,lists:seq(0,255))), file:write_file(Latin1Name,Latin1Data), file:write_file(Utf8Name,Utf8Data), - ?line [ latin1 = heuristic_encoding_file2(Latin1Name,N,utf8) || N <- lists:seq(1,100)++[1024,2048,10000]], - ?line [ utf8 = heuristic_encoding_file2(Utf8Name,N,utf8) || N <- lists:seq(1,100)++[1024,2048,10000]], - ?line [ latin1 = heuristic_encoding_file2(Latin1Name,N,utf16) || N <- lists:seq(1,100)++[1024,2048,10000]], - ?line [ latin1 = heuristic_encoding_file2(Latin1Name,N,utf32) || N <- lists:seq(1,100)++[1024,2048,10000]], + [ latin1 = heuristic_encoding_file2(Latin1Name,N,utf8) || N <- lists:seq(1,100)++[1024,2048,10000]], + [ utf8 = heuristic_encoding_file2(Utf8Name,N,utf8) || N <- lists:seq(1,100)++[1024,2048,10000]], + [ latin1 = heuristic_encoding_file2(Latin1Name,N,utf16) || N <- lists:seq(1,100)++[1024,2048,10000]], + [ latin1 = heuristic_encoding_file2(Latin1Name,N,utf32) || N <- lists:seq(1,100)++[1024,2048,10000]], ok. @@ -1294,10 +1294,10 @@ eof_on_pipe(Config) when is_list(Config) -> end end, CommandLine1 = EchoLine ++ - "\""++Erl++"\" -noshell -eval " - "'io:format(\"~p\",[io:get_line(\"\")])," - "io:format(\"~p\",[io:get_line(\"\")])," - "io:format(\"~p\",[io:get_line(\"\")]).' -run init stop", + "\""++Erl++"\" -noshell -eval " + "'io:format(\"~p\",[io:get_line(\"\")])," + "io:format(\"~p\",[io:get_line(\"\")])," + "io:format(\"~p\",[io:get_line(\"\")]).' -run init stop", case os:cmd(CommandLine1) of "\"a\\n\"\"bu\"eof" -> ok; @@ -1305,10 +1305,10 @@ eof_on_pipe(Config) when is_list(Config) -> exit({unexpected1,Other1}) end, CommandLine2 = EchoLine ++ - "\""++Erl++"\" -noshell -eval " - "'io:setopts([binary]),io:format(\"~p\",[io:get_line(\"\")])," - "io:format(\"~p\",[io:get_line(\"\")])," - "io:format(\"~p\",[io:get_line(\"\")]).' -run init stop", + "\""++Erl++"\" -noshell -eval " + "'io:setopts([binary]),io:format(\"~p\",[io:get_line(\"\")])," + "io:format(\"~p\",[io:get_line(\"\")])," + "io:format(\"~p\",[io:get_line(\"\")]).' -run init stop", case os:cmd(CommandLine2) of "<<\"a\\n\">><<\"bu\">>eof" -> ok; @@ -1317,12 +1317,12 @@ eof_on_pipe(Config) when is_list(Config) -> end catch throw:skip -> - {skipped,"unsupported echo program"} + {skipped,"unsupported echo program"} end; {_,_} -> {skipped,"Only on linux"} end. - + %% %% Tool for running interactive shell (stolen from the kernel @@ -1392,16 +1392,16 @@ timeout(normal) -> -ifndef(debug). rm_rf(Dir) -> try - {ok,List} = file:list_dir(Dir), - Files = [filename:join([Dir,X]) || X <- List], - [case file:list_dir(Y) of - {error, enotdir} -> - ok = file:delete(Y); - _ -> - ok = rm_rf(Y) - end || Y <- Files], - ok = file:del_dir(Dir), - ok + {ok,List} = file:list_dir(Dir), + Files = [filename:join([Dir,X]) || X <- List], + [case file:list_dir(Y) of + {error, enotdir} -> + ok = file:delete(Y); + _ -> + ok = rm_rf(Y) + end || Y <- Files], + ok = file:del_dir(Dir), + ok catch _:Exception -> {error, {Exception,Dir}} end. @@ -1466,7 +1466,7 @@ get_and_put(CPid, [{putline_raw, Line}|T],N) -> Timeout = timeout(normal), receive {send_line, ok} -> - get_and_put(CPid, T,N+1) + get_and_put(CPid, T,N+1) after Timeout -> error_logger:error_msg("~p: putline_raw timeout (~p) sending " "\"~s\" (command number ~p)~n", @@ -1480,7 +1480,7 @@ get_and_put(CPid, [{putline, Line}|T],N) -> Timeout = timeout(normal), receive {send_line, ok} -> - get_and_put(CPid, [{getline, []}|T],N) + get_and_put(CPid, [{getline, []}|T],N) after Timeout -> error_logger:error_msg("~p: putline timeout (~p) sending " "\"~s\" (command number ~p)~n[~p]~n", @@ -1497,8 +1497,8 @@ wait_for_runerl_server(SPid) -> after Timeout -> {error, timeout} end. - - + + stop_runerl_node(CPid) -> Ref = erlang:monitor(process, CPid), @@ -1549,8 +1549,8 @@ create_tempdir(Dir,X) when X > $Z, X < $a -> create_tempdir(Dir,$a); create_tempdir(Dir,X) when X > $z -> Estr = lists:flatten( - io_lib:format("Unable to create ~s, reason eexist", - [Dir++[$z]])), + io_lib:format("Unable to create ~s, reason eexist", + [Dir++[$z]])), {error, Estr}; create_tempdir(Dir0, Ch) -> %% Expect fairly standard unix. @@ -1591,8 +1591,8 @@ start_runerl_node(RunErl,Erl,Tempdir,Nodename,Extra) -> []; _ -> " -sname "++(if is_atom(Nodename) -> atom_to_list(Nodename); - true -> Nodename - end)++ + true -> Nodename + end)++ " -setcookie "++atom_to_list(erlang:get_cookie()) end, XXArg = case Extra of @@ -1603,9 +1603,9 @@ start_runerl_node(RunErl,Erl,Tempdir,Nodename,Extra) -> end, spawn(fun() -> ?dbg("\""++RunErl++"\" "++Tempdir++"/ "++Tempdir++ - " \""++Erl++XArg++XXArg++"\""), + " \""++Erl++XArg++XXArg++"\""), os:cmd("\""++RunErl++"\" "++Tempdir++"/ "++Tempdir++ - " \""++Erl++XArg++XXArg++"\"") + " \""++Erl++XArg++XXArg++"\"") end). start_toerl_server(ToErl,Tempdir) -> @@ -1663,7 +1663,7 @@ toerl_loop(Port,Acc) -> _ -> toerl_loop(Port,[{Tag0,Data}|Acc]) end; - {Pid,{get_line,Timeout}} -> + {Pid,{get_line,Timeout}} -> case Acc of [] -> case get_data_within(Port,Timeout,[]) of @@ -1712,10 +1712,10 @@ toerl_loop(Port,Acc) -> Other -> {error, {unexpected, Other}} end. - + millistamp() -> erlang:monotonic_time(milli_seconds). - + get_data_within(Port, X, Acc) when X =< 0 -> ?dbg({get_data_within, X, Acc, ?LINE}), receive @@ -1834,8 +1834,8 @@ request({get_until, Encoding, Prompt, M, F, As}, State) -> {ok, convert(State#state.nxt, Encoding, State#state.mode), State#state{nxt = eof, q = [{get_until, Encoding, Prompt, M, F, As} | State#state.q]}}; request({get_chars, Encoding, Prompt, N}, State) -> {ok, convert(State#state.nxt, Encoding, State#state.mode), State#state{nxt = eof, - q = [{get_chars, Encoding, Prompt, N} | - State#state.q]}}; + q = [{get_chars, Encoding, Prompt, N} | + State#state.q]}}; request({get_line, Encoding, Prompt}, State) -> {ok, convert(State#state.nxt, Encoding, State#state.mode), State#state{nxt = eof, @@ -1867,7 +1867,7 @@ request(getopts, State) -> binary -> [{binary, true}] end, State#state{q=[getopts | State#state.q ]}}; request({requests, Reqs}, State) -> - multi_request(Reqs, {ok, ok, State}). + multi_request(Reqs, {ok, ok, State}). multi_request([R|Rs], {ok, _Res, State}) -> multi_request(Rs, request(R, State)); @@ -1898,7 +1898,7 @@ convert(Data, latin1, binary) -> _ -> {error, {cannot_convert, unicode, latin1}} end. - + hostname() -> from($@, atom_to_list(node())). |