~ci-train-bot/biometryd/biometryd-ubuntu-yakkety-1978

« back to all changes in this revision

Viewing changes to src/biometry/cmds/test.cpp

Merge lp:~thomas-voss/biometryd/identify-in-a-loop-for-test

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
}
46
46
 
47
47
biometry::cmds::Test::Test()
48
 
    : CommandWithFlagsAndAction{cli::Name{"test"}, cli::Usage{"executes runtime tests for a device"}, cli::Description{"executes runtime tests for a device"}},
49
 
      user{biometry::User::current()}
 
48
    : CommandWithFlagsAndAction{cli::Name{"test"}, cli::Usage{"executes runtime tests for a device"}, cli::Description{"executes runtime tests for a device"}}
50
49
{
51
50
    flag(cli::make_flag(cli::Name{"config"}, cli::Description{"configuration file for the test"}, config));
52
 
    flag(cli::make_flag(cli::Name{"user"}, cli::Description{"The numeric user id for testing purposes"}, user));
 
51
    flag(cli::make_flag(cli::Name{"user"}, cli::Description{"The numeric user id for testing purposes"}, user = biometry::User::current()));
 
52
    flag(cli::make_flag(cli::Name{"trials"}, cli::Description{"Number of identification trials"}, trials = 20));
 
53
 
53
54
    action([this](const cli::Command::Context& ctxt)
54
55
    {
55
56
        if (not config) throw cli::Command::FlagsMissing{};
119
120
        std::make_shared<biometry::TracingObserver<biometry::TemplateStore::SizeQuery>>(2, ctxt.cout));
120
121
 
121
122
    ctxt.cout << "Identifying user:" << std::endl;
122
 
    device->identifier().identify_user(biometry::Application::system(), biometry::Reason{"testing"})->start_with_observer(
123
 
        std::make_shared<biometry::TracingObserver<biometry::Identification>>(2, ctxt.cout));
 
123
 
 
124
    for (std::uint32_t i = 0; i < trials; i++)
 
125
    {
 
126
        ctxt.cout << "  Trial " << i << ": " << std::endl;
 
127
        device->identifier().identify_user(biometry::Application::system(), biometry::Reason{"testing"})
 
128
            ->start_with_observer(
 
129
                std::make_shared<biometry::TracingObserver<biometry::Identification>>(4, ctxt.cout));
 
130
    }
124
131
 
125
132
    return EXIT_SUCCESS;
126
133
}