Changeset 30340

Show
Ignore:
Timestamp:
03.12.2015 16:30:26 (4 years ago)
Author:
jmt12
Message:

Minor changes to support drivers that don't support set_entry functionality

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • gs2-extensions/tdb/trunk/perllib/dbutil.pm

    r30335 r30340  
    6969my $test_count = 0; 
    7070my $pass_count = 0; 
     71my $skip_count = 0; 
    7172 
    7273 
     
    287288        &_printTest('read keys', (defined $keys1->{'Alpha'} && defined $keys1->{'Beta'})); 
    288289        # 6. Set entry 
    289         my $status = $driver->set_infodb_entry($db_path, 'Alpha', $data2); 
    290         &_printTest('set entry (1)', ($status >= 0)); 
    291         my $data5 = $driver->read_infodb_entry($db_path, 'Alpha'); 
    292         &_printTest('set entry (2)', &_compareHash($data2, $data5)); 
     290        if ($driver->supportsSet()) { 
     291        my $status = $driver->set_infodb_entry($db_path, 'Alpha', $data2); 
     292        &_printTest('set entry (1)', ($status >= 0)); 
     293        my $data5 = $driver->read_infodb_entry($db_path, 'Alpha'); 
     294        &_printTest('set entry (2)', &_compareHash($data2, $data5)); 
     295        } 
     296        else { 
     297        $test_count += 2; 
     298        $skip_count += 2; 
     299        print " - Skipping 2 tests as 'set' is not supported by this driver.\n"; 
     300        } 
    293301        # 7. Delete entry 
    294         my $db_handle2 = $driver->open_infodb_write_handle($db_path, '-append'); 
     302        my $db_handle2 = $driver->open_infodb_write_handle($db_path, 'append'); 
    295303        $driver->delete_infodb_entry($db_handle2, 'Alpha'); 
    296304        $driver->close_infodb_handle($db_handle2); 
     
    299307        &_printTest('delete entry', ((!defined $keys2->{'Alpha'}) && (defined $keys2->{'Beta'}))); 
    300308        # 8. Remove test db 
    301         unlink($db_path); 
     309        #unlink($db_path); 
    302310    } 
    303311    print "===== Results =====\n"; 
     
    305313    print "Tests Run:      " . $test_count . "\n"; 
    306314    print "Tests Passed:   " . $pass_count . "\n"; 
    307     print "Tests Failed:   " . ($test_count - $pass_count) . "\n"; 
     315    print "Tests Failed:   " . ($test_count - $pass_count - $skip_count) . "\n"; 
     316    print "Tests Skipped:  " . $skip_count . "\n"; 
    308317    } 
    309318    else