VirtualBox

Changeset 65963 in vbox


Ignore:
Timestamp:
Mar 7, 2017 10:30:26 AM (8 years ago)
Author:
vboxsync
Message:

ValidationKit/tests: pylint 2.0.0 fixes.

Location:
trunk/src/VBox/ValidationKit/tests
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r62484 r65963  
    14031403                        reporter.log2('Test #%d passed: Buffers match (%d bytes)' % (i, len(oRes.sBuf)));
    14041404                elif     oRes.sBuf is not None \
    1405                      and len(oRes.sBuf):
     1405                     and oRes.sBuf:
    14061406                    reporter.error('Test #%d failed: Got no buffer data, expected\n%s (%dbytes)' %
    14071407                                   (i, map(hex, map(ord, oRes.sBuf)), len(oRes.sBuf)));
     
    14601460                                or waitResult == vboxcon.ProcessWaitResult_WaitFlagNotSupported:
    14611461                                reporter.log2('Reading stdout ...');
    1462                                 buf = curProc.Read(1, 64 * 1024, oTest.timeoutMS);
    1463                                 if len(buf):
    1464                                     reporter.log2('Process (PID %d) got %d bytes of stdout data' % (curProc.PID, len(buf)));
    1465                                     oTest.cbStdOut += len(buf);
    1466                                     oTest.sBuf = buf; # Appending does *not* work atm, so just assign it. No time now.
     1462                                abBuf = curProc.Read(1, 64 * 1024, oTest.timeoutMS);
     1463                                if abBuf:
     1464                                    reporter.log2('Process (PID %d) got %d bytes of stdout data' % (curProc.PID, len(abBuf)));
     1465                                    oTest.cbStdOut += len(abBuf);
     1466                                    oTest.sBuf = abBuf; # Appending does *not* work atm, so just assign it. No time now.
    14671467                            # Try stderr.
    14681468                            if     waitResult == vboxcon.ProcessWaitResult_StdErr \
    14691469                                or waitResult == vboxcon.ProcessWaitResult_WaitFlagNotSupported:
    14701470                                reporter.log2('Reading stderr ...');
    1471                                 buf = curProc.Read(2, 64 * 1024, oTest.timeoutMS);
    1472                                 if len(buf):
    1473                                     reporter.log2('Process (PID %d) got %d bytes of stderr data' % (curProc.PID, len(buf)));
    1474                                     oTest.cbStdErr += len(buf);
    1475                                     oTest.sBuf = buf; # Appending does *not* work atm, so just assign it. No time now.
     1471                                abBuf = curProc.Read(2, 64 * 1024, oTest.timeoutMS);
     1472                                if abBuf:
     1473                                    reporter.log2('Process (PID %d) got %d bytes of stderr data' % (curProc.PID, len(abBuf)));
     1474                                    oTest.cbStdErr += len(abBuf);
     1475                                    oTest.sBuf = abBuf; # Appending does *not* work atm, so just assign it. No time now.
    14761476                            # Use stdin.
    14771477                            if     waitResult == vboxcon.ProcessWaitResult_StdIn \
  • trunk/src/VBox/ValidationKit/tests/autostart/tdAutostart1.py

    r62484 r65963  
    6969                # Extract the value
    7070            idxVmNameStart = sLine.find('"');
    71             if idxVmNameStart is -1:
     71            if idxVmNameStart == -1:
    7272                raise Exception('VBoxManageStdOutWrapper: Invalid output');
    7373
  • trunk/src/VBox/ValidationKit/tests/storage/remoteexecutor.py

    r65747 r65963  
    101101        if self.oTxsSession is not None:
    102102            return self.oTxsSession.syncIsFile(sFile);
    103         else:
    104             return os.path.isfile(sFile);
     103        return os.path.isfile(sFile);
    105104
    106105    def _getBinaryPath(self, sBinary):
  • trunk/src/VBox/ValidationKit/tests/storage/storagecfg.py

    r65746 r65963  
    291291            fRc = oExec.execBinaryNoStdOut('sfdisk', ('--no-reread', '--wipe', 'always', '-q', '-f', sDiskPath), sFdiskScript);
    292292            if fRc:
    293                 if sDiskPath.find('nvme') is not -1:
     293                if sDiskPath.find('nvme') != -1:
    294294                    sBlkDev = sDiskPath + 'p1';
    295295                else:
  • trunk/src/VBox/ValidationKit/tests/storage/tdStorageBenchmark1.py

    r65731 r65963  
    228228                        # Extract the value
    229229                        idxValue = sLine.rfind('=');
    230                         if idxValue is -1:
     230                        if idxValue == -1:
    231231                            raise Exception('IozoneTest: Invalid state');
    232232
     
    243243
    244244                        for sNeedle, sTestVal in self.lstTests:
    245                             if sLine.rfind(sNeedle) is not -1:
     245                            if sLine.rfind(sNeedle) != -1:
    246246                                reporter.testValue(sTestVal, sLine[idxValue:idxValueEnd],
    247247                                                   constants.valueunit.g_asNames[constants.valueunit.KILOBYTES_PER_SEC]);
     
    281281        # Get the first non blacklisted test.
    282282        asTestCfg = self.getCurrentTestCfg();
    283         while len(asTestCfg) > 0 and self.isTestCfgBlacklisted(asTestCfg):
     283        while asTestCfg and self.isTestCfgBlacklisted(asTestCfg):
    284284            asTestCfg = self.advanceTestCfg();
    285285
     
    305305        if fnTestFmt is not None:
    306306            return fnTestFmt(oCfg);
    307         else:
    308             return oCfg;
     307        return oCfg;
    309308
    310309    def isTestCfgBlacklisted(self, asTestCfg):
     
    375374
    376375        asTestCfg = self.advanceTestCfg();
    377         while len(asTestCfg) > 0 and self.isTestCfgBlacklisted(asTestCfg):
     376        while asTestCfg and self.isTestCfgBlacklisted(asTestCfg):
    378377            asTestCfg = self.advanceTestCfg();
    379378
     
    381380        # categories.
    382381        reporter.testDone(fSkippedLast);
    383         if len(asTestCfg) > 0:
     382        if asTestCfg:
    384383            idxSame = 0;
    385384            while asTestCfgCur[idxSame] == asTestCfg[idxSame]:
     
    832831            if fHardDisk:
    833832                return ('ahci', False);
    834             else:
    835                 return ('ahci', True);
    836         elif eStorageCtrl == vboxcon.StorageControllerType_PIIX4:
     833            return ('ahci', True);
     834        if eStorageCtrl == vboxcon.StorageControllerType_PIIX4:
    837835            return ('piix3ide', False);
    838         elif eStorageCtrl == vboxcon.StorageControllerType_LsiLogicSas:
     836        if eStorageCtrl == vboxcon.StorageControllerType_LsiLogicSas:
    839837            return ('lsilogicsas', True);
    840         elif eStorageCtrl == vboxcon.StorageControllerType_LsiLogic:
     838        if eStorageCtrl == vboxcon.StorageControllerType_LsiLogic:
    841839            return ('lsilogicscsi', True);
    842         elif eStorageCtrl == vboxcon.StorageControllerType_BusLogic:
     840        if eStorageCtrl == vboxcon.StorageControllerType_BusLogic:
    843841            return ('buslogic', True);
    844         elif eStorageCtrl == vboxcon.StorageControllerType_NVMe:
     842        if eStorageCtrl == vboxcon.StorageControllerType_NVMe:
    845843            return ('nvme', False);
    846844
     
    854852        # Check whether the disk variant is supported by the selected format.
    855853        asVariants = self.getDiskFormatVariantsForTesting(asTestCfg[self.kiDiskFmt], [ asTestCfg[self.kiDiskVar] ]);
    856         if len(asVariants) == 0:
     854        if not asVariants:
    857855            return False;
    858856
    859857        # For iSCSI check whether we have targets configured.
    860         if asTestCfg[self.kiDiskFmt] == 'iSCSI' and len(self.asIscsiTargets) == 0:
     858        if asTestCfg[self.kiDiskFmt] == 'iSCSI' and not self.asIscsiTargets:
    861859            return False;
    862860
     
    879877        if cCpus == 1:
    880878            return '1 cpu';
    881         else:
    882             return '%u cpus' % (cCpus);
     879        return '%u cpus' % (cCpus);
    883880
    884881    def fnFormatVirtMode(self, sVirtMode):
     
    11721169        fRc = True;
    11731170        asTestCfg = oTstCfgMgr.getCurrentTestCfg();
    1174         while len(asTestCfg) > 0:
     1171        while asTestCfg:
    11751172            fRc = self.testOneCfg(asTestCfg[self.kiVmName], self.getStorageCtrlFromName(asTestCfg[self.kiStorageCtrl]), \
    11761173                                  asTestCfg[self.kiHostIoCache], asTestCfg[self.kiDiskFmt], asTestCfg[self.kiDiskVar],
  • trunk/src/VBox/ValidationKit/tests/teleportation/tdTeleportLocal1.py

    r62484 r65963  
    115115            iArg += 1;
    116116            if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
    117             if len(asArgs[iArg]) > 0:
     117            if asArgs[iArg]:
    118118                self.asTestVMs = asArgs[iArg].split(':');
    119119                for s in self.asTestVMs:
  • trunk/src/VBox/ValidationKit/tests/unittests/tdUnitTest1.py

    r65236 r65963  
    346346                sPathName = 'Path';
    347347            sPath = os.environ.get(sPathName, '.');
    348             if len(sPath) > 0 and sPath[-1] != ';':
     348            if sPath and sPath[-1] != ';':
    349349                sPath += ';';
    350350            os.environ[sPathName] = sPath + self.sVBoxInstallRoot + ';';
     
    463463                    try:    aiValue = [int(sComp) for sComp in sValue.replace('r', '.').split('.')];
    464464                    except: aiValue = ();
    465                     if len(aiValue) == 0 or len(aiValue) > 4:
     465                    if not aiValue or len(aiValue) > 4:
    466466                        reporter.error('Invalid exclusion expression for %s: "%s" [%s]' % (sTest, sSubExpr, dExclList[sTest]));
    467467                        return True;
  • trunk/src/VBox/ValidationKit/tests/usb/usbgadget.py

    r61831 r65963  
    349349                                       ord(sOpcode[6]), \
    350350                                       ord(sOpcode[7]) ) ) );
    351             if len(abPayload) > 0:
     351            if abPayload:
    352352                abMsg.extend(abPayload);
    353353        except:
     
    374374
    375375        # Read the header.
    376         if len(self.abReadAheadHdr) > 0:
     376        if self.abReadAheadHdr:
    377377            assert(len(self.abReadAheadHdr) == 16);
    378378            abHdr = self.abReadAheadHdr;
     
    11651165                self.oSocket.setblocking(0);    # just in case it's not set.
    11661166                sData = "1";
    1167                 while len(sData) > 0:
     1167                while sData:
    11681168                    sData = self.oSocket.recv(16384);
    11691169            except:
     
    11811181        self.oCv.release();
    11821182
    1183     def sendBytes(self, abMsg, cMsTimeout):
     1183    def sendBytes(self, abBuf, cMsTimeout):
    11841184        if self.oSocket is None:
    11851185            reporter.error('TransportTcp.sendBytes: No connection.');
     
    11881188        # Try send it all.
    11891189        try:
    1190             cbSent = self.oSocket.send(abMsg);
    1191             if cbSent == len(abMsg):
     1190            cbSent = self.oSocket.send(abBuf);
     1191            if cbSent == len(abBuf):
    11921192                return True;
    11931193        except Exception, oXcpt:
    11941194            if not self.__isWouldBlockXcpt(oXcpt):
    1195                 reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(abMsg)));
     1195                reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(abBuf)));
    11961196                return False;
    11971197            cbSent = 0;
     
    12021202            cMsElapsed = base.timestampMilli() - msStart;
    12031203            if cMsElapsed > cMsTimeout:
    1204                 reporter.error('TranportTcp.sendBytes: %s bytes timed out (1)' % (len(abMsg)));
     1204                reporter.error('TranportTcp.sendBytes: %s bytes timed out (1)' % (len(abBuf)));
    12051205                break;
    12061206
     
    12081208            try:
    12091209                ttRc = select.select([], [self.oSocket], [self.oSocket], (cMsTimeout - cMsElapsed) / 1000.0);
    1210                 if len(ttRc[2]) > 0 and len(ttRc[1]) == 0:
     1210                if ttRc[2] and not ttRc[1]:
    12111211                    reporter.error('TranportTcp.sendBytes: select returned with exception');
    12121212                    break;
    1213                 if len(ttRc[1]) == 0:
    1214                     reporter.error('TranportTcp.sendBytes: %s bytes timed out (2)' % (len(abMsg)));
     1213                if not ttRc[1]:
     1214                    reporter.error('TranportTcp.sendBytes: %s bytes timed out (2)' % (len(abBuf)));
    12151215                    break;
    12161216            except:
     
    12201220            # Try send more.
    12211221            try:
    1222                 cbSent += self.oSocket.send(abMsg[cbSent:]);
    1223                 if cbSent == len(abMsg):
     1222                cbSent += self.oSocket.send(abBuf[cbSent:]);
     1223                if cbSent == len(abBuf):
    12241224                    return True;
    12251225            except Exception, oXcpt:
    12261226                if not self.__isWouldBlockXcpt(oXcpt):
    1227                     reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(abMsg)));
     1227                    reporter.errorXcpt('TranportTcp.sendBytes: %s bytes' % (len(abBuf)));
    12281228                    break;
    12291229
     
    12461246            try:
    12471247                abBuf = self.oSocket.recv(cb - len(self.abReadAhead));
    1248                 if len(abBuf) > 0:
     1248                if abBuf:
    12491249                    self.abReadAhead.extend(array.array('B', abBuf));
    12501250            except Exception, oXcpt:
     
    12611261            cMsElapsed = base.timestampMilli() - msStart;
    12621262            if cMsElapsed > cMsTimeout:
    1263                 if not fNoDataOk or len(self.abReadAhead) > 0:
     1263                if not fNoDataOk or self.abReadAhead:
    12641264                    reporter.error('TranportTcp.recvBytes: %s/%s bytes timed out (1)' % (len(self.abReadAhead), cb));
    12651265                break;
     
    12681268            try:
    12691269                ttRc = select.select([self.oSocket], [], [self.oSocket], (cMsTimeout - cMsElapsed) / 1000.0);
    1270                 if len(ttRc[2]) > 0 and len(ttRc[0]) == 0:
     1270                if ttRc[2] and not ttRc[0]:
    12711271                    reporter.error('TranportTcp.recvBytes: select returned with exception');
    12721272                    break;
    1273                 if len(ttRc[0]) == 0:
    1274                     if not fNoDataOk or len(self.abReadAhead) > 0:
     1273                if not ttRc[0]:
     1274                    if not fNoDataOk or self.abReadAhead:
    12751275                        reporter.error('TranportTcp.recvBytes: %s/%s bytes timed out (2) fNoDataOk=%s'
    12761276                                       % (len(self.abReadAhead), cb, fNoDataOk));
     
    12831283            try:
    12841284                abBuf = self.oSocket.recv(cb - len(self.abReadAhead));
    1285                 if len(abBuf) == 0:
     1285                if not abBuf:
    12861286                    reporter.error('TranportTcp.recvBytes: %s/%s bytes (%s) - connection has been shut down'
    12871287                                   % (len(self.abReadAhead), cb, fNoDataOk));
     
    12941294                reporter.log('recv => exception %s' % (oXcpt,));
    12951295                if not self.__isWouldBlockXcpt(oXcpt):
    1296                     if not fNoDataOk  or  not self.__isConnectionReset(oXcpt)  or  len(self.abReadAhead) > 0:
     1296                    if not fNoDataOk  or  not self.__isConnectionReset(oXcpt)  or  self.abReadAhead:
    12971297                        reporter.errorXcpt('TranportTcp.recvBytes: %s/%s bytes (%s)' % (len(self.abReadAhead), cb, fNoDataOk));
    12981298                    break;
     
    13101310        try:
    13111311            ttRc = select.select([], [], [self.oSocket], 0.0);
    1312             if len(ttRc[2]) > 0:
     1312            if ttRc[2]:
    13131313                return False;
    13141314
     
    13211321        try:
    13221322            ttRc = select.select([self.oSocket], [], [], cMsTimeout / 1000.0);
    1323             if len(ttRc[0]) == 0:
     1323            if not ttRc[0]:
    13241324                return False;
    13251325        except:
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