Re: [Pkg-octave-devel] Open ToDos for Wheezy
2012-06-20 21:22, Thomas Weber skrev:
> On Wed, Jun 20, 2012 at 01:45:40PM +0200, Paul Dreik wrote:
>> I agree there has not been any real development, but it is still useful.
>> I do not see the problem, as the package works as intended as far as I
>> know.
> The problem here is the word "know". There are two ways to get some
> assurance that a package works (at least somewhat):
>
> 1) You use it routinely.
> 2) It comes with tests.
>
> I (and probably nobody else on this list) use the sockets package, so 1)
> is out. And for 2), somebody needs to step up and convert the existing
> tests into something that can be run at build time (the easiest way is
> probably to convert the tests into using Octave's test harness).
>
> I left out option 3) which goes along the lines of "just upload it and
> give a damn about the rest", which seems to be quite popular elsewhere.
>
> So, I don't mind re-introducing the package, but please: convert the
> tests first so that there is at least some chance that errors are
> caught.
>
> Thanks
> Thomas
Well, I have actually used the package and implemented a client
communicating with a server using a binary protocol. I have sent quite a
lot of data through it, and I have not seen anything wrong with the
package. Or actually, there was a terrible memory leak which I fixed and
applied upstream, but the later versions work fine. This was on lenny,
using 1.0.6, but as you say, not much has changed in the package.
I took the time to convert the existing upstream test to be in the .cc
file, which has the drawback that the test must have access to the .cc
file. I do not know if you (debian octave group) run the tests manually
or automated? Could I do anything more, or is that sufficient? Or did
you mean the test should be run from a makefile target?
I attach the test, which should be appended to sockets.cc.
I have run it on octave 3.6.2 built from source, in ubuntu 12.04, and it
passes the test. The original test is what existed in the upstream
socket package, I have only modified it to be able to run it with the
octave test function.
In the meanwhile, I have also made changes for the gcc 4.7 ftbfs error
but I wait for commit access on octave forge to work for me. I guess you
already saw the message on the octave dev list.
I am glad you try to keep the Debian octave quality level at a high level!
Paul
/*
%!test
%!function fail = dotest()
%! fail = 0;
%!
%! # Create the sockets
%! ## Server socket
%! server = socket(AF_INET, SOCK_STREAM, 0);
%! if ( server < 0 )
%! ++fail;
%! return
%! end
%!
%! rc = bind(server,9001);
%! if ( rc ~= 0 )
%! ++fail;
%! return
%! end
%!
%! rc = listen(server,1);
%! if ( rc ~= 0 )
%! ++fail;
%! return
%! end
%!
%! ## Client socket
%! client = socket(AF_INET, SOCK_STREAM, 0);
%! if ( client < 0 )
%! ++fail;
%! return
%! end
%!
%! # Create the connection and accept the connection
%! server_info = struct("addr", "127.0.0.1", "port", 9001);
%! rc = connect(client, server_info);
%! if ( rc ~= 0 )
%! ++fail;
%! return
%! end
%!
%! server_data = accept(server);
%! if ( server_data < 0 )
%! ++fail;
%! return
%! end
%!
%! # Send and receive data
%!
%! ## Send as string from client
%! msg = "Hello socket-land!";
%! rc = send(client, msg);
%! if ( rc ~= length(msg) )
%! ++fail;
%! return
%! end
%!
%! ## Receive at server
%! [msg_s, len_s] = recv(server_data, 100);
%! if ( msg_s == -1 || len_s ~= length(msg) )
%! ++fail;
%! return
%! end
%!
%! ## Send back out from server
%! rc = send(server_data, msg_s);
%! if ( rc ~= length(msg_s) )
%! ++fail;
%! return
%! end
%!
%! ## Receive at client
%! [msg_c, len_c] = recv(client, 100);
%! if ( msg_c == -1 || len_c ~= length(msg) )
%! ++fail;
%! return
%! end
%!
%! ## Compare original string with recv string
%! msg_in = num2str(msg_c, '%c');
%! if ( msg_in ~= msg )
%! ++fail;
%! return
%! end
%!
%! disconnect(client);
%! disconnect(server_data);
%! disconnect(server);
%!endfunction
%!test
%! fail=dotest();
%! printf('Number of failures: %d\n', fail);
*/
Reply to: