Example #1
0
 def test_04_getconf(self, mock_conf, mock_fileover, mock_envover):
     """Test04 Config.getconf()."""
     mock_conf.return_value.conf["topdir"] = "/.udocker"
     config = Config()
     config.getconf()
     self.assertTrue(mock_fileover.called)
     self.assertTrue(mock_envover.called)
    def test_14__run_load_metadata(self, mock_attr, mock_meta):
        """Test14 ExecutionEngineCommon()._run_load_metadata()."""
        Config().conf['location'] = "/tmp/container"
        ex_eng = ExecutionEngineCommon(self.local, self.xmode)
        status = ex_eng._run_load_metadata("123")
        self.assertEqual(status, ("", []))

        Config().conf['location'] = ""
        mock_attr.return_value = (None, None)
        ex_eng = ExecutionEngineCommon(self.local, self.xmode)
        status = ex_eng._run_load_metadata("123")
        self.assertEqual(status, (None, None))
        self.assertTrue(mock_attr.called)

        Config().conf['location'] = ""
        mock_attr.return_value = ("/x", [])
        ex_eng = ExecutionEngineCommon(self.local, self.xmode)
        ex_eng.opt["nometa"] = True
        status = ex_eng._run_load_metadata("123")
        self.assertEqual(status, ("/x", []))

        Config().conf['location'] = ""
        mock_attr.return_value = ("/x", [])
        mock_meta.side_effects = ["user1", "cont/ROOT", "host1", "mydomain",
                                  "ls", "/bin/sh", "vol1", "8443", None]
        ex_eng = ExecutionEngineCommon(self.local, self.xmode)
        ex_eng.opt["nometa"] = False
        ex_eng.opt["portsexp"] = list()
        status = ex_eng._run_load_metadata("123")
        self.assertEqual(status, ("/x", []))
        self.assertTrue(mock_meta.call_count, 9)
Example #3
0
    def setUp(self):
        Config().getconf()
        Config().conf['hostauth_list'] = ("/etc/passwd", "/etc/group")
        Config().conf['cmd'] = "/bin/bash"
        Config().conf['cpu_affinity_exec_tools'] = \
            (["numactl", "-C", "%s", "--", ], ["taskset", "-c", "%s", ])
        Config().conf['runc_capabilities'] = [
            "CAP_KILL", "CAP_NET_BIND_SERVICE", "CAP_CHOWN", "CAP_DAC_OVERRIDE",
            "CAP_FOWNER", "CAP_FSETID", "CAP_KILL", "CAP_SETGID", "CAP_SETUID",
            "CAP_SETPCAP", "CAP_NET_BIND_SERVICE", "CAP_NET_RAW",
            "CAP_SYS_CHROOT", "CAP_MKNOD", "CAP_AUDIT_WRITE", "CAP_SETFCAP",
        ]
        Config().conf['valid_host_env'] = "HOME"
        Config().conf['username'] = "******"
        Config().conf['userhome'] = "/"
        Config().conf['oskernel'] = "4.8.13"
        Config().conf['location'] = ""
        str_local = 'udocker.container.localrepo.LocalRepository'
        self.lrepo = patch(str_local)
        self.local = self.lrepo.start()
        self.mock_lrepo = Mock()
        self.local.return_value = self.mock_lrepo

        str_exmode = 'udocker.engine.execmode.ExecutionMode'
        self.execmode = patch(str_exmode)
        self.xmode = self.execmode.start()
        self.mock_execmode = Mock()
        self.xmode.return_value = self.mock_execmode
Example #4
0
    def test_17_remove(self, mock_regpre, mock_base, mock_absp, mock_safe,
                       mock_uid, mock_isdir, mock_isfile, mock_islink,
                       mock_remove, mock_msg, mock_exists, mock_realpath):
        """Test17 FileUtil.remove()."""
        mock_msg.level = 0
        mock_regpre.return_value = None
        mock_base.return_value = '/filename4.txt'
        mock_absp.return_value = '/filename4.txt'
        mock_uid.return_value = 1000
        # file does not exist (regression of #50)
        mock_isdir.return_value = True
        mock_isfile.return_value = True
        mock_exists.return_value = True
        mock_safe.return_value = True
        mock_islink.return_value = False
        mock_remove.return_value = None
        Config().conf['uid'] = 1000
        Config().conf['tmpdir'] = "/tmp"
        mock_realpath.return_value = "/tmp"
        # under /
        futil = FileUtil("/filename4.txt")
        status = futil.remove()
        self.assertTrue(status)

        # wrong uid
        mock_base.return_value = 'filename4.txt'
        mock_absp.return_value = '/tmp/filename4.txt'
        mock_uid.return_value = 1001
        futil = FileUtil("/tmp/filename4.txt")
        status = futil.remove()
        self.assertTrue(status)

        # under /tmp TEST to be checked
        # mock_base.return_value = 'filename4.txt'
        # mock_absp.return_value = '/tmp/filename4.txt'
        # mock_uid.return_value = 1000
        # futil = FileUtil("/tmp/filename4.txt")
        # status = futil.remove()
        # self.assertTrue(status)

        # under user home TEST to be checked
        # mock_base.return_value = 'filename4.txt'
        # mock_absp.return_value = '/home/user/.udocker/filename4.txt'
        # futil = FileUtil("/home/user/.udocker/filename4.txt")
        # futil.safe_prefixes.append("/home/user/.udocker")
        # status = futil.remove()
        # self.assertTrue(status)

        # outside of scope 1
        mock_base.return_value = 'filename4.txt'
        mock_absp.return_value = '/etc/filename4.txt'
        mock_safe.return_value = False
        futil = FileUtil("/etc/filename4.txt")
        futil.safe_prefixes = []
        status = futil.remove()
        self.assertTrue(status)
Example #5
0
 def test_01_init(self, mock_msg, mock_gupycurl, mock_guexecurl,
                  mock_select):
     """Test01 GetURL() constructor."""
     mock_msg.level = 0
     mock_gupycurl.return_value = False
     mock_guexecurl.return_value = True
     geturl = GetURL()
     mock_select.assert_called()
     self.assertEqual(geturl.ctimeout, Config().conf['ctimeout'])
     self.assertEqual(geturl.insecure, Config().conf['http_insecure'])
     self.assertFalse(geturl.cache_support)
Example #6
0
 def setUp(self):
     Config().getconf()
     Config().conf['nvi_dev_list'] = ['/dev/nvidia']
     self.cont_id = "12345a"
     str_local = 'udocker.container.localrepo.LocalRepository'
     self.lrepo = patch(str_local)
     self.local = self.lrepo.start()
     self.mock_lrepo = Mock()
     self.local.return_value = self.mock_lrepo
     str_cd = str_local + '.cd_container'
     self.cdcont = patch(str_cd, return_value="/" + self.cont_id)
     self.mock_cdcont = self.cdcont.start()
Example #7
0
    def test_09_uid(self, mock_regpre, mock_base, mock_absp, mock_stat):
        """Test09 FileUtil.uid()."""
        mock_regpre.return_value = None
        mock_base.return_value = 'filename.txt'
        mock_absp.return_value = '/tmp/filename.txt'
        mock_stat.return_value.st_uid = 1234
        Config().conf['tmpdir'] = "/tmp"
        futil = FileUtil("filename.txt")
        uid = futil.uid()
        self.assertEqual(uid, 1234)

        mock_stat.side_effect = OSError("fail")
        Config().conf['tmpdir'] = "/tmp"
        futil = FileUtil("filename.txt")
        uid = futil.uid()
        self.assertEqual(uid, -1)
Example #8
0
 def setUp(self):
     Config().getconf()
     str_local = 'udocker.container.localrepo.LocalRepository'
     self.lrepo = patch(str_local)
     self.local = self.lrepo.start()
     self.mock_lrepo = Mock()
     self.local.return_value = self.mock_lrepo
Example #9
0
 def test_01_init(self):
     """Test01 Config() constructor."""
     config = Config()
     self.assertIsInstance(config.conf['verbose_level'], int)
     self.assertIsInstance(config.conf['topdir'], str)
     self.assertIs(config.conf['bindir'], None)
     self.assertIs(config.conf['libdir'], None)
     self.assertIs(config.conf['reposdir'], None)
     self.assertIs(config.conf['layersdir'], None)
     self.assertIs(config.conf['containersdir'], None)
     self.assertIsInstance(config.conf['homedir'], str)
     self.assertIsInstance(config.conf['config'], str)
     self.assertIsInstance(config.conf['keystore'], str)
     self.assertIsInstance(config.conf['tmpdir'], str)
     self.assertIsInstance(config.conf['tarball'], str)
     self.assertIsInstance(config.conf['sysdirs_list'], tuple)
     self.assertIsInstance(config.conf['dri_list'], tuple)
     self.assertIsInstance(config.conf['location'], str)
     self.assertIsInstance(config.conf['http_proxy'], str)
     self.assertIsInstance(config.conf['timeout'], int)
     self.assertIsInstance(config.conf['download_timeout'], int)
     self.assertIsInstance(config.conf['ctimeout'], int)
     self.assertIsInstance(config.conf['http_agent'], str)
     self.assertIsInstance(config.conf['http_insecure'], bool)
     self.assertIsInstance(config.conf['dockerio_index_url'], str)
     self.assertIsInstance(config.conf['dockerio_registry_url'], str)
Example #10
0
    def test_07_run(self, mock_run_init, mock_call, mock_getenv,
                    mock_sel_proot, mock_run_env_set, mock_set_cpu_aff,
                    mock_get_vol_bind, mock_set_uid_map, mock_env_cleanup_dict,
                    mock_run_banner, mock_isgreater, mock_msg, mock_netmap,
                    mock_envupd):
        """Test07 PRootEngine().run()."""
        mock_run_init.return_value = False
        prex = PRootEngine(self.local, self.xmode)
        status = prex.run("CONTAINERID")
        self.assertEqual(status, 2)

        Config().conf['proot_killonexit'] = False
        mock_run_init.return_value = True
        mock_sel_proot.return_value = None
        mock_isgreater.return_value = "2.9.0"
        mock_run_env_set.return_value = None
        mock_msg.level = 5
        mock_set_cpu_aff.return_value = []
        mock_get_vol_bind.return_value = ['-b', '/tmp:/tmp']
        mock_set_uid_map.return_value = ['-i', '1000:1001']
        mock_netmap.return_value = ['-p', '80:8080', '-n']
        mock_env_cleanup_dict.return_value = None
        mock_run_banner.return_value = None
        mock_call.return_value = 5
        mock_getenv.return_value = False
        mock_envupd.return_value = None
        prex = PRootEngine(self.local, self.xmode)
        prex.opt["kernel"] = "5.4.0"
        status = prex.run("CONTAINERID")
        self.assertEqual(status, 5)
        self.assertTrue(mock_run_init.called)
        self.assertTrue(mock_call.called)
        self.assertTrue(mock_envupd.called)
Example #11
0
 def setUp(self):
     Config().getconf()
     Config().conf['timeout'] = 1
     Config().conf['ctimeout'] = 1
     Config().conf['download_timeout'] = 1
     Config().conf['http_agent'] = ""
     Config().conf['http_proxy'] = ""
     Config().conf['http_insecure'] = 0
     Config().conf['use_curl_exec'] = ""
Example #12
0
 def test_02__file_override(self, mock_exists, mock_cpread, mock_cpitems):
     """Test02 Config()._file_override"""
     cfile = "/home/udocker.conf"
     mock_exists.side_effect = [False, False, True]
     mock_cpread.return_value = None
     mock_cpitems.return_value = [("verbose_level", 5)]
     Config()._file_override(cfile)
     self.assertEqual(Config.conf['verbose_level'], 5)
Example #13
0
 def test_03__env_override(self, mock_env):
     """Test03 Config()._env_override"""
     # Order of getenv:
     # UDOCKER_LOGLEVEL, UDOCKER_DIR, UDOCKER_BIN, UDOCKER_LIB,
     # UDOCKER_REPOS, UDOCKER_LAYERS
     mock_env.return_value = "5"
     Config()._env_override()
     self.assertEqual(Config.conf['verbose_level'], 5)
Example #14
0
 def test_21_cleanup(self, mock_regpre, mock_base, mock_absp, mock_remove):
     """Test21 FileUtil.cleanup()."""
     mock_regpre.return_value = None
     mock_base.return_value = 'filename.txt'
     mock_absp.return_value = '/tmp/filename.txt'
     Config().conf['tmpdir'] = "/tmp"
     FileUtil.tmptrash = {'file1.txt': None, 'file2.txt': None}
     FileUtil("").cleanup()
     self.assertEqual(mock_remove.call_count, 2)
Example #15
0
 def setUp(self):
     Config().getconf()
     self.bind_dir = "/.bind_host_files"
     self.orig_dir = "/.bind_orig_files"
     str_local = 'udocker.container.localrepo.LocalRepository'
     self.lrepo = patch(str_local)
     self.local = self.lrepo.start()
     self.mock_lrepo = Mock()
     self.local.return_value = self.mock_lrepo
Example #16
0
 def test_18_get_ld_library_path(self, mock_ldconf,
                                 mock_ldlib, mock_path):
     """Test18 ElfPatcher().get_ld_library_path()."""
     Config().conf['lib_dirs_list_essential'] = ""
     mock_ldconf.return_value = ["/lib"]
     mock_ldlib.return_value = ["/usr/lib"]
     mock_path.return_value = "/some_contdir"
     elfp = ElfPatcher(self.local, self.contid)
     status = elfp.get_ld_library_path()
     self.assertEqual(status, "/lib:/usr/lib:.")
Example #17
0
 def test_05_mktmp(self, mock_regpre, mock_base, mock_absp):
     """Test05 FileUtil.mktmp()."""
     mock_regpre.return_value = None
     mock_base.return_value = 'filename2.txt'
     mock_absp.return_value = '/tmp/filename2.txt'
     Config().conf['tmpdir'] = '/somewhere'
     tmp_file = FileUtil('filename2.txt').mktmp()
     self.assertTrue(tmp_file.endswith('-filename2.txt'))
     self.assertTrue(tmp_file.startswith('/somewhere/udocker-'))
     self.assertGreater(len(tmp_file.strip()), 68)
Example #18
0
    def test_02_select_proot(self, mock_exists, mock_fimage, mock_isgreater,
                             mock_issecomp):
        """Test02 PRootEngine().select_proot()."""
        Config().conf['arch'] = "amd64"
        Config().conf['proot_noseccomp'] = None
        mock_isgreater.return_value = False
        mock_fimage.return_value = "proot-4_8_0"
        mock_issecomp.return_value = False
        mock_exists.return_value = True
        prex = PRootEngine(self.local, self.xmode)
        prex.select_proot()
        self.assertFalse(prex.proot_noseccomp)

        Config().conf['proot_noseccomp'] = True
        mock_isgreater.return_value = True
        mock_fimage.return_value = "proot"
        mock_issecomp.return_value = False
        mock_exists.return_value = True
        prex = PRootEngine(self.local, self.xmode)
        prex.select_proot()
        self.assertTrue(prex.proot_noseccomp)

        Config().conf['proot_noseccomp'] = False
        mock_isgreater.return_value = True
        mock_fimage.return_value = "proot"
        mock_issecomp.return_value = False
        mock_exists.return_value = True
        prex = PRootEngine(self.local, self.xmode)
        prex.select_proot()
        self.assertFalse(prex.proot_noseccomp)

        Config().conf['proot_noseccomp'] = None
        mock_isgreater.return_value = True
        mock_fimage.return_value = "proot-x86_64-4_8_0"
        mock_issecomp.return_value = False
        mock_exists.return_value = True
        prex = PRootEngine(self.local, self.xmode)
        prex.select_proot()
        self.assertFalse(prex.proot_noseccomp)

        Config().conf['proot_noseccomp'] = False
        mock_isgreater.return_value = True
        mock_fimage.return_value = "proot-x86_64-4_8_0"
        mock_issecomp.return_value = False
        mock_exists.return_value = True
        prex = PRootEngine(self.local, self.xmode)
        prex.select_proot()
        self.assertFalse(prex.proot_noseccomp)

        Config().conf['proot_noseccomp'] = True
        mock_isgreater.return_value = True
        mock_fimage.return_value = "proot-x86_64-4_8_0"
        mock_issecomp.return_value = False
        mock_exists.return_value = True
        prex = PRootEngine(self.local, self.xmode)
        prex.select_proot()
        self.assertTrue(prex.proot_noseccomp)
Example #19
0
 def setUp(self):
     Config().getconf()
     Config().conf['timeout'] = 1
     Config().conf['ctimeout'] = 1
     Config().conf['download_timeout'] = 1
     Config().conf['http_agent'] = ""
     Config().conf['http_proxy'] = ""
Example #20
0
    def setUp(self):
        Config().getconf()
        Config().conf['hostauth_list'] = ("/etc/passwd", "/etc/group")
        Config().conf['cmd'] = "/bin/bash"
        Config().conf['cpu_affinity_exec_tools'] = \
            (["numactl", "-C", "%s", "--", ],
             ["taskset", "-c", "%s", ])
        Config().conf['valid_host_env'] = "HOME"
        Config().conf['username'] = "******"
        Config().conf['userhome'] = "/"
        Config().conf['location'] = ""
        Config().conf['oskernel'] = "4.8.13"

        str_local = 'udocker.container.localrepo.LocalRepository'
        self.lrepo = patch(str_local)
        self.local = self.lrepo.start()
        self.mock_lrepo = Mock()
        self.local.return_value = self.mock_lrepo
Example #21
0
    def setUp(self):
        Config().getconf()

        str_local = 'udocker.container.localrepo.LocalRepository'
        self.lrepo = patch(str_local)
        self.local = self.lrepo.start()
        self.mock_lrepo = Mock()
        self.local.return_value = self.mock_lrepo

        str_exmode = 'udocker.engine.execmode.ExecutionMode'
        self.execmode = patch(str_exmode)
        self.xmode = self.execmode.start()
        self.mock_execmode = Mock()
        self.xmode.return_value = self.mock_execmode
Example #22
0
    def test_02_get_container_attr(self, mock_msg):
        """Test02 ContainerStructure().get_container_attr()."""
        mock_msg.return_value.level.return_value = 0
        Config().conf['location'] = "/"
        prex = ContainerStructure(self.local)
        (container_dir, container_json) = prex.get_container_attr()
        self.assertEqual(container_dir, "")
        self.assertEqual(container_json, [])

        Config().conf['location'] = ""
        self.local.cd_container.return_value = ""
        prex = ContainerStructure(self.local)
        (container_dir, container_json) = prex.get_container_attr()
        self.assertEqual(container_dir, False)
        self.assertEqual(container_json, False)
        self.assertTrue(mock_msg.return_value.err.called)

        Config().conf['location'] = ""
        self.local.cd_container.return_value = "/"
        self.local.load_json.return_value = []
        prex = ContainerStructure(self.local)
        (container_dir, container_json) = prex.get_container_attr()
        self.assertEqual(container_dir, False)
        self.assertEqual(container_json, False)
        self.assertTrue(mock_msg.return_value.err.called)

        Config().conf['location'] = ""
        self.local.cd_container.return_value = "/"
        self.local.load_json.return_value = [
            "value",
        ]
        prex = ContainerStructure(self.local)
        (container_dir, container_json) = prex.get_container_attr()
        self.assertEqual(container_dir, "/")
        self.assertEqual(container_json, [
            "value",
        ])
    def setUp(self):
        Config().getconf()
        Config().conf['hostauth_list'] = ("/etc/passwd", "/etc/group")
        Config().conf['cmd'] = "/bin/bash"
        Config().conf['cpu_affinity_exec_tools'] = \
            (["numactl", "-C", "%s", "--", ], ["taskset", "-c", "%s", ])
        Config().conf['location'] = ""
        Config().conf['uid'] = 1000
        Config().conf['sysdirs_list'] = ["/", ]
        Config().conf['root_path'] = "/usr/sbin:/sbin:/usr/bin:/bin"
        Config().conf['user_path'] = "/usr/bin:/bin:/usr/local/bin"
        str_local = 'udocker.container.localrepo.LocalRepository'
        self.lrepo = patch(str_local)
        self.local = self.lrepo.start()
        self.mock_lrepo = Mock()
        self.local.return_value = self.mock_lrepo

        str_exmode = 'udocker.engine.execmode.ExecutionMode'
        self.execmode = patch(str_exmode)
        self.xmode = self.execmode.start()
        self.mock_execmode = Mock()
        self.xmode.return_value = self.mock_execmode
 def setUp(self):
     Config().getconf()
Example #25
0
 def test_12_get_devices(self, mock_glob):
     """Test12 NvidiaMode.get_devices()."""
     mock_glob.return_value = ['/dev/nvidia']
     nvmode = NvidiaMode(self.local, self.cont_id)
     status = nvmode.get_devices()
     self.assertEqual(status, Config().conf['nvi_dev_list'])
Example #26
0
 def test_05_container(self, mock_conf, mock_fileover):
     """Test05 Config.container()."""
     mock_conf.return_value.conf["topdir"] = "/.udocker"
     config = Config()
     config.container()
     self.assertTrue(mock_fileover.called)
Example #27
0
 def setUp(self):
     Config().getconf()
     Config().conf["tmpdir"] = "/tmp"
Example #28
0
    def setUp(self):
        Config().getconf()
        Config().conf['hostauth_list'] = ("/etc/passwd", "/etc/group")
        Config().conf['cmd'] = "/bin/bash"
        Config().conf['cpu_affinity_exec_tools'] = \
            (["numactl", "-C", "%s", "--", ], ["taskset", "-c", "%s", ])
        Config().conf['valid_host_env'] = "HOME"
        Config().conf['username'] = "******"
        Config().conf['userhome'] = "/"
        Config().conf['oskernel'] = "4.8.13"
        Config().conf['location'] = ""
        Config().conf['keystore'] = "KEYSTORE"
        Config().conf['osversion'] = "OSVERSION"
        Config().conf['arch'] = "ARCH"
        Config().conf['default_execution_mode'] = "P1"
        self.container_id = "CONTAINER_ID"

        str_local = 'udocker.container.localrepo.LocalRepository'
        self.lrepo = patch(str_local)
        self.local = self.lrepo.start()
        self.mock_lrepo = Mock()
        self.local.return_value = self.mock_lrepo

        str_cd = str_local + '.cd_container'
        self.cdcont = patch(str_cd, return_value="/tmp")
        self.mock_cdcont = self.cdcont.start()
Example #29
0
    def test_41_links_conv(self, mock_regpre, mock_base, mock_absp,
                           mock_realpath, mock_walk, mock_islink, mock_lstat,
                           mock_is_safe_prefix, mock_msg, mock_link_set,
                           mock_link_restore):
        """Test41 FileUtil.links_conv()."""
        mock_msg.level = 0
        mock_regpre.return_value = None
        mock_base.return_value = 'filename.txt'
        mock_absp.return_value = '/tmp/filename.txt'
        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = False
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, True, "")
        self.assertEqual(status, None)

        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = True
        mock_walk.return_value = []
        mock_islink.return_value = True
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, True, "")
        self.assertEqual(status, [])

        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = True
        mock_walk.return_value = [
            ("/", [], []),
        ]
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, True, "")
        self.assertEqual(status, [])

        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = True
        mock_islink = False
        mock_walk.return_value = [
            ("/", [], ["F1", "F2"]),
        ]
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, True, "")
        self.assertEqual(status, [])

        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = True
        mock_islink = True
        mock_lstat.return_value.st_uid = 1
        Config().conf['uid'] = 0
        mock_walk.return_value = [
            ("/", [], ["F1", "F2"]),
        ]
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, True, "")
        self.assertEqual(status, [])

        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = True
        mock_islink = True
        mock_lstat.return_value.st_uid = 1
        mock_link_set.reset_mock()
        mock_link_restore.reset_mock()
        Config().conf['uid'] = 1
        mock_walk.return_value = [
            ("/", [], ["F1", "F2"]),
        ]
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, True, "")
        self.assertFalse(mock_link_restore.called)

        mock_realpath.return_value = "/ROOT"
        mock_is_safe_prefix.return_value = True
        mock_islink = True
        mock_lstat.return_value.st_uid = 1
        mock_link_set.reset_mock()
        mock_link_restore.reset_mock()
        Config().conf['uid'] = 1
        mock_walk.return_value = [
            ("/", [], ["F1", "F2"]),
        ]
        futil = FileUtil("/ROOT")
        status = futil.links_conv(False, False, "")
        self.assertFalse(mock_link_set.called)