Beispiel #1
0
def validate_running_with_enough_cpus(cpu_set):
    max_available_cpu = sorted(testlib.online_cpus())[-1]
    max_required_cpu = sorted(cpu_set)[-1]

    if max_available_cpu < max_required_cpu:
        raise SkipTest(
            "This test requires at least %i available CPUs"
            " (running with %i)" % (max_required_cpu, max_available_cpu))
Beispiel #2
0
def validate_running_with_enough_cpus(cpu_set):
    max_available_cpu = sorted(online_cpus())[-1]
    max_required_cpu = sorted(cpu_set)[-1]

    if max_available_cpu < max_required_cpu:
        raise SkipTest(
            "This test requires at least %i available CPUs"
            " (running with %i)" % (max_required_cpu, max_available_cpu))
Beispiel #3
0
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEqual(taskset.get(os.getpid()), self.CPU_SET)

        proc = commands.start((EXT_SLEEP, '30s'))
        try:
            self.assertEqual(taskset.get(proc.pid), online_cpus())
        finally:
            proc.kill()
Beispiel #4
0
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEquals(taskset.get(os.getpid()), self.CPU_SET)

        try:
            proc = commands.execCmd((EXT_SLEEP, '30s'), sync=False)

            self.assertEquals(taskset.get(proc.pid), online_cpus())
        finally:
            proc.kill()
Beispiel #5
0
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEquals(taskset.get(os.getpid()), self.CPU_SET)

        try:
            proc = utils.execCmd((EXT_SLEEP, '30s'), sync=False)

            self.assertEquals(taskset.get(proc.pid), online_cpus())
        finally:
            proc.kill()
Beispiel #6
0
class TestExecCmdAffinity(TestCaseBase):

    CPU_SET = frozenset([0])
    ONLINE_CPUS = online_cpus()

    @forked
    @MonkeyPatch(cmdutils, '_USING_CPU_AFFINITY', False)
    def testResetAffinityByDefault(self):
        proc = commands.start((EXT_SLEEP, '30s'))
        try:
            self.assertEqual(taskset.get(proc.pid), taskset.get(os.getpid()))
        finally:
            proc.kill()

    @forked
    @MonkeyPatch(cmdutils, '_USING_CPU_AFFINITY', True)
    def testResetAffinityWhenConfigured(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEqual(taskset.get(os.getpid()), self.CPU_SET)

        proc = commands.start((EXT_SLEEP, '30s'))
        try:
            self.assertEqual(taskset.get(proc.pid), self.ONLINE_CPUS)
        finally:
            proc.kill()

    @forked
    @MonkeyPatch(cmdutils, '_USING_CPU_AFFINITY', True)
    def testKeepAffinity(self):
        taskset.set(os.getpid(), self.CPU_SET)
        self.assertEqual(taskset.get(os.getpid()), self.CPU_SET)

        proc = commands.start((EXT_SLEEP, '30s'), reset_cpu_affinity=False)
        try:
            self.assertEqual(taskset.get(proc.pid), self.CPU_SET)
        finally:
            proc.kill()