old_contents: #!/usr/bin/env python3
  
  # Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
  # Copyright (C) 2016 Oliver Hahm <oliver.hahm@inria.fr>
  #
  # This file is subject to the terms and conditions of the GNU Lesser
  # General Public License v2.1. See the file LICENSE in the top level
  # directory for more details.
  
  import os
  import sys
  
  thread_prio = {
          3:  6,
          4:  4,
          5:  0,
          6:  2,
          7:  1
          }
  first_group_size = 3
  
  
  def testfunc(child):
  
      for k in thread_prio.keys():
          child.expect_exact("T{} (prio {}): waiting on condition variable now"
                             .format(k, thread_prio[k]))
      count = 0
      last = -1
      child.expect_exact("First batch was signaled")
      for _ in range(len(thread_prio)):
          child.expect(r"T\d+ \(prio (\d+)\): condition variable was signaled now")
          assert(int(child.match.group(1)) > last)
          last = int(child.match.group(1))
          count += 1
          if count == 3:
              child.expect_exact("First batch has woken up")
              child.expect_exact("Second batch was signaled")
      child.expect_exact("Second batch has woken up")
  
  
  if __name__ == "__main__":
      sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
      from testrunner import run
      sys.exit(run(testfunc))
  
new_contents: #!/usr/bin/env python3
  
  # Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
  # Copyright (C) 2016 Oliver Hahm <oliver.hahm@inria.fr>
  #
  # This file is subject to the terms and conditions of the GNU Lesser
  # General Public License v2.1. See the file LICENSE in the top level
  # directory for more details.
  
  import os
  import sys
  
  NUM_THREADS = 5
  
  
  def testfunc(child):
      # First collect the thread info how they are created
      # A number of lines with:
      #  T4 (prio 6): waiting on condition variable now
      thread_prios = {}
      for _ in range(NUM_THREADS):
          child.expect(r"T(\d+) \(prio (\d+)\): waiting on condition variable now")
          thread_id = int(child.match.group(1))
          thread_prio = int(child.match.group(2))
          thread_prios[thread_id] = thread_prio
  
      child.expect_exact("First batch was signaled")
  
      count = 0
      last_prio = -1
      for _ in range(len(thread_prios)):
          child.expect(r"T(\d+) \(prio (\d+)\): condition variable was signaled now")
          thread_id = int(child.match.group(1))
          thread_prio = int(child.match.group(2))
          assert thread_prios[thread_id] == thread_prio
          assert thread_prio > last_prio
          last_prio = thread_prio
          count += 1
          if count == 3:
              child.expect_exact("First batch has woken up")
              child.expect_exact("Second batch was signaled")
      child.expect_exact("Second batch has woken up")
  
  
  if __name__ == "__main__":
      sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
      from testrunner import run
      sys.exit(run(testfunc))
  
subject: refactor the test to avoid knowing the thread IDs