Пример #1
0
/* code the taskname */
t_taskcode find_taskcode(const char *task_name) {
   rb_red_blk_node *newNode;
   assert(libraryStatus == initialized);      
   
   if ( ( newNode = RBExactQuery( all_tasknames, task_name) ) ) {
      /* if already present in the collection */
      TEST_PROGRESS("find_taskcode ALREADY SPECIFIED,  %s  -->  %d\n", task_name, *(t_taskcode*) newNode->info);
      return *(t_taskcode*) (newNode->info);
   } else {
      /* still not present in the collection */
      
      /* add it to the collection of tasknames */      
      t_taskcode task_code;
      task_code = get_new_taskname_code();
      add_taskname_to_tree(task_name, task_code, all_tasknames);

      /* add it to the collection of nonspecified tasknames */      
      exist_nonspecified_tasknames = True;
      add_taskname_to_tree(task_name, task_code, nonspecified_tasknames);
      
      /* now it is already present in the tree */      
      newNode = RBExactQuery( all_tasknames, task_name);
      assert(newNode);
      TEST_PROGRESS("find_taskcode NOT YET SPECIFIED,  %s  -->  %d\n", task_name, *(t_taskcode*) newNode->info);
      return *(t_taskcode*) (newNode->info);
   }
}
Пример #2
0
static int
test_lookup(void)
{
    struct poptrie *poptrie;
    int ret;
    void *nexthop;

    /* Initialize */
    poptrie = poptrie_init(NULL, 19, 22);
    if ( NULL == poptrie ) {
        return -1;
    }

    /* No route must be found */
    if ( NULL != poptrie_lookup(poptrie, 0x1c001203) ) {
        return -1;
    }

    /* Route add */
    nexthop = (void *)1234;
    ret = poptrie_route_add(poptrie, 0x1c001200, 24, nexthop);
    if ( ret < 0 ) {
        /* Failed to add */
        return -1;
    }
    if ( nexthop != poptrie_lookup(poptrie, 0x1c001203) ) {
        return -1;
    }
    TEST_PROGRESS();

    /* Route update */
    nexthop = (void *)5678;
    ret = poptrie_route_update(poptrie, 0x1c001200, 24, nexthop);
    if ( ret < 0 ) {
        /* Failed to update */
        return -1;
    }
    if ( nexthop != poptrie_lookup(poptrie, 0x1c001203) ) {
        return -1;
    }
    TEST_PROGRESS();

    /* Route delete */
    ret = poptrie_route_del(poptrie, 0x1c001200, 24);
    if ( ret < 0 ) {
        /* Failed to update */
        return -1;
    }
    if ( NULL != poptrie_lookup(poptrie, 0x1c001203) ) {
        return -1;
    }
    TEST_PROGRESS();

    /* Release */
    poptrie_release(poptrie);

    return 0;
}
Пример #3
0
/* insert new taskname
 * and assigning to it a new code  */
void add_taskname(char* task_name) {
   t_taskcode task_code;
   assert(libraryStatus == initialized);      
   task_code = get_new_taskname_code();
   add_taskname_to_tree(task_name, task_code, all_tasknames);
   TEST_PROGRESS("add taskname %s\n", task_name);
}
Пример #4
0
/* read the file and make the table for translating tasknames into codes
 * all MPI processes read the same file so the translations can be the same
 */   
void import_tasknames_from_file(char *filename) {
   FILE *file;
   t_taskcode code;
   char task_name[MAX_TASKNAME_LEN];
   int tasknames_read;
   
   /* put the main task  */
   add_taskname(main_task_name);
   code = find_taskcode(main_task_name);
   assert (code == code_of_mainTask);
   
   file = fopen(filename, "r");
   
   /* check if the specified file with task names is valid */
   if (file == NULL) {
      printf("Warning: cannot open file with specified tasknames, file name:  %s \n", filename);
      return;
   }
   
   /* each new task name gets a new identificator  */      
   while(! feof(file))   {
      tasknames_read = fscanf(file, "%s", task_name);
      TEST_PROGRESS("tasknames_read = %d   taskname %s\n", tasknames_read, task_name );
      if ((tasknames_read) > 0) {
         add_taskname(task_name);
      } else {
         task_name[0] = 0;
      }
   }
   fclose(file);
   
}
void replay_start_task() {
  if (!css_initialized) {
    event_start_css();
    css_initialized = 1;
  }
  TEST_PROGRESS("starting task with name fake_name\n");
//   printf("create and run wd\n");
  event_start_task("fake_name");
}
void replay_start_task(int wd_id) {
  char task_name[31];
  if (!css_initialized) {
    event_start_css();
    css_initialized = 1;
  }
  TEST_PROGRESS("starting task with name: %d\n", wd_id);
  sprintf(task_name, "%d", wd_id);
  event_start_task(&task_name[0]);
}
Пример #7
0
/*
 * Initialization test
 */
static int
test_init(void)
{
    struct poptrie *poptrie;

    /* Initialize */
    poptrie = poptrie_init(NULL, 19, 22);
    if ( NULL == poptrie ) {
        return -1;
    }

    TEST_PROGRESS();

    /* Release */
    poptrie_release(poptrie);

    return 0;
}
void replay_inout_task(const char *parName, void *ptr, unsigned long element_size, unsigned long elements){
   TEST_PROGRESS("replay_inout_task parName %s  ptr ,  element_size %lu,   elements  %lu      \n",
                 parName, element_size, elements);
   event_inout_parameter(ptr);   
}
void wait_on_valgrind(void *ptr) {
   TEST_PROGRESS("wait_on_valgrind      \n");
   event_wait_on(ptr);
}
void barrier_css_valgrind (void) {
   TEST_PROGRESS("barrier_css_valgrind      \n");
   event_barrier();
}
void replay_end_task() {
  TEST_PROGRESS("ending task \n");
  event_end_task();
}
void start_new_phase_valgrind(void) {
   TEST_PROGRESS("new_phase()      \n");
   event_new_phase();   
}
Пример #13
0
static int
test_lookup(void)
{
    struct poptrie6 *poptrie;
    int ret;
    __uint128_t addr;
    void *nexthop;

    /* Initialize */
    poptrie = poptrie6_init(NULL, 19, 22);
    if ( NULL == poptrie ) {
        return -1;
    }

    /* No route must be found */
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x3, 1, 2, 3, 4);
    if ( NULL != poptrie6_lookup(poptrie, addr) ) {
        return -1;
    }

    /* Route add */
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x0, 0, 0, 0, 0);
    nexthop = (void *)1234;
    ret = poptrie6_route_add(poptrie, addr, 48, nexthop);
    if ( ret < 0 ) {
        /* Failed to add */
        return -1;
    }
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x3, 1, 2, 3, 4);
    if ( nexthop != poptrie6_lookup(poptrie, addr) ) {
        return -1;
    }
    TEST_PROGRESS();

    /* Route update */
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x0, 0, 0, 0, 0);
    nexthop = (void *)5678;
    ret = poptrie6_route_update(poptrie, addr, 48, nexthop);
    if ( ret < 0 ) {
        /* Failed to update */
        return -1;
    }
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x3, 1, 2, 3, 4);
    if ( nexthop != poptrie6_lookup(poptrie, addr) ) {
        return -1;
    }
    TEST_PROGRESS();

    /* Route delete */
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x0, 0, 0, 0, 0);
    ret = poptrie6_route_del(poptrie, addr, 48);
    if ( ret < 0 ) {
        /* Failed to update */
        return -1;
    }
    addr = IPV6ADDR(0x2001, 0xdb8, 0x1, 0x3, 1, 2, 3, 4);
    if ( NULL != poptrie6_lookup(poptrie, addr) ) {
        return -1;
    }
    TEST_PROGRESS();

    /* Release */
    poptrie6_release(poptrie);

    return 0;
}
Пример #14
0
static int
test_lookup_linx(void)
{
    struct poptrie6 *poptrie;
    FILE *fp;
    char buf[4096];
    char v6str1[256];
    char v6str2[256];
    int prefix[8];
    int prefixlen;
    int nexthop[8];
    struct in6_addr v6addr;
    int ret;
    __uint128_t addr1;
    __uint128_t addr2;
    u64 i;

    /* Load from the linx file */
    fp = fopen("tests/linx-rib-ipv6.20141225.0000.p69.txt", "r");
    if ( NULL == fp ) {
        return -1;
    }

    /* Initialize */
    poptrie = poptrie6_init(NULL, 19, 22);
    if ( NULL == poptrie ) {
        return -1;
    }

    /* Load the full route */
    i = 0;
    while ( !feof(fp) ) {
        if ( !fgets(buf, sizeof(buf), fp) ) {
            continue;
        }
        memset(prefix, 0, sizeof(int) * 8);
        memset(nexthop, 0, sizeof(int) * 8);

        ret = sscanf(buf, "%255[^'/']/%d %255s", v6str1, &prefixlen, v6str2);
        if ( ret < 0 ) {
            return -1;
        }
        ret = inet_pton(AF_INET6, v6str1, &v6addr);
        if ( 1 != ret ) {
            return -1;
        }
        addr1 = in6_addr_to_uint128(&v6addr);
        ret = inet_pton(AF_INET6, v6str2, &v6addr);
        if ( 1 != ret ) {
            return -1;
        }
        addr2 = in6_addr_to_uint128(&v6addr);

        /* Add an entry */
        ret = poptrie6_route_add(poptrie, addr1, prefixlen, (void *)(u64)addr2);
        if ( ret < 0 ) {
            return -1;
        }
        if ( 0 == i % 10000 ) {
            TEST_PROGRESS();
        }
        i++;
    }

    for ( i = 0; i < 0x100000000ULL; i++ ) {
        if ( 0 == i % 0x10000000ULL ) {
            TEST_PROGRESS();
        }
        addr1 = (((__uint128_t)0x2000) << 112) | (((__uint128_t)i) << 92);
        if ( poptrie6_lookup(poptrie, addr1)
             != poptrie6_rib_lookup(poptrie, addr1) ) {
            return -1;
        }
    }

    /* Release */
    poptrie6_release(poptrie);

    /* Close */
    fclose(fp);

    return 0;
}
void task_input_value_valgrind(const char *parName, int value, unsigned long element_size, unsigned long elements){
   TEST_PROGRESS("task_input_value_valgrind parName %s   value %d,  element_size %lu,   elements  %lu      \n",
                 parName, value, element_size, elements);
   /* do nothing on this one */
}
void replay_end_task() {
//   printf("end task\n");
  TEST_PROGRESS("ending task \n");
  event_end_task();
}
Пример #17
0
static int
test_lookup_linx_update(void)
{
    struct poptrie *poptrie;
    FILE *fp;
    char buf[4096];
    int prefix[4];
    int prefixlen;
    int nexthop[4];
    int ret;
    u32 addr1;
    u32 addr2;
    u64 i;
    int tm;
    char type;

    /* Initialize */
    poptrie = poptrie_init(NULL, 19, 22);
    if ( NULL == poptrie ) {
        return -1;
    }

    /* Load from the linx file */
    fp = fopen("tests/linx-rib.20141217.0000-p52.txt", "r");
    if ( NULL == fp ) {
        return -1;
    }

    /* Load the full route */
    i = 0;
    while ( !feof(fp) ) {
        if ( !fgets(buf, sizeof(buf), fp) ) {
            continue;
        }
        ret = sscanf(buf, "%d.%d.%d.%d/%d %d.%d.%d.%d", &prefix[0], &prefix[1],
                     &prefix[2], &prefix[3], &prefixlen, &nexthop[0],
                     &nexthop[1], &nexthop[2], &nexthop[3]);
        if ( ret < 0 ) {
            return -1;
        }

        /* Convert to u32 */
        addr1 = ((u32)prefix[0] << 24) + ((u32)prefix[1] << 16)
            + ((u32)prefix[2] << 8) + (u32)prefix[3];
        addr2 = ((u32)nexthop[0] << 24) + ((u32)nexthop[1] << 16)
            + ((u32)nexthop[2] << 8) + (u32)nexthop[3];

        /* Add an entry */
        ret = poptrie_route_add(poptrie, addr1, prefixlen, (void *)(u64)addr2);
        if ( ret < 0 ) {
            return -1;
        }
        if ( 0 == i % 10000 ) {
            TEST_PROGRESS();
        }
        i++;
    }

    /* Close */
    fclose(fp);

    /* Load from the update file */
    fp = fopen("tests/linx-update.20141217.0000-p52.txt", "r");
    if ( NULL == fp ) {
        return -1;
    }

    /* Load the full route */
    i = 0;
    while ( !feof(fp) ) {
        if ( !fgets(buf, sizeof(buf), fp) ) {
            continue;
        }
        ret = sscanf(buf, "%d %c %d.%d.%d.%d/%d %d.%d.%d.%d", &tm, &type,
                     &prefix[0], &prefix[1], &prefix[2], &prefix[3], &prefixlen,
                     &nexthop[0], &nexthop[1], &nexthop[2], &nexthop[3]);
        if ( ret < 0 ) {
            return -1;
        }

        /* Convert to u32 */
        addr1 = ((u32)prefix[0] << 24) + ((u32)prefix[1] << 16)
            + ((u32)prefix[2] << 8) + (u32)prefix[3];
        addr2 = ((u32)nexthop[0] << 24) + ((u32)nexthop[1] << 16)
            + ((u32)nexthop[2] << 8) + (u32)nexthop[3];

        if ( 'a' == type ) {
            /* Add an entry (use update) */
            ret = poptrie_route_update(poptrie, addr1, prefixlen,
                                       (void *)(u64)addr2);
            if ( ret < 0 ) {
                return -1;
            }
        } else if ( 'w' == type ) {
            /* Delete an entry */
            ret = poptrie_route_del(poptrie, addr1, prefixlen);
            if ( ret < 0 ) {
                /* Ignore any errors */
            }
        }
        if ( 0 == i % 1000 ) {
            TEST_PROGRESS();
        }
        i++;
    }

    /* Close */
    fclose(fp);

    for ( i = 0; i < 0x100000000ULL; i++ ) {
        if ( 0 == i % 0x10000000ULL ) {
            TEST_PROGRESS();
        }
        if ( poptrie_lookup(poptrie, i) != poptrie_rib_lookup(poptrie, i) ) {
            return -1;
        }
    }

    /* Release */
    poptrie_release(poptrie);

    return 0;
}
void start_css_valgrind (void) {
   TEST_PROGRESS("start_css_valgrind      \n");
   event_start_css();
}
void end_css_valgrind (void) {
   TEST_PROGRESS("end_css_valgrind      \n");
   event_end_css();
}
void task_inout_valgrind(const char *parName, void *ptr, unsigned long element_size, unsigned long elements){
   TEST_PROGRESS("task_inout_valgrind parName %s  ptr ,  element_size %lu,   elements  %lu      \n",
                 parName, element_size, elements);
   event_inout_parameter(ptr);   
}