On 12/5/19 3:23 PM, Nick Rosbrook wrote: >> 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.
I mean, we already copy the source files over somewhere else. We could generate ctestproxies.go, and make a xenlighttestable package which includes that file (and the _test.go files), and a xenlight package which doesn't. But I'd say that's a lower priority at this point. -George _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel