Ignore:
Timestamp:
2015-12-10T12:19:20+13:00 (8 years ago)
Author:
jmt12
Message:

Continuing to refactor driver code to move shared code up to parent classes. Have all the basic drivers done...

File:
1 edited

Legend:

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

    r30340 r30347  
    3737    }
    3838    # Are we running standalone? In which case the INC won't be correct
    39     #if (!caller) {
    40     # Ensure the INC includes the path to FileUtils.pm
    41     unshift(@INC, $ENV{'GSDLHOME'} . '/perllib');
    42 
    43     #}
    44     require DBDrivers::GDBM;
    45     my $driver = DBDrivers::GDBM->new(1);
     39    my $perllib_path = $ENV{'GSDLHOME'} . '/perllib';
     40    my $all_inc = join(':', @INC);
     41    if ($all_inc !~ /$perllib_path/) {
     42    unshift(@INC, $perllib_path);
     43    }
    4644}
    4745
     
    240238         'tea' => ['a drink with jam and bread'],
    241239         'doh' => ['which brings us back to']};
     240    $test_count = 0;
     241    $pass_count = 0;
     242    $skip_count = 0;
    242243    print "===== DBUtils Testing Suite =====\n";
    243244    print "For each driver specified, run a battery of tests\n";
     
    259260    &_addPathsToINC();
    260261    foreach my $driver_name (@drivers) {
    261         print "* Testing: " . $driver_name . "\n";
     262        my $t1 = [gettimeofday()];
     263        print "=== Testing: " . $driver_name . " ===\n";
    262264        my $driver = _loadDBDriver($driver_name);
    263265        my $db_path = $driver->get_infodb_file_path('test','/tmp/');
     
    274276        &_printTest('writing raw entry', 1);
    275277        # 3. Close handle
    276         $driver->close_infodb_handle($db_handle);
    277         &_printTest('closing handle', (tell($db_handle) < 1));
     278        $driver->close_infodb_write_handle($db_handle);
     279        if ($driver->supportsPersistentConnection()) {
     280        $test_count += 1;
     281        $skip_count += 1;
     282        print " - Skipping test as persistent drivers delay 'close'.\n";
     283        }
     284        else {
     285        &_printTest('closing handle', (tell($db_handle) < 1));
     286        }
    278287        # 4a. Read entry
    279288        my $data3 = $driver->read_infodb_entry($db_path, 'Alpha');
     
    302311        my $db_handle2 = $driver->open_infodb_write_handle($db_path, 'append');
    303312        $driver->delete_infodb_entry($db_handle2, 'Alpha');
    304         $driver->close_infodb_handle($db_handle2);
     313        $driver->close_infodb_write_handle($db_handle2);
    305314        my $keys2 = {};
    306315        $driver->read_infodb_keys($db_path, $keys2);
     
    308317        # 8. Remove test db
    309318        #unlink($db_path);
     319        my $t2 = [gettimeofday()];
     320        my $elapsed1 = tv_interval($t1, $t2);
     321        print " - Testing took " . $elapsed1 . " seconds\n";
    310322    }
    311323    print "===== Results =====\n";
     
    320332    print "Warning! No drivers specified - expected as arguments to call\n";
    321333    }
    322     my $t1 = [gettimeofday()];
    323     my $elapsed = tv_interval($t0, $t1);
    324     print "===== Complete in " . $elapsed . " seconds =====\n";
     334    my $t3 = [gettimeofday()];
     335    my $elapsed2 = tv_interval($t0, $t3);
     336    print "===== Complete in " . $elapsed2 . " seconds =====\n";
    325337    print "\n";
    326338    exit(0);
Note: See TracChangeset for help on using the changeset viewer.