code: def run_test(
      label,
      routines,
      numerical_tests,
      language,
      commands,
      friendly=True,
  ):
      """A driver for the codegen tests.
  
      This driver assumes that a compiler ifort is present in the PATH and that
      ifort is (at least) a Fortran 90 compiler. The generated code is written in
      a temporary directory, together with a main program that validates the
      generated code. The test passes when the compilation and the validation
      run correctly.
      """
  
      # Check input arguments before touching the file system
      language = language.upper()
      assert language in main_template
      assert language in numerical_test_template
  
      # Check that environment variable makes sense
      clean = os.getenv("SYMPY_TEST_CLEAN_TEMP", "always").lower()
      if clean not in ("always", "success", "never"):
          raise ValueError(
              "SYMPY_TEST_CLEAN_TEMP must be one of the following: 'always', 'success' or 'never'."
          )
  
      # Do all the magic to compile, run and validate the test code
      # 1) prepare the temporary working directory, switch to that dir
      work = tempfile.mkdtemp(
          "_sympy_%s_test" % language, "%s_" % label
      )
      oldwork = os.getcwd()
      os.chdir(work)
  
      # 2) write the generated code
      if friendly:
          # interpret the routines as a name_expr list and call the friendly
          # function codegen
          codegen(routines, language, "codegen", to_files=True)
      else:
          code_gen = get_code_generator(language, "codegen")
          code_gen.write(routines, "codegen", to_files=True)
  
      # 3) write a simple main program that links to the generated code, and that
      #    includes the numerical tests
      test_strings = []
      for fn_name, args, expected, threshold in numerical_tests:
          call_string = "%s(%s)-(%s)" % (
              fn_name,
              ",".join(str(arg) for arg in args),
              expected,
          )
          if language == "F95":
              call_string = fortranize_double_constants(call_string)
              threshold = fortranize_double_constants(str(threshold))
          test_strings.append(
              numerical_test_template[language]
              % {
                  "call": call_string,
                  "threshold": threshold,
              }
          )
  
      if language == "F95":
          f_name = "main.f90"
      elif language.startswith("C"):
          f_name = "main.c"
      else:
          raise NotImplementedError(
              "FIXME: filename extension unknown for language: %s"
              % language
          )
  
      with open(f_name, "w") as f:
          f.write(
              main_template[language]
              % {"statements": "".join(test_strings)}
          )
  
      # 4) Compile and link
      compiled = try_run(commands)
  
      # 5) Run if compiled
      if compiled:
          executed = try_run(["./test.exe"])
      else:
          executed = False
  
      # 6) Clean up stuff
      if clean == "always" or (
          clean == "success" and compiled and executed
      ):
  
          def safe_remove(filename):
              if os.path.isfile(filename):
                  os.remove(filename)
  
          safe_remove("codegen.f90")
          safe_remove("codegen.c")
          safe_remove("codegen.h")
          safe_remove("codegen.o")
          safe_remove("main.f90")
          safe_remove("main.c")
          safe_remove("main.o")
          safe_remove("test.exe")
          os.chdir(oldwork)
          os.rmdir(work)
      else:
          print("TEST NOT REMOVED: %s" % work, file=sys.stderr)
          os.chdir(oldwork)
  
      # 7) Do the assertions in the end
      assert compiled, "failed to compile %s code with:\n%s" % (
          language,
          "\n".join(commands),
      )
      assert executed, "failed to execute %s code from:\n%s" % (
          language,
          "\n".join(commands),
      )
  
imports: from sympy.abc import x, y, z
  from sympy.external import import_module
  from sympy.testing.pytest import skip
  from sympy.utilities.codegen import codegen, make_routine, get_code_generator
  import sys
  import os
  import tempfile
  import subprocess
label_desc: Use image node_id 2 for calling a global function with example usage: run_test(label, routines, numerical_tests, language, commands, friendly) without return types