[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 02/22] golang/xenlight: define Defbool builtin type



> I implemented some tests for these methods to make sure everything
> worked as expected (they did); but there's an unexpected side-effect:
>
> -  *_test.go files cannot `import "C"`

Yeah, this is unfortunate.

> - The fromC / toC methods aren't exported
>
> So it's not possible to do the following check:
>
>   var b Defbool
>
>   b.Set(true)
>   cb, err := b.toC()
>   if ( !C.libxl_defbool_val(cb) ) {
>     // report an error
>   }
>
> defbool_test.go can't `import "C"`, so it can't call
> C.libxl_defbool_val().  We could make an external xenlighttest package,
> but that wouldn't be able to call toC().
>
> (I suppose we could write "proxy" functions for every such function we
> might want to check, but that seems excessive.)

If by "proxy" functions you mean something like:

func libxlDefboolVal(db Defbool) bool {
        return C.libxl_defbool_val(C.libxl_defbool(db))
}

I agree it could be a bit excessive. But, it might be necessary in
order to leverage go test. And, we could make sure that those extra
"proxy" functions are only included in test builds (maybe by making
internal package to house them).

Maybe there is a better solution to this. I'll need to think about it some more.

-NR

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.