Add range feature for cpu exclusion
- It is now possible to exclude cpu range by !1-3 - Also edited test for cpulist_unpack method to test this new feature - Resolves rhbz#1533908
This commit is contained in:
parent
560f5e7e56
commit
3722b15192
2 changed files with 18 additions and 3 deletions
|
|
@ -190,8 +190,12 @@ class CommandsTestCase(unittest2.TestCase):
|
|||
self.assertEqual(self._commands.hex2cpulist('0x1,0000,0001'),[0,32])
|
||||
|
||||
def test_cpulist_unpack(self):
|
||||
cpus = '4-8,^6,0xf00,,'
|
||||
self.assertEqual(self._commands.cpulist_unpack(cpus),[4,5,7,8,9,10,11])
|
||||
cpus = '4-8,^6,0xf00,,!10-11'
|
||||
self.assertEqual(self._commands.cpulist_unpack(cpus),[4,5,7,8,9])
|
||||
cpus = '1,2,3-x'
|
||||
self.assertEqual(self._commands.cpulist_unpack(cpus),[])
|
||||
cpus = '1,2,!3-x'
|
||||
self.assertEqual(self._commands.cpulist_unpack(cpus),[])
|
||||
|
||||
def test_cpulist_pack(self):
|
||||
self.assertEqual(self._commands.cpulist_pack([0,1,3,4,5,6,8,9,32]),\
|
||||
|
|
|
|||
|
|
@ -320,7 +320,18 @@ class commands:
|
|||
hexmask = True
|
||||
hv = sv
|
||||
elif sv and (sv[0] == "^" or sv[0] == "!"):
|
||||
negation_list.append(int(sv[1:]))
|
||||
nl = sv[1:].split("-")
|
||||
try:
|
||||
if (len(nl) > 1):
|
||||
negation_list += list(range(
|
||||
int(nl[0]),
|
||||
int(nl[1]) + 1
|
||||
)
|
||||
)
|
||||
else:
|
||||
negation_list.append(int(sv[1:]))
|
||||
except ValueError:
|
||||
return []
|
||||
else:
|
||||
if len(sv) > 0:
|
||||
ll2.append(sv)
|
||||
|
|
|
|||
Loading…
Reference in a new issue