Re: [PATCH kvm-unit-tests 4/4] Add sample test using the api test harness

Avi Kivity
2010-11-28T09:21:24Z

On 11/28/2010 11:04 AM, Michael S. Tsirkin wrote:
> On Sat, Nov 27, 2010 at 11:15:54AM +0200, Avi Kivity wrote:
> > On 11/26/2010 04:17 PM, Michael S. Tsirkin wrote:
> > >> +
> > >> +int main(int ac, char **av)
> > >> +{
> > >> + kvm::system system;
> > >> + kvm::vm vm(system);
> > >> + identity::setup_vm(vm);
> > >> + kvm::vcpu vcpu(vm, 0);
> > >> + identity::vcpu thread(vcpu, set_global);
> > >> + vcpu.run();
> > >> + printf("global %d\n", global);
> > >> + return global == 1;
> > >> +}
> > >
> > >I note that no exceptions are caught. So any failure will get us a crash,
> > >is there an indication what went wrong?
> > >
> >
> > I'll add a try/catch.
>
> So we'll get a "test failed: error 11" at high level?
> That's still not very helpful for debugging.
> The specific test might be better served by assert calls after each ioctl
> than an elaborate exception handling scheme.

Particular tests will use a report(message, bool) scheme like the other
unit tests. If a test checks for an error, it will have an explicit
try/catch (or better, expect_error(std::tr1::function<>, errno).

The top-level try/catch is for unexpected errors.

--
error compiling committee.c: too many arguments to function