Changeset 4270
- Timestamp:
- Jun 14, 2005, 5:20:36 PM (21 years ago)
- Location:
- trunk/psLib/test/dataIO
- Files:
-
- 2 edited
-
tst_psDB.c (modified) (7 diffs)
-
verified/tst_psDB.stderr (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/dataIO/tst_psDB.c
r4263 r4270 9 9 * @author Aaron Culliney, MHPCC 10 10 * 11 * @version $Revision: 1.1 4$ $Name: not supported by cvs2svn $12 * @date $Date: 2005-06-15 0 1:48:25$11 * @version $Revision: 1.15 $ $Name: not supported by cvs2svn $ 12 * @date $Date: 2005-06-15 03:20:36 $ 13 13 * 14 14 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 72 72 {TPDBInit, 841, "dbInit", 0, false}, 73 73 {TPDBChange, 842, "dbChange", 0, false}, 74 {TPDBCreateTable, -3, "dbCreateTable", 0, false},74 {TPDBCreateTable, 843, "dbCreateTable", 0, false}, 75 75 {TPDBDropTable, -4, "dbDropTable", 0, false}, 76 76 {TPDBSelectColumn, -5, "dbSelectColumn", 0, false}, … … 305 305 306 306 // Attempt to initialize database with invalid arguments 307 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid host"); 307 308 dbh = psDBInit("xxx",NULL,NULL,NULL); 308 309 if(dbh != NULL) { … … 312 313 313 314 // Attempt cleanup database/connection with NULL psDB object 315 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for NULL database objec"); 314 316 psDBCleanup(NULL); 315 317 … … 336 338 337 339 // Attemp to change database to invalid database name 340 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for invalid database"); 338 341 if(psDBChange(dbh,"abc")) { 339 342 psError(PS_ERR_UNKNOWN,true,"Did not expect return true for unknown database name"); … … 345 348 346 349 // Attempt to change database with NULL database object 350 psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message for null database object"); 347 351 if(psDBChange(NULL,dbname)) { 348 352 psError(PS_ERR_UNKNOWN,true,"Did not expect return true for NULL database object"); … … 353 357 } 354 358 355 // Testpoint # XXX, psDBCreateTable shall create tables in the test database ...359 // Testpoint #843, psDBCreateTable shall create tables in the test database ... 356 360 psS32 TPDBCreateTable( void ) 357 361 { 358 psS32 failed = 0;359 362 psDB *dbh = NULL; 360 363 const char* table = "table1"; 364 365 // Create metadata for table definition 361 366 psMetadata *md = _get_CreateTableMetadata(); 362 367 363 dbh = _init_psDB(); 364 if (dbh == NULL) { 365 return 1; 366 } 367 368 psLogMsg( __func__, PS_LOG_INFO, "psDBCreateTable shall create a new table in the new test database.\n" ); 369 370 failed = ! psDBCreateTable(dbh, table, md); 371 if (!failed) { 368 // Initialize database connection 369 dbh = _init_psDB(); 370 if (dbh == NULL) { 371 psError(PS_ERR_UNKNOWN,true,"Did not expect NULL for valid argument in database connection"); 372 return 1; 373 } 374 375 // Attempt to create database table with valid arguments 376 if(!psDBCreateTable(dbh, table, md)) { 377 psError(PS_ERR_UNKNOWN,true,"Did not expect return of false for valid arguments"); 378 return 2; 379 } else { 380 // Drop the table from the test database 372 381 psDBDropTable(dbh, table); 373 382 } 374 383 384 // Free metadata definition of table 375 385 psFree(md); 376 psDBCleanup(dbh); 377 378 return failed; 386 387 // Attempt to create table with NULL table definition 388 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL parameter"); 389 if(psDBCreateTable(dbh,table,NULL)) { 390 psError(PS_ERR_UNKNOWN,true,"Did not expect return of true for NULL metadata object"); 391 return 3; 392 } 393 394 // Attempt to create table with NULL connection 395 psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message for NULL parameter"); 396 if(psDBCreateTable(NULL, table, md)) { 397 psError(PS_ERR_UNKNOWN,true,"Did not expect return of true for NULL database object"); 398 return 4; 399 } 400 401 // Close/cleanup database connection 402 psDBCleanup(dbh); 403 404 return 0; 379 405 } 380 406 -
trunk/psLib/test/dataIO/verified/tst_psDB.stderr
r4263 r4270 5 5 \**********************************************************************************/ 6 6 7 <DATE><TIME>|<HOST>|I|TPDBInit 8 Following should generate error message for invalid host 7 9 <DATE><TIME>|<HOST>|E|psDBInit (FILE:LINENO) 8 10 Failed to connect to database. Error: Unknown MySQL server host 'xxx' (1) 11 <DATE><TIME>|<HOST>|I|TPDBInit 12 Following should generate error message for NULL database objec 9 13 <DATE><TIME>|<HOST>|E|psDBCleanup (FILE:LINENO) 10 14 Invalid psDB has been specified. … … 18 22 \**********************************************************************************/ 19 23 24 <DATE><TIME>|<HOST>|I|TPDBChange 25 Following should generate error message for invalid database 20 26 <DATE><TIME>|<HOST>|E|psDBChange (FILE:LINENO) 21 27 Failed to change database. Error: Access denied for user ''@'localhost' to database 'abc' 28 <DATE><TIME>|<HOST>|I|TPDBChange 29 Following should generate error message for null database object 22 30 <DATE><TIME>|<HOST>|E|psDBChange (FILE:LINENO) 23 31 Invalid psDB has been specified. … … 32 40 33 41 <DATE><TIME>|<HOST>|I|TPDBCreateTable 34 psDBCreateTable shall create a new table in the new test database. 42 Following should generate an error message for NULL parameter 43 <DATE><TIME>|<HOST>|E|psDBGenerateCreateTableSQL (FILE:LINENO) 44 Create table parameters may not be NULL. 45 <DATE><TIME>|<HOST>|E|psDBCreateTable (FILE:LINENO) 46 Query generation failed. 47 <DATE><TIME>|<HOST>|I|TPDBCreateTable 48 Following should generate an error message for NULL parameter 49 <DATE><TIME>|<HOST>|E|psDBCreateTable (FILE:LINENO) 50 Invalid psDB has been specified. 35 51 36 52 ---> TESTPOINT PASSED (psDB{dbCreateTable} | tst_psDB.c)
Note:
See TracChangeset
for help on using the changeset viewer.
