
import sys
from testrunner import run


def testfunc(child):
    child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)\r\n')
    children = int(child.match.group(1))
    iterations = int(child.match.group(2))
    for i in range(children):
        child.expect(f'Start {i + 1}')
    for _ in range(iterations):
        sleeps = []
        for _ in range(children):
            child.expect(r'Child (\d+) sleeps for \s* (\d+) us.\r\n')
            child_num = int(child.match.group(1))
            sleep = int(child.match.group(2))
            sleeps.append([sleep, child_num])
    for _, child_num in sorted(sleeps):
        child.expect(r'Done (\d+)\r\n')
        assert(child_num == int(child.match.group(1)))
    child.expect('SUCCESS')


if __name__ == "__main__":
    sys.exit(run(testfunc))


import sys
from testrunner import run


def testfunc(child):
    child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)\r\n')
    children = int(child.match.group(1))
    iterations = int(child.match.group(2))
    for i in range(children):
        child.expect('Start {}'.format(i + 1))
    for _ in range(iterations):
        sleeps = []
        for _ in range(children):
            child.expect(r'Child (\d+) sleeps for \s* (\d+) us.\r\n')
            child_num = int(child.match.group(1))
            sleep = int(child.match.group(2))
            sleeps.append([sleep, child_num])
    for _, child_num in sorted(sleeps):
        child.expect(r'Done (\d+)\r\n')
        assert(child_num == int(child.match.group(1)))
    child.expect('SUCCESS')


if __name__ == "__main__":
    sys.exit(run(testfunc))

Remove f string in test
tests/thread_pthread_barrier: Remove f string in test

This causes nightlies to fail as the HiL test runners don't have python3.6+

  
  import sys
  from testrunner import run
  
  
  def testfunc(child):
      child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)\r\n')
      children = int(child.match.group(1))
      iterations = int(child.match.group(2))
      for i in range(children):
-         child.expect(f'Start {i + 1}')
+         child.expect('Start {}'.format(i + 1))
      for _ in range(iterations):
          sleeps = []
          for _ in range(children):
              child.expect(r'Child (\d+) sleeps for \s* (\d+) us.\r\n')
              child_num = int(child.match.group(1))
              sleep = int(child.match.group(2))
              sleeps.append([sleep, child_num])
      for _, child_num in sorted(sleeps):
          child.expect(r'Done (\d+)\r\n')
          assert(child_num == int(child.match.group(1)))
      child.expect('SUCCESS')
  
  
  if __name__ == "__main__":
      sys.exit(run(testfunc))
  
Remove f string in test
## Code Before:

import sys
from testrunner import run


def testfunc(child):
    child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)\r\n')
    children = int(child.match.group(1))
    iterations = int(child.match.group(2))
    for i in range(children):
        child.expect(f'Start {i + 1}')
    for _ in range(iterations):
        sleeps = []
        for _ in range(children):
            child.expect(r'Child (\d+) sleeps for \s* (\d+) us.\r\n')
            child_num = int(child.match.group(1))
            sleep = int(child.match.group(2))
            sleeps.append([sleep, child_num])
    for _, child_num in sorted(sleeps):
        child.expect(r'Done (\d+)\r\n')
        assert(child_num == int(child.match.group(1)))
    child.expect('SUCCESS')


if __name__ == "__main__":
    sys.exit(run(testfunc))

## Instruction:
Remove f string in test
## Code After:

import sys
from testrunner import run


def testfunc(child):
    child.expect(r'NUM_CHILDREN: (\d+), NUM_ITERATIONS: (\d+)\r\n')
    children = int(child.match.group(1))
    iterations = int(child.match.group(2))
    for i in range(children):
        child.expect('Start {}'.format(i + 1))
    for _ in range(iterations):
        sleeps = []
        for _ in range(children):
            child.expect(r'Child (\d+) sleeps for \s* (\d+) us.\r\n')
            child_num = int(child.match.group(1))
            sleep = int(child.match.group(2))
            sleeps.append([sleep, child_num])
    for _, child_num in sorted(sleeps):
        child.expect(r'Done (\d+)\r\n')
        assert(child_num == int(child.match.group(1)))
    child.expect('SUCCESS')


if __name__ == "__main__":
    sys.exit(run(testfunc))
