VirtualBox

Ignore:
Timestamp:
Mar 8, 2022 1:51:26 PM (3 years ago)
Author:
vboxsync
Message:

ValKit/utils.py,tests: Move crc32_of_file to common/utils.py as calcCrc32OfFile, no point in having two copies of it. pylint fixes.

Location:
trunk/src/VBox/ValidationKit/tests/storage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/storage/tdStorageRawDrive1.py

    r93115 r94123  
    3131# Standard Python imports.
    3232import os;
     33import re;
    3334import sys;
    34 import re;
    35 import zlib;
    3635
    3736# Only the main script needs to modify the path.
     
    4241
    4342# Validation Kit imports.
     43from common     import utils;
    4444from testdriver import reporter;
    4545from testdriver import base;
     
    4949from testdriver import vboxwrappers;
    5050
    51 
    52 def crc32_of_file(filepath):
    53     fileobj = open(filepath,'rb');
    54     current = 0;
    55 
    56     while True:
    57         buf = fileobj.read(1024 * 1024);
    58         if not buf:
    59             break
    60         current = zlib.crc32(buf, current);
    61 
    62     fileobj.close();
    63     return current % 2**32;
    6451
    6552class tdStorageRawDriveOs(vboxtestvms.BaseTestVm):
     
    12121199                                        reporter.error('Download vmdktest-pt.vmdk from guest to host failed');
    12131200                                    else:
    1214                                         uResCrc32 = crc32_of_file(sDstFile);
     1201                                        uResCrc32 = utils.calcCrc32OfFile(sDstFile);
    12151202                                        if uResCrc32 != action['data-crc'][sHdd]:
    12161203                                            fRc = reporter.error('vmdktest-pt.vmdk does not match what was expected');
  • trunk/src/VBox/ValidationKit/tests/storage/tdStorageSnapshotMerging1.py

    r93115 r94123  
    4343
    4444# Validation Kit imports.
     45from common     import utils;
    4546from testdriver import reporter;
    4647from testdriver import base;
     
    5253if sys.version_info[0] >= 3:
    5354    long = int;     # pylint: disable=redefined-builtin,invalid-name
    54 
    55 
    56 def crc32_of_file(filepath):
    57     fileobj = open(filepath,'rb');
    58     current = 0;
    59 
    60     while True:
    61         buf = fileobj.read(1024 * 1024);
    62         if not buf:
    63             break
    64         current = zlib.crc32(buf, current);
    65 
    66     fileobj.close();
    67     return current % 2**32;
    6855
    6956
     
    349336                    uResCrc32 = long(0);
    350337                    if fRc:
    351                         uResCrc32 = long(crc32_of_file(sResFilePathRaw));
     338                        uResCrc32 = long(utils.calcCrc32OfFile(sResFilePathRaw));
    352339                        if uResCrc32 == uOrigCrc:
    353340                            reporter.log('Snapshot merged successfully. Crc32 is correct');
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette