code: def test_shared_cache_dir(tmp_dir):
      cache_dir = os.path.abspath(os.path.join(os.curdir, "cache"))
      for d in ["dir1", "dir2"]:
          os.mkdir(d)
          with (tmp_dir / d).chdir():
              ret = main(["init", "--no-scm"])
              assert ret == 0
  
              ret = main(["config", "cache.dir", cache_dir])
              assert ret == 0
  
              assert not os.path.exists(os.path.join(".dvc", "cache"))
  
              (tmp_dir / d).gen({"common": "common", "unique": d})
  
              ret = main(["add", "common", "unique"])
              assert ret == 0
  
      assert not os.path.exists(os.path.join("dir1", ".dvc", "cache"))
      assert not os.path.exists(os.path.join("dir2", ".dvc", "cache"))
      assert os.path.exists(
          os.path.join(
              cache_dir,
              "files",
              "md5",
              "dc",
              "f6c2fa538b445a3a095255c3641dfc",
          )
      )
      assert os.path.exists(
          os.path.join(
              cache_dir,
              "files",
              "md5",
              "b4",
              "333c8cfa2ebba7ef20ec6c3265902b",
          )
      )
      assert os.path.exists(
          os.path.join(
              cache_dir,
              "files",
              "md5",
              "9e",
              "fab2399c7c560b34de477b9aa0a465",
          )
      )
  
file_path: dvc/tests/func/test_odb.py
imports: import os
  import stat
  import configobj
  import pytest
  from dvc.cachemgr import CacheManager
  from dvc.cli import main
  from dvc.utils import relpath
  from dvc_data.hashfile.hash_info import HashInfo
  from dvc_objects.errors import ObjectFormatError
label_desc: Use image node_id 4 for calling a global function with example usage: test_shared_cache_dir(tmp_dir) without return types