[zeromq-dev] Adding new tests to Malamute

Osiris Pedroso opedroso at gmail.com
Fri May 6 18:04:29 CEST 2016


Here is the code:
```
zmsg_t *mlm_client_content (mlm_client_t *self)
{
    assert (self);
    return self->content;
}
```
Can't add lots of printfs, at least not smart ones.

I thought it was an implicit contract that when an API says it returns a
pointer to type X, that the returned pointer points to a valid object of
type X.
I should be able to all methods on that class at least.

Here is the documentation for zmsg_is ():
```
    //  Probe the supplied object, and report if it looks like a zmsg_t.
    CZMQ_EXPORT bool zmsg_is (void *self);
```
If one calls zmsg_is() on the pointer returned by the API above, it returns
false.

This means that the returned zmsg_t* does not look like a zmsg.

Further looked into calling other methods on the zmsg_t* received:
```
//  Return size of message, i.e. number of frames (0 or more).
size_t zmsg_size (zmsg_t *self)
{
    assert (self);
    assert (zmsg_is (self));

    return zlist_size (self->frames);
}
```
The check on zmsg_is () prevents calling any further methods.

I searched the whole zeromq for every place "content =" appears. They are
always zmsg_new(), zmsg_dup(), zmsg_recv(), mlm_client_recv(). I would
expect all of these returns to return true when calling zmsg_is().



On Thu, May 5, 2016 at 4:28 PM Kevin Sapper <kevinsapper88 at gmail.com> wrote:

> I agree enabled verbose and add lots of printf statements. Expect that it
> will take you a day or two to understand.
> Am 05.05.2016 10:32 nachm. schrieb "Pieter Hintjens" <ph at imatix.com>:
>
>> The best way to understand what's going on is to look at the code for
>> mlm_client_content () and possibly debug by adding printfs as it runs.
>> This is really educational and will help you use Malamute better.
>>
>> Please do read & follow coding style on all patches, space before '('
>> and noNamesLikeThis.
>>
>> Cheers :)
>> Pieter
>>
>> On Thu, May 5, 2016 at 5:25 PM, Osiris Pedroso <opedroso at gmail.com>
>> wrote:
>> > I am in the process of adding a few new tests to malamute self tests,
>> > learning its API in the process.
>> >
>> > They will target specific portions of the APIs:
>> >
>> > mlm_stream_api_test      (single broadcaster, single listener)
>> > mlm_service_api_test      (single requester, single service provider)
>> > mlm_services_api_test    (multiple requesters, multiple service
>> providers)
>> > mlm_mailbox_api_test
>> >
>> > I am midway through the services API (#3) test and encountered an
>> unexpected
>> > behavior (see last code line):
>> > ```
>> > // define that requesters will generate printJob events
>> > rc = mlm_client_set_producer(requester1, "printServiceStream");
>> > assert(rc == 0);
>> > rc = mlm_client_set_producer(requester2, "printServiceStream");
>> > assert(rc == 0);
>> > // define that workers will listen to printJob events related to
>> requests
>> > rc = mlm_client_set_consumer(worker1, "printServiceStream",
>> "request.*");
>> > assert(rc == 0);
>> > rc = mlm_client_set_consumer(worker2, "printServiceStream",
>> "request.*");
>> > assert(rc == 0);
>> >
>> > rc = mlm_client_sendx(requester1, "request", "start", NULL);
>> > assert(rc == 0);
>> >
>> > rc = mlm_client_recvx(worker1, &subject, &content, NULL);
>> > assert(rc != -1);
>> >
>> > assert(mlm_client_status(worker1) == 0);
>> > assert(streq(mlm_client_command(worker1), "STREAM DELIVER"));
>> > assert(mlm_client_reason(worker1) == NULL);
>> > assert(streq(mlm_client_address(worker1), "printServiceStream"));
>> > assert(streq(mlm_client_sender(worker1), "requesterAddress1"));
>> > assert(streq(mlm_client_subject(worker1), "request"));
>> > assert(mlm_client_tracker(worker1) == NULL);
>> > zmsg_t *zmsg_content = mlm_client_content(worker1);
>> > assert(zmsg_content != NULL);
>> > int isZmsg = zmsg_is(zmsg_content);
>> > assert(isZmsg == 0); // don't understand why, but this is the return
>> value
>> > ```
>> >
>> > The problem is that the zmsg* returned by mlm_client_content() does not
>> seem
>> > like a valid zmsg* according to zmsg_is(). The tag value in the message
>> is
>> > 0xfeeefeee, but the expected value is 0x0003cafe
>> >
>> > Since it is a zmsg_t* returned by malamute itself , I expected it to be
>> a
>> > valid zmsg.
>> >
>> > Please advise.
>> >
>> >
>> > _______________________________________________
>> > zeromq-dev mailing list
>> > zeromq-dev at lists.zeromq.org
>> > http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>> _______________________________________________
>> zeromq-dev mailing list
>> zeromq-dev at lists.zeromq.org
>> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
>>
> _______________________________________________
> zeromq-dev mailing list
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20160506/b371d0b3/attachment.htm>


More information about the zeromq-dev mailing list