'run CPU limit test with \'while true\' processes.
cpu: desired CPU fraction of each host
duration: test duration in seconds (integer)
returns a single list of measured CPU fractions as floats.'

def runCpuLimitTest(self, cpu, duration=5):

    pct = (cpu * 100)
    info(('***    Testing    CPU    %.0f%%    bandwidth    limit\n' % pct))
    hosts = self.hosts
    cores = int(quietRun('nproc'))
    num_procs = int(ceil((cores * cpu)))
    pids = {}
    for h in hosts:
        pids[h] = []
        for _core in range(num_procs):
            h.cmd('while    true;    do    a=1;    done    &')
            pids[h].append(h.cmd('echo    $!').strip())
    outputs = {}
    time = {}
    for host in hosts:
        outputs[host] = []
        with open(('/sys/fs/cgroup/cpuacct/%s/cpuacct.usage' % host), 'r') as f:
            time[host] = float(f.read())
    for _ in range(duration):
        sleep(1)
        for host in hosts:
            with open(('/sys/fs/cgroup/cpuacct/%s/cpuacct.usage' % host), 'r') as f:
                readTime = float(f.read())
            outputs[host].append(((((readTime - time[host]) / 1000000000) / cores) * 100))
            time[host] = readTime
    for (h, pids) in pids.items():
        for pid in pids:
            h.cmd(('kill    -9    %s' % pid))
    cpu_fractions = []
    for (_host, outputs) in outputs.items():
        for pct in outputs:
            cpu_fractions.append(pct)
    output(('***    Results:    %s\n' % cpu_fractions))
    return cpu_fractions
