Example #1
0
static void
test_init_match_table_dies_if_already_initialized() {
  init_match_table();
  assert_true( _match_table_head != NULL );
  expect_assert_failure( init_match_table() );
  finalize_match_table();
}
Example #2
0
static void
test_insert_and_delete_of_exact_all_entry_failed() {
  setup();

  struct ofp_match lookup_match;
  match_entry *match_entry;

  init_match_table();

  intsert_alice_match_entry();
  intsert_bob_match_entry();
  intsert_carol_match_entry();

  delete_carol_match_entry();
  set_carol_match_entry( &lookup_match );
  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry == NULL );

  delete_bob_match_entry();
  set_bob_match_entry( &lookup_match );
  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry == NULL );

  delete_alice_match_entry();
  set_alice_match_entry( &lookup_match );
  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry == NULL );

  finalize_match_table();

  teardown();
}
/**
 * @name cc_recog
 *
 * Recognize a word.
 */
BLOB_CHOICE_LIST_VECTOR *Wordrec::cc_recog(TWERD *tessword,
                                           WERD_CHOICE *best_choice,
                                           WERD_CHOICE *best_raw_choice,
                                           BOOL8 tester,
                                           BOOL8 trainer,
                                           bool last_word_on_line) {
  int fx;
  BLOB_CHOICE_LIST_VECTOR *results;          /*matcher results */

  if (SetErrorTrap (NULL)) {
    cprintf ("Tess copped out!\n");
    ReleaseErrorTrap();
    class_string (best_choice) = NULL;
    return NULL;
  }
  getDict().InitChoiceAccum();
  getDict().reset_hyphen_vars(last_word_on_line);
  init_match_table();
  for (fx = 0; fx < MAX_FX && (acts[OCR] & (FXSELECT << fx)) == 0; fx++);
  results =
    chop_word_main(tessword,
                   fx,
                   best_choice,
                   best_raw_choice,
                   tester,
                   trainer);
  getDict().DebugWordChoices();
  ReleaseErrorTrap();
  return results;
}
Example #4
0
static void
test_insert_and_lookup_of_exact_alice_entry_conflict() {
  setup();

  struct ofp_match lookup_match;
  match_entry *match_entry;

  init_match_table();

  intsert_alice_match_entry();
  intsert_mallory_match_entry();

  set_alice_match_entry( &lookup_match );

  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry != NULL );

  assert_memory_equal( &match_entry->ofp_match, &lookup_match, sizeof( struct ofp_match ) );
  assert_string_equal( match_entry->service_name, ALICE_MATCH_SERVICE_NAME );
  assert_string_equal( match_entry->entry_name, ALICE_MATCH_ENTRY_NAME );

  finalize_match_table();

  teardown();
}
Example #5
0
static void
test_insert_and_lookup_of_wildcard_lldp_entry() {
  setup();

  struct ofp_match match, lookup_match;
  match_entry *match_entry;

  init_match_table();

  intsert_lldp_match_entry();

  memset( &lookup_match, 0, sizeof( struct ofp_match ) );
  lookup_match.dl_type = ETH_ETHTYPE_LLDP;

  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry != NULL );

  set_lldp_match_entry( &match );
  assert_memory_equal( &match_entry->ofp_match, &match, sizeof( struct ofp_match ) );
  assert_true( match_entry->priority == LLDP_MATCH_PRIORITY );
  assert_string_equal( match_entry->service_name, LLDP_MATCH_SERVICE_NAME );
  assert_string_equal( match_entry->entry_name, LLDP_MATCH_ENTRY_NAME );

  finalize_match_table();

  teardown();
}
Example #6
0
static void
test_init_and_finalize_match_table_succeeds() {
  assert_true( _match_table_head == NULL );
  init_match_table();
  assert_true( _match_table_head != NULL );
  finalize_match_table();
  assert_true( _match_table_head == NULL );
}
Example #7
0
static void
test_delete_of_exact_alice_entry_failed() {
  setup();

  init_match_table();

  delete_alice_match_entry();

  finalize_match_table();

  teardown();
}
Example #8
0
static void
test_delete_of_wildcard_any_entry_failed() {
  setup();

  init_match_table();

  delete_any_match_entry();
  assert_true( match_table_head.wildcard_table == NULL );

  finalize_match_table();

  teardown();
}
Example #9
0
static void
test_init_and_finalize_match_table_successed() {
  setup();

  assert_true( match_table_head.exact_table == NULL );
  assert_true( match_table_head.wildcard_table == NULL );

  init_match_table();
  assert_true( match_table_head.exact_table != NULL );
  assert_true( match_table_head.wildcard_table == NULL );

  finalize_match_table();
  assert_true( match_table_head.exact_table == NULL );
  assert_true( match_table_head.wildcard_table == NULL );

  teardown();
}
Example #10
0
static void
test_lookup_of_exact_alice_entry_failed() {
  setup();

  struct ofp_match lookup_match;
  match_entry *match_entry;

  init_match_table();

  set_alice_match_entry( &lookup_match );

  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry == NULL );

  finalize_match_table();

  teardown();
}
Example #11
0
static void
test_lookup_of_wildcard_lldp_entry_failed() {
  setup();

  struct ofp_match lookup_match;
  match_entry *match_entry;

  init_match_table();

  memset( &lookup_match, 0, sizeof( struct ofp_match ) );

  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry == NULL );

  finalize_match_table();

  teardown();
}
Example #12
0
int
main( int argc, char *argv[] ) {
  init_trema( &argc, &argv );

  init_match_table();

  // built-in packetin-filter-rule
  if ( !set_match_type( argc, argv ) ) {
    usage();
    finalize_match_table();
    exit( EXIT_FAILURE );
  }

  set_packet_in_handler( handle_packet_in, NULL );

  start_trema();

  finalize_match_table();

  return 0;
}
Example #13
0
static void
test_insert_and_delete_of_wildcard_any_entry() {
  setup();

  struct ofp_match lookup_match;
  match_entry *match_entry;

  init_match_table();

  intsert_any_match_entry();
  delete_any_match_entry();

  memset( &lookup_match, 0, sizeof( struct ofp_match ) );

  match_entry = lookup_match_entry( &lookup_match );
  assert_true( match_entry == NULL );

  finalize_match_table();

  teardown();
}
Example #14
0
static void
setup_and_init() {
  setup();
  init_match_table();
}
Example #15
0
static void
init_packetin_match_table( void ) {
  init_match_table();
}