Esempio n. 1
0
static int _chibi_suite_run(chibi_suite *suite, void (*report_num_tests)(int),
                            void (*report_success)(int, chibi_testcase *),
                            void (*report_fail)(int, chibi_testcase *),
                            int tcnum, int level)
{
    if (suite) {
        chibi_testcase *testcase;

        if (suite->first_child) {
            tcnum = _chibi_suite_run(suite->first_child, report_num_tests,
                                     report_success, report_fail, tcnum, level + 1);
        }
        if (suite->next) {
            tcnum = _chibi_suite_run(suite->next, report_num_tests,
                                     report_success, report_fail, tcnum, level + 1);
        }

        /* only report the number of tests at the top level */
        if (level == 0) report_num_tests(_count_tests(suite));

        /* run this level's tests */
        testcase = suite->head;
        while (testcase) {
#ifndef AMIGA
            if (!setjmp(testcase->env)) {
#endif
                if (suite->setup) suite->setup(suite->userdata);
                testcase->fun(testcase);
                if (suite->teardown) suite->teardown(suite->userdata);
#ifndef AMIGA
            }
#endif
            if (testcase->success) report_success(tcnum, testcase);
            else report_fail(tcnum, testcase);
            testcase = testcase->next;
            tcnum++;
        }
    }
    return tcnum;
}
Esempio n. 2
0
int symex_parseoptionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }

  register_language(new_ansi_c_language);
  register_language(new_cpp_language);

  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);

  eval_verbosity();

  goto_functionst goto_functions;

  if(get_goto_program(options, goto_functions))
    return 6;

  label_properties(goto_functions);

  if(cmdline.isset("show-properties"))
  {
    const namespacet ns(symbol_table);
    show_properties(ns, get_ui(), goto_functions);
    return 0;
  }

  if(set_properties(goto_functions))
    return 7;

  if(cmdline.isset("show-locs"))
  {
    const namespacet ns(symbol_table);
    locst locs(ns);
    locs.build(goto_functions);
    locs.output(std::cout);
    return 0;
  }

  // do actual Symex

  try
  {
    const namespacet ns(symbol_table);
    path_searcht path_search(ns);

    path_search.set_message_handler(get_message_handler());
    path_search.set_verbosity(get_verbosity());

    if(cmdline.isset("depth"))
      path_search.depth_limit=unsafe_string2unsigned(cmdline.getval("depth"));

    if(cmdline.isset("context-bound"))
      path_search.context_bound=unsafe_string2unsigned(cmdline.getval("context-bound"));

    if(cmdline.isset("unwind"))
      path_search.unwind_limit=unsafe_string2unsigned(cmdline.getval("unwind"));

    if(cmdline.isset("show-vcc"))
    {
      path_search.show_vcc=true;
      path_search(goto_functions);
      return 0;
    }

    // do actual symex
    switch(path_search(goto_functions))
    {
    case safety_checkert::SAFE:
      report_properties(path_search.property_map);
      report_success();
      return 0;

    case safety_checkert::UNSAFE:
      report_properties(path_search.property_map);
      report_failure();
      return 10;

    default:
      return 8;
    }
  }

  catch(const std::string error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  catch(const char *error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  #if 0
  // let's log some more statistics
  debug() << "Memory consumption:" << messaget::endl;
  memory_info(debug());
  debug() << eom;
  #endif
}
Esempio n. 3
0
int symex_parse_optionst::doit()
{
  if(cmdline.isset("version"))
  {
    std::cout << CBMC_VERSION << std::endl;
    return 0;
  }

  register_language(new_ansi_c_language);
  register_language(new_cpp_language);
  register_language(new_java_bytecode_language);

  //
  // command line options
  //

  optionst options;
  get_command_line_options(options);

  eval_verbosity();

  goto_model.set_message_handler(get_message_handler());

  if(goto_model(cmdline.args))
    return 6;

  if(process_goto_program(options))
    return 6;

  label_properties(goto_model);

  if(cmdline.isset("show-properties"))
  {
    show_properties(goto_model, get_ui());
    return 0;
  }

  if(set_properties())
    return 7;

  if(cmdline.isset("show-locs"))
  {
    const namespacet ns(goto_model.symbol_table);
    locst locs(ns);
    locs.build(goto_model.goto_functions);
    locs.output(std::cout);
    return 0;
  }

  // do actual Symex

  try
  {
    const namespacet ns(goto_model.symbol_table);
    path_searcht path_search(ns);

    path_search.set_message_handler(get_message_handler());

    if(cmdline.isset("depth"))
      path_search.set_depth_limit(unsafe_string2unsigned(cmdline.get_value("depth")));

    if(cmdline.isset("context-bound"))
      path_search.set_context_bound(unsafe_string2unsigned(cmdline.get_value("context-bound")));

    if(cmdline.isset("branch-bound"))
      path_search.set_branch_bound(unsafe_string2unsigned(cmdline.get_value("branch-bound")));

    if(cmdline.isset("unwind"))
      path_search.set_unwind_limit(unsafe_string2unsigned(cmdline.get_value("unwind")));

    if(cmdline.isset("dfs"))
      path_search.set_dfs();

    if(cmdline.isset("bfs"))
      path_search.set_bfs();

    if(cmdline.isset("locs"))
      path_search.set_locs();

    if(cmdline.isset("show-vcc"))
    {
      path_search.show_vcc=true;
      path_search(goto_model.goto_functions);
      return 0;
    }

    path_search.eager_infeasibility=
      cmdline.isset("eager-infeasibility");

    if(cmdline.isset("cover"))
    {
      // test-suite generation
      path_search(goto_model.goto_functions);
      report_cover(path_search.property_map);
      return 0;
    }
    else
    {
      // do actual symex, for assertion checking
      switch(path_search(goto_model.goto_functions))
      {
      case safety_checkert::SAFE:
        report_properties(path_search.property_map);
        report_success();
        return 0;

      case safety_checkert::UNSAFE:
        report_properties(path_search.property_map);
        report_failure();
        return 10;

      default:
        return 8;
      }
    }
  }

  catch(const std::string error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  catch(const char *error_msg)
  {
    error() << error_msg << messaget::eom;
    return 8;
  }

  #if 0
  // let's log some more statistics
  debug() << "Memory consumption:" << messaget::endl;
  memory_info(debug());
  debug() << eom;
  #endif
}