code: def do_test(
      filename,
      args,
      verbose=None,
      repeat_args=None,
      known_failure=False,
  ):
      if isinstance(args, list):
          args = " ".join(args)
  
      if verbose is None:
          verbose = globals()["verbose"]
  
      if repeat_args is None:
          repeat_args = globals()["repeat_args"]
  
      file_size = get_file_size(filename)
      if verbose:
          sys.stderr.write(
              "Testing %s %s on %s (%s lines)\n"
              % (VW, args, filename, file_size)
          )
      splits = choice_no_replacement(range(1, file_size - 2), size=10)
      splits.sort()
      splits = list(splits)
      if verbose:
          sys.stderr.write("Using splits: %s\n" % splits)
  
      tmp_model = "tmp.save_resume_test.%s" % os.getpid()
  
      resume_args = args if repeat_args else ""
  
      try:
          for index, split in enumerate(splits[:-1]):
              try:
                  system(
                      "head -n %s %s | VW %s -f %s.full --quiet"
                      % (split, filename, args, tmp_model),
                      verbose=verbose,
                  )
  
                  if index:
                      system(
                          "head -n %s %s | tail -n %s | VW --quiet -f %s.resume -i %s.resume %s"
                          % (
                              split,
                              filename,
                              split - splits[index - 1],
                              tmp_model,
                              tmp_model,
                              resume_args,
                          ),
                          verbose=verbose,
                      )
                  else:
                      system(
                          "head -n %s %s | VW %s --quiet -f %s.resume"
                          % (split, filename, args, tmp_model),
                          verbose=verbose,
                      )
  
                  predictions_normal = read_output(
                      "head -n %s %s | tail -n %s | VW --quiet -i %s.full -t -p /dev/stdout"
                      % (
                          splits[index + 1],
                          filename,
                          splits[index + 1] - split,
                          tmp_model,
                      ),
                      verbose=verbose,
                  )
                  predictions_resume = read_output(
                      "head -n %s %s | tail -n %s | VW --quiet -i %s.resume -t -p /dev/stdout"
                      % (
                          splits[index + 1],
                          filename,
                          splits[index + 1] - split,
                          tmp_model,
                      ),
                      verbose=verbose,
                  )
  
                  for index, (p_normal, p_resume) in enumerate(
                      zip_longest(
                          predictions_normal.split("\n"),
                          predictions_resume.split("\n"),
                      )
                  ):
                      if p_normal != p_resume:
                          if verbose:
                              sys.stderr.write(
                                  "line %s: %r != %r\n"
                                  % (index + 1, p_normal, p_resume)
                              )
                          if known_failure:
                              sys.stderr.write(
                                  "KNOWN FAILURE %s %s\n" % (VW, args)
                              )
                              return 0
                          sys.stderr.write(
                              "FAILED %s %s%s\n"
                              % (
                                  VW,
                                  args,
                                  " (known failure)"
                                  if known_failure
                                  else "",
                              )
                          )
                          if not verbose and verbose_on_fail:
                              sys.stderr.write(
                                  "Redoing with verbose on:\n"
                              )
                              do_test(filename, args, verbose=True)
                          return 1
              finally:
                  unlink(tmp_model + ".full")
      finally:
          unlink(tmp_model + ".resume")
  
      if known_failure:
          sys.stderr.write(
              "OK (BUT EXPECTED TO FAIL) %s %s\n" % (VW, args)
          )
          return 1
  
      sys.stderr.write("OK %s %s\n" % (VW, args))
      return 0
  
file_path: vowpal_wabbit/test/save_resume_test.py
imports: import sys
  import os
  import optparse
  import random
  from itertools import zip_longest
label_desc: Use image node_id 6 for calling a global function with example usage: do_test(filename, args, verbose, repeat_args, known_failure) and returns: int, int, int, int