Exemplo n.º 1
0
Arquivo: Test.cpp Projeto: fU9ANg/ab
int main ()
{
    SheetUtils::initSheets ();
    
#if 0
    SheetTestData* pdata;
    pdata = shTest->getRow (0);
    dump_test_data (pdata);

    vector<SheetTestData*> datas;
    datas = shTest->getAll ();
    printf ("----------------- DUMP VECTOR -----------------\n");
    for (unsigned int i=0; i<datas.size(); i++) {
        printf ("SheetTestDatas[%d].ID   = %d\n", i+1, datas[i]->ID);
        printf ("SheetTestDatas[%d].Type = %d\n", i+1, datas[i]->Type);
        printf ("SheetTestDatas[%d].Name = %s\n", i+1, datas[i]->Name.c_str());
    }

    // test find by PK.
    pdata = shTest->findByID (7);
    dump_test_data (pdata);
#endif

#if 0
    shTest->dump ();
    shTest2->dump ();
    shPlayer->dump ();
    shMonster->dump ();
#endif

    return (0);
}
Exemplo n.º 2
0
/* the main */
int main(void){
    /* the base directory to be used/created */
    const char *base_dir = "data";
    /* the default test db connection string */
    char DEFAULT_TEST_DB_CONN_STR[] = "@localhost";
    char *test_db = DEFAULT_TEST_DB_CONN_STR;

    /* create the target directory where the dump(s) will be stored */
    if( 0 > mkdir_recursive(base_dir)) {
        LOGGER_ERROR("Failed to create target directory: [%s]", base_dir);
        exit(EXIT_FAILURE);
    }
    LOGGER_INFO("target directory: [%s]", base_dir);

    /* the mysql_login_info struct will be used to access the database */
    struct mysql_login_info login_db_test;

    /* parse the test_db connection string in case of any errors */
    /* not necessarily used in this example unless you use a database
        connection string other than '@localhost' */
    if (0 > ribs_mysql_parse_db_conn_str(test_db, &login_db_test)) {
        LOGGER_ERROR("failed to parse DB connection string: [%s]", test_db);
        exit(EXIT_FAILURE);
    }
    login_db_test.db = DB_TEST;

    /* initialize the event loop */
    if( 0 > epoll_worker_init()) {
        LOGGER_ERROR("epoll_worker_init failed");
        exit(EXIT_FAILURE);
    }

    /* initialize the client pool */
    http_client_pool_init(&client_pool, 10, 10);

    /* initialize the query buffer used in dump_test_data() */
    struct vmbuf query = VMBUF_INITIALIZER;
    vmbuf_init(&query, 65536);

    /* dump the test db data table into its target directory */
    if( 0 > dump_test_data(base_dir, login_db_test, &query)) {
        LOGGER_ERROR("Faied to dump data from test db");
        exit(EXIT_FAILURE);
    }

    /* return when successful */
    LOGGER_INFO("completed successfully");
    exit(EXIT_SUCCESS);
    return 0;
}