All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ronald Rojas <ronladred@gmail.com>
To: George Dunlap <george.dunlap@citrix.com>
Cc: wei.liu2@citrix.com, Ian Jackson <ian.jackson@eu.citrix.com>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH v2 5/5] golang/xenlight: Add tests host related functionality functions
Date: Thu, 2 Mar 2017 13:22:40 -0500	[thread overview]
Message-ID: <20170302182240.GA26686@debian.rojas> (raw)
In-Reply-To: <6d64e672-cae0-b165-7869-c452beb961b8@citrix.com>

On Thu, Mar 02, 2017 at 05:53:00PM +0000, George Dunlap wrote:
> On 02/03/17 17:36, Ian Jackson wrote:
> > Ronald Rojas writes ("[PATCH v2 5/5] golang/xenlight: Add tests host related functionality functions"):
> >> Create tests for the following functions:
> >> - GetVersionInfo
> >> - GetPhysinfo
> >> - GetDominfo
> >> - GetMaxCpus
> >> - GetOnlineCpus
> >> - GetMaxNodes
> >> - GetFreeMemory
> > 
> > I assume this whole series is RFC still ?
> 
> I think the earlier patches looked pretty close to being checked in.  I
> think having a basic chunk of functionality checked in will make it
> easier to actually collaborate on improving things.
> 
> > I don't feel competent to review the golang code.  But I did spot some
> > C to review :-)
> > 
> >> diff --git a/tools/golang/xenlight/test/xeninfo/freememory.c b/tools/golang/xenlight/test/xeninfo/freememory.c
> >> new file mode 100644
> >> index 0000000..04ee90d
> >> --- /dev/null
> >> +++ b/tools/golang/xenlight/test/xeninfo/freememory.c
> >> @@ -0,0 +1,24 @@
> >> +#include <stdio.h>
> >> +#include <stdlib.h>
> >> +#include <libxl.h>
> >> +#include "print.h"
> >> +
> >> +int main(){
> > 
> > This is an unusual definition of main.  (I think it's still legal, but
> > probably not what you meant.)
> > 

I did this because I'm not expecting any arguments  to be passed into
main. I can change it to the standard definition instead.

> >> +    libxl_ctx *context;
> >> +    libxl_ctx_alloc(&context,LIBXL_VERSION, 0, NULL);
> >> +
> >> +    uint64_t free_memory;
> >> +    int err = libxl_get_free_memory(context, &free_memory);
> >> +    if (err < 0)
> >> +    {
> >> +        printf("%d\n", err);
> >> +    }
> >> +    else
> >> +    {
> >> +        printf("%lu\n", free_memory);
> >> +    }
> > 
> > This output is ambiguous.
> > 
> >> +    libxl_ctx_free(context);
> >> +
> >> +}
> > 
> > Returns from main without returning a value.  Error code is lost.
> 
> He's not testing whether the call succeeds; he's testing if the call has
> the same result as the golang function.
> 
> But this won't quite work anymore, because as of v2 the golang return
> values are positive constants (to make it easy to use them for indexes).
>  So if there were an identical error, the output would be different even
> if the error number were identical.

You are right. I need to negate the value that I print in the go file.

> 
> That needs to be fixed; but I also agree it would probably be better to
> print something that distinguishes between success and failure.

I think it's always clear whether the function failed or succeeded. The
error code will always be a negative number while free_memory can only
be non-negative because it is an unsigned long. There is no overlap
between those two values.


Ronald

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-03-02 18:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02 16:07 [PATCH v2 1/5] golang/xenlight: Create stub package Ronald Rojas
2017-03-02 16:07 ` [PATCH v2 2/5] golang/xenlight: Add error constants and standard handling Ronald Rojas
2017-03-03 14:47   ` George Dunlap
2017-03-02 16:07 ` [PATCH v2 3/5] golang/xenlight: Add host-related functionality Ronald Rojas
2017-03-03 14:54   ` George Dunlap
2017-03-03 18:49     ` Ronald Rojas
2017-03-02 16:07 ` [PATCH v2 4/5] golang/xenlight: Implement libxl_domain_info and libxl_domain_unpause Ronald Rojas
2017-03-03 15:15   ` George Dunlap
2017-03-03 19:31     ` Ronald Rojas
2017-03-02 16:07 ` [PATCH v2 5/5] golang/xenlight: Add tests host related functionality functions Ronald Rojas
2017-03-02 17:36   ` Ian Jackson
2017-03-02 17:53     ` George Dunlap
2017-03-02 17:55       ` Ian Jackson
2017-03-02 18:01         ` George Dunlap
2017-03-03 15:02           ` Ian Jackson
2017-03-03 15:10             ` George Dunlap
2017-03-03 15:41               ` Ian Jackson
2017-03-02 18:22       ` Ronald Rojas [this message]
2017-03-03 16:20   ` George Dunlap
2017-03-03 14:42 ` [PATCH v2 1/5] golang/xenlight: Create stub package George Dunlap

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170302182240.GA26686@debian.rojas \
    --to=ronladred@gmail.com \
    --cc=george.dunlap@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.